ZQN
2024-06-19 e59e6a8a2fcf3ac2194a69927cd5690453a83e91
project-system/src/main/java/com/project/system/service/impl/SysDictDataServiceImpl.java
@@ -1,12 +1,14 @@
package com.project.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.project.common.core.domain.entity.SysDictData;
import com.project.common.exception.base.BaseException;
import com.project.common.utils.DictUtils;
import com.project.system.mapper.SysDictDataMapper;
import com.project.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 字典 业务层处理
@@ -95,6 +97,14 @@
    @Override
    public int insertDictData(SysDictData data)
    {
        int valueCount = dictDataMapper.countByDictTypeAndValue(data.getDictType(),data.getDictValue(), null);
        if (valueCount>0) {
            throw new BaseException("类型中字典值已存在!");
        }
        int labelCount = dictDataMapper.countByDictTypeAndLabel(data.getDictType(),data.getDictLabel(), null);
        if (labelCount>0) {
            throw new BaseException("类型中字典标签已存在!");
        }
        int row = dictDataMapper.insertDictData(data);
        if (row > 0)
        {
@@ -113,6 +123,14 @@
    @Override
    public int updateDictData(SysDictData data)
    {
        int valueCount = dictDataMapper.countByDictTypeAndValue(data.getDictType(),data.getDictValue(), data.getDictCode());
        if (valueCount>0) {
            throw new BaseException("类型中字典值已存在!");
        }
        int labelCount = dictDataMapper.countByDictTypeAndLabel(data.getDictType(),data.getDictLabel(), data.getDictCode());
        if (labelCount>0) {
            throw new BaseException("类型中字典标签已存在!");
        }
        int row = dictDataMapper.updateDictData(data);
        if (row > 0)
        {