mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-16 20:15:06 +08:00
分销:Review代码修改
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.api.dict;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO;
|
||||
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||
@ -9,10 +8,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
/**
|
||||
* 字典数据 API 实现类
|
||||
@ -36,19 +31,6 @@ public class DictDataApiImpl implements DictDataApi {
|
||||
return DictDataConvert.INSTANCE.convert02(dictData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDataRespDTO> getDictDataList(String type) {
|
||||
// TODO @疯狂:不用 DictDataExportReqVO 哈;可以考虑直接加个允许传递 type 传递的
|
||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type));
|
||||
return DictDataConvert.INSTANCE.convertList04(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDictDataLabelMap(String type) {
|
||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type));
|
||||
return convertMap(list, DictDataDO::getValue, DictDataDO::getLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictDataRespDTO parseDictData(String dictType, String label) {
|
||||
DictDataDO dictData = dictDataService.parseDictData(dictType, label);
|
||||
|
@ -1,17 +1,17 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.dict;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.app.dict.vo.AppDictDataRespVO;
|
||||
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -28,11 +28,11 @@ public class AppDictDataController {
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
|
||||
// TODO @疯狂:暂时不用 path 参数哈;主要考虑一些中间件支持的一般,例如说链路追踪之类的;还是作为一个参数噶;
|
||||
@GetMapping("/type/{dictType}")
|
||||
@GetMapping("/type")
|
||||
@Operation(summary = "根据字典类型查询字典数据信息")
|
||||
public CommonResult<List<AppDictDataRespVO>> getDictDataList(@PathVariable String dictType) {
|
||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(dictType));
|
||||
@Parameter(name = "type", description = "字典类型", required = true, example = "common_status")
|
||||
public CommonResult<List<AppDictDataRespVO>> getDictDataListByType(@RequestParam String type) {
|
||||
List<DictDataDO> list = dictDataService.getEnabledDictDataListByType(type);
|
||||
return success(DictDataConvert.INSTANCE.convertList03(list));
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,41 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.dict.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataBaseVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "用户 App - 字典数据信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AppDictDataRespVO extends DictDataBaseVO {
|
||||
|
||||
// TODO @疯狂:app 的接口,不集成 admin 接口的 vo 哈;看看是不是只返回必要的字段,类似 remark、sort 不好返回的哈;
|
||||
public class AppDictDataRespVO {
|
||||
|
||||
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(max = 100, message = "字典标签长度不能超过100个字符")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "iocoder")
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(max = 100, message = "字典键值长度不能超过100个字符")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex")
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(max = 100, message = "字典类型长度不能超过100个字符")
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
private String colorType;
|
||||
@Schema(description = "css 样式", example = "btn-visible")
|
||||
private String cssClass;
|
||||
|
||||
}
|
||||
|
@ -48,4 +48,8 @@ public interface DictDataMapper extends BaseMapperX<DictDataDO> {
|
||||
.eqIfPresent(DictDataDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
default List<DictDataDO> selectListByTypeAndStatus(String dictType, Integer status) {
|
||||
return selectList(new LambdaQueryWrapper<DictDataDO>()
|
||||
.eq(DictDataDO::getDictType, dictType).eq(DictDataDO::getStatus, status));
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,14 @@ public interface DictDataService {
|
||||
*/
|
||||
List<DictDataDO> getDictDataList(DictDataExportReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获得字典数据列表
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据列表
|
||||
*/
|
||||
List<DictDataDO> getEnabledDictDataListByType(String dictType);
|
||||
|
||||
/**
|
||||
* 获得字典数据详情
|
||||
*
|
||||
@ -84,7 +92,7 @@ public interface DictDataService {
|
||||
* 2. 字典数据被禁用
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param values 字典数据值的数组
|
||||
* @param values 字典数据值的数组
|
||||
*/
|
||||
void validateDictDataList(String dictType, Collection<String> values);
|
||||
|
||||
@ -92,7 +100,7 @@ public interface DictDataService {
|
||||
* 获得指定的字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param value 字典数据值
|
||||
* @param value 字典数据值
|
||||
* @return 字典数据
|
||||
*/
|
||||
DictDataDO getDictData(String dictType, String value);
|
||||
@ -101,7 +109,7 @@ public interface DictDataService {
|
||||
* 解析获得指定的字典数据,从缓存中
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param label 字典数据标签
|
||||
* @param label 字典数据标签
|
||||
* @return 字典数据
|
||||
*/
|
||||
DictDataDO parseDictData(String dictType, String label);
|
||||
|
@ -66,6 +66,13 @@ public class DictDataServiceImpl implements DictDataService {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDataDO> getEnabledDictDataListByType(String dictType) {
|
||||
List<DictDataDO> list = dictDataMapper.selectListByTypeAndStatus(dictType, CommonStatusEnum.ENABLE.getStatus());
|
||||
list.sort(COMPARATOR_TYPE_AND_SORT);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictDataDO getDictData(Long id) {
|
||||
return dictDataMapper.selectById(id);
|
||||
|
Reference in New Issue
Block a user