Commit 625b0a0c by 吴迪

【修改】高级查询修改

parent 9cd35792
......@@ -535,7 +535,7 @@ public class NewsController extends AbstractController {
@RequestMapping("/api/getSearchInfo")
// @RequiresPermissions("manage:product:findPage")
public R getSearchInfo(@RequestBody Map<String, String> param) {
Page<SearchVo> pag = this.newsService.getSearchInfo(param.get("name") == null ? null : param.get("name"),
Page<SearchVo> pag = this.newsService.getSearchInfo(param.get("name") == null ? null : param.get("name"),param.get("type") == null ? null : param.get("type"),
new Page(Integer.valueOf(param.get("page")),
Integer.valueOf(param.get("size"))));
PageUtils pageUtils = new PageUtils(pag);
......
......@@ -94,5 +94,5 @@ public interface NewsDao extends BaseMapper<NewsEntity> {
List<NewsEntity> relatedLinks(Map<String, Object> params);
List<SearchVo> getSearchInfo(@Param("name") String name, Page page);
List<SearchVo> getSearchInfo(@Param("name") String name,@Param("type") String type, Page page);
}
......@@ -92,6 +92,6 @@ public interface NewsService extends IService<NewsEntity> {
List<NewsEntity> relatedLinks(Map<String, Object> params);
Page<SearchVo> getSearchInfo(String name, Page page);
Page<SearchVo> getSearchInfo(String name,String type, Page page);
}
......@@ -542,12 +542,20 @@ public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements
@Override
public Page<SearchVo> getSearchInfo(String name, Page page) {
List<SearchVo> list = this.newsDao.getSearchInfo(name, page);
if(CollectionUtils.isNotEmpty(list)) {
for (SearchVo searchVo : list) {
public Page<SearchVo> getSearchInfo(String name, String type,Page page) {
if(StringUtils.isNotBlank(type)&&type.indexOf(",")>-1) {
String[] splitStr = type.split(",");
String finalStr = "";
for (String s : splitStr) {
finalStr=s+",";
}
type= finalStr.substring(0,finalStr.length()-1);
}
List<SearchVo> list = this.newsDao.getSearchInfo(name, type,page);
if(CollectionUtils.isNotEmpty(list)) {
for (SearchVo searchVo : list) {
if(StringUtils.isNotBlank(searchVo.getContent())) {
searchVo.setContent(searchVo.getContent().replaceAll(name,"<font color='red'>"+name+"</font>"));
}
......
......@@ -611,9 +611,16 @@ order by releasedate desc
<select id="getSearchInfo" parameterType="string" resultType="io.office.modules.manage.vo.response.SearchVo">
select * from NewsSearch
<if test="name!=null and name!=''">
where (title like concat('%',#{name},'%') or keyword like concat('%',#{name},'%') or content like concat('%',#{name},'%'))
</if>
<where>
<if test="name!=null and name!=''">
(title like concat('%',#{name},'%') or keyword like concat('%',#{name},'%') or content like concat('%',#{name},'%'))
</if>
<if test="type!=null and type!=''">
and type in (${type})
</if>
</where>
</select>
......
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