Search in sources :

Example 16 with SysDictData

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

the class SysDictTypeServiceImpl method getDictValue.

/**
 * 根据字典类型和字典标签获取字典值
 *
 * @param dictType  字典类型
 * @param dictLabel 字典标签
 * @param separator 分隔符
 * @return 字典值
 */
@Override
public String getDictValue(String dictType, String dictLabel, String separator) {
    StringBuilder propertyString = new StringBuilder();
    List<SysDictData> datas = selectDictDataByType(dictType);
    if (StringUtils.containsAny(dictLabel, separator) && CollUtil.isNotEmpty(datas)) {
        for (SysDictData dict : datas) {
            for (String label : dictLabel.split(separator)) {
                if (label.equals(dict.getDictLabel())) {
                    propertyString.append(dict.getDictValue() + separator);
                    break;
                }
            }
        }
    } else {
        for (SysDictData dict : datas) {
            if (dictLabel.equals(dict.getDictLabel())) {
                return dict.getDictValue();
            }
        }
    }
    return StringUtils.stripEnd(propertyString.toString(), separator);
}
Also used : SysDictData(com.ruoyi.common.core.domain.entity.SysDictData)

Example 17 with SysDictData

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

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.common.core.domain.entity.SysDictData) SysDictType(com.ruoyi.common.core.domain.entity.SysDictType) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with SysDictData

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

the class SysDictDataServiceImpl method deleteDictDataByIds.

/**
 * 批量删除字典数据信息
 *
 * @param dictCodes 需要删除的字典数据ID
 * @return 结果
 */
@Override
public void deleteDictDataByIds(Long[] dictCodes) {
    for (Long dictCode : dictCodes) {
        SysDictData data = selectDictDataById(dictCode);
        dictDataMapper.deleteDictDataById(dictCode);
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
        DictUtils.setDictCache(data.getDictType(), dictDatas);
    }
}
Also used : SysDictData(com.ruoyi.common.core.domain.entity.SysDictData)

Example 19 with SysDictData

use of com.ruoyi.common.core.domain.entity.SysDictData in project RuoYi-Vue by yangzongzhuan.

the class DictUtils method getDictValue.

/**
 * 根据字典类型和字典标签获取字典值
 *
 * @param dictType 字典类型
 * @param dictLabel 字典标签
 * @param separator 分隔符
 * @return 字典值
 */
public static String getDictValue(String dictType, String dictLabel, String separator) {
    StringBuilder propertyString = new StringBuilder();
    List<SysDictData> datas = getDictCache(dictType);
    if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) {
        for (SysDictData dict : datas) {
            for (String label : dictLabel.split(separator)) {
                if (label.equals(dict.getDictLabel())) {
                    propertyString.append(dict.getDictValue()).append(separator);
                    break;
                }
            }
        }
    } else {
        for (SysDictData dict : datas) {
            if (dictLabel.equals(dict.getDictLabel())) {
                return dict.getDictValue();
            }
        }
    }
    return StringUtils.stripEnd(propertyString.toString(), separator);
}
Also used : SysDictData(com.ruoyi.common.core.domain.entity.SysDictData)

Example 20 with SysDictData

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

the class DictUtils method getDictValue.

/**
 * 根据字典类型和字典标签获取字典值
 *
 * @param dictType 字典类型
 * @param dictLabel 字典标签
 * @param separator 分隔符
 * @return 字典值
 */
public static String getDictValue(String dictType, String dictLabel, String separator) {
    StringBuilder propertyString = new StringBuilder();
    List<SysDictData> datas = getDictCache(dictType);
    if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) {
        for (SysDictData dict : datas) {
            for (String label : dictLabel.split(separator)) {
                if (label.equals(dict.getDictLabel())) {
                    propertyString.append(dict.getDictValue() + separator);
                    break;
                }
            }
        }
    } else {
        for (SysDictData dict : datas) {
            if (dictLabel.equals(dict.getDictLabel())) {
                return dict.getDictValue();
            }
        }
    }
    return StringUtils.stripEnd(propertyString.toString(), separator);
}
Also used : SysDictData(com.ruoyi.common.core.domain.entity.SysDictData)

Aggregations

SysDictData (com.ruoyi.common.core.domain.entity.SysDictData)21 SysDictType (com.ruoyi.common.core.domain.entity.SysDictType)6 Transactional (org.springframework.transaction.annotation.Transactional)4 List (java.util.List)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1