Browse Source

根据类型获取对应的分类

Shi Kejing 4 years ago
parent
commit
7d1f3aa5aa

+ 3 - 2
guns-main/src/main/java/cn/stylefeng/guns/zjxl/cnotroller/ZjxlArticleContentController.java

@ -182,11 +182,12 @@ public class ZjxlArticleContentController extends BaseController {
                                        // @ApiParam(name = "articleContentTitle", value = "文章标题", required = false) @RequestParam(value = "articleContentTitle", required = false)String articleContentTitle,
                                        // @ApiParam(name = "systemDictType", value = "内容类型 1-产品与服务  2-公司案例  3-新闻中心  4-关于我们", required = false, defaultValue = "3") @RequestParam(value = "systemDictType", required = false)Integer systemDictType,
                               @ApiParam(name = "articleContentClassify", value = "分类: 公司动态  媒体报道  参观交流", defaultValue = "公司动态") @RequestParam(value = "articleContentClassify") String articleContentClassify,
                               @ApiParam(name = "articleContentSubclassify", value = "子分类") @RequestParam(value = "articleContentSubclassify") String articleContentSubclassify,
                               @ApiParam(name = "pageNo", value = "第几页", defaultValue = "1") @RequestParam(value = "pageNo", required = false) Integer pageNo,
                               @ApiParam(name = "pageSize", value = "分页大小", defaultValue = "10") @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            List<ZjxlArticleContent> articleContentList = articleContentService.findNewsList(id,articleContentClassify,3,pageNo-1,pageSize);
            return write(200,"查询成功","data", PageUtil.getPage(articleContentList,pageNo,pageSize,articleContentService.allNewsCount(articleContentClassify)));
            List<ZjxlArticleContent> articleContentList = articleContentService.findNewsList(id,articleContentClassify,articleContentSubclassify,3,pageNo-1,pageSize);
            return write(200,"查询成功","data", PageUtil.getPage(articleContentList,pageNo,pageSize,articleContentService.allNewsCount(articleContentClassify,articleContentSubclassify)));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败");

+ 13 - 0
guns-main/src/main/java/cn/stylefeng/guns/zjxl/cnotroller/ZjxlSystemDictController.java

@ -107,4 +107,17 @@ public class ZjxlSystemDictController extends BaseController {
            return write(-1,"修改上线失败");
        }
    }
    @RequestMapping(value = "/findNewsType", method = RequestMethod.GET)
    @ApiOperation("查询新闻中心分类")
    public String findNewsType( @ApiParam(name = "systemDictType", value = "类型 1-产品与服务  2-公司案例  3-新闻中心  4-关于我们", required = false) @RequestParam(value = "systemDictType", required = false)Integer systemDictType){
        try {
            List<ZjxlSystemDict> systemDictList = systemDictService.findNewsType(systemDictType);
            return write(200,"查询成功","data", systemDictList);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败");
        }
    }
}

+ 6 - 3
guns-main/src/main/java/cn/stylefeng/guns/zjxl/service/ZjxlArticleContentService.java

@ -85,7 +85,7 @@ public class ZjxlArticleContentService extends BaseService {
    }
    public List<ZjxlArticleContent> findNewsList(String id,String articleContentClassify,Integer systemDictType,Integer page,Integer pagesiz){
    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+"'";
@ -93,6 +93,9 @@ public class ZjxlArticleContentService extends BaseService {
        if (StringUtils.isNotEmpty(articleContentClassify)){
            sql += " and article_content_classify = '"+articleContentClassify+"'";
        }
        if (StringUtils.isNotEmpty(articleContentSubclassify)){
            sql += " and article_content_subclassify = '"+articleContentSubclassify+"'";
        }
        if (systemDictType != null && systemDictType > 0){
            sql += " and article_content_type = "+systemDictType+"";
        }
@ -101,8 +104,8 @@ public class ZjxlArticleContentService extends BaseService {
        return articleContentList;
    }
    public int allNewsCount(String articleContentClassify){
        String sql = "select count(*) from zjxl_article_content where article_content_type = 3  and article_content_classify = '"+articleContentClassify+"'";
    public int allNewsCount(String articleContentClassify,String articleContentSubclassify){
        String sql = "select count(*) from zjxl_article_content where article_content_type = 3  and article_content_classify = '"+articleContentClassify+"' and article_content_subclassify = '"+articleContentSubclassify+"'";
        Integer allCount = jdbcTemplate.queryForObject(sql, Integer.class);;
        return allCount;
    }

+ 11 - 0
guns-main/src/main/java/cn/stylefeng/guns/zjxl/service/ZjxlSystemDictService.java

@ -61,4 +61,15 @@ public class ZjxlSystemDictService extends BaseService {
        systemDictDao.deleteBySystemDictId(id);
        return 1;
    }
    public List<ZjxlSystemDict> findNewsType(Integer systemDictType){
        String sql = "select * from zjxl_system_dict where 1=1 ";
        if (systemDictType != null && systemDictType > 0){
            sql += " and system_dict_type = "+systemDictType+"";
        }
        sql += " group by system_dict_classify ";
        List<ZjxlSystemDict> systemDictList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlSystemDict.class));
        return systemDictList;
    }
}