Commit c64baecc by huangZW

111

parent 143e7816
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
* Created by tgs on 2020/2/9. * Created by tgs on 2020/2/9.
*/ */
public interface DictApiService { public interface DictApiService {
void saveDict(DictDTO dto); int saveDict(DictDTO dto);
DictDTO findOneDict(String dictId); DictDTO findOneDict(String dictId);
......
...@@ -29,7 +29,13 @@ public class DictController extends WebBaseController{ ...@@ -29,7 +29,13 @@ public class DictController extends WebBaseController{
//保存字典 //保存字典
@RequestMapping("save-dict") @RequestMapping("save-dict")
public HaobanResponse saveDict(DictDTO dto) { public HaobanResponse saveDict(DictDTO dto) {
dictApiService.saveDict(dto); int i = dictApiService.saveDict(dto);
if(i == 8){
return resultResponse(HaoBanErrCode.ERR_10006);
}
if(i == 9){
return resultResponse(HaoBanErrCode.ERR_10007);
}
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
//查看字典详情 //查看字典详情
......
...@@ -67,6 +67,8 @@ public enum HaoBanErrCode { ...@@ -67,6 +67,8 @@ public enum HaoBanErrCode {
ERR_10004(10004,"成员名称不能为空"), ERR_10004(10004,"成员名称不能为空"),
ERR_10005(10005,"成员已存在"), ERR_10005(10005,"成员已存在"),
ERR_10006(10006,"字典key已存在"),
ERR_10007(10007,"字典名称已存在"),
ERR_DEFINE(-888, "自定义错误"), ERR_DEFINE(-888, "自定义错误"),
......
...@@ -23,4 +23,8 @@ public interface DictMapper { ...@@ -23,4 +23,8 @@ public interface DictMapper {
List<TabHaobanDict> queryList(@Param("keys") List<String> keys); List<TabHaobanDict> queryList(@Param("keys") List<String> keys);
TabHaobanDict selectByDictKey(String dictKey);
TabHaobanDict selectByDictName(String dictKey);
} }
\ No newline at end of file
...@@ -26,16 +26,25 @@ public class DictApiServiceImpl implements DictApiService{ ...@@ -26,16 +26,25 @@ public class DictApiServiceImpl implements DictApiService{
@Autowired @Autowired
private DictMapper dictMapper; private DictMapper dictMapper;
@Override @Override
public void saveDict(DictDTO dto) { public int saveDict(DictDTO dto) {
if(StringUtils.isBlank(dto.getDictId())){ if(StringUtils.isBlank(dto.getDictId())){
//空,则新增 //空,则新增
dto.setDictId(UuidUtil.randomUUID()); dto.setDictId(UuidUtil.randomUUID());
TabHaobanDict tab = EntityUtil.changeEntity(TabHaobanDict.class, dto); TabHaobanDict tab = EntityUtil.changeEntity(TabHaobanDict.class, dto);
dictMapper.insert(tab); TabHaobanDict tab1 = dictMapper.selectByDictKey(dto.getDictKey());
if(tab1!=null){
return 8;
}
TabHaobanDict tab2 = dictMapper.selectByDictName(dto.getDictName());
if(tab2!=null){
return 9;
}
dictMapper.insert(tab);
}else{ }else{
TabHaobanDict tab = EntityUtil.changeEntity(TabHaobanDict.class, dto); TabHaobanDict tab = EntityUtil.changeEntity(TabHaobanDict.class, dto);
dictMapper.updateByPrimaryKeySelective(tab); dictMapper.updateByPrimaryKeySelective(tab);
} }
return 1;
} }
@Override @Override
......
...@@ -133,4 +133,19 @@ ...@@ -133,4 +133,19 @@
#{item} #{item}
</foreach> </foreach>
</select> </select>
<select id="selectByDictKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_dict
where dict_key = #{dictKey,jdbcType=VARCHAR}
and status_flag = 1
</select>
<select id="selectByDictName" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_dict
where dict_name = #{dictName,jdbcType=VARCHAR}
and status_flag = 1
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment