Search in sources :

Example 1 with SysDictType

use of com.ruoyi.common.core.domain.entity.SysDictType in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysDictTypeServiceImpl method updateDictType.

/**
 * 修改保存字典类型信息
 *
 * @param dict 字典类型信息
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
public int updateDictType(SysDictType dict) {
    SysDictType oldDict = baseMapper.selectById(dict.getDictId());
    dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>().set(SysDictData::getDictType, dict.getDictType()).eq(SysDictData::getDictType, oldDict.getDictType()));
    int row = baseMapper.updateById(dict);
    if (row > 0) {
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType());
        RedisUtils.setCacheObject(getCacheKey(dict.getDictType()), dictDatas);
    }
    return row;
}
Also used : SysDictData(com.ruoyi.common.core.domain.entity.SysDictData) SysDictType(com.ruoyi.common.core.domain.entity.SysDictType) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SysDictType

use of com.ruoyi.common.core.domain.entity.SysDictType in project RuoYi-Flowable-Plus by KonBAI-Q.

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()));
        }
        RedisUtils.deleteObject(getCacheKey(dictType.getDictType()));
    }
    baseMapper.deleteBatchIds(Arrays.asList(dictIds));
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) SysDictType(com.ruoyi.common.core.domain.entity.SysDictType) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 3 with SysDictType

use of com.ruoyi.common.core.domain.entity.SysDictType in project RuoYi-Vue-Plus by JavaLionLi.

the class SysDictTypeServiceImpl method updateDictType.

/**
 * 修改保存字典类型信息
 *
 * @param dict 字典类型信息
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
public int updateDictType(SysDictType dict) {
    SysDictType oldDict = baseMapper.selectById(dict.getDictId());
    dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>().set(SysDictData::getDictType, dict.getDictType()).eq(SysDictData::getDictType, oldDict.getDictType()));
    int row = baseMapper.updateById(dict);
    if (row > 0) {
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType());
        RedisUtils.setCacheObject(getCacheKey(dict.getDictType()), dictDatas);
    }
    return row;
}
Also used : SysDictData(com.ruoyi.common.core.domain.entity.SysDictData) SysDictType(com.ruoyi.common.core.domain.entity.SysDictType) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with SysDictType

use of com.ruoyi.common.core.domain.entity.SysDictType in project RuoYi-Vue-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()));
        }
        RedisUtils.deleteObject(getCacheKey(dictType.getDictType()));
    }
    baseMapper.deleteBatchIds(Arrays.asList(dictIds));
}
Also used : ServiceException(com.ruoyi.common.exception.ServiceException) SysDictType(com.ruoyi.common.core.domain.entity.SysDictType) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 5 with SysDictType

use of com.ruoyi.common.core.domain.entity.SysDictType in project wumei-smart by kerwincui.

the class SysDictTypeServiceImpl method deleteDictTypeByIds.

/**
 * 批量删除字典类型信息
 *
 * @param dictIds 需要删除的字典ID
 * @return 结果
 */
@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)

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