Commit 203861aa20ab0ec970017779dc39b6793a60d8fa
1 parent
a4d09e52ba
Exists in
master
and in
1 other branch
查询同vtype类型,字典编码是否重复bug
Showing 1 changed file with 20 additions and 2 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/RegionsController.java
View file @
203861a
... | ... | @@ -14,7 +14,9 @@ |
14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
15 | 15 | import org.springframework.web.bind.annotation.*; |
16 | 16 | |
17 | +import java.util.HashMap; | |
17 | 18 | import java.util.List; |
19 | +import java.util.Map; | |
18 | 20 | |
19 | 21 | /** |
20 | 22 | * 获取区域 |
... | ... | @@ -112,6 +114,8 @@ |
112 | 114 | public BaseResponse getDictByParam(Integer vtype, Integer code,String value, @RequestParam(required = false) Integer id){ |
113 | 115 | BaseResponse baseResponse=new BaseResponse(); |
114 | 116 | try { |
117 | + Map<String, Boolean> map= new HashMap<>(); | |
118 | + map.put("code", true);map.put("value", true); | |
115 | 119 | QueryWrapper<LymsDict> queryWrapper=new QueryWrapper<>(); |
116 | 120 | queryWrapper.eq("vtype", vtype); |
117 | 121 | queryWrapper.eq("code", code).or().eq("value",value ); |
118 | 122 | |
... | ... | @@ -120,10 +124,24 @@ |
120 | 124 | queryWrapper2.eq("id", id); |
121 | 125 | LymsDict dict2=lymsDictService.getOne(queryWrapper2); |
122 | 126 | LymsDict dict=lymsDictService.getOne(queryWrapper); |
123 | - baseResponse.setObject(null==dict?true:(dict2.getCode().equals(code)&&dict2.getValue().equals(value)?true:false)); | |
127 | + if(null!=dict){ | |
128 | + if(null!=code && dict2.getCode()!=code){ | |
129 | + map.put("code", false); | |
130 | + } | |
131 | + if(StringUtil.isNotEmpty(value) && !value.equals(dict2.getValue())){ | |
132 | + map.put("value", false); | |
133 | + } | |
134 | + } | |
135 | + baseResponse.setObject(map); | |
124 | 136 | }else { |
125 | 137 | LymsDict dict=lymsDictService.getOne(queryWrapper); |
126 | - baseResponse.setObject(null==dict?true:false); | |
138 | + if(null!=code && dict.getCode()==code){ | |
139 | + map.put("code", false); | |
140 | + } | |
141 | + if(StringUtil.isNotEmpty(value) && value.equals(dict.getValue())){ | |
142 | + map.put("value", false); | |
143 | + } | |
144 | + baseResponse.setObject(map); | |
127 | 145 | } |
128 | 146 | baseResponse.setErrormsg("成功"); |
129 | 147 | } catch (Exception e) { |