疯狂的狮子li
2020-02-13 2841620be623be15c1832a783136a2b73c2b4424
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,141 @@
package com.ruoyi.project.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.system.domain.SysDictType;
import com.ruoyi.project.system.mapper.SysDictDataMapper;
import com.ruoyi.project.system.mapper.SysDictTypeMapper;
import com.ruoyi.project.system.service.ISysDictTypeService;
/**
 * å­—å…¸ ä¸šåŠ¡å±‚å¤„ç†
 *
 * @author ruoyi
 */
@Service
public class SysDictTypeServiceImpl implements ISysDictTypeService
{
    @Autowired
    private SysDictTypeMapper dictTypeMapper;
    @Autowired
    private SysDictDataMapper dictDataMapper;
    /**
     * æ ¹æ®æ¡ä»¶åˆ†é¡µæŸ¥è¯¢å­—典类型
     *
     * @param dictType å­—典类型信息
     * @return å­—典类型集合信息
     */
    @Override
    public List<SysDictType> selectDictTypeList(SysDictType dictType)
    {
        return dictTypeMapper.selectDictTypeList(dictType);
    }
    /**
     * æ ¹æ®æ‰€æœ‰å­—典类型
     *
     * @return å­—典类型集合信息
     */
    @Override
    public List<SysDictType> selectDictTypeAll()
    {
        return dictTypeMapper.selectDictTypeAll();
    }
    /**
     * æ ¹æ®å­—典类型ID查询信息
     *
     * @param dictId å­—典类型ID
     * @return å­—典类型
     */
    @Override
    public SysDictType selectDictTypeById(Long dictId)
    {
        return dictTypeMapper.selectDictTypeById(dictId);
    }
    /**
     * æ ¹æ®å­—典类型查询信息
     *
     * @param dictType å­—典类型
     * @return å­—典类型
     */
    public SysDictType selectDictTypeByType(String dictType)
    {
        return dictTypeMapper.selectDictTypeByType(dictType);
    }
    /**
     * é€šè¿‡å­—å…¸ID删除字典信息
     *
     * @param dictId å­—å…¸ID
     * @return ç»“æžœ
     */
    @Override
    public int deleteDictTypeById(Long dictId)
    {
        return dictTypeMapper.deleteDictTypeById(dictId);
    }
    /**
     * æ‰¹é‡åˆ é™¤å­—典类型信息
     *
     * @param dictIds éœ€è¦åˆ é™¤çš„å­—å…¸ID
     * @return ç»“æžœ
     */
    public int deleteDictTypeByIds(Long[] dictIds)
    {
        return dictTypeMapper.deleteDictTypeByIds(dictIds);
    }
    /**
     * æ–°å¢žä¿å­˜å­—典类型信息
     *
     * @param dictType å­—典类型信息
     * @return ç»“æžœ
     */
    @Override
    public int insertDictType(SysDictType dictType)
    {
        return dictTypeMapper.insertDictType(dictType);
    }
    /**
     * ä¿®æ”¹ä¿å­˜å­—典类型信息
     *
     * @param dictType å­—典类型信息
     * @return ç»“æžœ
     */
    @Override
    @Transactional
    public int updateDictType(SysDictType dictType)
    {
        SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());
        dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType());
        return dictTypeMapper.updateDictType(dictType);
    }
    /**
     * æ ¡éªŒå­—典类型称是否唯一
     *
     * @param dict å­—典类型
     * @return ç»“æžœ
     */
    @Override
    public String checkDictTypeUnique(SysDictType dict)
    {
        Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
        SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
        if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }
}