Commit 599a7482 authored by fangxinjiang's avatar fangxinjiang

字典项优化

parent 47ce3629
...@@ -146,4 +146,9 @@ public interface ErrorCodes { ...@@ -146,4 +146,9 @@ public interface ErrorCodes {
* 已存在对应编码的字典 * 已存在对应编码的字典
*/ */
String SYS_DICT_ADD_TYPE_EXISTS = "sys.dict.add.type.exist"; String SYS_DICT_ADD_TYPE_EXISTS = "sys.dict.add.type.exist";
/**
* 已存在对应值的字典项
*/
String SYS_DICT_ITEM_ADD_VALUE_EXIST = "sys.dict.item.add.value.exist";
} }
...@@ -29,6 +29,7 @@ sys.dict.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u8 ...@@ -29,6 +29,7 @@ sys.dict.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u8
sys.dict.update.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u80FD\u4FEE\u6539 sys.dict.update.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u80FD\u4FEE\u6539
sys.dict.delete.existing=\u5B57\u5178\u5B58\u5728\u4E0B\u7EA7\u8282\u70B9\u4E0D\u80FD\u5220\u9664 sys.dict.delete.existing=\u5B57\u5178\u5B58\u5728\u4E0B\u7EA7\u8282\u70B9\u4E0D\u80FD\u5220\u9664
sys.dict.add.type.exist=\u5DF2\u5B58\u5728\u5BF9\u5E94\u7F16\u7801\u7684\u5B57\u5178 sys.dict.add.type.exist=\u5DF2\u5B58\u5728\u5BF9\u5E94\u7F16\u7801\u7684\u5B57\u5178
sys.dict.item.add.value.exist=\u5DF2\u5B58\u5728\u5BF9\u5E94\u503C\u7684\u5B57\u5178\u9879
sys.role.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u89D2\u8272\u4E0D\u80FD\u5220\u9664 sys.role.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u89D2\u8272\u4E0D\u80FD\u5220\u9664
sys.role.update.system=\u7CFB\u7EDF\u5185\u7F6E\u89D2\u8272\u4E0D\u80FD\u4FEE\u6539 sys.role.update.system=\u7CFB\u7EDF\u5185\u7F6E\u89D2\u8272\u4E0D\u80FD\u4FEE\u6539
......
...@@ -180,6 +180,13 @@ public class DictController { ...@@ -180,6 +180,13 @@ public class DictController {
@PostMapping("/item") @PostMapping("/item")
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true) @CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public R<Boolean> save(@RequestBody SysDictItem sysDictItem) { public R<Boolean> save(@RequestBody SysDictItem sysDictItem) {
SysDictItem item = sysDictItemService.getOne(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getType,sysDictItem.getType())
.eq(SysDictItem::getValue,sysDictItem.getValue())
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(item)){
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_DICT_ITEM_ADD_VALUE_EXIST));
}
return R.ok(sysDictItemService.save(sysDictItem)); return R.ok(sysDictItemService.save(sysDictItem));
} }
...@@ -191,6 +198,14 @@ public class DictController { ...@@ -191,6 +198,14 @@ public class DictController {
@SysLog("修改字典项") @SysLog("修改字典项")
@PutMapping("/item") @PutMapping("/item")
public R updateById(@RequestBody SysDictItem sysDictItem) { public R updateById(@RequestBody SysDictItem sysDictItem) {
SysDictItem item = sysDictItemService.getOne(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getType,sysDictItem.getType())
.ne(SysDictItem::getId,sysDictItem.getDictId())
.eq(SysDictItem::getValue,sysDictItem.getValue())
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(item)){
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_DICT_ITEM_ADD_VALUE_EXIST));
}
return R.ok(sysDictItemService.updateDictItem(sysDictItem)); return R.ok(sysDictItemService.updateDictItem(sysDictItem));
} }
......
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