Search in sources :

Example 11 with SysDictType

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

Example 12 with SysDictType

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

Example 13 with SysDictType

use of com.ruoyi.common.core.domain.entity.SysDictType in project hocassian-media-matrix by hokaso.

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.common.core.domain.entity.SysDictType)

Example 14 with SysDictType

use of com.ruoyi.common.core.domain.entity.SysDictType in project hocassian-media-matrix by hokaso.

the class SysDictTypeServiceImpl method init.

/**
 * 项目启动时,初始化字典到缓存
 */
@PostConstruct
public void init() {
    List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
    for (SysDictType dictType : dictTypeList) {
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
        DictUtils.setDictCache(dictType.getDictType(), dictDatas);
    }
}
Also used : SysDictData(com.ruoyi.common.core.domain.entity.SysDictData) SysDictType(com.ruoyi.common.core.domain.entity.SysDictType) PostConstruct(javax.annotation.PostConstruct)

Aggregations

SysDictType (com.ruoyi.common.core.domain.entity.SysDictType)14 SysDictData (com.ruoyi.common.core.domain.entity.SysDictData)6 Transactional (org.springframework.transaction.annotation.Transactional)5 ServiceException (com.ruoyi.common.exception.ServiceException)4 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 PostConstruct (javax.annotation.PostConstruct)1