Bingbing 4 år sedan
förälder
incheckning
e943df9607

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

@ -1,7 +1,9 @@
package cn.stylefeng.guns.zjxl.cnotroller;
import cn.stylefeng.guns.zjxl.model.ZjxlArticleContent;
import cn.stylefeng.guns.zjxl.model.ZjxlSystemDict;
import cn.stylefeng.guns.zjxl.service.ZjxlArticleContentService;
import cn.stylefeng.guns.zjxl.service.ZjxlSystemDictService;
import cn.stylefeng.guns.zjxlUtil.BaseController;
import cn.stylefeng.guns.zjxlUtil.PageUtil;
import com.alibaba.fastjson.JSONObject;
@ -9,6 +11,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jdk.nashorn.internal.ir.WithNode;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -39,6 +42,9 @@ public class ZjxlArticleContentController extends BaseController {
    @Autowired
    private ZjxlArticleContentService articleContentService;
    @Autowired
    private ZjxlSystemDictService systemDictService;
    @RequestMapping(value = "/findArticleContentById", method = RequestMethod.GET)
    @ApiOperation(value = "查询文章管理列表")
    public String findArticleContentById(@ApiParam(name = "id", value = "文章id", required = false) @RequestParam(value = "id", required = false)String id,
@ -74,8 +80,9 @@ public class ZjxlArticleContentController extends BaseController {
            if (list.size() > 0){
                Iterator<ZjxlArticleContent> iterator = list.iterator();
                while (iterator.hasNext()){
                    if (articleContentTitle.equals(iterator.next()));
                    return write(-1,"改文章已存在");
                    if (articleContentTitle.equals(iterator.next().getArticleContentTitle())){
                        return write(-1,"改文章已存在");
                    }
                }
            }
@ -162,7 +169,20 @@ public class ZjxlArticleContentController extends BaseController {
            }
            logger.info("内容类型:articleContentType====="+articleContentType);
            logger.info("分类:articleContentClassify====="+articleContentClassify);
            return write(200,"操作成功","data",articleContentService.getArticleContentSubclassify(articleContentType,articleContentClassify));
            List<ZjxlArticleContent> list = articleContentService.getArticleContentSubclassify(articleContentType,articleContentClassify);
            if (list.size() > 0){
                return write(200,"操作成功","data",list);
            }else {
                ZjxlArticleContent content = new ZjxlArticleContent();
                List<ZjxlSystemDict> systemDictList = systemDictService.findNewsTypeA(new Integer(articleContentType),articleContentClassify);
                if (systemDictList.size() > 0){
                    for (int i=0;i<systemDictList.size();i++){
                        content.setArticleContentSubclassify(systemDictList.get(i).getSystemDictSubclassify());
                        list.add(content);
                    }
                }
             return write(200,"操作成功","data",list);
            }
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"操作失败");

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

@ -130,6 +130,18 @@ public class ZjxlSystemDictController extends BaseController {
        }
    }
    @RequestMapping(value = "/findAllType", method = RequestMethod.GET)
    @ApiOperation("获取系统字典的所有分类")
    public String findAllType(){
        try {
            List<ZjxlSystemDict> systemDictList = systemDictService.findAllType();
            return write(200,"查询成功","data", systemDictList);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/updateSystemDictInfo", method = RequestMethod.POST)
    @ApiOperation("修改字典表信息")
    public String updateSystemDictInfo(

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

@ -82,6 +82,7 @@ public class ZjxlArticleContentService extends BaseService {
        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;
        //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){

+ 13 - 1
guns-main/src/main/java/cn/stylefeng/guns/zjxl/service/ZjxlSystemDictService.java

@ -33,7 +33,6 @@ public class ZjxlSystemDictService extends BaseService {
    @Autowired
    private ZjxlSystemDictDao systemDictDao;
    public String addSystemDict(ZjxlSystemDict systemDict){
        systemDict.setSystemDictId(getCode());
        ZjxlSystemDict dict = systemDictDao.save(systemDict);
@ -124,4 +123,17 @@ public class ZjxlSystemDictService extends BaseService {
        result.put("dictInfo", JSON.toJSONString(zjxlSystemDict));
        return result;
    }
    public List<ZjxlSystemDict> findAllType(){
        String sql = "select * from zjxl_system_dict where system_dict_is_line = 1 group by system_dict_type";
        List<ZjxlSystemDict> systemDictList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlSystemDict.class));
        return systemDictList;
    }
    public List<ZjxlSystemDict> findNewsTypeA(Integer systemDictType,String articleContentClassify){
        String sql = "select * from zjxl_system_dict where system_dict_type = "+systemDictType+"    AND system_dict_classify = '"+articleContentClassify+"' group by system_dict_subclassify";
        List<ZjxlSystemDict> systemDictList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ZjxlSystemDict.class));
        return systemDictList;
    }
}