Commit 6e877f96 by qwmqiuwenmin

Merge branch 'developer' of http://115.159.76.241/haoban3.0/haoban-manage3.0.git into developer

parents 7139e9c1 c64baecc
......@@ -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
......
......@@ -28,7 +28,7 @@
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDict" >
insert into tab_haoban_dict (dict_id, dict_name, dict_key,
dict_title, dict_desc, dict_content,opt_user_name,opt_user_id,create_time,update_time
dict_title, dict_desc, dict_content,opt_user_id,opt_user_name,create_time,update_time
)
values (#{dictId,jdbcType=VARCHAR}, #{dictName,jdbcType=VARCHAR}, #{dictKey,jdbcType=VARCHAR},
#{dictTitle,jdbcType=VARCHAR}, #{dictDesc,jdbcType=VARCHAR}, #{dictContent,jdbcType=VARCHAR}
......@@ -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