Commit ddaac54d1a778b76ddafbf9f2b41ca3905ae8ece
Exists in
master
and in
1 other branch
Merge remote-tracking branch 'origin/master'
Showing 1 changed file
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BasicConfigFacade.java
View file @
ddaac54
1 | 1 | package com.lyms.platform.operate.web.facade; |
2 | 2 | |
3 | -import java.util.ArrayList; | |
4 | -import java.util.List; | |
5 | - | |
6 | -import com.lyms.platform.operate.web.result.BasicConfigResult; | |
7 | -import org.apache.commons.collections.CollectionUtils; | |
8 | -import org.springframework.beans.factory.annotation.Autowired; | |
9 | -import org.springframework.stereotype.Component; | |
10 | - | |
11 | 3 | import com.lyms.platform.biz.service.BasicConfigService; |
12 | 4 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
13 | 5 | import com.lyms.platform.common.enums.YnEnums; |
14 | 6 | import com.lyms.platform.common.result.BaseListResponse; |
15 | 7 | import com.lyms.platform.common.result.BaseResponse; |
16 | -import com.lyms.platform.operate.web.request.BasicConfigQueryRequest; | |
17 | 8 | import com.lyms.platform.operate.web.request.BasicConfigAddRequest; |
9 | +import com.lyms.platform.operate.web.request.BasicConfigQueryRequest; | |
18 | 10 | import com.lyms.platform.operate.web.request.BasicConfigUpdateRequest; |
11 | +import com.lyms.platform.operate.web.result.BasicConfigResult; | |
19 | 12 | import com.lyms.platform.operate.web.result.TreeNode; |
20 | 13 | import com.lyms.platform.operate.web.utils.TreeHelper; |
21 | 14 | import com.lyms.platform.pojo.BasicConfig; |
22 | 15 | import com.lyms.platform.query.BasicConfigQuery; |
16 | +import org.apache.commons.collections.CollectionUtils; | |
17 | +import org.springframework.beans.factory.annotation.Autowired; | |
18 | +import org.springframework.stereotype.Component; | |
23 | 19 | |
20 | +import java.util.ArrayList; | |
21 | +import java.util.List; | |
22 | + | |
24 | 23 | @Component |
25 | 24 | public class BasicConfigFacade { |
26 | 25 | @Autowired |
... | ... | @@ -28,9 +27,8 @@ |
28 | 27 | |
29 | 28 | /** |
30 | 29 | * 基础项查询 |
31 | - * | |
32 | - * @param basicConfigQueryRequest | |
33 | - * 基础项查询请求 | |
30 | + * | |
31 | + * @param basicConfigQueryRequest 基础项查询请求 | |
34 | 32 | * @return 返回结果 |
35 | 33 | */ |
36 | 34 | public BaseListResponse findBasicConfigList(BasicConfigQueryRequest basicConfigQueryRequest) { |
... | ... | @@ -41,9 +39,9 @@ |
41 | 39 | basicConfigQuery.setYn(YnEnums.YES.getId()); |
42 | 40 | basicConfigQuery.setKeyword(basicConfigQueryRequest.getKeywords()); |
43 | 41 | List<BasicConfig> data = basicConfigService.queryBasicConfig(basicConfigQuery); |
44 | - List<BasicConfigResult> dataList =new ArrayList<>(); | |
45 | - if(CollectionUtils.isNotEmpty(data)){ | |
46 | - for(BasicConfig basicConfig:data){ | |
42 | + List<BasicConfigResult> dataList = new ArrayList<>(); | |
43 | + if (CollectionUtils.isNotEmpty(data)) { | |
44 | + for (BasicConfig basicConfig : data) { | |
47 | 45 | BasicConfigResult basicConfigResult = new BasicConfigResult(); |
48 | 46 | basicConfigResult.convertToResult(basicConfig); |
49 | 47 | dataList.add(basicConfigResult); |
... | ... | @@ -54,9 +52,8 @@ |
54 | 52 | |
55 | 53 | /** |
56 | 54 | * 修改一条基础项配置 |
57 | - * | |
58 | - * @param basicConfigUpdateRequest | |
59 | - * 修改基础项请求 | |
55 | + * | |
56 | + * @param basicConfigUpdateRequest 修改基础项请求 | |
60 | 57 | * @return 返回结果 |
61 | 58 | */ |
62 | 59 | public BaseResponse updateOneBasicConfig(BasicConfigUpdateRequest basicConfigUpdateRequest) { |
63 | 60 | |
64 | 61 | |
65 | 62 | |
... | ... | @@ -65,15 +62,22 @@ |
65 | 62 | obj.setName(basicConfigUpdateRequest.getName()); |
66 | 63 | obj.setId(basicConfigUpdateRequest.getId()); |
67 | 64 | obj.setEnable(basicConfigUpdateRequest.getEnable()); |
68 | - basicConfigService.updateBasicConfig(obj); | |
69 | - return new BaseResponse("成功", ErrorCodeConstants.SUCCESS); | |
65 | + BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); | |
66 | + basicConfigQuery.setId(basicConfigUpdateRequest.getId()); | |
67 | + basicConfigQuery.setYn(YnEnums.YES.getId()); | |
68 | + List<BasicConfig> data = basicConfigService.queryBasicConfig(basicConfigQuery); | |
69 | + if (CollectionUtils.isNotEmpty(data)) { | |
70 | + obj.setYn(data.get(0).getYn()); | |
71 | + basicConfigService.updateBasicConfig(obj); | |
72 | + return new BaseResponse("成功", ErrorCodeConstants.SUCCESS); | |
73 | + } | |
74 | + return new BaseResponse("数据不存在", ErrorCodeConstants.BUSINESS_ERROR); | |
70 | 75 | } |
71 | - | |
76 | + | |
72 | 77 | /** |
73 | 78 | * 删除一条基础项配置 |
74 | - * | |
79 | + * | |
75 | 80 | * @param id 基础项id |
76 | - * | |
77 | 81 | * @return 执行结果 |
78 | 82 | */ |
79 | 83 | public BaseResponse deleteOneBasicConfig(String id) { |
80 | 84 | |
81 | 85 | |
82 | 86 | |
... | ... | @@ -83,14 +87,13 @@ |
83 | 87 | basicConfigService.updateBasicConfig(obj); |
84 | 88 | return new BaseResponse("成功", ErrorCodeConstants.SUCCESS); |
85 | 89 | } |
86 | - | |
90 | + | |
87 | 91 | /** |
88 | - * | |
89 | 92 | * 获取树形结构的数据 |
90 | - * | |
93 | + * | |
91 | 94 | * @return 树形结构数据 |
92 | 95 | */ |
93 | - public List<TreeNode> findAllBasicConfigWithTree(){ | |
96 | + public List<TreeNode> findAllBasicConfigWithTree() { | |
94 | 97 | List<TreeNode> list = new ArrayList<TreeNode>(); |
95 | 98 | List<BasicConfig> l = basicConfigService.queryParentConfig(); |
96 | 99 | for (BasicConfig b : l) { |
97 | 100 | |
98 | 101 | |
99 | 102 | |
... | ... | @@ -101,18 +104,18 @@ |
101 | 104 | } |
102 | 105 | return list; |
103 | 106 | } |
104 | - | |
107 | + | |
105 | 108 | /** |
106 | 109 | * 批量添加基础数据项 |
107 | - * | |
110 | + * | |
108 | 111 | * @param basicConfigRequests |
109 | 112 | * @return |
110 | 113 | */ |
111 | - public BaseResponse batchAddBasicConfig(List<BasicConfigAddRequest> basicConfigRequests){ | |
114 | + public BaseResponse batchAddBasicConfig(List<BasicConfigAddRequest> basicConfigRequests) { | |
112 | 115 | for (BasicConfigAddRequest ba : basicConfigRequests) { |
113 | 116 | //转换的时候验证如果为空就跳过添加数据 |
114 | - BasicConfig basicConfig =ba.convertToDataModel(); | |
115 | - if(null!=basicConfig){ | |
117 | + BasicConfig basicConfig = ba.convertToDataModel(); | |
118 | + if (null != basicConfig) { | |
116 | 119 | basicConfigService.addBasicConfig(basicConfig); |
117 | 120 | } |
118 | 121 | } |