提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.api.dict; |
H |
2 |
|
|
3 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
4 |
import io.swagger.v3.oas.annotations.Parameter; |
|
5 |
import io.swagger.v3.oas.annotations.Parameters; |
|
6 |
import io.swagger.v3.oas.annotations.Operation; |
|
7 |
import com.iailab.framework.common.pojo.CommonResult; |
|
8 |
import com.iailab.module.system.api.dict.dto.DictDataRespDTO; |
|
9 |
import com.iailab.module.system.enums.ApiConstants; |
|
10 |
import org.springframework.cloud.openfeign.FeignClient; |
|
11 |
import org.springframework.web.bind.annotation.GetMapping; |
|
12 |
import org.springframework.web.bind.annotation.RequestParam; |
|
13 |
|
|
14 |
import java.util.Collection; |
|
15 |
import java.util.List; |
|
16 |
|
|
17 |
import static com.iailab.framework.common.util.collection.CollectionUtils.convertList; |
|
18 |
|
1ecdfb
|
19 |
@FeignClient(name = ApiConstants.NAME) |
e7c126
|
20 |
@Tag(name = "RPC 服务 - 字典数据") |
H |
21 |
public interface DictDataApi { |
|
22 |
|
|
23 |
String PREFIX = ApiConstants.PREFIX + "/dict-data"; |
|
24 |
|
|
25 |
@GetMapping(PREFIX + "/valid") |
|
26 |
@Operation(summary = "校验字典数据们是否有效") |
|
27 |
@Parameters({ |
|
28 |
@Parameter(name = "dictType", description = "字典类型", example = "SEX", required = true), |
|
29 |
@Parameter(name = "descriptions", description = "字典数据值的数组", example = "1,2", required = true) |
|
30 |
}) |
|
31 |
CommonResult<Boolean> validateDictDataList(@RequestParam("dictType") String dictType, |
|
32 |
@RequestParam("values") Collection<String> values); |
|
33 |
|
|
34 |
@GetMapping(PREFIX + "/get") |
|
35 |
@Operation(summary = "获得指定的字典数据") |
|
36 |
@Parameters({ |
|
37 |
@Parameter(name = "dictType", description = "字典类型", example = "SEX", required = true), |
|
38 |
@Parameter(name = "description", description = "字典数据值", example = "1", required = true) |
|
39 |
}) |
|
40 |
CommonResult<DictDataRespDTO> getDictData(@RequestParam("dictType") String dictType, |
|
41 |
@RequestParam("value") String value); |
|
42 |
|
|
43 |
@GetMapping(PREFIX + "/parse") |
|
44 |
@Operation(summary = "解析获得指定的字典数据") |
|
45 |
@Parameters({ |
|
46 |
@Parameter(name = "dictType", description = "字典类型", example = "SEX", required = true), |
|
47 |
@Parameter(name = "label", description = "字典标签", example = "男", required = true) |
|
48 |
}) |
|
49 |
CommonResult<DictDataRespDTO> parseDictData(@RequestParam("dictType") String dictType, |
|
50 |
@RequestParam("label") String label); |
|
51 |
|
|
52 |
@GetMapping(PREFIX + "/list") |
|
53 |
@Operation(summary = "获得指定字典类型的字典数据列表") |
|
54 |
@Parameter(name = "dictType", description = "字典类型", example = "SEX", required = true) |
|
55 |
CommonResult<List<DictDataRespDTO>> getDictDataList(@RequestParam("dictType") String dictType); |
|
56 |
|
|
57 |
/** |
|
58 |
* 获得字典数据标签列表 |
|
59 |
* |
|
60 |
* @param dictType 字典类型 |
|
61 |
* @return 字典数据标签列表 |
|
62 |
*/ |
|
63 |
default List<String> getDictDataLabelList(String dictType) { |
|
64 |
List<DictDataRespDTO> list = getDictDataList(dictType).getData(); |
|
65 |
return convertList(list, DictDataRespDTO::getLabel); |
|
66 |
} |
|
67 |
|
|
68 |
} |