refactor: 重构查询参数及字典接口

This commit is contained in:
2024-06-05 20:59:08 +08:00
parent 1e73d06a97
commit 1d60213437
8 changed files with 21 additions and 105 deletions

View File

@@ -17,11 +17,10 @@
package top.continew.admin.system.mapper;
import org.apache.ibatis.annotations.Param;
import top.continew.admin.common.model.resp.LabelValueResp;
import top.continew.admin.system.model.entity.DictItemDO;
import top.continew.starter.data.mybatis.plus.base.BaseMapper;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import java.io.Serializable;
import java.util.List;
/**
@@ -38,5 +37,5 @@ public interface DictItemMapper extends BaseMapper<DictItemDO> {
* @param dictCode 字典编码
* @return 字典项列表
*/
List<LabelValueResp<Serializable>> listByDictCode(@Param("dictCode") String dictCode);
List<LabelValueResp> listByDictCode(@Param("dictCode") String dictCode);
}

View File

@@ -16,15 +16,14 @@
package top.continew.admin.system.service;
import top.continew.admin.common.model.resp.LabelValueResp;
import top.continew.admin.system.model.entity.DictItemDO;
import top.continew.admin.system.model.query.DictItemQuery;
import top.continew.admin.system.model.req.DictItemReq;
import top.continew.admin.system.model.resp.DictItemResp;
import top.continew.starter.data.mybatis.plus.service.IService;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.extension.crud.service.BaseService;
import java.io.Serializable;
import java.util.List;
/**
@@ -41,7 +40,7 @@ public interface DictItemService extends BaseService<DictItemResp, DictItemResp,
* @param dictCode 字典编码
* @return 字典项列表
*/
List<LabelValueResp<Serializable>> listByDictCode(String dictCode);
List<LabelValueResp> listByDictCode(String dictCode);
/**
* 根据字典 ID 列表删除

View File

@@ -18,7 +18,6 @@ package top.continew.admin.system.service.impl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.continew.admin.common.model.resp.LabelValueResp;
import top.continew.admin.system.mapper.DictItemMapper;
import top.continew.admin.system.model.entity.DictItemDO;
import top.continew.admin.system.model.query.DictItemQuery;
@@ -26,9 +25,9 @@ import top.continew.admin.system.model.req.DictItemReq;
import top.continew.admin.system.model.resp.DictItemResp;
import top.continew.admin.system.service.DictItemService;
import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
import java.io.Serializable;
import java.util.List;
/**
@@ -54,7 +53,7 @@ public class DictItemServiceImpl extends BaseServiceImpl<DictItemMapper, DictIte
}
@Override
public List<LabelValueResp<Serializable>> listByDictCode(String dictCode) {
public List<LabelValueResp> listByDictCode(String dictCode) {
return baseMapper.listByDictCode(dictCode);
}

View File

@@ -58,7 +58,6 @@ public class OptionServiceImpl implements OptionService {
private final OptionMapper baseMapper;
@Override
@Cached(key = "#query.category", name = CacheConstants.OPTION_KEY_PREFIX)
public List<OptionResp> list(OptionQuery query) {
return BeanUtil.copyToList(baseMapper.selectList(QueryWrapperHelper.build(query)), OptionResp.class);
}

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="top.continew.admin.system.mapper.DictItemMapper">
<select id="listByDictCode" resultType="top.continew.admin.common.model.resp.LabelValueResp">
SELECT t1.label, t1.value, t1.color
<select id="listByDictCode" resultType="top.continew.starter.extension.crud.model.resp.LabelValueResp">
SELECT t1.label, t1.value, t1.color AS extend
FROM sys_dict_item AS t1
LEFT JOIN sys_dict AS t2 ON t1.dict_id = t2.id
WHERE t1.status = 1 AND t2.code = #{dictCode}