Commit 48311fea51701fdbed8425bcd72d772c9bcba476
1 parent
31c2de8d42
Exists in
master
and in
1 other branch
c
Showing 4 changed files with 173 additions and 32 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BasicConfigService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BasicConfigController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasicConfigRequest.java
- platform-operate-api/src/main/webapp/WEB-INF/web.xml
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BasicConfigService.java
View file @
48311fe
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | import com.lyms.platform.biz.dal.IBasicConfigDao; |
10 | 10 | import com.lyms.platform.common.dao.operator.MongoCondition; |
11 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
11 | 12 | import com.lyms.platform.common.dao.operator.Page; |
12 | 13 | import com.lyms.platform.pojo.BasicConfig; |
13 | 14 | |
14 | 15 | |
... | ... | @@ -24,8 +25,13 @@ |
24 | 25 | basicConfigDao.updateBasicConfig(obj, obj.getId()); |
25 | 26 | } |
26 | 27 | |
27 | - public List<BasicConfig> queryGuides(int start, int end) { | |
28 | + public List<BasicConfig> queryBasicConfig(int start, int end) { | |
28 | 29 | return basicConfigDao.queryBasicConfig(MongoCondition.newInstance().toMongoQuery().start(start).end(end) |
30 | + .addOrder(Direction.ASC, "id")); | |
31 | + } | |
32 | + | |
33 | + public List<BasicConfig> queryParentConfig(){ | |
34 | + return basicConfigDao.queryBasicConfig(MongoCondition.newInstance("parentId",null,MongoOper.IS).toMongoQuery().start(0).end(100) | |
29 | 35 | .addOrder(Direction.ASC, "id")); |
30 | 36 | } |
31 | 37 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BasicConfigController.java
View file @
48311fe
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import java.io.IOException; | |
3 | 4 | import java.util.ArrayList; |
5 | +import java.util.HashMap; | |
4 | 6 | import java.util.List; |
7 | +import java.util.Map; | |
5 | 8 | |
9 | +import javax.servlet.http.HttpServletRequest; | |
10 | + | |
11 | +import org.apache.commons.collections.CollectionUtils; | |
12 | +import org.apache.commons.io.IOUtils; | |
6 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
14 | +import org.springframework.http.MediaType; | |
7 | 15 | import org.springframework.stereotype.Controller; |
16 | +import org.springframework.web.bind.annotation.PathVariable; | |
8 | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
9 | 18 | import org.springframework.web.bind.annotation.RequestMethod; |
19 | +import org.springframework.web.bind.annotation.RequestParam; | |
10 | 20 | import org.springframework.web.bind.annotation.ResponseBody; |
11 | 21 | |
12 | 22 | import com.lyms.platform.biz.service.BasicConfigService; |
13 | 23 | import com.lyms.platform.common.result.BaseListResponse; |
14 | 24 | import com.lyms.platform.common.result.BaseResponse; |
25 | +import com.lyms.platform.common.utils.JsonUtil; | |
15 | 26 | import com.lyms.platform.operate.web.request.BasicConfigRequest; |
16 | 27 | import com.lyms.platform.pojo.BasicConfig; |
17 | 28 | |
18 | 29 | |
19 | 30 | |
20 | 31 | |
21 | 32 | |
... | ... | @@ -20,21 +31,123 @@ |
20 | 31 | @Autowired |
21 | 32 | private BasicConfigService basicConfigService; |
22 | 33 | |
34 | + private static final String NODE = "child"; | |
35 | + | |
23 | 36 | @RequestMapping(method = RequestMethod.GET, value = "/basicConfig") |
24 | 37 | @ResponseBody |
25 | - public BaseListResponse queryBasicConfig() { | |
26 | - List<BasicConfig> data = basicConfigService.queryGuides(0, 100); | |
38 | + public BaseListResponse queryBasicConfig(@RequestParam(value="keywords",required=false) | |
39 | + String keywords) { | |
40 | + List<BasicConfig> data = basicConfigService.queryBasicConfig(0, 100); | |
27 | 41 | BaseListResponse baseListResponse = new BaseListResponse(); |
28 | 42 | baseListResponse.setData(data); |
29 | 43 | baseListResponse.setErrorcode("0"); |
30 | 44 | baseListResponse.setErrormsg("ๆๅ"); |
31 | 45 | return baseListResponse; |
32 | 46 | } |
33 | - @RequestMapping(method = RequestMethod.POST, value = "/basicConfig") | |
47 | + | |
48 | + @RequestMapping(method = RequestMethod.PUT, value = "/basicConfig/{id}") | |
34 | 49 | @ResponseBody |
35 | - public BaseResponse addBasicConfig(BasicConfigRequest basicConfigRequests){ | |
36 | -// basicConfigService.addBasicConfig(basicConfigRequests); | |
50 | + public BaseResponse updateBasicConfig(@PathVariable("id")String id, | |
51 | + @RequestParam("title")String title, | |
52 | + @RequestParam("code") String code) { | |
53 | + BasicConfig obj = new BasicConfig(); | |
54 | + obj.setId(id); | |
55 | + obj.setName(title); | |
56 | + obj.setCode(code); | |
57 | + basicConfigService.updateBasicConfig(obj); | |
58 | + BaseResponse baseResponse = new BaseResponse(); | |
59 | + baseResponse.setErrorcode("0"); | |
60 | + baseResponse.setErrormsg("ๆๅ"); | |
61 | + return baseResponse; | |
62 | + } | |
63 | + @RequestMapping(method = RequestMethod.DELETE, value = "/basicConfig/{id}") | |
64 | + @ResponseBody | |
65 | + public BaseResponse updateBasicConfig(@PathVariable("id")String id){ | |
66 | + BasicConfig obj = new BasicConfig(); | |
67 | + obj.setId(id); | |
68 | + obj.setYn(0); | |
69 | + basicConfigService.updateBasicConfig(obj); | |
37 | 70 | |
71 | + BaseResponse baseResponse = new BaseResponse(); | |
72 | + baseResponse.setErrorcode("0"); | |
73 | + baseResponse.setErrormsg("ๆๅ"); | |
74 | + return baseResponse; | |
75 | + } | |
76 | + | |
77 | + private static List convertToTreeMap(List<BasicConfig> basicList) { | |
78 | + List list = new ArrayList(); | |
79 | + // ๅญๆพๆจกๅๅๅญๅ็ดขๅผๆ ๅฐ | |
80 | + Map<String, Integer> nameToIndex = new HashMap<>(); | |
81 | + Map<String, BasicConfig> nameToIndex1 = new HashMap<>(); | |
82 | + for (BasicConfig b : basicList) { | |
83 | + nameToIndex1.put(b.getId(), b); | |
84 | + } | |
85 | + | |
86 | + int index = 0; | |
87 | + | |
88 | + for (BasicConfig config : basicList) { | |
89 | + Map<String, Object> moduleMap = new HashMap<>(); | |
90 | + // ๅฆๆๅญๅจๅฐฑๅ ไธไธ็บง่็น | |
91 | + moduleMap.put("id", config.getId()); | |
92 | + moduleMap.put("parentId", config.getParentId()); | |
93 | + moduleMap.put("name", config.getName()); | |
94 | + | |
95 | + if (null == config.getParentId()) { | |
96 | + | |
97 | + } else { | |
98 | + nameToIndex1.get(config.getParentId()); | |
99 | + } | |
100 | + | |
101 | + list.add(moduleMap); | |
102 | + } | |
103 | + System.out.print(JsonUtil.array2JsonString(list)); | |
104 | + return list; | |
105 | + } | |
106 | + | |
107 | + public static void main(String[] args) { | |
108 | + BasicConfig basicConfig = new BasicConfig(); | |
109 | + basicConfig.setId("1"); | |
110 | + basicConfig.setName("1"); | |
111 | + | |
112 | + BasicConfig basicConfig1 = new BasicConfig(); | |
113 | + basicConfig1.setId("11"); | |
114 | + basicConfig1.setName("11"); | |
115 | + basicConfig1.setParentId("1"); | |
116 | + | |
117 | + BasicConfig basicConfig2 = new BasicConfig(); | |
118 | + basicConfig2.setId("112"); | |
119 | + basicConfig2.setName("112"); | |
120 | + basicConfig2.setParentId("11"); | |
121 | + | |
122 | + BasicConfig basicConfig3 = new BasicConfig(); | |
123 | + basicConfig3.setId("113"); | |
124 | + basicConfig3.setName("113"); | |
125 | + basicConfig3.setParentId("11"); | |
126 | + | |
127 | + List<BasicConfig> list = new ArrayList<>(); | |
128 | + list.add(basicConfig); | |
129 | + list.add(basicConfig1); | |
130 | + list.add(basicConfig2); | |
131 | + list.add(basicConfig3); | |
132 | + System.out.println(convertToTreeMap(list)); | |
133 | + } | |
134 | + | |
135 | + @RequestMapping(method = RequestMethod.POST, value = "/basicConfig", consumes = { MediaType.APPLICATION_OCTET_STREAM_VALUE }) | |
136 | + @ResponseBody | |
137 | + public BaseResponse addBasicConfig(HttpServletRequest httpServletRequest) { | |
138 | + String json = ""; | |
139 | + try { | |
140 | + json = IOUtils.toString(httpServletRequest.getInputStream(), "utf8"); | |
141 | + } catch (IOException e) { | |
142 | + e.printStackTrace(); | |
143 | + } | |
144 | + List<BasicConfigRequest> li = JsonUtil.toList(json, BasicConfigRequest.class); | |
145 | + | |
146 | + if (CollectionUtils.isNotEmpty(li)) { | |
147 | + for (BasicConfigRequest ba : li) { | |
148 | + basicConfigService.addBasicConfig(ba.convertToBasicConfig()); | |
149 | + } | |
150 | + } | |
38 | 151 | BaseResponse baseResponse = new BaseResponse(); |
39 | 152 | baseResponse.setErrorcode("0"); |
40 | 153 | baseResponse.setErrormsg("ๆๅ"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasicConfigRequest.java
View file @
48311fe
... | ... | @@ -2,10 +2,10 @@ |
2 | 2 | |
3 | 3 | import org.hibernate.validator.constraints.NotEmpty; |
4 | 4 | |
5 | -import com.lyms.platform.common.core.annotation.form.Form; | |
6 | 5 | import com.lyms.platform.common.core.annotation.form.FormParam; |
6 | +import com.lyms.platform.pojo.BasicConfig; | |
7 | 7 | |
8 | -@Form | |
8 | +//@Form | |
9 | 9 | public class BasicConfigRequest { |
10 | 10 | @FormParam |
11 | 11 | private String parentId; |
... | ... | @@ -30,6 +30,13 @@ |
30 | 30 | } |
31 | 31 | public void setCode(String code) { |
32 | 32 | this.code = code; |
33 | + } | |
34 | + public BasicConfig convertToBasicConfig(){ | |
35 | + BasicConfig basicConfig = new BasicConfig(); | |
36 | + basicConfig.setCode(code); | |
37 | + basicConfig.setName(name); | |
38 | + basicConfig.setParentId(parentId); | |
39 | + return basicConfig; | |
33 | 40 | } |
34 | 41 | } |
platform-operate-api/src/main/webapp/WEB-INF/web.xml
View file @
48311fe
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | -<!-- | |
3 | - Licensed to the Apache Software Foundation (ASF) under one | |
4 | - or more contributor license agreements. See the NOTICE file | |
5 | - distributed with this work for additional information | |
6 | - regarding copyright ownership. The ASF licenses this file | |
7 | - to you under the Apache License, Version 2.0 (the | |
8 | - "License"); you may not use this file except in compliance | |
9 | - with the License. You may obtain a copy of the License at | |
10 | - | |
11 | - http://www.apache.org/licenses/LICENSE-2.0 | |
12 | - | |
13 | - Unless required by applicable law or agreed to in writing, | |
14 | - software distributed under the License is distributed on an | |
15 | - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | - KIND, either express or implied. See the License for the | |
17 | - specific language governing permissions and limitations | |
18 | - under the License. | |
19 | ---> | |
20 | -<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> | |
21 | - <context-param> | |
2 | +<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor | |
3 | + license agreements. See the NOTICE file distributed with this work for additional | |
4 | + information regarding copyright ownership. The ASF licenses this file to | |
5 | + you under the Apache License, Version 2.0 (the "License"); you may not use | |
6 | + this file except in compliance with the License. You may obtain a copy of | |
7 | + the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required | |
8 | + by applicable law or agreed to in writing, software distributed under the | |
9 | + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | |
10 | + OF ANY KIND, either express or implied. See the License for the specific | |
11 | + language governing permissions and limitations under the License. --> | |
12 | +<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
13 | + version="2.5" | |
14 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> | |
15 | + <context-param> | |
22 | 16 | <param-name>contextConfigLocation</param-name> |
23 | 17 | <param-value> |
24 | 18 | classpath*:/spring/applicationContext.xml |
25 | 19 | </param-value> |
26 | 20 | </context-param> |
27 | 21 | |
28 | - <session-config> | |
29 | - <session-timeout>60</session-timeout> | |
30 | - </session-config> | |
31 | - <context-param> | |
22 | + <session-config> | |
23 | + <session-timeout>60</session-timeout> | |
24 | + </session-config> | |
25 | + <context-param> | |
32 | 26 | <param-name>log4jConfigLocation</param-name> |
33 | 27 | <param-value>classpath:log4j_config.xml</param-value> |
34 | 28 | </context-param> |
... | ... | @@ -49,6 +43,27 @@ |
49 | 43 | <servlet-name>dispatcher</servlet-name> |
50 | 44 | <url-pattern>/</url-pattern> |
51 | 45 | </servlet-mapping> |
46 | + <filter> | |
47 | + <filter-name>HttpMethodFilter</filter-name> | |
48 | + <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> | |
49 | + </filter> | |
50 | + <filter-mapping> | |
51 | + <filter-name>HttpMethodFilter</filter-name> | |
52 | + <url-pattern>/*</url-pattern> | |
53 | + </filter-mapping> | |
54 | + <filter> | |
55 | + <filter-name>encodingFilter</filter-name> | |
56 | + <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> | |
57 | + <init-param> | |
58 | + <param-name>encoding</param-name> | |
59 | + <param-value>UTF-8</param-value> | |
60 | + </init-param> | |
61 | + </filter> | |
62 | + | |
63 | + <filter-mapping> | |
64 | + <filter-name>encodingFilter</filter-name> | |
65 | + <url-pattern>/*</url-pattern> | |
66 | + </filter-mapping> | |
52 | 67 | <listener> |
53 | 68 | <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> |
54 | 69 | </listener> |