数据字典重复值问题
This commit is contained in:
parent
ac50102555
commit
cffcc9e372
|
|
@ -85,8 +85,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
public List<TreeSelect> selectDeptUserTreeList(SysDept dept)
|
||||
{
|
||||
if (dept != null && dept.getDeptId() != null && dept.getDeptId() == 0L) {
|
||||
List<SysDept> userList = userMapper.getTree(dept);
|
||||
return buildDeptTreeSelect(userList);
|
||||
List<SysDept> deptList = userMapper.getTree(dept);
|
||||
return buildDeptTreeSelect(deptList);
|
||||
}
|
||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
for (SysDept sysDept : depts) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -106,6 +108,9 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
|||
@Override
|
||||
public int updateDictData(SysDictData data)
|
||||
{
|
||||
if (checkIfDictValueOrLabelAreRepeat(data)) {
|
||||
throw new ServiceException("发现重复字典标签或字典键值");
|
||||
}
|
||||
int row = dictDataMapper.updateDictData(data);
|
||||
if (row > 0)
|
||||
{
|
||||
|
|
@ -124,8 +129,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
|||
boolean checkIfDictValueOrLabelAreRepeat(SysDictData data) {
|
||||
boolean result = false;
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
if (!CollectionUtils.isEmpty(dictDatas)) {
|
||||
for (SysDictData dictData : dictDatas) {
|
||||
List<SysDictData> filteredItems = dictDatas.stream().collect(Collectors.toList());
|
||||
if (Objects.nonNull(data.getDictCode())) {
|
||||
filteredItems = dictDatas.stream().filter(item -> !data.getDictCode().equals(item.getDictCode())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(filteredItems)) {
|
||||
for (SysDictData dictData : filteredItems) {
|
||||
if (dictData.getDictLabel().equals(data.getDictLabel()) || dictData.getDictValue().equals(data.getDictValue())) {
|
||||
result = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue