Bingbing %!s(int64=4) %!d(string=hai) anos
pai
achega
959ffc65cd

+ 4 - 5
guns-main/src/main/java/cn/stylefeng/guns/zjxl/cnotroller/ZjxlSystemDictController.java

@ -64,13 +64,12 @@ public class ZjxlSystemDictController extends BaseController {
            ZjxlSystemDict systemDict = new ZjxlSystemDict();
            systemDict.setSystemDictType(systemDictType);
            //查询分类是否存在
            int systemDictClassifyList = systemDictService.findSystemDictClassify(systemDictClassify);
            //查询子分类是否存在
            int systemDictSubclassifyList = systemDictService.findSystemDictSubclassify(systemDictSubclassify);
            if (systemDictClassifyList>0){
            int systemIsExist = systemDictService.findSystemDictExistByCondition(null,systemDictType,systemDictClassify,null);
            if (systemIsExist>0){
                return write(-1,"该分类已存在,请勿重复添加");
            }
            if (systemDictSubclassifyList>0){
            systemIsExist = systemDictService.findSystemDictExistByCondition(null,systemDictType,systemDictClassify,systemDictSubclassify);
            if (systemIsExist>0){
                return write(-1,"该子分类已存在,请勿重复添加");
            }
            systemDict.setSystemDictClassify(systemDictClassify);

+ 17 - 8
guns-main/src/main/java/cn/stylefeng/guns/zjxl/service/ZjxlSystemDictService.java

@ -51,12 +51,22 @@ public class ZjxlSystemDictService extends BaseService {
        return articleContentList;
    }
    public int findSystemDictClassifyByCondition(String systemDictClassify,String dictId){
        String sql = "select count(1) from zjxl_system_dict where system_dict_classify = '"+systemDictClassify+"' ";
        if (StringUtils.isNoneBlank(dictId)){
            sql +="and system_dict_id <>'"+dictId+"' ";
    public int findSystemDictExistByCondition(String id,Integer systemDictType,String systemDictClassify,String systemDictSubclassify){
        StringBuffer sql = new StringBuffer("select count(1) from zjxl_system_dict where 1=1 ");
        if(StringUtils.isNoneBlank(id)){
            sql.append("and system_dict_id <>'"+id+"' ");
        }
        Integer articleContentList = jdbcTemplate.queryForObject(sql, Integer.class);
        if (systemDictType !=null){
            sql.append("and system_dict_type ='"+systemDictType+"' ");
        }
        if (StringUtils.isNoneBlank(systemDictClassify)){
           sql.append("and system_dict_classify ='"+systemDictClassify+"' ");
        }
        if (StringUtils.isNoneBlank(systemDictSubclassify)){
            sql.append("and system_dict_subclassify ='"+systemDictSubclassify+"' ");
        }
        Integer articleContentList = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
        return articleContentList;
    }
@ -120,10 +130,9 @@ public class ZjxlSystemDictService extends BaseService {
            result.put("status",-1);
            return result;
        }
        int systemDictClassifyList = findSystemDictClassifyByCondition(systemDictClassify,systemDictId);
        //查询子分类是否存在
        int systemDictSubclassifyList = findSystemDictSubclassifyByCondition(systemDictSubclassify,systemDictId);
        if (systemDictClassifyList>0&&systemDictSubclassifyList>0){
        int systemIsExist = findSystemDictExistByCondition(systemDictId,systemDictType,systemDictClassify,systemDictSubclassify);
        if (systemIsExist>0){
            result.put("status",0);
            return result;
        }