Search in sources :

Example 1 with SysDictType

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

the class SysDictTypeServiceImpl method updateDictType.

/**
 * 修改保存字典类型信息
 *
 * @param dict 字典类型信息
 * @return 结果
 */
@Override
@Transactional
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.project.system.domain.SysDictData) SysDictType(com.ruoyi.project.system.domain.SysDictType) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SysDictType

use of com.ruoyi.project.system.domain.SysDictType in project RuoYi-Vue-Oracle 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.project.system.domain.SysDictType)

Example 3 with SysDictType

use of com.ruoyi.project.system.domain.SysDictType in project RuoYi-Vue-Oracle 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.exception.ServiceException) SysDictType(com.ruoyi.project.system.domain.SysDictType)

Example 4 with SysDictType

use of com.ruoyi.project.system.domain.SysDictType in project RuoYi-Vue-fast by yangzongzhuan.

the class SysDictTypeServiceImpl method updateDictType.

/**
 * 修改保存字典类型信息
 *
 * @param dict 字典类型信息
 * @return 结果
 */
@Override
@Transactional
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.project.system.domain.SysDictData) SysDictType(com.ruoyi.project.system.domain.SysDictType) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with SysDictType

use of com.ruoyi.project.system.domain.SysDictType in project RuoYi-Vue-fast 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.project.system.domain.SysDictType)

Aggregations

SysDictType (com.ruoyi.project.system.domain.SysDictType)6 ServiceException (com.ruoyi.common.exception.ServiceException)2 SysDictData (com.ruoyi.project.system.domain.SysDictData)2 Transactional (org.springframework.transaction.annotation.Transactional)2