Commit b11571a2 by rongkailun

【修改】资讯中心相关链接 关键字支持半角/全角逗号

parent 440c8ca9
......@@ -2,11 +2,11 @@ package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qiniu.util.StringUtils;
import io.office.common.utils.R;
import io.office.modules.manage.entity.*;
import io.office.modules.manage.entity.dto.NewsParams;
import io.office.modules.sys.entity.SysUserEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -503,6 +503,22 @@ public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements
@Override
public List<NewsEntity> relatedLinks(Map<String, Object> params) {
StringBuffer stringBuffer = new StringBuffer();
if(params.containsKey("keyword")){
if (StringUtils.isNotBlank(String.valueOf(params.get("keyword")))){
String[] keywords = params.get("keyword").toString().split(",").length ==0 ? params.get("keyword").toString().split(",") :params.get("keyword").toString().split(",");
int length = keywords.length;
for (int i = 0; i <length ; i++) {
stringBuffer.append("keyword LIKE concat ('%','")
.append(keywords[i]).append("', '%')");
if(i != length-1){
stringBuffer.append(" or ");
}
}
params.put("sql",stringBuffer.toString());
}
}
List<NewsEntity> list = this.newsDao.relatedLinks(params);
return list;
}
......
......@@ -602,7 +602,9 @@ WHERE
levels > 0
AND status = 1
AND Id != #{id}
AND keyword LIKE concat ('%', #{keyword}, '%')
<if test="sql !=null">
AND (${sql})
</if>
order by releasedate desc
</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