Commit bf1f39eeff1e7f41f74d24c7d0ef43187d33da13
1 parent
878c93a5b0
Exists in
master
and in
1 other branch
platform permission
fix bug
Showing 3 changed files with 71 additions and 11 deletions
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
View file @
bf1f39e
| ... | ... | @@ -20,8 +20,15 @@ |
| 20 | 20 | @Autowired |
| 21 | 21 | private CommunityConfigDao communityConfigDao; |
| 22 | 22 | |
| 23 | + //添加小区 | |
| 24 | + public void appendCommunity(CommunityConfig communityConfig) { | |
| 25 | + communityConfig.setType(2); | |
| 26 | + communityConfigDao.addArea(communityConfig); | |
| 27 | + } | |
| 28 | + | |
| 23 | 29 | //添加区域 |
| 24 | 30 | public void appendArea(CommunityConfig communityConfig) { |
| 31 | + communityConfig.setType(1); | |
| 25 | 32 | communityConfigDao.addArea(communityConfig); |
| 26 | 33 | } |
| 27 | 34 | |
| 28 | 35 | |
| 29 | 36 | |
| ... | ... | @@ -40,10 +47,21 @@ |
| 40 | 47 | public List<CommunityConfig> queryArea(String keyword) { |
| 41 | 48 | MongoCondition mongoCondition = MongoCondition.newInstance(); |
| 42 | 49 | if(null != keyword) { |
| 43 | - mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", keyword, MongoOper.LIKE), new MongoCondition("parentId", keyword, MongoOper.LIKE), new MongoCondition("id", keyword, MongoOper.LIKE)}); | |
| 50 | + mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", keyword, MongoOper.LIKE), new MongoCondition("parentId", keyword, MongoOper.LIKE), new MongoCondition("id", keyword, MongoOper.IS)}); | |
| 51 | + | |
| 44 | 52 | } |
| 45 | - mongoCondition.andCondition(new MongoCondition("yn", YnEnums.YES.getId(), MongoOper.IS)); | |
| 53 | + mongoCondition.andCondition(new MongoCondition("yn", YnEnums.YES.getId(), MongoOper.IS).and("type", 1, MongoOper.IS)); | |
| 54 | + | |
| 46 | 55 | return communityConfigDao.queryArea(mongoCondition.toMongoQuery()); |
| 56 | + } | |
| 57 | + | |
| 58 | + //查询区域根据PID | |
| 59 | + public List<CommunityConfig> queryAreaByParentId(String pid) { | |
| 60 | + if(null == pid) return null; | |
| 61 | + MongoCondition mongoCondition = MongoCondition.newInstance().and("parentId", pid, MongoOper.IS).and("yn", YnEnums.YES.getId(), MongoOper.IS); | |
| 62 | + List<CommunityConfig> communityConfigs = communityConfigDao.queryArea(mongoCondition.toMongoQuery()); | |
| 63 | + | |
| 64 | + return communityConfigs; | |
| 47 | 65 | } |
| 48 | 66 | |
| 49 | 67 |
platform-dal/src/main/java/com/lyms/platform/pojo/CommunityConfig.java
View file @
bf1f39e
| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.common.enums.YnEnums; |
| 4 | 4 | |
| 5 | +import java.util.List; | |
| 6 | + | |
| 5 | 7 | /** |
| 6 | 8 | * Created by Zhang.Rui on 2016/3/18. |
| 7 | 9 | */ |
| 8 | 10 | |
| 9 | 11 | |
| 10 | 12 | |
| ... | ... | @@ -10,15 +12,33 @@ |
| 10 | 12 | private String name; |
| 11 | 13 | private String parentId; |
| 12 | 14 | private Integer yn; |
| 13 | - | |
| 15 | + private Integer type; //1 地名, 2 小区 | |
| 14 | 16 | private CommunityConfig parent; |
| 17 | + private List<CommunityConfig> nodes; | |
| 15 | 18 | |
| 19 | + | |
| 20 | + public List<CommunityConfig> getNodes() { | |
| 21 | + return nodes; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public void setNodes(List<CommunityConfig> nodes) { | |
| 25 | + this.nodes = nodes; | |
| 26 | + } | |
| 27 | + | |
| 16 | 28 | public CommunityConfig getParent() { |
| 17 | 29 | return parent; |
| 18 | 30 | } |
| 19 | 31 | |
| 20 | 32 | public void setParent(CommunityConfig parent) { |
| 21 | 33 | this.parent = parent; |
| 34 | + } | |
| 35 | + | |
| 36 | + public Integer getType() { | |
| 37 | + return type; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setType(Integer type) { | |
| 41 | + this.type = type; | |
| 22 | 42 | } |
| 23 | 43 | |
| 24 | 44 | public CommunityConfig(String parentId, String tmp) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
View file @
bf1f39e
| ... | ... | @@ -29,6 +29,22 @@ |
| 29 | 29 | @Autowired |
| 30 | 30 | private CommunityConfigService communityConfigService; |
| 31 | 31 | |
| 32 | + | |
| 33 | + //新增小区 | |
| 34 | + @RequestMapping(value = "addCommunity", method = RequestMethod.POST) | |
| 35 | + @ResponseBody | |
| 36 | + public BaseResponse addCommunity(@RequestBody @Valid CommunityConfigRequest communityConfigRequest) { | |
| 37 | + CommunityConfig communityConfig = null; | |
| 38 | + for(String tmp : communityConfigRequest.getNames()) { | |
| 39 | + communityConfig = new CommunityConfig(communityConfigRequest.getParentId(), tmp); | |
| 40 | + communityConfigService.appendCommunity(communityConfig); | |
| 41 | + } | |
| 42 | + return new BaseResponse() | |
| 43 | + .setErrorcode(ErrorCodeConstants.SUCCESS) | |
| 44 | + .setErrormsg("添加成功!"); | |
| 45 | + } | |
| 46 | + | |
| 47 | + | |
| 32 | 48 | //新增区域 |
| 33 | 49 | @RequestMapping(value = "communityConfig", method = RequestMethod.POST) |
| 34 | 50 | @ResponseBody |
| 35 | 51 | |
| 36 | 52 | |
| 37 | 53 | |
| 38 | 54 | |
| ... | ... | @@ -75,18 +91,24 @@ |
| 75 | 91 | public BaseListResponse queryArea(String keyword ) { |
| 76 | 92 | List<CommunityConfig> communityConfigList = communityConfigService.queryArea(keyword); |
| 77 | 93 | |
| 78 | - for(CommunityConfig communityConfig : communityConfigList) { | |
| 79 | - if(null != communityConfig.getParentId()) { | |
| 80 | - communityConfig.setParent(communityConfigService.queryAreaById(communityConfig.getParentId())); | |
| 81 | - } else { | |
| 82 | - communityConfig.setParent(new CommunityConfig("0", "root")); | |
| 94 | + if(null != communityConfigList) { | |
| 95 | + for(CommunityConfig communityConfig : communityConfigList) { | |
| 96 | + communityConfig.setNodes(communityConfigService.queryAreaByParentId(communityConfig.getId())); | |
| 97 | + if(null != communityConfig.getParentId()) { | |
| 98 | + communityConfig.setParent(communityConfigService.queryAreaById(communityConfig.getParentId())); | |
| 99 | + } else { | |
| 100 | + communityConfig.setParent(new CommunityConfig("0", "root")); | |
| 101 | + } | |
| 83 | 102 | } |
| 103 | + return new BaseListResponse().setData(communityConfigList) | |
| 104 | + .setErrorcode(ErrorCodeConstants.SUCCESS) | |
| 105 | + .setErrormsg("查询成功!"); | |
| 84 | 106 | } |
| 107 | + return new BaseListResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR) | |
| 108 | + .setErrormsg("没有数据"); | |
| 85 | 109 | |
| 86 | - return new BaseListResponse().setData(communityConfigList) | |
| 87 | - .setErrorcode(ErrorCodeConstants.SUCCESS) | |
| 88 | - .setErrormsg("查询成功!"); | |
| 89 | 110 | } |
| 111 | + | |
| 90 | 112 | |
| 91 | 113 | |
| 92 | 114 | // |