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