|
@ -2,6 +2,7 @@ package cn.stylefeng.guns.zjxl.service;
|
|
|
|
|
|
import cn.stylefeng.guns.zjxl.dao.ZjxlArticleContentDao;
|
|
|
import cn.stylefeng.guns.zjxl.model.ZjxlArticleContent;
|
|
|
import cn.stylefeng.guns.zjxl.model.ZjxlSystemDict;
|
|
|
import cn.stylefeng.guns.zjxlUtil.BaseService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@ -31,27 +32,45 @@ public class ZjxlArticleContentService extends BaseService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private ZjxlSystemDictService systemDictService;
|
|
|
@Autowired
|
|
|
private ZjxlArticleContentDao articleContentDao;
|
|
|
|
|
|
public List<ZjxlArticleContent> findArticleContentById(String id,String articleContentTitle,Integer systemDictType,Integer page,Integer pagesiz){
|
|
|
String sql = "select * from zjxl_article_content where 1=1 ";
|
|
|
if (StringUtils.isNotEmpty(id)){
|
|
|
sql += " and article_content_id = '"+id+"'";
|
|
|
String sql = "select ac.article_content_id,ac.article_content_title,ac.article_content_cover,ac.article_content_abstract,\n" +
|
|
|
"sd.system_dict_type article_content_type,sd.system_dict_classify article_content_classify,sd.system_dict_subclassify article_content_subclassify,\n" +
|
|
|
"ac.article_content_sort,ac.article_content_is_line,ac.article_content_create_time,ac.article_content_content,ac.dict_id\n" +
|
|
|
"from zjxl_article_content ac \n" +
|
|
|
"LEFT JOIN zjxl_system_dict sd on ac.dict_id = sd.system_dict_id\n" +
|
|
|
"where 1=1 ";
|
|
|
|
|
|
if (StringUtils.isNoneBlank(id)){
|
|
|
sql += " and ac.article_content_id = '"+id+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(articleContentTitle)){
|
|
|
sql += " and article_content_title like '%"+articleContentTitle+"%'";
|
|
|
if (StringUtils.isNoneBlank(articleContentTitle)){
|
|
|
sql += " and ac.article_content_title like '%"+articleContentTitle+"%' ";
|
|
|
}
|
|
|
if (systemDictType != null && systemDictType > 0){
|
|
|
sql += " and article_content_type = "+systemDictType+"";
|
|
|
sql += " and sd.system_dict_type = "+systemDictType+" ";
|
|
|
}
|
|
|
sql += " order by article_content_sort asc,article_content_create_time desc limit "+page+" , "+pagesiz+"";
|
|
|
sql += " order by ac.article_content_sort asc,ac.article_content_create_time desc limit "+page+" , "+pagesiz+"";
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
return articleContentList;
|
|
|
}
|
|
|
|
|
|
public int allCount(){
|
|
|
String sql = "select count(*) from zjxl_article_content ";
|
|
|
public int allCount(String id,String articleContentTitle,Integer systemDictType){
|
|
|
String sql = "select count(*) from zjxl_article_content ac LEFT JOIN zjxl_system_dict sd on ac.dict_id = sd.system_dict_id\n" +
|
|
|
"where 1=1 ";
|
|
|
if (StringUtils.isNoneBlank(id)){
|
|
|
sql += " and ac.article_content_id = '"+id+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(articleContentTitle)){
|
|
|
sql += " and ac.article_content_title like '%"+articleContentTitle+"%' ";
|
|
|
}
|
|
|
if (systemDictType != null && systemDictType > 0){
|
|
|
sql += " and sd.system_dict_type = "+systemDictType+" ";
|
|
|
}
|
|
|
Integer allCount = jdbcTemplate.queryForObject(sql, Integer.class);;
|
|
|
return allCount;
|
|
|
}
|
|
@ -72,54 +91,82 @@ public class ZjxlArticleContentService extends BaseService {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
public List<ZjxlArticleContent> getLeftTabs(String articleContentType){
|
|
|
String sql = "select * from zjxl_article_content where article_content_type = "+articleContentType+" group by article_content_classify";
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
return articleContentList;
|
|
|
public List<ZjxlSystemDict> getLeftTabs(String articleContentType){
|
|
|
String sql = "select * from zjxl_system_dict where system_dict_type = "+articleContentType+" and system_dict_is_line='1' group by system_dict_classify";
|
|
|
List<ZjxlSystemDict> zjxlSystemDictList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlSystemDict.class));
|
|
|
return zjxlSystemDictList;
|
|
|
}
|
|
|
|
|
|
public List<ZjxlArticleContent> getArticleContentSubclassify(String articleContentType,String articleContentClassify){
|
|
|
String sql = "select * from zjxl_article_content where article_content_type = "+articleContentType+" and article_content_classify = '"+articleContentClassify+"' group by article_content_subclassify";
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
return articleContentList;
|
|
|
public List<ZjxlSystemDict> getArticleContentSubclassify(String articleContentType,String articleContentClassify){
|
|
|
String sql = "select * from zjxl_system_dict where system_dict_type = "+articleContentType+" and system_dict_classify = '"+articleContentClassify+"' and system_dict_is_line='1' group by system_dict_subclassify";
|
|
|
List<ZjxlSystemDict> zjxlsystemDictList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlSystemDict.class));
|
|
|
return zjxlsystemDictList;
|
|
|
//SELECT * FROM zjxl_system_dict WHERE system_dict_type = 4 AND system_dict_classify = '公司介绍分类4'
|
|
|
}
|
|
|
|
|
|
public List<ZjxlArticleContent> getArticleContent(String articleContentType,String articleContentClassify,String articleContentSubclassify){
|
|
|
String sql = "select * from zjxl_article_content where article_content_type = "+articleContentType+" and article_content_classify = '"+articleContentClassify+"' and article_content_subclassify = '"+articleContentSubclassify+"' order by article_content_sort asc ,article_content_create_time desc limit 1";
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
StringBuffer sql = new StringBuffer("select ac.article_content_id,ac.article_content_title,ac.article_content_cover,ac.article_content_abstract,\n" +
|
|
|
"sd.system_dict_type article_content_type,sd.system_dict_classify article_content_classify,sd.system_dict_subclassify article_content_subclassify,\n" +
|
|
|
"ac.article_content_sort,ac.article_content_is_line,ac.article_content_create_time,ac.article_content_content,ac.dict_id\n" +
|
|
|
"from zjxl_article_content ac \n" +
|
|
|
"INNER JOIN zjxl_system_dict sd on ac.dict_id = sd.system_dict_id\n" +
|
|
|
"where 1=1 ");
|
|
|
if (StringUtils.isNoneBlank(articleContentType)){
|
|
|
sql.append("and sd.system_dict_type='"+articleContentType+"' ");
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(articleContentClassify)){
|
|
|
sql.append("and sd.system_dict_classify ='"+articleContentClassify+"' ");
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(articleContentSubclassify)){
|
|
|
sql.append("and sd.system_dict_subclassify='"+articleContentSubclassify+"' ");
|
|
|
}
|
|
|
sql.append("order by ac.article_content_sort asc ,ac.article_content_create_time desc limit 1");
|
|
|
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
return articleContentList;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<ZjxlArticleContent> findNewsList(String id,String articleContentClassify,String articleContentSubclassify,Integer systemDictType,Integer page,Integer pagesiz){
|
|
|
String sql = "select * from zjxl_article_content where 1=1 ";
|
|
|
if (StringUtils.isNotEmpty(id)){
|
|
|
sql += " and article_content_id = '"+id+"'";
|
|
|
StringBuffer sql =new StringBuffer("select ac.article_content_id,ac.article_content_title,ac.article_content_cover,ac.article_content_abstract,\n" +
|
|
|
"sd.system_dict_type article_content_type,sd.system_dict_classify article_content_classify,sd.system_dict_subclassify article_content_subclassify,\n" +
|
|
|
"ac.article_content_sort,ac.article_content_is_line,ac.article_content_create_time,ac.article_content_content,ac.dict_id\n" +
|
|
|
"from zjxl_article_content ac \n" +
|
|
|
"INNER JOIN zjxl_system_dict sd on ac.dict_id = sd.system_dict_id\n" +
|
|
|
"where 1=1 and ac.article_content_is_line = 1 and sd.system_dict_is_line =1 ") ;
|
|
|
if (StringUtils.isNoneBlank(id)){
|
|
|
sql.append(" and ac.article_content_id = '"+id+"' ") ;
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(articleContentClassify)){
|
|
|
sql += " and article_content_classify = '"+articleContentClassify+"'";
|
|
|
if (StringUtils.isNoneBlank(articleContentClassify)){
|
|
|
sql.append(" and sd.system_dict_classify = '"+articleContentClassify+"' ");
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(articleContentSubclassify)){
|
|
|
sql += " and article_content_subclassify = '"+articleContentSubclassify+"'";
|
|
|
if (StringUtils.isNoneBlank(articleContentSubclassify)){
|
|
|
sql.append(" and sd.system_dict_subclassify = '"+articleContentSubclassify+"' ");
|
|
|
}
|
|
|
if (systemDictType != null && systemDictType > 0){
|
|
|
sql += " and article_content_type = "+systemDictType+"";
|
|
|
sql.append(" and sd.system_dict_type = "+systemDictType+" ");
|
|
|
}
|
|
|
sql += " order by article_content_sort asc,article_content_create_time desc limit "+page+" , "+pagesiz+"";
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
sql.append("ORDER BY ac.article_content_sort asc,ac.article_content_create_time desc limit "+page+" , "+pagesiz+" ");
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
return articleContentList;
|
|
|
}
|
|
|
|
|
|
public int allNewsCount(String articleContentClassify,String articleContentSubclassify){
|
|
|
String sql = "select count(*) from zjxl_article_content where article_content_type = 3 ";
|
|
|
if (StringUtils.isNotEmpty(articleContentClassify)){
|
|
|
sql += " and article_content_classify = '"+articleContentClassify+"'";
|
|
|
public int allNewsCount(String id,String articleContentClassify,String articleContentSubclassify){
|
|
|
StringBuffer sql = new StringBuffer("\n" +
|
|
|
"select count(1)\n" +
|
|
|
"from zjxl_article_content ac \n" +
|
|
|
"INNER JOIN zjxl_system_dict sd on ac.dict_id = sd.system_dict_id\n" +
|
|
|
"where 1=1 and ac.article_content_is_line = 1 and sd.system_dict_is_line =1 and sd.system_dict_type = '3' ");
|
|
|
if (StringUtils.isNoneBlank(id)){
|
|
|
sql.append(" and ac.article_content_id = '"+id+"' ") ;
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(articleContentSubclassify)){
|
|
|
sql += " and article_content_subclassify = '"+articleContentSubclassify+"'";
|
|
|
if (StringUtils.isNoneBlank(articleContentClassify)){
|
|
|
sql.append(" and sd.system_dict_classify = '"+articleContentClassify+"' ");
|
|
|
}
|
|
|
Integer allCount = jdbcTemplate.queryForObject(sql, Integer.class);;
|
|
|
if (StringUtils.isNoneBlank(articleContentSubclassify)){
|
|
|
sql.append(" and sd.system_dict_subclassify = '"+articleContentSubclassify+"' ");
|
|
|
}
|
|
|
Integer allCount = jdbcTemplate.queryForObject(sql.toString(), Integer.class);;
|
|
|
return allCount;
|
|
|
}
|
|
|
|
|
@ -130,12 +177,17 @@ public class ZjxlArticleContentService extends BaseService {
|
|
|
}
|
|
|
|
|
|
public List<ZjxlArticleContent> findArticleAll(String articleContentType){
|
|
|
String sql = "select * from zjxl_article_content where article_content_is_line = 1";
|
|
|
StringBuffer sql = new StringBuffer("select ac.article_content_id,ac.article_content_title,ac.article_content_cover,ac.article_content_abstract,\n" +
|
|
|
"sd.system_dict_type article_content_type,sd.system_dict_classify article_content_classify,sd.system_dict_subclassify article_content_subclassify,\n" +
|
|
|
"ac.article_content_sort,ac.article_content_is_line,ac.article_content_create_time,ac.article_content_content,ac.dict_id\n" +
|
|
|
"from zjxl_article_content ac \n" +
|
|
|
"LEFT JOIN zjxl_system_dict sd on ac.dict_id = sd.system_dict_id\n" +
|
|
|
"where 1=1 and ac.article_content_is_line = 1 and sd.system_dict_is_line =1 ");
|
|
|
if (StringUtils.isNotEmpty(articleContentType)){
|
|
|
sql += " and article_content_type = '"+articleContentType+"'";
|
|
|
sql.append("and sd.system_dict_type ='"+articleContentType+"' ");
|
|
|
}
|
|
|
sql += " order by article_content_sort asc ,article_content_create_time desc ";
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
sql.append("ORDER BY ac.article_content_sort asc,ac.article_content_create_time,sd.system_dict_subclassify desc ");
|
|
|
List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
|
|
|
return articleContentList;
|
|
|
}
|
|
|
|
|
@ -155,4 +207,15 @@ public class ZjxlArticleContentService extends BaseService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public String updateArticleDictId(){
|
|
|
|
|
|
List<ZjxlArticleContent> list = articleContentDao.findAll();
|
|
|
list.forEach(article->{
|
|
|
String dictId = systemDictService.findSystemDictByCondition(article.getArticleContentType(),article.getArticleContentClassify(),article.getArticleContentSubclassify());
|
|
|
article.setDictId(StringUtils.isBlank(dictId)?"":dictId);
|
|
|
articleContentDao.save(article);
|
|
|
});
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
}
|