Commit 2ca64c74b2bb065952f7da06428ea9b6f0d6428a
1 parent
1d2544695b
Exists in
master
and in
3 other branches
c
Showing 5 changed files with 155 additions and 144 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BasicConfigService.java
- platform-dal/src/main/java/com/lyms/platform/pojo/BasicConfigQuery.java
- platform-dal/src/main/java/com/lyms/platform/query/BasicConfigQuery.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/utils/TreeHelper.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BasicConfigService.java
View file @
2ca64c7
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | import com.lyms.platform.common.dao.operator.MongoQuery; |
| 14 | 14 | import com.lyms.platform.common.dao.operator.Page; |
| 15 | 15 | import com.lyms.platform.pojo.BasicConfig; |
| 16 | -import com.lyms.platform.pojo.BasicConfigQuery; | |
| 16 | +import com.lyms.platform.query.BasicConfigQuery; | |
| 17 | 17 | |
| 18 | 18 | @Service("basicConfigService") |
| 19 | 19 | public class BasicConfigService { |
platform-dal/src/main/java/com/lyms/platform/pojo/BasicConfigQuery.java
View file @
2ca64c7
| 1 | -package com.lyms.platform.pojo; | |
| 2 | - | |
| 3 | -import com.lyms.platform.common.dao.BaseQuery; | |
| 4 | -import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 5 | -import com.lyms.platform.common.dao.operator.MongoOper; | |
| 6 | -import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 7 | - | |
| 8 | -public class BasicConfigQuery extends BaseQuery { | |
| 9 | - | |
| 10 | - private String id; | |
| 11 | - | |
| 12 | - private String parentId; | |
| 13 | - | |
| 14 | - private String code; | |
| 15 | - | |
| 16 | - private String name; | |
| 17 | - | |
| 18 | - private String keyword; | |
| 19 | - | |
| 20 | - public MongoQuery convertToQuery() { | |
| 21 | -// MongoCondition condition = MongoCondition.newInstance("1","1",MongoOper.IS); | |
| 22 | - MongoCondition condition = MongoCondition.newInstance(); | |
| 23 | - if (null != id) { | |
| 24 | - condition = condition.and("id", id, MongoOper.IS); | |
| 25 | - } | |
| 26 | - | |
| 27 | - if (null != code) { | |
| 28 | - condition = condition.and("code", code, MongoOper.IS); | |
| 29 | - } | |
| 30 | - if (null != name) { | |
| 31 | - condition = condition.and("name", name, MongoOper.IS); | |
| 32 | - } | |
| 33 | - if (null != parentId) { | |
| 34 | - condition = condition.and("parentId", parentId, MongoOper.IS); | |
| 35 | - } | |
| 36 | - if (null != keyword) { | |
| 37 | - MongoCondition con1= MongoCondition.newInstance("code", keyword, MongoOper.LIKE); | |
| 38 | - MongoCondition con = MongoCondition.newInstance("name", keyword, MongoOper.LIKE); | |
| 39 | - condition = condition.orCondition(new MongoCondition[]{con1,con}); | |
| 40 | - } | |
| 41 | - | |
| 42 | - return condition.toMongoQuery(); | |
| 43 | - } | |
| 44 | - | |
| 45 | - public String getKeyword() { | |
| 46 | - return keyword; | |
| 47 | - } | |
| 48 | - | |
| 49 | - public void setKeyword(String keyword) { | |
| 50 | - this.keyword = keyword; | |
| 51 | - } | |
| 52 | - | |
| 53 | - public String getName() { | |
| 54 | - return name; | |
| 55 | - } | |
| 56 | - | |
| 57 | - public void setName(String name) { | |
| 58 | - this.name = name; | |
| 59 | - } | |
| 60 | - | |
| 61 | - private int yn; | |
| 62 | - | |
| 63 | - public String getId() { | |
| 64 | - return id; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public void setId(String id) { | |
| 68 | - this.id = id; | |
| 69 | - } | |
| 70 | - | |
| 71 | - public String getParentId() { | |
| 72 | - return parentId; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public void setParentId(String parentId) { | |
| 76 | - this.parentId = parentId; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public String getCode() { | |
| 80 | - return code; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public void setCode(String code) { | |
| 84 | - this.code = code; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public int getYn() { | |
| 88 | - return yn; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public void setYn(int yn) { | |
| 92 | - this.yn = yn; | |
| 93 | - } | |
| 94 | -} |
platform-dal/src/main/java/com/lyms/platform/query/BasicConfigQuery.java
View file @
2ca64c7
| 1 | +package com.lyms.platform.query; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.dao.BaseQuery; | |
| 4 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 5 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
| 6 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 7 | + | |
| 8 | +public class BasicConfigQuery extends BaseQuery { | |
| 9 | + | |
| 10 | + private String id; | |
| 11 | + | |
| 12 | + private String parentId; | |
| 13 | + | |
| 14 | + private String code; | |
| 15 | + | |
| 16 | + private String name; | |
| 17 | + | |
| 18 | + private String keyword; | |
| 19 | + | |
| 20 | + public MongoQuery convertToQuery() { | |
| 21 | +// MongoCondition condition = MongoCondition.newInstance("1","1",MongoOper.IS); | |
| 22 | + MongoCondition condition = MongoCondition.newInstance(); | |
| 23 | + if (null != id) { | |
| 24 | + condition = condition.and("id", id, MongoOper.IS); | |
| 25 | + } | |
| 26 | + | |
| 27 | + if (null != code) { | |
| 28 | + condition = condition.and("code", code, MongoOper.IS); | |
| 29 | + } | |
| 30 | + if (null != name) { | |
| 31 | + condition = condition.and("name", name, MongoOper.IS); | |
| 32 | + } | |
| 33 | + if (null != parentId) { | |
| 34 | + condition = condition.and("parentId", parentId, MongoOper.IS); | |
| 35 | + } | |
| 36 | + if (null != keyword) { | |
| 37 | + MongoCondition con1= MongoCondition.newInstance("code", keyword, MongoOper.LIKE); | |
| 38 | + MongoCondition con = MongoCondition.newInstance("name", keyword, MongoOper.LIKE); | |
| 39 | + condition = condition.orCondition(new MongoCondition[]{con1,con}); | |
| 40 | + } | |
| 41 | + | |
| 42 | + return condition.toMongoQuery(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + public String getKeyword() { | |
| 46 | + return keyword; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void setKeyword(String keyword) { | |
| 50 | + this.keyword = keyword; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public String getName() { | |
| 54 | + return name; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public void setName(String name) { | |
| 58 | + this.name = name; | |
| 59 | + } | |
| 60 | + | |
| 61 | + private int yn; | |
| 62 | + | |
| 63 | + public String getId() { | |
| 64 | + return id; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void setId(String id) { | |
| 68 | + this.id = id; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public String getParentId() { | |
| 72 | + return parentId; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void setParentId(String parentId) { | |
| 76 | + this.parentId = parentId; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public String getCode() { | |
| 80 | + return code; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void setCode(String code) { | |
| 84 | + this.code = code; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public int getYn() { | |
| 88 | + return yn; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public void setYn(int yn) { | |
| 92 | + this.yn = yn; | |
| 93 | + } | |
| 94 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BasicConfigController.java
View file @
2ca64c7
| 1 | 1 | package com.lyms.platform.operate.web.controller; |
| 2 | 2 | |
| 3 | -import java.io.IOException; | |
| 4 | 3 | import java.util.ArrayList; |
| 5 | 4 | import java.util.List; |
| 6 | 5 | |
| 7 | -import javax.servlet.http.HttpServletRequest; | |
| 8 | - | |
| 9 | -import org.apache.commons.collections.CollectionUtils; | |
| 10 | -import org.apache.commons.io.IOUtils; | |
| 11 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 7 | import org.springframework.http.MediaType; |
| 13 | 8 | import org.springframework.stereotype.Controller; |
| 14 | 9 | |
| 15 | 10 | |
| 16 | 11 | |
| 17 | 12 | |
| 18 | 13 | |
| ... | ... | @@ -22,19 +17,16 @@ |
| 22 | 17 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 23 | 18 | import com.lyms.platform.common.result.BaseListResponse; |
| 24 | 19 | import com.lyms.platform.common.result.BaseResponse; |
| 25 | -import com.lyms.platform.common.utils.JsonUtil; | |
| 26 | 20 | import com.lyms.platform.operate.web.request.BasicConfigRequest; |
| 27 | 21 | import com.lyms.platform.operate.web.result.TreeNode; |
| 22 | +import com.lyms.platform.operate.web.utils.TreeHelper; | |
| 28 | 23 | import com.lyms.platform.pojo.BasicConfig; |
| 29 | -import com.lyms.platform.pojo.BasicConfigQuery; | |
| 24 | +import com.lyms.platform.query.BasicConfigQuery; | |
| 30 | 25 | |
| 31 | - | |
| 32 | 26 | /** |
| 33 | - * | |
| 34 | 27 | * 基础项配置接口 |
| 35 | 28 | * |
| 36 | 29 | * @author Administrator |
| 37 | - * | |
| 38 | 30 | */ |
| 39 | 31 | @Controller |
| 40 | 32 | public class BasicConfigController { |
| ... | ... | @@ -44,8 +36,10 @@ |
| 44 | 36 | @RequestMapping(method = RequestMethod.GET, value = "/basicConfig") |
| 45 | 37 | @ResponseBody |
| 46 | 38 | public BaseListResponse queryBasicConfig(@RequestParam(value = "keywords", required = false) |
| 47 | - String keywords,@RequestParam("page")int page,@RequestParam("limit")int limit) { | |
| 48 | - BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); | |
| 39 | + String keywords, @RequestParam("page") | |
| 40 | + int page, @RequestParam("limit") | |
| 41 | + int limit) { | |
| 42 | + BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); | |
| 49 | 43 | basicConfigQuery.setNeed("1"); |
| 50 | 44 | basicConfigQuery.setPage(page); |
| 51 | 45 | basicConfigQuery.setLimit(limit); |
| 52 | 46 | |
| ... | ... | @@ -90,25 +84,13 @@ |
| 90 | 84 | return baseResponse; |
| 91 | 85 | } |
| 92 | 86 | |
| 93 | - public TreeNode recursiveTree(BasicConfig b) { | |
| 94 | - TreeNode node = converToNode(b); | |
| 95 | - List<BasicConfig> l2 = basicConfigService.queryByParentId(b.getId()); | |
| 96 | - for (BasicConfig b1 : l2) { | |
| 97 | - TreeNode node1 = recursiveTree(b1); | |
| 98 | - if (null != node1) { | |
| 99 | - node.getNodes().add(node1); | |
| 100 | - } | |
| 101 | - } | |
| 102 | - return node; | |
| 103 | - } | |
| 104 | - | |
| 105 | 87 | @RequestMapping(method = RequestMethod.GET, value = "/basicConfigTree") |
| 106 | 88 | @ResponseBody |
| 107 | 89 | public List<TreeNode> buildJson() { |
| 108 | 90 | List<TreeNode> list = new ArrayList<TreeNode>(); |
| 109 | 91 | List<BasicConfig> l = basicConfigService.queryParentConfig(); |
| 110 | 92 | for (BasicConfig b : l) { |
| 111 | - TreeNode node = recursiveTree(b); | |
| 93 | + TreeNode node = TreeHelper.recursiveTree(b, basicConfigService); | |
| 112 | 94 | if (null != node) { |
| 113 | 95 | list.add(node); |
| 114 | 96 | } |
| 115 | 97 | |
| 116 | 98 | |
| ... | ... | @@ -116,34 +98,14 @@ |
| 116 | 98 | return list; |
| 117 | 99 | } |
| 118 | 100 | |
| 119 | - private TreeNode converToNode(BasicConfig c) { | |
| 120 | - TreeNode node = new TreeNode(); | |
| 121 | - node.setCid(c.getId()); | |
| 122 | - node.setCname(c.getName()); | |
| 123 | - node.setPid(c.getParentId()); | |
| 124 | - return node; | |
| 125 | - } | |
| 126 | - | |
| 127 | - @RequestMapping(method = RequestMethod.POST, value = "/basicConfig"/*, consumes = { MediaType.APPLICATION_OCTET_STREAM_VALUE }*/) | |
| 101 | + @RequestMapping(method = RequestMethod.POST, value = "/basicConfig", consumes = { MediaType.APPLICATION_JSON_VALUE }) | |
| 128 | 102 | @ResponseBody |
| 129 | - public BaseResponse addBasicConfig(@RequestBody List<BasicConfigRequest> listReq) { | |
| 130 | - /* String json = ""; | |
| 131 | - try { | |
| 132 | - json = IOUtils.toString(httpServletRequest.getInputStream(), "utf8"); | |
| 133 | - } catch (IOException e) { | |
| 134 | - e.printStackTrace(); | |
| 135 | - } | |
| 136 | - List<BasicConfigRequest> li = JsonUtil.toList(json, BasicConfigRequest.class); | |
| 137 | - | |
| 138 | - if (CollectionUtils.isNotEmpty(li)) { | |
| 139 | - for (BasicConfigRequest ba : li) { | |
| 140 | - basicConfigService.addBasicConfig(ba.convertToBasicConfig()); | |
| 141 | - } | |
| 142 | - }*/ | |
| 103 | + public BaseResponse addBasicConfig(@RequestBody | |
| 104 | + List<BasicConfigRequest> listReq) { | |
| 143 | 105 | for (BasicConfigRequest ba : listReq) { |
| 144 | 106 | basicConfigService.addBasicConfig(ba.convertToBasicConfig()); |
| 145 | 107 | } |
| 146 | - | |
| 108 | + | |
| 147 | 109 | BaseResponse baseResponse = new BaseResponse(); |
| 148 | 110 | baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |
| 149 | 111 | baseResponse.setErrormsg("成功"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/TreeHelper.java
View file @
2ca64c7
| 1 | +package com.lyms.platform.operate.web.utils; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 6 | +import com.lyms.platform.operate.web.result.TreeNode; | |
| 7 | +import com.lyms.platform.pojo.BasicConfig; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 树形结构的帮助类 | |
| 11 | + * | |
| 12 | + * @author Administrator | |
| 13 | + */ | |
| 14 | +public class TreeHelper { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 构建子节点信息 | |
| 18 | + * | |
| 19 | + * @param b | |
| 20 | + * 父节点信息 | |
| 21 | + * @param basicConfigService | |
| 22 | + * @return 节点 | |
| 23 | + */ | |
| 24 | + public static TreeNode recursiveTree(BasicConfig b, BasicConfigService basicConfigService) { | |
| 25 | + TreeNode node = converToNode(b); | |
| 26 | + List<BasicConfig> l2 = basicConfigService.queryByParentId(b.getId()); | |
| 27 | + for (BasicConfig b1 : l2) { | |
| 28 | + TreeNode node1 = recursiveTree(b1, basicConfigService); | |
| 29 | + if (null != node1) { | |
| 30 | + node.getNodes().add(node1); | |
| 31 | + } | |
| 32 | + } | |
| 33 | + return node; | |
| 34 | + } | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 创建新的节点 | |
| 38 | + * | |
| 39 | + * @param c | |
| 40 | + * @return | |
| 41 | + */ | |
| 42 | + private static TreeNode converToNode(BasicConfig c) { | |
| 43 | + TreeNode node = new TreeNode(); | |
| 44 | + node.setCid(c.getId()); | |
| 45 | + node.setCname(c.getName()); | |
| 46 | + node.setPid(c.getParentId()); | |
| 47 | + return node; | |
| 48 | + } | |
| 49 | +} |