Преглед изворни кода

官网主页内容与摘要

Shi Kejing пре 4 година
родитељ
комит
382c3c5c76

+ 19 - 0
guns-main/src/main/java/cn/stylefeng/guns/zjxl/cnotroller/ZjxlArticleContentController.java

@ -58,6 +58,7 @@ public class ZjxlArticleContentController extends BaseController {
            @ApiParam(name = "articleContentTitle", value = "文章标题", required = false) @RequestParam(value = "articleContentTitle", required = false)String articleContentTitle,
            @ApiParam(name = "articleContentCover", value = "封面", required = false) @RequestParam(value = "articleContentCover", required = false)String articleContentCover,
            @ApiParam(name = "articleContentAbstract", value = "摘要", required = false) @RequestParam(value = "articleContentAbstract", required = false) String articleContentAbstract,
            @ApiParam(name = "articleContentContent", value = "内容", required = false) @RequestParam(value = "articleContentContent", required = false) String articleContentContent,
            @ApiParam(name = "articleContentType", value = "内容类型 1-产品与服务  2-公司案例  3-新闻中心  4-关于我们", required = false) @RequestParam(value = "articleContentType", required = false)Integer articleContentType,
            @ApiParam(name = "articleContentClassify", value = "分类", required = false) @RequestParam(value = "articleContentClassify", required = false)String articleContentClassify,
            @ApiParam(name = "articleContentSubclassify", value = "子分类", required = false) @RequestParam(value = "articleContentSubclassify", required = false)String articleContentSubclassify,
@ -73,6 +74,7 @@ public class ZjxlArticleContentController extends BaseController {
            articleContent.setArticleContentSubclassify(articleContentSubclassify);
            articleContent.setArticleContentSort(articleContentSort);
            articleContent.setArticleContentIsLine(articleContentIsLine);
            articleContent.setArticleContentContent(articleContentContent);
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
            articleContent.setArticleContentCreateTime(df.format(new Date()));// new Date()为获取当前系统时间
@ -173,4 +175,21 @@ public class ZjxlArticleContentController extends BaseController {
            return write(-1,"操作失败");
        }
    }
    @RequestMapping(value = "/findNewsList", method = RequestMethod.GET)
    @ApiOperation(value = "查询新闻中心列表")
    public String findNewsList(@ApiParam(name = "id", value = "文章id", required = false) @RequestParam(value = "id", required = false)String id,
                                        // @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 = "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)));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败");
        }
    }
}

+ 9 - 0
guns-main/src/main/java/cn/stylefeng/guns/zjxl/model/ZjxlArticleContent.java

@ -23,6 +23,7 @@ public class ZjxlArticleContent {
    private Integer articleContentSort;
    private Integer articleContentIsLine;
    private String articleContentCreateTime;
    private String articleContentContent;
    @Id
    public String getArticleContentId() {
@ -104,4 +105,12 @@ public class ZjxlArticleContent {
    public void setArticleContentCreateTime(String articleContentCreateTime) {
        this.articleContentCreateTime = articleContentCreateTime;
    }
    public String getArticleContentContent() {
        return articleContentContent;
    }
    public void setArticleContentContent(String articleContentContent) {
        this.articleContentContent = articleContentContent;
    }
}

+ 24 - 0
guns-main/src/main/java/cn/stylefeng/guns/zjxl/service/ZjxlArticleContentService.java

@ -83,4 +83,28 @@ public class ZjxlArticleContentService extends BaseService {
        List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
        return articleContentList;
    }
    public List<ZjxlArticleContent> findNewsList(String id,String articleContentClassify,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+"'";
        }
        if (StringUtils.isNotEmpty(articleContentClassify)){
            sql += " and article_content_classify = '"+articleContentClassify+"'";
        }
        if (systemDictType != null && systemDictType > 0){
            sql += " and article_content_type = "+systemDictType+"";
        }
        sql += " order by article_content_sort,article_content_create_time desc limit "+page+" , "+pagesiz+"";
        List<ZjxlArticleContent> articleContentList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlArticleContent.class));
        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+"'";
        Integer allCount = jdbcTemplate.queryForObject(sql, Integer.class);;
        return allCount;
    }
}