没有的字典值新增

This commit is contained in:
13036795865 2025-05-26 09:34:34 +08:00
parent d815c57f12
commit 7c6617626a
3 changed files with 16 additions and 3 deletions

View File

@ -64,4 +64,6 @@ public interface AchievementDictDataMapper
public int deleteAchievementDictDataByDictCodes(Long[] dictCodes);
List<KeyValueVo> selectDictDataByType(@Param("dictType") String dictType);
int selectDictDataByLabel(@Param("label") String label,@Param("type") String type);
}

View File

@ -56,9 +56,16 @@ public class AchievementDictDataServiceImpl implements IAchievementDictDataServi
public int insertAchievementDictData(AchievementDictData achievementDictData)
{
//判断字典是否存在存在则不管不存在则新增
String label = achievementDictData.getDictLabel();
String type = achievementDictData.getDictType();
int num = achievementDictDataMapper.selectDictDataByLabel(label,type);
if (num > 0){
return 0;
}else{
achievementDictData.setCreateTime(DateUtils.getNowDate());
return achievementDictDataMapper.insertAchievementDictData(achievementDictData);
}
}
/**
* 修改成果相关字典

View File

@ -95,6 +95,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectDictDataByType" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select dict_value as "key",dict_label as "value" from achievement_dict_data where dict_type = #{dictType}
select dict_code as "key",dict_label as "value" from achievement_dict_data where dict_type = #{dictType}
</select>
<select id="selectDictDataByLabel" resultType="int">
select count(1) from achievement_dict_data where dict_type = #{type} and dict_label = #{label}
</select>
</mapper>