Commit 6f8e8597af30122efed4c2ce6e84079e9a3411fc
1 parent
a00b562e7c
Exists in
master
and in
1 other branch
配置中心 社区管理 社区管辖范围管理
Showing 7 changed files with 279 additions and 11 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/CommunityConfigDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/CommunityConfigDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
- platform-dal/src/main/java/com/lyms/platform/pojo/CommunityConfig.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/CommunityConfigRequest.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/CommunityConfigDao.java
View file @
6f8e859
| 1 | +package com.lyms.platform.biz.dal; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 4 | +import com.lyms.platform.pojo.CommunityConfig; | |
| 5 | +import com.lyms.platform.pojo.ReferValue; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Created by Zhang.Rui on 2016/3/17. | |
| 11 | + */ | |
| 12 | +public interface CommunityConfigDao { | |
| 13 | + void addArea(CommunityConfig communityConfig); | |
| 14 | + | |
| 15 | + void updateArea(MongoQuery query, CommunityConfig communityConfig); | |
| 16 | + | |
| 17 | + void deleteArea(MongoQuery query); | |
| 18 | + | |
| 19 | + List<CommunityConfig> queryArea(MongoQuery query); | |
| 20 | + | |
| 21 | + | |
| 22 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/CommunityConfigDaoImpl.java
View file @
6f8e859
| 1 | +package com.lyms.platform.biz.dal.impl; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.dal.CommunityConfigDao; | |
| 4 | +import com.lyms.platform.biz.dal.ReferConfigDao; | |
| 5 | +import com.lyms.platform.common.dao.BaseMongoDAOImpl; | |
| 6 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 7 | +import com.lyms.platform.pojo.CommunityConfig; | |
| 8 | +import com.lyms.platform.pojo.ReferValue; | |
| 9 | +import org.springframework.stereotype.Repository; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Created by Zhang.Rui on 2016/3/17. | |
| 15 | + */ | |
| 16 | +@Repository("communityConfigDao") | |
| 17 | +public class CommunityConfigDaoImpl extends BaseMongoDAOImpl<CommunityConfig> implements CommunityConfigDao { | |
| 18 | + | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public void addArea(CommunityConfig communityConfig) { | |
| 22 | + save(communityConfig); | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public void updateArea(MongoQuery query, CommunityConfig communityConfig) { | |
| 27 | + update(query.convertToMongoQuery(), communityConfig); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public void deleteArea(MongoQuery query ) { | |
| 32 | + delete(query.convertToMongoQuery()); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public List<CommunityConfig> queryArea(MongoQuery query) { | |
| 37 | + return find(query.convertToMongoQuery()); | |
| 38 | + } | |
| 39 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
View file @
6f8e859
| 1 | +package com.lyms.platform.biz.service; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.dal.CommunityConfigDao; | |
| 4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 5 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 6 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
| 7 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.result.BaseResponse; | |
| 10 | +import com.lyms.platform.pojo.CommunityConfig; | |
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 16 | +import org.springframework.web.bind.annotation.ResponseBody; | |
| 17 | + | |
| 18 | +import javax.validation.Valid; | |
| 19 | +import java.util.List; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Created by Zhang.Rui on 2016/3/18. | |
| 23 | + */ | |
| 24 | +@Service("communityConfig") | |
| 25 | +public class CommunityConfigService { | |
| 26 | + @Autowired | |
| 27 | + private CommunityConfigDao communityConfigDao; | |
| 28 | + | |
| 29 | + //添加区域 | |
| 30 | + public void appendArea(CommunityConfig communityConfig) { | |
| 31 | + communityConfigDao.addArea(communityConfig); | |
| 32 | + } | |
| 33 | + | |
| 34 | + //删除区域 | |
| 35 | + public void deleteArea(CommunityConfig communityConfig) { | |
| 36 | + communityConfig.setYn(YnEnums.NO.getId()); | |
| 37 | + communityConfigDao.updateArea(MongoCondition.newInstance("id", communityConfig.getId(), MongoOper.IS).toMongoQuery(), communityConfig); | |
| 38 | + } | |
| 39 | + | |
| 40 | + //更新区域 | |
| 41 | + public void updateArea(CommunityConfig communityConfig) { | |
| 42 | + communityConfigDao.updateArea(MongoCondition.newInstance("id", communityConfig.getId(), MongoOper.IS).toMongoQuery(), communityConfig); | |
| 43 | + } | |
| 44 | + | |
| 45 | + //查询区域 | |
| 46 | + public List<CommunityConfig> queryArea(String keyword) { | |
| 47 | + MongoCondition mongoCondition = MongoCondition.newInstance(); | |
| 48 | + if(null != keyword) { | |
| 49 | + MongoCondition con1= MongoCondition.newInstance("name", keyword, MongoOper.LIKE); | |
| 50 | + MongoCondition con = MongoCondition.newInstance("parentId", keyword, MongoOper.LIKE); | |
| 51 | + mongoCondition = mongoCondition.orCondition(new MongoCondition[]{con1,con}); | |
| 52 | + } | |
| 53 | + | |
| 54 | + return communityConfigDao.queryArea(mongoCondition.toMongoQuery()); | |
| 55 | + } | |
| 56 | + | |
| 57 | +} |
platform-dal/src/main/java/com/lyms/platform/pojo/CommunityConfig.java
View file @
6f8e859
| 1 | +package com.lyms.platform.pojo; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.enums.YnEnums; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by Zhang.Rui on 2016/3/18. | |
| 7 | + */ | |
| 8 | +public class CommunityConfig { | |
| 9 | + private String id; | |
| 10 | + private String name; | |
| 11 | + private String parentId; | |
| 12 | + private Integer yn; | |
| 13 | + | |
| 14 | + public CommunityConfig(String parentId, String tmp) { | |
| 15 | + this.parentId = parentId; | |
| 16 | + this.yn = YnEnums.YES.getId(); | |
| 17 | + this.name = tmp; | |
| 18 | + } | |
| 19 | + public CommunityConfig() {} | |
| 20 | + | |
| 21 | + | |
| 22 | + public String getId() { | |
| 23 | + return id; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public void setId(String id) { | |
| 27 | + this.id = id; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public String getName() { | |
| 31 | + return name; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setName(String name) { | |
| 35 | + this.name = name; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public String getParentId() { | |
| 39 | + return parentId; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void setParentId(String parentId) { | |
| 43 | + this.parentId = parentId; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public Integer getYn() { | |
| 47 | + return yn; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setYn(Integer yn) { | |
| 51 | + this.yn = yn; | |
| 52 | + } | |
| 53 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
View file @
6f8e859
| 1 | +package com.lyms.platform.operate.web.controller; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.CommunityConfigService; | |
| 4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 5 | +import com.lyms.platform.common.enums.YnEnums; | |
| 6 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 7 | +import com.lyms.platform.common.result.BaseResponse; | |
| 8 | +import com.lyms.platform.operate.web.request.CommunityConfigRequest; | |
| 9 | +import com.lyms.platform.pojo.CommunityConfig; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.stereotype.Controller; | |
| 12 | +import org.springframework.web.bind.annotation.*; | |
| 13 | + | |
| 14 | +import javax.validation.Valid; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * Created by Zhang.Rui on 2016/3/18. | |
| 19 | + */ | |
| 20 | +@Controller | |
| 21 | +public class CommunityConfigController extends RestController { | |
| 22 | + @Autowired | |
| 23 | + private CommunityConfigService communityConfigService; | |
| 24 | + | |
| 25 | + //新增区域 | |
| 26 | + @RequestMapping(value = "communityConfig", method = RequestMethod.POST) | |
| 27 | + @ResponseBody | |
| 28 | + public BaseResponse appendArea(@RequestBody @Valid CommunityConfigRequest communityConfigRequest) { | |
| 29 | + CommunityConfig communityConfig = null; | |
| 30 | + for(String tmp : communityConfigRequest.getNames()) { | |
| 31 | + communityConfig = new CommunityConfig(communityConfigRequest.getParentId(), tmp); | |
| 32 | + communityConfigService.appendArea(communityConfig); | |
| 33 | + } | |
| 34 | + return new BaseResponse() | |
| 35 | + .setErrorcode(ErrorCodeConstants.SUCCESS) | |
| 36 | + .setErrormsg("添加成功!"); | |
| 37 | + } | |
| 38 | + | |
| 39 | + //删除区域 | |
| 40 | + @RequestMapping(value = "communityConfig/{id}", method = RequestMethod.DELETE) | |
| 41 | + @ResponseBody | |
| 42 | + public BaseResponse deleteArea(@PathVariable String id) { | |
| 43 | + CommunityConfig communityConfig = new CommunityConfig(); | |
| 44 | + communityConfig.setId(id); | |
| 45 | + communityConfigService.deleteArea(communityConfig); | |
| 46 | + return new BaseResponse() | |
| 47 | + .setErrorcode(ErrorCodeConstants.SUCCESS) | |
| 48 | + .setErrormsg("删除成功!"); | |
| 49 | + } | |
| 50 | + | |
| 51 | + //更新区域 | |
| 52 | + @RequestMapping(value = "communityConfig/{id}", method = RequestMethod.PUT) | |
| 53 | + @ResponseBody | |
| 54 | + public BaseResponse updateArea(@RequestParam(required=true) String name,@RequestParam(required=true) String parentId, @PathVariable String id) { | |
| 55 | + CommunityConfig communityConfig = new CommunityConfig(); | |
| 56 | + communityConfig.setParentId(parentId); | |
| 57 | + communityConfig.setId(id); | |
| 58 | + communityConfig.setName(name); | |
| 59 | + communityConfigService.updateArea(communityConfig); | |
| 60 | + return new BaseResponse() | |
| 61 | + .setErrorcode(ErrorCodeConstants.SUCCESS) | |
| 62 | + .setErrormsg("更新成功!"); | |
| 63 | + } | |
| 64 | + | |
| 65 | + //查询区域 | |
| 66 | + @RequestMapping(value = "communityConfig", method = RequestMethod.GET) | |
| 67 | + @ResponseBody | |
| 68 | + public BaseListResponse queryArea(String keyword) { | |
| 69 | + List<CommunityConfig> communityConfigList = communityConfigService.queryArea(keyword); | |
| 70 | + return new BaseListResponse().setData(communityConfigList) | |
| 71 | + .setErrorcode(ErrorCodeConstants.SUCCESS) | |
| 72 | + .setErrormsg("查询成功!"); | |
| 73 | + } | |
| 74 | + | |
| 75 | + | |
| 76 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityController.java
View file @
6f8e859
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/CommunityConfigRequest.java
View file @
6f8e859
| 1 | +package com.lyms.platform.operate.web.request; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.core.annotation.form.Form; | |
| 4 | + | |
| 5 | +import javax.validation.constraints.NotNull; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Created by Zhang.Rui on 2016/3/18. | |
| 9 | + */ | |
| 10 | +@Form | |
| 11 | +public class CommunityConfigRequest { | |
| 12 | + @NotNull(message = "父ID不能为空") | |
| 13 | + private String parentId; | |
| 14 | + @NotNull(message = "添加内容不能为空") | |
| 15 | + private String[] names; | |
| 16 | + | |
| 17 | + public String getParentId() { | |
| 18 | + return parentId; | |
| 19 | + } | |
| 20 | + | |
| 21 | + public void setParentId(String parentId) { | |
| 22 | + this.parentId = parentId; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public String[] getNames() { | |
| 26 | + return names; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setNames(String[] names) { | |
| 30 | + this.names = names; | |
| 31 | + } | |
| 32 | +} |