Commit db2278e17d5e000825877a8bbb8ab0d749a6ec0b
1 parent
8c1f5efc26
Exists in
master
and in
1 other branch
bug fix
Showing 6 changed files with 306 additions and 1 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IServiceMonitorDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/ServiceMonitorImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/ServiceMonitorService.java
- platform-common/src/main/java/com/lyms/platform/common/dao/BaseQuery.java
- platform-dal/src/main/java/com/lyms/platform/pojo/ServiceMonitor.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ServiceMonitorController.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IServiceMonitorDao.java
View file @
db2278e
1 | +package com.lyms.platform.biz.dal; | |
2 | + | |
3 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
4 | +import com.lyms.platform.common.dao.operator.Page; | |
5 | +import com.lyms.platform.pojo.ServiceMonitor; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +public interface IServiceMonitorDao { | |
10 | + | |
11 | + public ServiceMonitor add(ServiceMonitor obj); | |
12 | + | |
13 | + public void update(ServiceMonitor obj, String id); | |
14 | + | |
15 | + public ServiceMonitor getById(String id); | |
16 | + | |
17 | + public int queryCount(MongoQuery query); | |
18 | + | |
19 | + public List<ServiceMonitor> query(MongoQuery query); | |
20 | + | |
21 | + public Page<ServiceMonitor> findWithPage(MongoQuery query); | |
22 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/ServiceMonitorImpl.java
View file @
db2278e
1 | +package com.lyms.platform.biz.dal.impl; | |
2 | + | |
3 | +import com.lyms.platform.biz.dal.IServiceMonitorDao; | |
4 | +import com.lyms.platform.common.dao.BaseMongoDAOImpl; | |
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.dao.operator.Page; | |
9 | +import com.lyms.platform.pojo.ServiceMonitor; | |
10 | +import org.springframework.stereotype.Repository; | |
11 | + | |
12 | +import java.util.List; | |
13 | + | |
14 | +@Repository("serviceMonitorDao") | |
15 | +public class ServiceMonitorImpl extends BaseMongoDAOImpl<ServiceMonitor> implements IServiceMonitorDao { | |
16 | + | |
17 | + | |
18 | + @Override | |
19 | + public ServiceMonitor add(ServiceMonitor obj) { | |
20 | + return save(obj); | |
21 | + } | |
22 | + | |
23 | + @Override | |
24 | + public void update(ServiceMonitor obj, String id) { | |
25 | + update(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery(), obj); | |
26 | + } | |
27 | + | |
28 | + | |
29 | + @Override | |
30 | + public ServiceMonitor getById(String id) { | |
31 | + return findById(id); | |
32 | + } | |
33 | + | |
34 | + @Override | |
35 | + public int queryCount(MongoQuery query) { | |
36 | + return (int) count(query.convertToMongoQuery()); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + public List<ServiceMonitor> query(MongoQuery query) { | |
41 | + return find(query.convertToMongoQuery()); | |
42 | + } | |
43 | + | |
44 | + @Override | |
45 | + public Page<ServiceMonitor> findWithPage(MongoQuery query) { | |
46 | + return findPage(query.convertToMongoQuery()); | |
47 | + } | |
48 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/ServiceMonitorService.java
View file @
db2278e
1 | +package com.lyms.platform.biz.service; | |
2 | + | |
3 | +import com.lyms.platform.biz.dal.IServiceMonitorDao; | |
4 | +import com.lyms.platform.common.dao.BaseQuery; | |
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.pojo.ServiceMonitor; | |
10 | +import org.apache.commons.lang.ObjectUtils; | |
11 | +import org.apache.commons.lang.StringUtils; | |
12 | +import org.springframework.beans.factory.annotation.Autowired; | |
13 | +import org.springframework.data.domain.Sort; | |
14 | +import org.springframework.stereotype.Service; | |
15 | + | |
16 | +import java.util.List; | |
17 | + | |
18 | +/** | |
19 | + * Created by Zhang.Rui on 2016/6/12. | |
20 | + */ | |
21 | +@Service | |
22 | +public class ServiceMonitorService { | |
23 | + @Autowired | |
24 | + private IServiceMonitorDao serviceMonitorDao; | |
25 | + | |
26 | + public void add(ServiceMonitor serviceMonitor) { | |
27 | + serviceMonitor.setYn(YnEnums.YES.getId()); | |
28 | + serviceMonitor.setCreateDate(System.currentTimeMillis()); | |
29 | + serviceMonitorDao.add(serviceMonitor); | |
30 | + } | |
31 | + | |
32 | + public void delete(String id) { | |
33 | + ServiceMonitor serviceMonitor = serviceMonitorDao.getById(id); | |
34 | + if(null != serviceMonitor) { | |
35 | + serviceMonitor.setYn(YnEnums.NO.getId()); | |
36 | + serviceMonitorDao.update(serviceMonitor, id); | |
37 | + } | |
38 | + } | |
39 | + | |
40 | + public List<ServiceMonitor> queryByFullName(String fullName) { | |
41 | + MongoCondition mongoCondition = MongoCondition.newInstance(); | |
42 | + | |
43 | + mongoCondition=MongoCondition.newInstance("name", fullName, MongoOper.IS); | |
44 | + mongoCondition = mongoCondition.andCondition(new MongoCondition("yn", YnEnums.YES.getId(), MongoOper.IS)); | |
45 | + MongoQuery mongoQuery = mongoCondition.toMongoQuery(); | |
46 | + | |
47 | + return serviceMonitorDao.query(mongoQuery.addOrder(Sort.Direction.DESC, "createDate")); | |
48 | + } | |
49 | + | |
50 | + public List<ServiceMonitor> query(BaseQuery baseQuery) { | |
51 | + MongoCondition mongoCondition = MongoCondition.newInstance(); | |
52 | + | |
53 | + if(StringUtils.isNotBlank(baseQuery.getKeyword())) { | |
54 | + mongoCondition=MongoCondition.newInstance("name", baseQuery.getKeyword(), MongoOper.LIKE); | |
55 | + } | |
56 | + mongoCondition = mongoCondition.andCondition(new MongoCondition("yn", YnEnums.YES.getId(), MongoOper.IS)); | |
57 | + | |
58 | + MongoQuery mongoQuery = mongoCondition.toMongoQuery(); | |
59 | + if(null != baseQuery.getNeed()) { | |
60 | + baseQuery.mysqlBuild((int) serviceMonitorDao.queryCount(mongoQuery)); | |
61 | + mongoQuery.start(baseQuery.getOffset()).end(baseQuery.getLimit()); | |
62 | + } | |
63 | + | |
64 | + return serviceMonitorDao.query(mongoQuery.addOrder(Sort.Direction.DESC, "createDate")); | |
65 | + } | |
66 | + | |
67 | + public ServiceMonitor queryById(String id) { | |
68 | + return serviceMonitorDao.getById(id); | |
69 | + } | |
70 | + | |
71 | + public void update(String id, ServiceMonitor serviceMonitor) { | |
72 | + serviceMonitorDao.update(serviceMonitor, id); | |
73 | + } | |
74 | +} |
platform-common/src/main/java/com/lyms/platform/common/dao/BaseQuery.java
View file @
db2278e
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | import java.util.List; |
9 | 9 | |
10 | 10 | public class BaseQuery { |
11 | - | |
11 | + private String keyword; | |
12 | 12 | // 排序 |
13 | 13 | private String sort; |
14 | 14 | // 是否分页 |
... | ... | @@ -40,6 +40,13 @@ |
40 | 40 | private Date endTimeStart; |
41 | 41 | private Date endTimeEnd; |
42 | 42 | |
43 | + public String getKeyword() { | |
44 | + return keyword; | |
45 | + } | |
46 | + | |
47 | + public void setKeyword(String keyword) { | |
48 | + this.keyword = keyword; | |
49 | + } | |
43 | 50 | |
44 | 51 | public Date getStartTimeStart() { |
45 | 52 | return startTimeStart; |
platform-dal/src/main/java/com/lyms/platform/pojo/ServiceMonitor.java
View file @
db2278e
1 | +package com.lyms.platform.pojo; | |
2 | + | |
3 | +import org.springframework.data.mongodb.core.mapping.Document; | |
4 | + | |
5 | +/** | |
6 | + * Created by Zhang.Rui on 2016/6/12. | |
7 | + */ | |
8 | +@Document(collection="lyms_serviceMonitor") | |
9 | +public class ServiceMonitor { | |
10 | + private String id; | |
11 | + private Integer type; // 1短信 2邮箱 | |
12 | + private String name; | |
13 | + private String text; // 多个邮箱或者多个手机号 | |
14 | + private Long createDate; | |
15 | + private Integer yn; | |
16 | + | |
17 | + public String getId() { | |
18 | + return id; | |
19 | + } | |
20 | + | |
21 | + public void setId(String id) { | |
22 | + this.id = id; | |
23 | + } | |
24 | + | |
25 | + public Integer getYn() { | |
26 | + return yn; | |
27 | + } | |
28 | + | |
29 | + public void setYn(Integer yn) { | |
30 | + this.yn = yn; | |
31 | + } | |
32 | + | |
33 | + public Long getCreateDate() { | |
34 | + return createDate; | |
35 | + } | |
36 | + | |
37 | + public void setCreateDate(Long createDate) { | |
38 | + this.createDate = createDate; | |
39 | + } | |
40 | + | |
41 | + public Integer getType() { | |
42 | + return type; | |
43 | + } | |
44 | + | |
45 | + public void setType(Integer type) { | |
46 | + this.type = type; | |
47 | + } | |
48 | + | |
49 | + public String getName() { | |
50 | + return name; | |
51 | + } | |
52 | + | |
53 | + public void setName(String name) { | |
54 | + this.name = name; | |
55 | + } | |
56 | + | |
57 | + public String getText() { | |
58 | + return text; | |
59 | + } | |
60 | + | |
61 | + public void setText(String text) { | |
62 | + this.text = text; | |
63 | + } | |
64 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ServiceMonitorController.java
View file @
db2278e
1 | +package com.lyms.platform.operate.web.controller; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.ServiceMonitorService; | |
4 | +import com.lyms.platform.common.annotation.TokenRequired; | |
5 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
6 | +import com.lyms.platform.common.dao.BaseQuery; | |
7 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
8 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
9 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
10 | +import com.lyms.platform.common.enums.YnEnums; | |
11 | +import com.lyms.platform.common.result.BaseListResponse; | |
12 | +import com.lyms.platform.common.result.BaseResponse; | |
13 | +import com.lyms.platform.common.utils.ResultUtils; | |
14 | +import com.lyms.platform.pojo.ServiceMonitor; | |
15 | +import org.apache.commons.lang.StringUtils; | |
16 | +import org.springframework.beans.factory.annotation.Autowired; | |
17 | +import org.springframework.data.domain.Sort; | |
18 | +import org.springframework.stereotype.Controller; | |
19 | +import org.springframework.web.bind.annotation.PathVariable; | |
20 | +import org.springframework.web.bind.annotation.RequestMapping; | |
21 | +import org.springframework.web.bind.annotation.RequestMethod; | |
22 | +import org.springframework.web.bind.annotation.ResponseBody; | |
23 | + | |
24 | +import javax.servlet.http.HttpServletResponse; | |
25 | +import java.util.List; | |
26 | + | |
27 | +/** | |
28 | + * Created by Zhang.Rui on 2016/6/12. | |
29 | + */ | |
30 | +@Controller | |
31 | +public class ServiceMonitorController { | |
32 | + @Autowired | |
33 | + private ServiceMonitorService serviceMonitorService; | |
34 | + | |
35 | + @ResponseBody | |
36 | +// @TokenRequired | |
37 | + @RequestMapping(value = "/serviceMonitor",method = RequestMethod.POST) | |
38 | + public void add(ServiceMonitor serviceMonitor, HttpServletResponse httpServletResponse) { | |
39 | + if(serviceMonitorService.queryByFullName(serviceMonitor.getName()).size() > 0) { | |
40 | + ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse, "名称已存在"); | |
41 | + return; | |
42 | + } | |
43 | + | |
44 | + serviceMonitorService.add(serviceMonitor); | |
45 | + ResultUtils.buildSuccessResultAndWrite(httpServletResponse); | |
46 | + } | |
47 | + | |
48 | + @ResponseBody | |
49 | +// @TokenRequired | |
50 | + @RequestMapping(value = "/serviceMonitor",method = RequestMethod.DELETE) | |
51 | + public void delete(String id, HttpServletResponse httpServletResponse) { | |
52 | + serviceMonitorService.delete(id); | |
53 | + ResultUtils.buildSuccessResultAndWrite(httpServletResponse); | |
54 | + } | |
55 | + | |
56 | + @ResponseBody | |
57 | +// @TokenRequired | |
58 | + @RequestMapping(value = "/serviceMonitor",method = RequestMethod.GET) | |
59 | + public BaseListResponse query(BaseQuery baseQuery) { | |
60 | + baseQuery.setNeed("true"); | |
61 | + | |
62 | + BaseListResponse baseResponse = new BaseListResponse(); | |
63 | + baseResponse.setData(serviceMonitorService.query(baseQuery)); | |
64 | + baseResponse.setPageInfo(baseQuery.getPageInfo()); | |
65 | + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
66 | + return baseResponse; | |
67 | + } | |
68 | + | |
69 | + @ResponseBody | |
70 | +// @TokenRequired | |
71 | + @RequestMapping(value = "/serviceMonitor/{id}",method = RequestMethod.PUT) | |
72 | + public void update(ServiceMonitor serviceMonitor,@PathVariable String id, HttpServletResponse httpServletResponse) { | |
73 | + ServiceMonitor serviceMonitor1 = serviceMonitorService.queryById(id); | |
74 | + | |
75 | + if(null != serviceMonitor1) { | |
76 | + if(!serviceMonitor1.getName().equals(serviceMonitor.getName())) { | |
77 | + if(serviceMonitorService.queryByFullName(serviceMonitor.getName()).size() > 0) { | |
78 | + ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse, "名称已存在"); | |
79 | + return; | |
80 | + } | |
81 | + } | |
82 | + | |
83 | + serviceMonitorService.update(id, serviceMonitor); | |
84 | + ResultUtils.buildSuccessResultAndWrite(httpServletResponse); | |
85 | + } | |
86 | + } | |
87 | + | |
88 | + | |
89 | + | |
90 | +} |