Commit 188c19ca3add58a7fc68a938c0e37bd9f1fbb594
1 parent
7925f87485
Exists in
master
and in
8 other branches
c
Showing 22 changed files with 1104 additions and 194 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/CustomMappingMongoConverter.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPuerperaDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PuerperaDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PuerperaService.java
- platform-biz-patient-service/src/main/resources/spring/spring-mongodb1.xml
- platform-common/src/main/java/com/lyms/platform/common/base/IConvertToNaviteQuery.java
- platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoCondition.java
- platform-common/src/main/java/com/lyms/platform/common/enums/YnEnums.java
- platform-common/src/main/java/com/lyms/platform/common/result/BaseListResponse.java
- platform-common/src/main/java/com/lyms/platform/common/result/BaseResponse.java
- platform-dal/src/main/java/com/lyms/platform/pojo/BasicConfig.java
- platform-dal/src/main/java/com/lyms/platform/pojo/CommunityModel.java
- platform-dal/src/main/java/com/lyms/platform/pojo/PuerperaModel.java
- platform-dal/src/main/java/com/lyms/platform/query/BasicConfigQuery.java
- platform-dal/src/main/java/com/lyms/platform/query/CommunityModelQuery.java
- platform-dal/src/main/java/com/lyms/platform/query/PuerperaModelQuery.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/controller/CommunityController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasicConfigRequest.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/PuerperaManagerRequest.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java
View file @
188c19c
| 1 | 1 | package com.lyms.platform.biz; |
| 2 | 2 | |
| 3 | +import java.text.ParseException; | |
| 4 | +import java.text.SimpleDateFormat; | |
| 5 | +import java.util.Date; | |
| 6 | +import java.util.List; | |
| 7 | +import java.util.Map; | |
| 8 | + | |
| 3 | 9 | import org.springframework.context.ApplicationContext; |
| 4 | 10 | import org.springframework.context.support.ClassPathXmlApplicationContext; |
| 11 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 12 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 13 | +import org.springframework.data.mongodb.core.query.Query; | |
| 5 | 14 | |
| 6 | 15 | import com.lyms.platform.biz.service.BasicConfigService; |
| 16 | +import com.lyms.platform.biz.service.PuerperaService; | |
| 7 | 17 | import com.lyms.platform.pojo.BasicConfig; |
| 18 | +import com.lyms.platform.pojo.PuerperaModel; | |
| 19 | +import com.lyms.platform.query.PuerperaModelQuery; | |
| 20 | +import com.mongodb.util.JSON; | |
| 8 | 21 | |
| 9 | - | |
| 10 | - | |
| 11 | - | |
| 12 | 22 | public class BasicConfigServiceTest { |
| 13 | - public static void main(String[] args) { | |
| 23 | + public static void main(String[] args) throws Exception { | |
| 24 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 14 | 25 | ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml"); |
| 15 | - BasicConfigService basicConfigService = (BasicConfigService) applicationContext.getBean("basicConfigService"); | |
| 16 | - System.out.println(basicConfigService.queryParentConfig()); | |
| 17 | - | |
| 18 | - for(int i = 6;i<7;i++){ | |
| 19 | - BasicConfig obj = new BasicConfig(); | |
| 20 | - obj.setCode("xc123456"+i); | |
| 21 | - obj.setName("哮喘123456"+i); | |
| 22 | - obj.setYn(1); | |
| 23 | - obj.setParentId("56ea134c24fdaafbabbb0025"); | |
| 24 | - basicConfigService.addBasicConfig(obj); | |
| 26 | + PuerperaService basicConfigService = (PuerperaService) applicationContext.getBean(PuerperaService.class); | |
| 27 | + PuerperaModel obj = new PuerperaModel(); | |
| 28 | + obj.setAddress("成都市高新区天府2街"); | |
| 29 | + obj.setAge(111); | |
| 30 | + obj.setDueDate(new Date()); | |
| 31 | + obj.setIsVisit(1); | |
| 32 | + obj.setName("小王2"); | |
| 33 | + obj.setPhone("13996289315"); | |
| 34 | + obj.setYn(1); | |
| 35 | + // basicConfigService.addPuerpera(obj); | |
| 36 | + | |
| 37 | + PuerperaModel obj1 = new PuerperaModel(); | |
| 38 | + obj1.setAddress("成都市高新区天府4街"); | |
| 39 | + obj1.setAge(11); | |
| 40 | + obj1.setDueDate(sdf.parse("2016-1-12")); | |
| 41 | + obj1.setIsVisit(0); | |
| 42 | + obj1.setName("小王3"); | |
| 43 | + obj1.setPhone("15197164164"); | |
| 44 | + obj1.setYn(1); | |
| 45 | + obj1.setCommunityId("dqweqwdadadaddad"); | |
| 46 | + basicConfigService.addPuerpera(obj1); | |
| 47 | + | |
| 48 | + PuerperaModelQuery puerperaQuery = new PuerperaModelQuery(); | |
| 49 | + | |
| 50 | + ; | |
| 51 | + puerperaQuery.setKeyword("小王"); | |
| 52 | + puerperaQuery.setDueDateStart(sdf.parse("2016-1-12")); | |
| 53 | + puerperaQuery.setDueDateEnd(sdf.parse("2016-3-16")); | |
| 54 | + System.out.println(basicConfigService.queryPuerpera(puerperaQuery)); | |
| 55 | + /* | |
| 56 | + * for(int i = 6;i<7;i++){ BasicConfig obj = new BasicConfig(); obj.setCode("xc123456"+i); obj.setName("哮喘123456"+i); obj.setYn(1); | |
| 57 | + * obj.setParentId("56ea134c24fdaafbabbb0025"); basicConfigService.addBasicConfig(obj); } | |
| 58 | + */ | |
| 59 | + /* | |
| 60 | + * BasicConfig obj = new BasicConfig(); obj.setCode("111"); obj.setId("111"); | |
| 61 | + */ | |
| 62 | + /* | |
| 63 | + * System.out.println(JSON.parse("{\"名称\":111}")); MongoTemplate mongoTemplate =applicationContext.getBean(MongoTemplate.class); // | |
| 64 | + * mongoTemplate.save(JSON.parse("{\"名称\":111}"),"aa"); System.out.println(mongoTemplate.find(null, Map.class)); | |
| 65 | + */ | |
| 66 | + System.out.println("----------------------------------------------------"); | |
| 67 | + Criteria cri = Criteria.where("dueDate").gte(sdf.parse("2016-1-12")).lte(sdf.parse("2016-3-16")); | |
| 68 | + Query query = new Query(cri); | |
| 69 | + List<PuerperaModel> users = applicationContext.getBean(MongoTemplate.class).find(query, PuerperaModel.class); | |
| 70 | + for (PuerperaModel users2 : users) { | |
| 71 | + System.out.println(users2.toString()); | |
| 25 | 72 | } |
| 26 | 73 | } |
| 27 | 74 | } |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/CustomMappingMongoConverter.java
View file @
188c19c
| 1 | +package com.lyms.platform.biz; | |
| 2 | + | |
| 3 | +import org.springframework.data.mapping.context.MappingContext; | |
| 4 | +import org.springframework.data.mongodb.core.convert.DbRefResolver; | |
| 5 | +import org.springframework.data.mongodb.core.convert.MappingMongoConverter; | |
| 6 | +import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; | |
| 7 | +import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; | |
| 8 | + | |
| 9 | +import com.mongodb.DBObject; | |
| 10 | + | |
| 11 | +public class CustomMappingMongoConverter extends MappingMongoConverter{ | |
| 12 | + | |
| 13 | + public CustomMappingMongoConverter(DbRefResolver dbRefResolver, | |
| 14 | + MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) { | |
| 15 | + super(dbRefResolver, mappingContext); | |
| 16 | + } | |
| 17 | + | |
| 18 | + | |
| 19 | + @Override | |
| 20 | + public void write(Object obj, DBObject dbo) { | |
| 21 | + super.write(obj, dbo); | |
| 22 | + } | |
| 23 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPuerperaDao.java
View file @
188c19c
| 1 | +package com.lyms.platform.biz.dal; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 6 | +import com.lyms.platform.common.dao.operator.Page; | |
| 7 | +import com.lyms.platform.pojo.PuerperaModel; | |
| 8 | + | |
| 9 | +public interface IPuerperaDao { | |
| 10 | + | |
| 11 | + public PuerperaModel addPuerpera(PuerperaModel obj); | |
| 12 | + | |
| 13 | + public void updatePuerpera(PuerperaModel obj, String id); | |
| 14 | + | |
| 15 | + public void deletePuerpera(String id); | |
| 16 | + | |
| 17 | + public PuerperaModel getPuerpera(String id); | |
| 18 | + | |
| 19 | + public int queryPuerperaCount(MongoQuery query); | |
| 20 | + | |
| 21 | + public List<PuerperaModel> queryPuerpera(MongoQuery query); | |
| 22 | + | |
| 23 | + public Page<PuerperaModel> findPage(MongoQuery query); | |
| 24 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PuerperaDaoImpl.java
View file @
188c19c
| 1 | +package com.lyms.platform.biz.dal.impl; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import org.springframework.stereotype.Repository; | |
| 6 | + | |
| 7 | +import com.lyms.platform.biz.dal.IPuerperaDao; | |
| 8 | +import com.lyms.platform.common.dao.BaseMongoDAOImpl; | |
| 9 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 10 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
| 11 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 12 | +import com.lyms.platform.common.dao.operator.Page; | |
| 13 | +import com.lyms.platform.pojo.PuerperaModel; | |
| 14 | + | |
| 15 | +@Repository("puerperaDao") | |
| 16 | +public class PuerperaDaoImpl extends BaseMongoDAOImpl<PuerperaModel> implements IPuerperaDao { | |
| 17 | + | |
| 18 | + @Override | |
| 19 | + public PuerperaModel addPuerpera(PuerperaModel obj) { | |
| 20 | + return save(obj); | |
| 21 | + } | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public void updatePuerpera(PuerperaModel obj, String id) { | |
| 25 | + update(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery(), obj); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public void deletePuerpera(String id) { | |
| 30 | + delete(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery()); | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public PuerperaModel getPuerpera(String id) { | |
| 35 | + return findById(id); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public int queryPuerperaCount(MongoQuery query) { | |
| 40 | + return (int) count(query.convertToMongoQuery()); | |
| 41 | + } | |
| 42 | + | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public Page<PuerperaModel> findPage(MongoQuery query) { | |
| 46 | + return findPage(query.convertToMongoQuery()); | |
| 47 | + } | |
| 48 | + | |
| 49 | + @Override | |
| 50 | + public List<PuerperaModel> queryPuerpera(MongoQuery query) { | |
| 51 | + return find(query.convertToMongoQuery()); | |
| 52 | + } | |
| 53 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PuerperaService.java
View file @
188c19c
| 1 | +package com.lyms.platform.biz.service; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import org.apache.commons.lang.StringUtils; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.data.domain.Sort.Direction; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | + | |
| 10 | +import com.lyms.platform.biz.dal.IPuerperaDao; | |
| 11 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 12 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
| 13 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 14 | +import com.lyms.platform.common.dao.operator.Page; | |
| 15 | +import com.lyms.platform.pojo.PuerperaModel; | |
| 16 | +import com.lyms.platform.query.PuerperaModelQuery; | |
| 17 | + | |
| 18 | + | |
| 19 | +@Service | |
| 20 | +public class PuerperaService { | |
| 21 | + @Autowired | |
| 22 | + private IPuerperaDao iPuerperaDao; | |
| 23 | + public void addPuerpera(PuerperaModel obj) { | |
| 24 | + iPuerperaDao.addPuerpera(obj); | |
| 25 | + } | |
| 26 | + | |
| 27 | + public void updatePuerpera(PuerperaModel obj) { | |
| 28 | + iPuerperaDao.updatePuerpera(obj, obj.getId()); | |
| 29 | + } | |
| 30 | + | |
| 31 | + public List<PuerperaModel> queryPuerpera(PuerperaModelQuery puerperaQuery) { | |
| 32 | + MongoQuery query = puerperaQuery.convertToQuery(); | |
| 33 | + if (StringUtils.isNotEmpty(puerperaQuery.getNeed())) { | |
| 34 | + puerperaQuery.mysqlBuild(iPuerperaDao.queryPuerperaCount(puerperaQuery.convertToQuery())); | |
| 35 | + query.start(puerperaQuery.getOffset()).end(puerperaQuery.getLimit()); | |
| 36 | + } | |
| 37 | + | |
| 38 | + return iPuerperaDao.queryPuerpera(query.addOrder(Direction.ASC, "id")); | |
| 39 | + } | |
| 40 | + | |
| 41 | + | |
| 42 | + public List<PuerperaModel> queryByParentId(String parentId) { | |
| 43 | + return iPuerperaDao.queryPuerpera(MongoCondition.newInstance("parentId", parentId, MongoOper.IS).toMongoQuery()); | |
| 44 | + } | |
| 45 | + | |
| 46 | + public Page<PuerperaModel> queryGuidesAndPage(int start, int end) { | |
| 47 | + return iPuerperaDao.findPage(MongoCondition.newInstance().toMongoQuery().start(start).end(end).addOrder(Direction.ASC, "id")); | |
| 48 | + } | |
| 49 | +} |
platform-biz-patient-service/src/main/resources/spring/spring-mongodb1.xml
View file @
188c19c
| ... | ... | @@ -8,9 +8,28 @@ |
| 8 | 8 | |
| 9 | 9 | <mongo:db-factory id="mongoDbFactory" host="${mongo.db.host}" |
| 10 | 10 | port="${mongo.db.port}" dbname="${mongo.db.dbname}" /> |
| 11 | - | |
| 11 | + | |
| 12 | 12 | <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> |
| 13 | 13 | <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> |
| 14 | + <constructor-arg name="mongoConverter" ref="mappingMongoConverter" /> | |
| 15 | + </bean> | |
| 16 | + | |
| 17 | + <bean id="defaultMongoTypeMapper" | |
| 18 | + class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper"> | |
| 19 | + <constructor-arg name="typeKey"> | |
| 20 | + <null /><!-- 这里设置为空,可以把 spring data mongodb 多余保存的_class字段去掉 --> | |
| 21 | + </constructor-arg> | |
| 22 | + </bean> | |
| 23 | + | |
| 24 | + <bean id="mappingContext" | |
| 25 | + class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" /> | |
| 26 | + | |
| 27 | + <!-- 配置mongodb映射类型 --> | |
| 28 | + <bean id="mappingMongoConverter" | |
| 29 | + class="org.springframework.data.mongodb.core.convert.MappingMongoConverter"> | |
| 30 | + <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> | |
| 31 | + <constructor-arg name="mappingContext" ref="mappingContext" /> | |
| 32 | + <property name="typeMapper" ref="defaultMongoTypeMapper" /> | |
| 14 | 33 | </bean> |
| 15 | 34 | </beans> |
platform-common/src/main/java/com/lyms/platform/common/base/IConvertToNaviteQuery.java
View file @
188c19c
| 1 | +package com.lyms.platform.common.base; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * | |
| 7 | + * 转换成可执行的查询对象 | |
| 8 | + * | |
| 9 | + * @author Administrator | |
| 10 | + * | |
| 11 | + */ | |
| 12 | +public interface IConvertToNaviteQuery { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * | |
| 16 | + * @return | |
| 17 | + */ | |
| 18 | + MongoQuery convertToQuery(); | |
| 19 | +} |
platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoCondition.java
View file @
188c19c
| ... | ... | @@ -3,169 +3,184 @@ |
| 3 | 3 | import org.springframework.data.mongodb.core.query.Criteria; |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | - * 封装mongo 条件属性的操作 | |
| 7 | - * | |
| 8 | - * 对于模糊查询的时候 obj为一个正则表达式 如: | |
| 9 | - * | |
| 10 | - * <code> | |
| 6 | + * 封装mongo 条件属性的操作 对于模糊查询的时候 obj为一个正则表达式 如: <code> | |
| 11 | 7 | * <ui> |
| 12 | 8 | * <li>1.MongoCondition.newInstance("name", "^小七测试",MongoOper.LIKE) '^小七测试' 查询名字为小七测试开头</li> |
| 13 | 9 | * <li>2.MongoCondition.newInstance("name", "小七测试$",MongoOper.LIKE) '小七测试$' 查询名字为小七测试结尾</li> |
| 14 | 10 | * </ui> |
| 15 | 11 | * </code> |
| 16 | 12 | * |
| 17 | - * | |
| 18 | - * | |
| 19 | 13 | * @link MongoOper |
| 20 | - * | |
| 21 | 14 | * @author Administrator |
| 22 | - * | |
| 23 | 15 | */ |
| 24 | 16 | public class MongoCondition { |
| 25 | 17 | |
| 26 | - private Criteria criteria; | |
| 18 | + private Criteria criteria; | |
| 27 | 19 | |
| 28 | - public Criteria getCriteria() { | |
| 29 | - return criteria; | |
| 30 | - } | |
| 20 | + public Criteria getCriteria() { | |
| 21 | + return criteria; | |
| 22 | + } | |
| 31 | 23 | |
| 32 | - public static MongoCondition newInstance() { | |
| 33 | - return new MongoCondition(); | |
| 34 | - } | |
| 24 | + public static MongoCondition newInstance() { | |
| 25 | + return new MongoCondition(); | |
| 26 | + } | |
| 35 | 27 | |
| 36 | - /** | |
| 37 | - * | |
| 38 | - * 创建一个实例 | |
| 39 | - * | |
| 40 | - * @param key | |
| 41 | - * 字段名 | |
| 42 | - * @param obj | |
| 43 | - * 值 | |
| 44 | - * @param oper | |
| 45 | - * 查询运算符 | |
| 46 | - * @return | |
| 47 | - */ | |
| 48 | - public static MongoCondition newInstance(String key, Object obj, | |
| 49 | - MongoOper oper) { | |
| 50 | - return new MongoCondition(key, obj, oper); | |
| 51 | - } | |
| 28 | + /** | |
| 29 | + * 创建一个实例 | |
| 30 | + * | |
| 31 | + * @param key | |
| 32 | + * 字段名 | |
| 33 | + * @param obj | |
| 34 | + * 值 | |
| 35 | + * @param oper | |
| 36 | + * 查询运算符 | |
| 37 | + * @return | |
| 38 | + */ | |
| 39 | + public static MongoCondition newInstance(String key, Object obj, MongoOper oper) { | |
| 40 | + return new MongoCondition(key, obj, oper); | |
| 41 | + } | |
| 52 | 42 | |
| 53 | - public MongoCondition(String key, Object obj, MongoOper oper) { | |
| 54 | - super(); | |
| 55 | - if (null == criteria) { | |
| 56 | - criteria = Criteria.where(key); | |
| 57 | - } | |
| 58 | - set(oper, obj, criteria); | |
| 59 | - } | |
| 43 | + public MongoCondition(String key, Object obj, MongoOper oper) { | |
| 44 | + super(); | |
| 45 | + if (null == criteria) { | |
| 46 | + criteria = Criteria.where(key); | |
| 47 | + } | |
| 48 | + set(oper, obj, criteria); | |
| 49 | + } | |
| 60 | 50 | |
| 61 | - public MongoCondition() { | |
| 62 | - criteria = new Criteria(); | |
| 63 | - } | |
| 51 | + public MongoCondition() { | |
| 52 | + criteria = new Criteria(); | |
| 53 | + } | |
| 54 | + public MongoCondition(Criteria c) { | |
| 55 | + criteria = c; | |
| 56 | + } | |
| 64 | 57 | |
| 65 | - /** | |
| 66 | - * and 条件查询 | |
| 67 | - * | |
| 68 | - * @param key | |
| 69 | - * 数据库中的字段名 | |
| 70 | - * @param obj | |
| 71 | - * 值 | |
| 72 | - * @param oper | |
| 73 | - * 运算符 @link MongoOper | |
| 74 | - * @return | |
| 75 | - */ | |
| 76 | - public MongoCondition and(String key, Object obj, MongoOper oper) { | |
| 77 | - if(criteria ==null){ | |
| 78 | - criteria = Criteria.where(key); | |
| 79 | - set(oper, obj, criteria); | |
| 80 | - }else{ | |
| 81 | - Criteria criteria1 = criteria.and(key); | |
| 82 | - set(oper, obj, criteria1); | |
| 83 | - criteria = criteria1; | |
| 84 | - } | |
| 85 | - | |
| 86 | - return this; | |
| 87 | - } | |
| 58 | + /** | |
| 59 | + * and 条件查询 | |
| 60 | + * | |
| 61 | + * @param key | |
| 62 | + * 数据库中的字段名 | |
| 63 | + * @param obj | |
| 64 | + * 值 | |
| 65 | + * @param oper | |
| 66 | + * 运算符 @link MongoOper | |
| 67 | + * @return | |
| 68 | + */ | |
| 69 | + public MongoCondition and(String key, Object obj, MongoOper oper) { | |
| 70 | + if (criteria == null) { | |
| 71 | + criteria = Criteria.where(key); | |
| 72 | + set(oper, obj, criteria); | |
| 73 | + } else { | |
| 74 | + Criteria criteria1 = criteria.and(key); | |
| 75 | + set(oper, obj, criteria1); | |
| 76 | + criteria = criteria1; | |
| 77 | + } | |
| 88 | 78 | |
| 89 | - /** | |
| 90 | - * 2个查询条件的交集 | |
| 91 | - * | |
| 92 | - * @param con | |
| 93 | - * @return | |
| 94 | - */ | |
| 95 | - public MongoCondition andCondition(MongoCondition con) { | |
| 96 | - Criteria localCriteria = con.criteria; | |
| 97 | - criteria = criteria.andOperator(localCriteria); | |
| 98 | - return this; | |
| 99 | - } | |
| 79 | + return this; | |
| 80 | + } | |
| 100 | 81 | |
| 101 | - /** | |
| 102 | - * 2个查询条件的并集 | |
| 103 | - * | |
| 104 | - * @param con | |
| 105 | - * @return | |
| 106 | - */ | |
| 107 | - public MongoCondition orCondition(MongoCondition con) { | |
| 108 | - if(null==criteria){ | |
| 109 | - criteria= con.criteria; | |
| 110 | - }else{ | |
| 111 | - criteria = criteria.orOperator(con.criteria); | |
| 112 | - } | |
| 113 | - return this; | |
| 114 | - } | |
| 115 | - | |
| 116 | - public MongoCondition orCondition(MongoCondition... con){ | |
| 117 | - /* public Criteria orOperator(Criteria... criteria) { | |
| 118 | - BasicDBList bsonList = createCriteriaList(criteria); | |
| 119 | - return registerCriteriaChainElement(new Criteria("$or").is(bsonList)); | |
| 120 | - }*/ | |
| 121 | - Criteria[] list=new Criteria[con.length]; | |
| 122 | - int index= 0; | |
| 123 | - for(MongoCondition c:con){ | |
| 124 | - list[index++]=c.criteria; | |
| 125 | - } | |
| 126 | - if(null==criteria){ | |
| 127 | - criteria=list[0]; | |
| 128 | - if(con.length>1){ | |
| 129 | - Criteria[] dest = new Criteria[con.length-1]; | |
| 130 | - System.arraycopy(list, 1, dest, 0, dest.length); | |
| 131 | - criteria.orOperator(dest); | |
| 132 | - } | |
| 133 | - }else{ | |
| 134 | - criteria.orOperator(list); | |
| 135 | - } | |
| 136 | - return this; | |
| 137 | - } | |
| 82 | + /** | |
| 83 | + * Query query = new Query(Criteria.where("b").elemMatch( Criteria.where("startDate").gte(date) .and("endDate").lte(date) ); | |
| 84 | + * | |
| 85 | + * @param c | |
| 86 | + * @return | |
| 87 | + */ | |
| 88 | + @SuppressWarnings("static-access") | |
| 89 | + public MongoCondition elemMatch(String field,MongoCondition c) { | |
| 90 | + criteria.where(field).elemMatch(c.criteria); | |
| 91 | + return this; | |
| 92 | + } | |
| 138 | 93 | |
| 139 | - /** | |
| 140 | - * 如果是模糊匹配,obj则为需要匹配的正则表达式 | |
| 141 | - * | |
| 142 | - * @param oper | |
| 143 | - * @param obj | |
| 144 | - * @param criteria | |
| 145 | - */ | |
| 146 | - private void set(MongoOper oper, Object obj, Criteria criteria) { | |
| 147 | - if (MongoOper.GT == oper) { | |
| 148 | - criteria.gt(obj); | |
| 149 | - } else if (MongoOper.GTE == oper) { | |
| 150 | - criteria.gte(obj); | |
| 151 | - } else if (MongoOper.IS == oper) { | |
| 152 | - criteria.is(obj); | |
| 153 | - } else if (MongoOper.LIKE == oper) { | |
| 154 | - criteria.regex(String.valueOf(obj), "m"); | |
| 155 | - } else if (MongoOper.LT == oper) { | |
| 156 | - criteria.lt(obj); | |
| 157 | - } else if (MongoOper.NE == oper) { | |
| 158 | - criteria.ne(obj); | |
| 159 | - } | |
| 160 | - } | |
| 94 | + /** | |
| 95 | + * Query query = new Query(Criteria.where("b").elemMatch( Criteria.where("startDate").gte(date) .and("endDate").lte(date) ); | |
| 96 | + * | |
| 97 | + * @param c | |
| 98 | + * @return | |
| 99 | + */ | |
| 100 | + public MongoCondition elemMatch(MongoCondition c) { | |
| 101 | + criteria.elemMatch(c.criteria); | |
| 102 | + return this; | |
| 103 | + } | |
| 104 | + /** | |
| 105 | + * 2个查询条件的交集 | |
| 106 | + * | |
| 107 | + * @param con | |
| 108 | + * @return | |
| 109 | + */ | |
| 110 | + public MongoCondition andCondition(MongoCondition con) { | |
| 111 | + Criteria localCriteria = con.criteria; | |
| 112 | + criteria = criteria.andOperator(localCriteria); | |
| 113 | + return this; | |
| 114 | + } | |
| 161 | 115 | |
| 162 | - /** | |
| 163 | - * 把当前条件转成查询对象 | |
| 164 | - * | |
| 165 | - * @return | |
| 166 | - */ | |
| 167 | - public MongoQuery toMongoQuery() { | |
| 168 | - return new MongoQuery(this); | |
| 169 | - } | |
| 116 | + /** | |
| 117 | + * 2个查询条件的并集 | |
| 118 | + * | |
| 119 | + * @param con | |
| 120 | + * @return | |
| 121 | + */ | |
| 122 | + public MongoCondition orCondition(MongoCondition con) { | |
| 123 | + if (null == criteria) { | |
| 124 | + criteria = con.criteria; | |
| 125 | + } else { | |
| 126 | + criteria = criteria.orOperator(con.criteria); | |
| 127 | + } | |
| 128 | + return this; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public MongoCondition orCondition(MongoCondition... con) { | |
| 132 | + /* | |
| 133 | + * public Criteria orOperator(Criteria... criteria) { BasicDBList bsonList = createCriteriaList(criteria); return | |
| 134 | + * registerCriteriaChainElement(new Criteria("$or").is(bsonList)); } | |
| 135 | + */ | |
| 136 | + Criteria[] list = new Criteria[con.length]; | |
| 137 | + int index = 0; | |
| 138 | + for (MongoCondition c : con) { | |
| 139 | + list[index++] = c.criteria; | |
| 140 | + } | |
| 141 | + if (null == criteria) { | |
| 142 | + criteria = list[0]; | |
| 143 | + if (con.length > 1) { | |
| 144 | + Criteria[] dest = new Criteria[con.length - 1]; | |
| 145 | + System.arraycopy(list, 1, dest, 0, dest.length); | |
| 146 | + criteria.orOperator(dest); | |
| 147 | + } | |
| 148 | + } else { | |
| 149 | + criteria.orOperator(list); | |
| 150 | + } | |
| 151 | + return this; | |
| 152 | + } | |
| 153 | + | |
| 154 | + /** | |
| 155 | + * 如果是模糊匹配,obj则为需要匹配的正则表达式 | |
| 156 | + * | |
| 157 | + * @param oper | |
| 158 | + * @param obj | |
| 159 | + * @param criteria | |
| 160 | + */ | |
| 161 | + private void set(MongoOper oper, Object obj, Criteria criteria) { | |
| 162 | + if (MongoOper.GT == oper) { | |
| 163 | + criteria.gt(obj); | |
| 164 | + } else if (MongoOper.GTE == oper) { | |
| 165 | + criteria.gte(obj); | |
| 166 | + } else if (MongoOper.IS == oper) { | |
| 167 | + criteria.is(obj); | |
| 168 | + } else if (MongoOper.LIKE == oper) { | |
| 169 | + criteria.regex(String.valueOf(obj), "m"); | |
| 170 | + } else if (MongoOper.LT == oper) { | |
| 171 | + criteria.lt(obj); | |
| 172 | + } else if (MongoOper.NE == oper) { | |
| 173 | + criteria.ne(obj); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + /** | |
| 178 | + * 把当前条件转成查询对象 | |
| 179 | + * | |
| 180 | + * @return | |
| 181 | + */ | |
| 182 | + public MongoQuery toMongoQuery() { | |
| 183 | + return new MongoQuery(this); | |
| 184 | + } | |
| 170 | 185 | } |
platform-common/src/main/java/com/lyms/platform/common/enums/YnEnums.java
View file @
188c19c
| 1 | +package com.lyms.platform.common.enums; | |
| 2 | + | |
| 3 | +public enum YnEnums { | |
| 4 | + | |
| 5 | + YES(1, "有效"), NO(0, "无效"); | |
| 6 | + | |
| 7 | + private YnEnums(int id, String title) { | |
| 8 | + this.id = id; | |
| 9 | + this.title = title; | |
| 10 | + } | |
| 11 | + | |
| 12 | + private int id; | |
| 13 | + | |
| 14 | + private String title; | |
| 15 | + | |
| 16 | + public YnEnums getEnum(int id) { | |
| 17 | + for (YnEnums yn : values()) { | |
| 18 | + if (yn.getId() == id) { | |
| 19 | + return yn; | |
| 20 | + } | |
| 21 | + } | |
| 22 | + return null; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public int getId() { | |
| 26 | + return id; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public String getTitle() { | |
| 30 | + return title; | |
| 31 | + } | |
| 32 | +} |
platform-common/src/main/java/com/lyms/platform/common/result/BaseListResponse.java
View file @
188c19c
| ... | ... | @@ -15,8 +15,18 @@ |
| 15 | 15 | return data; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public void setData(List data) { | |
| 18 | + public BaseListResponse setData(List data) { | |
| 19 | 19 | this.data = data; |
| 20 | + return this; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public BaseListResponse setErrorcode(int errorcode) { | |
| 24 | + super.setErrorcode(errorcode); | |
| 25 | + return this; | |
| 26 | + } | |
| 27 | + public BaseListResponse setErrormsg(String errormsg) { | |
| 28 | + super.setErrormsg(errormsg); | |
| 29 | + return this; | |
| 20 | 30 | } |
| 21 | 31 | } |
platform-common/src/main/java/com/lyms/platform/common/result/BaseResponse.java
View file @
188c19c
| ... | ... | @@ -31,16 +31,18 @@ |
| 31 | 31 | return errormsg; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public void setErrormsg(String errormsg) { | |
| 34 | + public BaseResponse setErrormsg(String errormsg) { | |
| 35 | 35 | this.errormsg = errormsg; |
| 36 | + return this; | |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | public int getErrorcode() { |
| 39 | 40 | return errorcode; |
| 40 | 41 | } |
| 41 | 42 | |
| 42 | - public void setErrorcode(int errorcode) { | |
| 43 | + public BaseResponse setErrorcode(int errorcode) { | |
| 43 | 44 | this.errorcode = errorcode; |
| 45 | + return this; | |
| 44 | 46 | } |
| 45 | 47 | } |
platform-dal/src/main/java/com/lyms/platform/pojo/BasicConfig.java
View file @
188c19c
platform-dal/src/main/java/com/lyms/platform/pojo/CommunityModel.java
View file @
188c19c
| 1 | +package com.lyms.platform.pojo; | |
| 2 | + | |
| 3 | +import org.springframework.data.mongodb.core.mapping.Document; | |
| 4 | + | |
| 5 | +import com.lyms.platform.common.result.BaseModel; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 社区模型 | |
| 9 | + * | |
| 10 | + * @author Administrator | |
| 11 | + */ | |
| 12 | +@Document(collection="lyms_community") | |
| 13 | +public class CommunityModel extends BaseModel { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * | |
| 17 | + */ | |
| 18 | + private static final long serialVersionUID = 1L; | |
| 19 | + | |
| 20 | + private String id; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 社区名称 | |
| 24 | + */ | |
| 25 | + private String communityName; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 社区所属地域 | |
| 29 | + */ | |
| 30 | + private String areaId; | |
| 31 | + | |
| 32 | + public String getId() { | |
| 33 | + return id; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setId(String id) { | |
| 37 | + this.id = id; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public String getCommunityName() { | |
| 41 | + return communityName; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setCommunityName(String communityName) { | |
| 45 | + this.communityName = communityName; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public String getAreaId() { | |
| 49 | + return areaId; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setAreaId(String areaId) { | |
| 53 | + this.areaId = areaId; | |
| 54 | + } | |
| 55 | +} |
platform-dal/src/main/java/com/lyms/platform/pojo/PuerperaModel.java
View file @
188c19c
| 1 | +package com.lyms.platform.pojo; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | + | |
| 5 | +import org.springframework.data.mongodb.core.mapping.Document; | |
| 6 | +import org.springframework.data.mongodb.core.mapping.Field; | |
| 7 | + | |
| 8 | +import com.lyms.platform.common.result.BaseModel; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * | |
| 12 | + * 产妇模型定义 | |
| 13 | + * | |
| 14 | + * @author Administrator | |
| 15 | + * | |
| 16 | + */ | |
| 17 | +@Document(collection="lyms_puerpera") | |
| 18 | +public class PuerperaModel extends BaseModel { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + private static final long serialVersionUID = 1L; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 身份证号码 | |
| 27 | + */ | |
| 28 | + @Field("cardno") | |
| 29 | + private String cardNo; | |
| 30 | + /** | |
| 31 | + * 助产机构 | |
| 32 | + */ | |
| 33 | + @Field("deliverorg") | |
| 34 | + private String deliverOrg; | |
| 35 | + /** | |
| 36 | + * 分娩方式 | |
| 37 | + */ | |
| 38 | + @Field("duetype") | |
| 39 | + private String dueType; | |
| 40 | + | |
| 41 | + private String id; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 产妇名称 | |
| 45 | + */ | |
| 46 | + private String name; | |
| 47 | + /** | |
| 48 | + * 产妇年龄 | |
| 49 | + */ | |
| 50 | + private int age; | |
| 51 | + /** | |
| 52 | + * 产妇手机号 | |
| 53 | + */ | |
| 54 | + private String phone; | |
| 55 | + /** | |
| 56 | + * 产妇分娩日期 | |
| 57 | + */ | |
| 58 | + private Date dueDate; | |
| 59 | + /** | |
| 60 | + * 地址 | |
| 61 | + */ | |
| 62 | + private String address; | |
| 63 | + /** | |
| 64 | + * 社区id | |
| 65 | + */ | |
| 66 | + private String communityId; | |
| 67 | + /** | |
| 68 | + * 是否访视 | |
| 69 | + */ | |
| 70 | + private int isVisit; | |
| 71 | + /** | |
| 72 | + * 是否有效 | |
| 73 | + */ | |
| 74 | + private int yn; | |
| 75 | + | |
| 76 | + public String getCardNo() { | |
| 77 | + return cardNo; | |
| 78 | + } | |
| 79 | + public void setCardNo(String cardNo) { | |
| 80 | + this.cardNo = cardNo; | |
| 81 | + } | |
| 82 | + public String getDeliverOrg() { | |
| 83 | + return deliverOrg; | |
| 84 | + } | |
| 85 | + public void setDeliverOrg(String deliverOrg) { | |
| 86 | + this.deliverOrg = deliverOrg; | |
| 87 | + } | |
| 88 | + public String getDueType() { | |
| 89 | + return dueType; | |
| 90 | + } | |
| 91 | + public void setDueType(String dueType) { | |
| 92 | + this.dueType = dueType; | |
| 93 | + } | |
| 94 | + public int getIsVisit() { | |
| 95 | + return isVisit; | |
| 96 | + } | |
| 97 | + public void setIsVisit(int isVisit) { | |
| 98 | + this.isVisit = isVisit; | |
| 99 | + } | |
| 100 | + public String getId() { | |
| 101 | + return id; | |
| 102 | + } | |
| 103 | + public void setId(String id) { | |
| 104 | + this.id = id; | |
| 105 | + } | |
| 106 | + public int getYn() { | |
| 107 | + return yn; | |
| 108 | + } | |
| 109 | + public void setYn(int yn) { | |
| 110 | + this.yn = yn; | |
| 111 | + } | |
| 112 | + public String getName() { | |
| 113 | + return name; | |
| 114 | + } | |
| 115 | + public void setName(String name) { | |
| 116 | + this.name = name; | |
| 117 | + } | |
| 118 | + public int getAge() { | |
| 119 | + return age; | |
| 120 | + } | |
| 121 | + public void setAge(int age) { | |
| 122 | + this.age = age; | |
| 123 | + } | |
| 124 | + public String getPhone() { | |
| 125 | + return phone; | |
| 126 | + } | |
| 127 | + public void setPhone(String phone) { | |
| 128 | + this.phone = phone; | |
| 129 | + } | |
| 130 | + public Date getDueDate() { | |
| 131 | + return dueDate; | |
| 132 | + } | |
| 133 | + public void setDueDate(Date dueDate) { | |
| 134 | + this.dueDate = dueDate; | |
| 135 | + } | |
| 136 | + public String getAddress() { | |
| 137 | + return address; | |
| 138 | + } | |
| 139 | + public void setAddress(String address) { | |
| 140 | + this.address = address; | |
| 141 | + } | |
| 142 | + public String getCommunityId() { | |
| 143 | + return communityId; | |
| 144 | + } | |
| 145 | + public void setCommunityId(String communityId) { | |
| 146 | + this.communityId = communityId; | |
| 147 | + } | |
| 148 | +} |
platform-dal/src/main/java/com/lyms/platform/query/BasicConfigQuery.java
View file @
188c19c
| 1 | 1 | package com.lyms.platform.query; |
| 2 | 2 | |
| 3 | +import com.lyms.platform.common.base.IConvertToNaviteQuery; | |
| 3 | 4 | import com.lyms.platform.common.dao.BaseQuery; |
| 4 | 5 | import com.lyms.platform.common.dao.operator.MongoCondition; |
| 5 | 6 | import com.lyms.platform.common.dao.operator.MongoOper; |
| 6 | 7 | import com.lyms.platform.common.dao.operator.MongoQuery; |
| 7 | 8 | |
| 8 | -public class BasicConfigQuery extends BaseQuery { | |
| 9 | +public class BasicConfigQuery extends BaseQuery implements IConvertToNaviteQuery { | |
| 9 | 10 | |
| 10 | 11 | private String id; |
| 11 | 12 |
platform-dal/src/main/java/com/lyms/platform/query/CommunityModelQuery.java
View file @
188c19c
| 1 | +package com.lyms.platform.query; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.base.IConvertToNaviteQuery; | |
| 4 | +import com.lyms.platform.common.dao.BaseQuery; | |
| 5 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 社区模型 | |
| 9 | + * | |
| 10 | + * @author Administrator | |
| 11 | + */ | |
| 12 | +public class CommunityModelQuery extends BaseQuery implements IConvertToNaviteQuery{ | |
| 13 | + | |
| 14 | + | |
| 15 | + private String id; | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 社区名称 | |
| 19 | + */ | |
| 20 | + private String communityName; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 社区所属地域 | |
| 24 | + */ | |
| 25 | + private String areaId; | |
| 26 | + | |
| 27 | + public String getId() { | |
| 28 | + return id; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public void setId(String id) { | |
| 32 | + this.id = id; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public String getCommunityName() { | |
| 36 | + return communityName; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setCommunityName(String communityName) { | |
| 40 | + this.communityName = communityName; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public String getAreaId() { | |
| 44 | + return areaId; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setAreaId(String areaId) { | |
| 48 | + this.areaId = areaId; | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public MongoQuery convertToQuery() { | |
| 53 | + return null; | |
| 54 | + } | |
| 55 | +} |
platform-dal/src/main/java/com/lyms/platform/query/PuerperaModelQuery.java
View file @
188c19c
| 1 | +package com.lyms.platform.query; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | + | |
| 5 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 6 | + | |
| 7 | +import com.lyms.platform.common.base.IConvertToNaviteQuery; | |
| 8 | +import com.lyms.platform.common.dao.BaseQuery; | |
| 9 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 10 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
| 11 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * | |
| 15 | + * 产妇模型定义 | |
| 16 | + * | |
| 17 | + * @author Administrator | |
| 18 | + * | |
| 19 | + */ | |
| 20 | +public class PuerperaModelQuery extends BaseQuery implements IConvertToNaviteQuery{ | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 关键字 | |
| 24 | + */ | |
| 25 | + private String keyword; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 产妇名称 | |
| 29 | + */ | |
| 30 | + private String name; | |
| 31 | + /** | |
| 32 | + * 产妇年龄 | |
| 33 | + */ | |
| 34 | + private int age; | |
| 35 | + /** | |
| 36 | + * 访视状态 | |
| 37 | + */ | |
| 38 | + private int visitstatus=-1; | |
| 39 | + /** | |
| 40 | + * 产妇手机号 | |
| 41 | + */ | |
| 42 | + private String phone; | |
| 43 | + /** | |
| 44 | + * 产妇分娩日期 | |
| 45 | + */ | |
| 46 | + private Date dueDateStart; | |
| 47 | + | |
| 48 | + private Date dueDateEnd; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 地址 | |
| 52 | + */ | |
| 53 | + private String address; | |
| 54 | + /** | |
| 55 | + * 社区id | |
| 56 | + */ | |
| 57 | + private String communityId; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 是否有效 | |
| 61 | + */ | |
| 62 | + private int yn; | |
| 63 | + | |
| 64 | + | |
| 65 | + public int getVisitstatus() { | |
| 66 | + return visitstatus; | |
| 67 | + } | |
| 68 | + public void setVisitstatus(int visitstatus) { | |
| 69 | + this.visitstatus = visitstatus; | |
| 70 | + } | |
| 71 | + public String getKeyword() { | |
| 72 | + return keyword; | |
| 73 | + } | |
| 74 | + public void setKeyword(String keyword) { | |
| 75 | + this.keyword = keyword; | |
| 76 | + } | |
| 77 | + public Date getDueDateStart() { | |
| 78 | + return dueDateStart; | |
| 79 | + } | |
| 80 | + public void setDueDateStart(Date dueDateStart) { | |
| 81 | + this.dueDateStart = dueDateStart; | |
| 82 | + } | |
| 83 | + public Date getDueDateEnd() { | |
| 84 | + return dueDateEnd; | |
| 85 | + } | |
| 86 | + public void setDueDateEnd(Date dueDateEnd) { | |
| 87 | + this.dueDateEnd = dueDateEnd; | |
| 88 | + } | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + public int getYn() { | |
| 93 | + return yn; | |
| 94 | + } | |
| 95 | + public void setYn(int yn) { | |
| 96 | + this.yn = yn; | |
| 97 | + } | |
| 98 | + public String getName() { | |
| 99 | + return name; | |
| 100 | + } | |
| 101 | + public void setName(String name) { | |
| 102 | + this.name = name; | |
| 103 | + } | |
| 104 | + public int getAge() { | |
| 105 | + return age; | |
| 106 | + } | |
| 107 | + public void setAge(int age) { | |
| 108 | + this.age = age; | |
| 109 | + } | |
| 110 | + public String getPhone() { | |
| 111 | + return phone; | |
| 112 | + } | |
| 113 | + public void setPhone(String phone) { | |
| 114 | + this.phone = phone; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public String getAddress() { | |
| 118 | + return address; | |
| 119 | + } | |
| 120 | + public void setAddress(String address) { | |
| 121 | + this.address = address; | |
| 122 | + } | |
| 123 | + public String getCommunityId() { | |
| 124 | + return communityId; | |
| 125 | + } | |
| 126 | + public void setCommunityId(String communityId) { | |
| 127 | + this.communityId = communityId; | |
| 128 | + } | |
| 129 | + public MongoQuery convertToQuery() { | |
| 130 | + MongoCondition condition = MongoCondition.newInstance(); | |
| 131 | + if(null!=keyword){ | |
| 132 | + MongoCondition con1= MongoCondition.newInstance("phone", keyword, MongoOper.LIKE); | |
| 133 | + MongoCondition con = MongoCondition.newInstance("name", keyword, MongoOper.LIKE); | |
| 134 | + condition = condition.orCondition(new MongoCondition[]{con1,con}); | |
| 135 | + } | |
| 136 | + if(visitstatus!=-1){ | |
| 137 | + condition= condition.and("visitstatus", visitstatus, MongoOper.IS); | |
| 138 | + } | |
| 139 | + if(null!=communityId){ | |
| 140 | + condition= condition.and("communityId", communityId, MongoOper.IS); | |
| 141 | + } | |
| 142 | + | |
| 143 | + if(null!=dueDateStart){ | |
| 144 | +// condition= condition.elemMatch("dueDate",MongoCondition.newInstance("$lte", dueDateStart, MongoOper.IS).and("$gte", dueDateEnd, MongoOper.IS)); | |
| 145 | +// condition=condition.and("dueDate", dueDateStart, MongoOper.GTE).and("dueDate", dueDateEnd, MongoOper.LTE); | |
| 146 | + Criteria c = Criteria.where("dueDate").gte(dueDateStart).lte(dueDateEnd).andOperator(condition.getCriteria()); | |
| 147 | + return new MongoCondition(c).toMongoQuery(); | |
| 148 | + } | |
| 149 | + | |
| 150 | + return condition.toMongoQuery(); | |
| 151 | + } | |
| 152 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BasicConfigController.java
View file @
188c19c
| ... | ... | @@ -45,11 +45,8 @@ |
| 45 | 45 | basicConfigQuery.setLimit(limit); |
| 46 | 46 | basicConfigQuery.setKeyword(keywords); |
| 47 | 47 | List<BasicConfig> data = basicConfigService.queryBasicConfig(basicConfigQuery); |
| 48 | - BaseListResponse baseListResponse = new BaseListResponse(); | |
| 49 | - baseListResponse.setData(data); | |
| 50 | - baseListResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 51 | - baseListResponse.setErrormsg("成功"); | |
| 52 | - return baseListResponse; | |
| 48 | + | |
| 49 | + return new BaseListResponse().setData(data).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 53 | 50 | } |
| 54 | 51 | |
| 55 | 52 | @RequestMapping(method = RequestMethod.PUT, value = "/basicConfig/{id}") |
| ... | ... | @@ -63,10 +60,7 @@ |
| 63 | 60 | obj.setName(title); |
| 64 | 61 | obj.setCode(code); |
| 65 | 62 | basicConfigService.updateBasicConfig(obj); |
| 66 | - BaseResponse baseResponse = new BaseResponse(); | |
| 67 | - baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 68 | - baseResponse.setErrormsg("成功"); | |
| 69 | - return baseResponse; | |
| 63 | + return new BaseResponse("成功",ErrorCodeConstants.SUCCESS); | |
| 70 | 64 | } |
| 71 | 65 | |
| 72 | 66 | @RequestMapping(method = RequestMethod.DELETE, value = "/basicConfig/{id}") |
| ... | ... | @@ -78,10 +72,7 @@ |
| 78 | 72 | obj.setYn(0); |
| 79 | 73 | basicConfigService.updateBasicConfig(obj); |
| 80 | 74 | |
| 81 | - BaseResponse baseResponse = new BaseResponse(); | |
| 82 | - baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 83 | - baseResponse.setErrormsg("成功"); | |
| 84 | - return baseResponse; | |
| 75 | + return new BaseResponse("成功",ErrorCodeConstants.SUCCESS); | |
| 85 | 76 | } |
| 86 | 77 | |
| 87 | 78 | @RequestMapping(method = RequestMethod.GET, value = "/basicConfigTree") |
| ... | ... | @@ -105,11 +96,7 @@ |
| 105 | 96 | for (BasicConfigRequest ba : listReq) { |
| 106 | 97 | basicConfigService.addBasicConfig(ba.convertToBasicConfig()); |
| 107 | 98 | } |
| 108 | - | |
| 109 | - BaseResponse baseResponse = new BaseResponse(); | |
| 110 | - baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 111 | - baseResponse.setErrormsg("成功"); | |
| 112 | - return baseResponse; | |
| 99 | + return new BaseResponse("成功",ErrorCodeConstants.SUCCESS); | |
| 113 | 100 | } |
| 114 | 101 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityController.java
View file @
188c19c
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
View file @
188c19c
| 1 | +package com.lyms.platform.operate.web.controller; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import javax.validation.Valid; | |
| 6 | + | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.stereotype.Controller; | |
| 9 | +import org.springframework.web.bind.annotation.PathVariable; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 12 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 13 | +import org.springframework.web.bind.annotation.ResponseBody; | |
| 14 | + | |
| 15 | +import com.lyms.platform.biz.service.PuerperaService; | |
| 16 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 17 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 18 | +import com.lyms.platform.common.result.BaseResponse; | |
| 19 | +import com.lyms.platform.operate.web.request.PuerperaManagerRequest; | |
| 20 | +import com.lyms.platform.pojo.PuerperaModel; | |
| 21 | +import com.lyms.platform.query.PuerperaModelQuery; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 产妇管理接口 | |
| 25 | + * | |
| 26 | + * @author Administrator | |
| 27 | + */ | |
| 28 | +@Controller | |
| 29 | +public class PuerperaManageController { | |
| 30 | + | |
| 31 | + @Autowired | |
| 32 | + private PuerperaService puerperaService; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 产妇管理查询接口 | |
| 36 | + * | |
| 37 | + * @param managerRequest | |
| 38 | + * @return | |
| 39 | + */ | |
| 40 | + @RequestMapping(value = "/puerperamanage", method = RequestMethod.GET) | |
| 41 | + @ResponseBody | |
| 42 | + public BaseListResponse queryPuerperaManage(@Valid | |
| 43 | + PuerperaManagerRequest managerRequest) { | |
| 44 | + | |
| 45 | + PuerperaModelQuery puerperaQuery = new PuerperaModelQuery(); | |
| 46 | + puerperaQuery.setLimit(managerRequest.getLimit()); | |
| 47 | + puerperaQuery.setPage(managerRequest.getPage()); | |
| 48 | + puerperaQuery.setDueDateEnd(managerRequest.getDueDateEnd()); | |
| 49 | + puerperaQuery.setDueDateStart(managerRequest.getDueDateStart()); | |
| 50 | + puerperaQuery.setKeyword(managerRequest.getKeyword()); | |
| 51 | + puerperaQuery.setCommunityId(managerRequest.getCommunityId()); | |
| 52 | + puerperaQuery.setVisitstatus(managerRequest.getVisitstatus()); | |
| 53 | + | |
| 54 | + // 调用service查询 | |
| 55 | + | |
| 56 | + List<PuerperaModel> data = puerperaService.queryPuerpera(puerperaQuery); | |
| 57 | + | |
| 58 | + return new BaseListResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(data); | |
| 59 | + } | |
| 60 | + | |
| 61 | + @RequestMapping(value = "/puerperamanage", method = RequestMethod.DELETE) | |
| 62 | + @ResponseBody | |
| 63 | + public BaseResponse deletePuerperaManager(@RequestParam("id") | |
| 64 | + String id) { | |
| 65 | + PuerperaModel obj = new PuerperaModel(); | |
| 66 | + obj.setId(id); | |
| 67 | + obj.setYn(0); | |
| 68 | + puerperaService.updatePuerpera(obj); | |
| 69 | + return new BaseResponse("成功", 0); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @RequestMapping(value = "/puerperamanage/{id}", method = RequestMethod.PUT) | |
| 73 | + @ResponseBody | |
| 74 | + public BaseResponse updatePuerperaManager(@PathVariable("id") | |
| 75 | + String id) { | |
| 76 | + return new BaseResponse("成功", 0); | |
| 77 | + } | |
| 78 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasicConfigRequest.java
View file @
188c19c
| ... | ... | @@ -10,29 +10,40 @@ |
| 10 | 10 | public class BasicConfigRequest { |
| 11 | 11 | @FormParam |
| 12 | 12 | private String parentId; |
| 13 | - @NotEmpty(message="名称不能为空") | |
| 13 | + | |
| 14 | + @NotEmpty(message = "名称不能为空") | |
| 15 | + @FormParam | |
| 14 | 16 | private String name; |
| 15 | - @NotEmpty(message="简码不能为空") | |
| 17 | + | |
| 18 | + @NotEmpty(message = "简码不能为空") | |
| 19 | + @FormParam | |
| 16 | 20 | private String code; |
| 21 | + | |
| 17 | 22 | public String getParentId() { |
| 18 | 23 | return parentId; |
| 19 | 24 | } |
| 25 | + | |
| 20 | 26 | public void setParentId(String parentId) { |
| 21 | 27 | this.parentId = parentId; |
| 22 | 28 | } |
| 29 | + | |
| 23 | 30 | public String getName() { |
| 24 | 31 | return name; |
| 25 | 32 | } |
| 33 | + | |
| 26 | 34 | public void setName(String name) { |
| 27 | 35 | this.name = name; |
| 28 | 36 | } |
| 37 | + | |
| 29 | 38 | public String getCode() { |
| 30 | 39 | return code; |
| 31 | 40 | } |
| 41 | + | |
| 32 | 42 | public void setCode(String code) { |
| 33 | 43 | this.code = code; |
| 34 | 44 | } |
| 35 | - public BasicConfig convertToBasicConfig(){ | |
| 45 | + | |
| 46 | + public BasicConfig convertToBasicConfig() { | |
| 36 | 47 | BasicConfig basicConfig = new BasicConfig(); |
| 37 | 48 | basicConfig.setCode(code); |
| 38 | 49 | basicConfig.setName(name); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/PuerperaManagerRequest.java
View file @
188c19c
| 1 | +package com.lyms.platform.operate.web.request; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | + | |
| 5 | +import com.lyms.platform.common.core.annotation.form.Form; | |
| 6 | +import com.lyms.platform.common.core.annotation.form.FormParam; | |
| 7 | +import com.lyms.platform.common.result.BaseModel; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 产妇管理请求 | |
| 11 | + * | |
| 12 | + * @author Administrator | |
| 13 | + */ | |
| 14 | +@Form | |
| 15 | +public class PuerperaManagerRequest extends BaseModel { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * | |
| 19 | + */ | |
| 20 | + private static final long serialVersionUID = 1L; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 关键字查询 | |
| 24 | + */ | |
| 25 | + @FormParam | |
| 26 | + private String keyword; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 社区名称 | |
| 30 | + */ | |
| 31 | + @FormParam | |
| 32 | + private String communityId; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 访视状态 | |
| 36 | + */ | |
| 37 | + @FormParam | |
| 38 | + private int visitstatus = -1; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 分娩日期开始 | |
| 42 | + */ | |
| 43 | + @FormParam | |
| 44 | + private Date dueDateStart; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 分娩日期结束 | |
| 48 | + */ | |
| 49 | + @FormParam | |
| 50 | + private Date dueDateEnd; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 页数 | |
| 54 | + */ | |
| 55 | + @FormParam | |
| 56 | + private int page; | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 行数 | |
| 60 | + */ | |
| 61 | + @FormParam | |
| 62 | + private int limit; | |
| 63 | + | |
| 64 | + public String getCommunityId() { | |
| 65 | + return communityId; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setCommunityId(String communityId) { | |
| 69 | + this.communityId = communityId; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public String getKeyword() { | |
| 73 | + return keyword; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setKeyword(String keyword) { | |
| 77 | + this.keyword = keyword; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public int getVisitstatus() { | |
| 81 | + return visitstatus; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public void setVisitstatus(int visitstatus) { | |
| 85 | + this.visitstatus = visitstatus; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public Date getDueDateStart() { | |
| 89 | + return dueDateStart; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setDueDateStart(long dueDateStart) { | |
| 93 | + this.dueDateStart = new Date(dueDateStart * 1000); | |
| 94 | + } | |
| 95 | + | |
| 96 | + public Date getDueDateEnd() { | |
| 97 | + return dueDateEnd; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public void setDueDateEnd(long dueDateEnd) { | |
| 101 | + this.dueDateEnd = new Date(dueDateEnd * 1000); | |
| 102 | + } | |
| 103 | + | |
| 104 | + public int getPage() { | |
| 105 | + return page; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public void setPage(int page) { | |
| 109 | + this.page = page; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public int getLimit() { | |
| 113 | + return limit; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void setLimit(int limit) { | |
| 117 | + this.limit = limit; | |
| 118 | + } | |
| 119 | +} |