Search in sources :

Example 1 with SysDictType

use of com.ruoyi.system.api.domain.SysDictType in project RuoYi-Cloud by yangzongzhuan.

the class SysDictTypeServiceImpl method deleteDictTypeByIds.

/**
 * 批量删除字典类型信息
 *
 * @param dictIds 需要删除的字典ID
 */
@Override
public void deleteDictTypeByIds(Long[] dictIds) {
    for (Long dictId : dictIds) {
        SysDictType dictType = selectDictTypeById(dictId);
        if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) {
            throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
        }
        dictTypeMapper.deleteDictTypeById(dictId);
        DictUtils.removeDictCache(dictType.getDictType());
    }
}
Also used : ServiceException(com.ruoyi.common.core.exception.ServiceException) SysDictType(com.ruoyi.system.api.domain.SysDictType)

Example 2 with SysDictType

use of com.ruoyi.system.api.domain.SysDictType in project RuoYi-Cloud by yangzongzhuan.

the class SysDictTypeServiceImpl method updateDictType.

/**
 * 修改保存字典类型信息
 *
 * @param dict 字典类型信息
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
public int updateDictType(SysDictType dict) {
    SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
    dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
    int row = dictTypeMapper.updateDictType(dict);
    if (row > 0) {
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType());
        DictUtils.setDictCache(dict.getDictType(), dictDatas);
    }
    return row;
}
Also used : SysDictData(com.ruoyi.system.api.domain.SysDictData) SysDictType(com.ruoyi.system.api.domain.SysDictType) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SysDictType

use of com.ruoyi.system.api.domain.SysDictType in project RuoYi-Cloud by yangzongzhuan.

the class SysDictTypeServiceImpl method checkDictTypeUnique.

/**
 * 校验字典类型称是否唯一
 *
 * @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;
}
Also used : SysDictType(com.ruoyi.system.api.domain.SysDictType)

Example 4 with SysDictType

use of com.ruoyi.system.api.domain.SysDictType in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysDictTypeServiceImpl method updateDictType.

/**
 * 修改保存字典类型信息
 *
 * @param dict 字典类型信息
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
public int updateDictType(SysDictType dict) {
    SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
    dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
    int row = dictTypeMapper.updateDictType(dict);
    if (row > 0) {
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType());
        DictUtils.setDictCache(dict.getDictType(), dictDatas);
    }
    return row;
}
Also used : SysDictData(com.ruoyi.system.api.domain.SysDictData) SysDictType(com.ruoyi.system.api.domain.SysDictType) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with SysDictType

use of com.ruoyi.system.api.domain.SysDictType in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysDictTypeServiceImpl method deleteDictTypeByIds.

/**
 * 批量删除字典类型信息
 *
 * @param dictIds 需要删除的字典ID
 */
@Override
public void deleteDictTypeByIds(Long[] dictIds) {
    for (Long dictId : dictIds) {
        SysDictType dictType = selectDictTypeById(dictId);
        if (dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, dictType.getDictType()))) {
            throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
        }
        DictUtils.removeDictCache(dictType.getDictType());
    }
    baseMapper.deleteBatchIds(Arrays.asList(dictIds));
}
Also used : ServiceException(com.ruoyi.common.core.exception.ServiceException) SysDictType(com.ruoyi.system.api.domain.SysDictType) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

SysDictType (com.ruoyi.system.api.domain.SysDictType)8 ServiceException (com.ruoyi.common.core.exception.ServiceException)3 SysDictData (com.ruoyi.system.api.domain.SysDictData)3 Transactional (org.springframework.transaction.annotation.Transactional)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1