Commit c64baecc by huangZW

111

parent 143e7816
......@@ -10,7 +10,7 @@ import java.util.List;
* Created by tgs on 2020/2/9.
*/
public interface DictApiService {
void saveDict(DictDTO dto);
int saveDict(DictDTO dto);
DictDTO findOneDict(String dictId);
......
......@@ -29,7 +29,13 @@ public class DictController extends WebBaseController{
//保存字典
@RequestMapping("save-dict")
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);
}
//查看字典详情
......
......@@ -67,6 +67,8 @@ public enum HaoBanErrCode {
ERR_10004(10004,"成员名称不能为空"),
ERR_10005(10005,"成员已存在"),
ERR_10006(10006,"字典key已存在"),
ERR_10007(10007,"字典名称已存在"),
ERR_DEFINE(-888, "自定义错误"),
......
......@@ -23,4 +23,8 @@ public interface DictMapper {
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{
@Autowired
private DictMapper dictMapper;
@Override
public void saveDict(DictDTO dto) {
public int saveDict(DictDTO dto) {
if(StringUtils.isBlank(dto.getDictId())){
//空,则新增
dto.setDictId(UuidUtil.randomUUID());
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{
TabHaobanDict tab = EntityUtil.changeEntity(TabHaobanDict.class, dto);
dictMapper.updateByPrimaryKeySelective(tab);
}
}
return 1;
}
@Override
......
......@@ -133,4 +133,19 @@
#{item}
</foreach>
</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>
\ 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