耗材目录包装单位的拼音搜索
This commit is contained in:
@@ -28,6 +28,18 @@ public interface SysDictDataMapper {
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByType(String dictType);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据字典类型和搜索关键字查询字典数据(支持拼音搜索)
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param searchKey 搜索关键字(支持名称和拼音首字母搜索)
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByTypeWithSearch(@Param("dictType") String dictType, @Param("searchKey") String searchKey);
|
||||
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
|
||||
@@ -34,6 +34,15 @@ public interface ISysDictTypeService {
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型和搜索关键字查询字典数据(支持拼音搜索)
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param searchKey 搜索关键字(支持名称和拼音首字母搜索),可为null
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByType(String dictType, String searchKey);
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.core.common.core.domain.entity.SysDictData;
|
||||
import com.core.common.utils.DictUtils;
|
||||
import com.core.system.mapper.SysDictDataMapper;
|
||||
import com.core.common.utils.ChineseConvertUtils;
|
||||
import com.core.system.service.ISysDictDataService;
|
||||
|
||||
/**
|
||||
@@ -88,6 +89,10 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
*/
|
||||
@Override
|
||||
public int insertDictData(SysDictData data) {
|
||||
// 自动计算拼音首字母
|
||||
if (data.getDictLabel() != null && !data.getDictLabel().isEmpty()) {
|
||||
data.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(data.getDictLabel()));
|
||||
}
|
||||
int row = dictDataMapper.insertDictData(data);
|
||||
if (row > 0) {
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
@@ -104,6 +109,10 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
*/
|
||||
@Override
|
||||
public int updateDictData(SysDictData data) {
|
||||
// 如果字典标签有变化,重新计算拼音首字母
|
||||
if (data.getDictLabel() != null && !data.getDictLabel().isEmpty()) {
|
||||
data.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(data.getDictLabel()));
|
||||
}
|
||||
int row = dictDataMapper.updateDictData(data);
|
||||
if (row > 0) {
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
|
||||
@@ -71,6 +71,24 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataByType(String dictType) {
|
||||
return selectDictDataByType(dictType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和搜索关键字查询字典数据(支持拼音搜索)
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param searchKey 搜索关键字(支持名称和拼音首字母搜索),可为null
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByType(String dictType, String searchKey) {
|
||||
// 如果有搜索关键字,使用带搜索的SQL查询
|
||||
if (StringUtils.isNotEmpty(searchKey) && !searchKey.trim().isEmpty()) {
|
||||
String trimmedKey = searchKey.trim();
|
||||
return dictDataMapper.selectDictDataByTypeWithSearch(dictType, trimmedKey);
|
||||
}
|
||||
|
||||
// 否则使用原有方法(带缓存)
|
||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||
return dictDatas;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<result property="listClass" column="list_class"/>
|
||||
<result property="isDefault" column="is_default"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="pyStr" column="py_str"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
@@ -30,6 +31,7 @@
|
||||
list_class,
|
||||
is_default,
|
||||
status,
|
||||
py_str,
|
||||
create_by,
|
||||
create_time,
|
||||
remark
|
||||
@@ -56,6 +58,19 @@
|
||||
<include refid="selectDictDataVo"/>
|
||||
where status = '0' and dict_type = #{dictType} order by dict_sort asc
|
||||
</select>
|
||||
<select id="selectDictDataByTypeWithSearch" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
where status = '0'
|
||||
and dict_type = #{dictType}
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
and (
|
||||
(dict_label is not null and dict_label like concat('%', #{searchKey}, '%'))
|
||||
or (py_str is not null and py_str like concat('%', #{searchKey}, '%'))
|
||||
)
|
||||
</if>
|
||||
order by dict_sort asc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectDictLabel" resultType="String">
|
||||
select dict_label
|
||||
@@ -105,6 +120,7 @@
|
||||
<if test="listClass != null">list_class = #{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="pyStr !=null">pyStr = #{pyStr}</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = now()
|
||||
@@ -128,6 +144,7 @@
|
||||
<if test="listClass != null and listClass != ''">list_class,</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="pyStr !=null and pyStr !=null ''" >py_str,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
@@ -140,6 +157,7 @@
|
||||
<if test="listClass != null and listClass != ''">#{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">#{isDefault},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="pyStr !=null and pyStr !=''" >{pystr},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
now()
|
||||
|
||||
Reference in New Issue
Block a user