rk
2025-09-28 2304d7b140c5c5b4bf3a83f9ced8bff37d20c42e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.doumee.biz.system.impl;
 
import com.doumee.biz.system.SystemDictBiz;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.dao.system.model.SystemDict;
import com.doumee.service.system.SystemDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service
public class SystemDictBizImpl implements SystemDictBiz {
 
    @Autowired
    private SystemDictService systemDictService;
 
    @Override
    public Integer create(SystemDict systemDict) {
        SystemDict queryDto = new SystemDict();
        queryDto.setCode(systemDict.getCode());
        queryDto.setDeleted(Boolean.FALSE);
        SystemDict dict = systemDictService.findOne(queryDto);
        if (dict != null) {
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "字典编码已存在");
        }
        return systemDictService.create(systemDict);
    }
 
    @Override
    public void updateById(SystemDict systemDict) {
        SystemDict queryDto = new SystemDict();
        queryDto.setCode(systemDict.getCode());
        queryDto.setDeleted(Boolean.FALSE);
        SystemDict dict = systemDictService.findOne(queryDto);
        if (dict != null && !dict.getId().equals(systemDict.getId())) {
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "字典编码已存在");
        }
        systemDictService.updateById(systemDict);
    }
}