houzhongjian
2024-10-16 7da8f196dee8e3c526c009a4bc7f5983ece6bb97
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.api.dict;
H 2
3 import com.iailab.framework.common.pojo.CommonResult;
4 import com.iailab.framework.common.util.object.BeanUtils;
5 import com.iailab.module.system.api.dict.dto.DictDataRespDTO;
6 import com.iailab.module.system.dal.dataobject.dict.DictDataDO;
7 import com.iailab.module.system.service.dict.DictDataService;
8 import org.springframework.validation.annotation.Validated;
9 import org.springframework.web.bind.annotation.RestController;
10
11 import javax.annotation.Resource;
12 import java.util.Collection;
13 import java.util.List;
14
15 import static com.iailab.framework.common.pojo.CommonResult.success;
16
17 @RestController // 提供 RESTful API 接口,给 Feign 调用
18 @Validated
19 public class DictDataApiImpl implements DictDataApi {
20
21     @Resource
22     private DictDataService dictDataService;
23
24     @Override
25     public CommonResult<Boolean> validateDictDataList(String dictType, Collection<String> values) {
26         dictDataService.validateDictDataList(dictType, values);
27         return success(true);
28     }
29
30     @Override
31     public CommonResult<DictDataRespDTO> getDictData(String dictType, String value) {
32         DictDataDO dictData = dictDataService.getDictData(dictType, value);
33         return success(BeanUtils.toBean(dictData, DictDataRespDTO.class));
34     }
35
36     @Override
37     public CommonResult<DictDataRespDTO> parseDictData(String dictType, String label) {
38         DictDataDO dictData = dictDataService.parseDictData(dictType, label);
39         return success(BeanUtils.toBean(dictData, DictDataRespDTO.class));
40     }
41
42     @Override
43     public CommonResult<List<DictDataRespDTO>> getDictDataList(String dictType) {
44         List<DictDataDO> list = dictDataService.getDictDataListByDictType(dictType);
45         return success(BeanUtils.toBean(list, DictDataRespDTO.class));
46     }
47
48 }