Commit 7220d44d by rongkailun

【新增】知识检索接口

parent ec2a8369
......@@ -354,5 +354,13 @@ public class NewsController extends AbstractController {
return R.ok().put("data", list);
}
/**知识检索*/
@Login
@PostMapping("/api/searchKnowledgeInfo")
public R searchKnowledgeInfo(@RequestBody NewsParams newsParams) {
Map<String,Object> retMap = this.newsService.searchKnowledgeInfo(newsParams);
return R.ok().put("data", retMap);
}
}
......@@ -64,4 +64,7 @@ public interface NewsDao extends BaseMapper<NewsEntity> {
List<KnowledgeinfoEntity> selectTips(NewsParams newsParams);
List<String> selectChild(Map<String,Object> params);
List<Map<String, Object>> searchKnowledgeInfo(Map<String, Object> map);
}
......@@ -64,5 +64,7 @@ public interface NewsService extends IService<NewsEntity> {
List<GlossaryEntity> glossaryList(NewsParams newsParams);
List<KnowledgeinfoEntity> selectTips(NewsParams newsParams);
Map<String, Object> searchKnowledgeInfo(NewsParams newsParams);
}
......@@ -8,9 +8,9 @@ import io.office.modules.manage.entity.dto.NewsParams;
import io.office.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -225,5 +225,131 @@ public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements
return list;
}
@Override
public Map<String, Object> searchKnowledgeInfo(NewsParams newsParams) {
final Map<String, Object>[] map = new Map[]{new HashMap<>()};
Map<String,Object> retMap = new HashMap<>();
List<String> list = new ArrayList<>();
if("all".equals(newsParams.getType())){
list.add("sptm");
list.add("ewtm");
list.add("zxcbm");
list.add("dwbm");
list.add("gln");
list.add("epc");
list.add("rfid");
list.add("gds");
list.add("ecr");
list.add("ebXML");
}else{
list.add(newsParams.getType());
}
list.stream().forEach(item->{
//判断是否是全部分类
if("sptm".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","40");
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","sptm");
map[0].put("title",newsParams.getTitle());
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("sptm",dataList);
}else if("ewtm".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","45");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","ewtm");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("ewtm",dataList);
}else if("zxcbm".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","93");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","zxcbm");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("zxcbm",dataList);
}else if("dwbm".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","94");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","dwbm");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("dwbm",dataList);
}else if("gln".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","95");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","gln");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("gln",dataList);
}else if("epc".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","83");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","epc");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("epc",dataList);
}else if("rfid".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","77");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","rfid");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("rfid",dataList);
}else if("gds".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","85");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","gds");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("gds",dataList);
}else if("ecr".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","81");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","ecr");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("ecr",dataList);
}else if("ebXML".equals(item)){
map[0] = new HashMap<>();
map[0].put("name","79");
map[0].put("title",newsParams.getTitle());
List<String> child = getChild(map[0]);
map[0].put("list",child);
map[0].put("typeName","ebXML");
List<Map<String, Object>> dataList = getDataList(map[0]);
retMap.put("ebXML",dataList);
}
});
return retMap;
}
private List<Map<String,Object>> getDataList(Map<String, Object> map) {
List<Map<String,Object>> list = this.newsDao.searchKnowledgeInfo(map);
return list;
}
private List<String> getChild(Map<String, Object> map) {
List<String> list = this.newsDao.selectChild(map);
return list;
}
}
\ No newline at end of file
......@@ -424,4 +424,26 @@
levels DESC,
knowledgeInfoid DESC
</select>
<select id="selectChild" resultType="java.lang.String">
select t.knowledgeCategoryID FROM knowledgeCategory t where t.parentCategoryID = #{name}
</select>
<select id="searchKnowledgeInfo" resultType="java.util.Map">
SELECT
t.Title,
t.knowledgeInfoID,
tt.description,
#{typeName} as type
FROM
knowledgeInfo t
LEFT JOIN knowledgeCategory tt ON t.knowledgeCategoryID = tt.knowledgeCategoryID
where 1=1
<if test="title !=null and title !=''">
and t.Title like concat(concat('%',#{title}),'%')
</if>
and t.knowledgeCategoryID in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment