Commit 31c2de8d42a0f14a9fe69e5f9d34b990091af038

Authored by jiangjiazhi
1 parent 10d304b22d

commit

Showing 34 changed files with 1247 additions and 105 deletions

platform-biz-patient-service/pom.xml View file @ 31c2de8
... ... @@ -16,6 +16,11 @@
16 16 <artifactId>platform-common</artifactId>
17 17 <version>${project.version}</version>
18 18 </dependency>
  19 + <dependency>
  20 + <groupId>com.lyms.core</groupId>
  21 + <artifactId>platform-dal</artifactId>
  22 + <version>${project.version}</version>
  23 + </dependency>
19 24 </dependencies>
20 25 <build>
21 26 <plugins>
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java View file @ 31c2de8
  1 +package com.lyms.platform.biz;
  2 +
  3 +import org.springframework.context.ApplicationContext;
  4 +import org.springframework.context.support.ClassPathXmlApplicationContext;
  5 +
  6 +import com.lyms.platform.biz.service.BasicConfigService;
  7 +import com.lyms.platform.pojo.BasicConfig;
  8 +
  9 +
  10 +
  11 +
  12 +public class BasicConfigServiceTest {
  13 + public static void main(String[] args) {
  14 + ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient.xml");
  15 + BasicConfigService basicConfigService = (BasicConfigService) applicationContext.getBean("basicConfigService");
  16 +
  17 +
  18 + for(int i = 6;i<10;i++){
  19 + BasicConfig obj = new BasicConfig();
  20 + obj.setCode("xc"+i);
  21 + obj.setName("哮喘"+i);
  22 + obj.setYn(1);
  23 + obj.setParentId("56e8cf6e24fdcc51d22a4f27");
  24 + basicConfigService.addBasicConfig(obj);
  25 + }
  26 + }
  27 +}
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IBasicConfigDao.java View file @ 31c2de8
  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.BasicConfig;
  8 +
  9 +public interface IBasicConfigDao {
  10 +
  11 + public BasicConfig addBasicConfig(BasicConfig obj);
  12 +
  13 + public void updateBasicConfig(BasicConfig obj, String id);
  14 +
  15 + public void deleteBasicConfig(String id);
  16 +
  17 + public BasicConfig getBasicConfig(String id);
  18 +
  19 + public int queryBasicConfigCount(MongoQuery query);
  20 +
  21 + public List<BasicConfig> queryBasicConfig(MongoQuery query);
  22 +
  23 + public Page<BasicConfig> findPage(MongoQuery query);
  24 +}
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/BasicConfigDaoImpl.java View file @ 31c2de8
  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.IBasicConfigDao;
  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.BasicConfig;
  14 +
  15 +@Repository("basicConfigDao")
  16 +public class BasicConfigDaoImpl extends BaseMongoDAOImpl<BasicConfig> implements IBasicConfigDao {
  17 + public BasicConfig addBasicConfig(BasicConfig obj) {
  18 + return save(obj);
  19 + }
  20 +
  21 + public void updateBasicConfig(BasicConfig obj, String id) {
  22 + update(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery(), obj);
  23 + }
  24 +
  25 + public void deleteBasicConfig(String id) {
  26 + delete(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery());
  27 + }
  28 +
  29 + public BasicConfig getBasicConfig(String id) {
  30 + return findById(id);
  31 + }
  32 +
  33 + public int queryBasicConfigCount(MongoQuery query) {
  34 + return (int) count(query.convertToMongoQuery());
  35 + }
  36 +
  37 + public List<BasicConfig> queryBasicConfig(MongoQuery query) {
  38 + return find(query.convertToMongoQuery());
  39 + }
  40 +
  41 + public Page<BasicConfig> findPage(MongoQuery query) {
  42 + return findPage(query.convertToMongoQuery());
  43 + }
  44 +}
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BasicConfigService.java View file @ 31c2de8
  1 +package com.lyms.platform.biz.service;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.data.domain.Sort.Direction;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +import com.lyms.platform.biz.dal.IBasicConfigDao;
  10 +import com.lyms.platform.common.dao.operator.MongoCondition;
  11 +import com.lyms.platform.common.dao.operator.Page;
  12 +import com.lyms.platform.pojo.BasicConfig;
  13 +
  14 +@Service("basicConfigService")
  15 +public class BasicConfigService {
  16 + @Autowired
  17 + private IBasicConfigDao basicConfigDao;
  18 +
  19 + public void addBasicConfig(BasicConfig obj) {
  20 + basicConfigDao.addBasicConfig(obj);
  21 + }
  22 +
  23 + public void updateBasicConfig(BasicConfig obj) {
  24 + basicConfigDao.updateBasicConfig(obj, obj.getId());
  25 + }
  26 +
  27 + public List<BasicConfig> queryGuides(int start, int end) {
  28 + return basicConfigDao.queryBasicConfig(MongoCondition.newInstance().toMongoQuery().start(start).end(end)
  29 + .addOrder(Direction.ASC, "id"));
  30 + }
  31 +
  32 + public Page<BasicConfig> queryGuidesAndPage(int start, int end) {
  33 + return basicConfigDao.findPage(MongoCondition.newInstance().toMongoQuery().start(start).end(end)
  34 + .addOrder(Direction.ASC, "id"));
  35 + }
  36 +}
platform-biz-patient-service/src/main/resources/database.properties View file @ 31c2de8
  1 +mongo.db.host=localhost
  2 +mongo.db.port=27017
  3 +mongo.db.dbname=platform
platform-biz-patient-service/src/main/resources/spring/applicationContext_biz_patient.xml View file @ 31c2de8
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<beans xmlns="http://www.springframework.org/schema/beans"
3   - xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
4   - xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5   - xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task"
6   - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
7   - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
8   - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
9   - http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
10   - http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
11   - <context:component-scan base-package="com.lyms.biz.core.dao.mongo" />
12   - <context:component-scan base-package="com.lyms.biz.core.service" />
13   - <context:annotation-config />
14   - <!-- Cache -->
15   - <cache:annotation-driven cache-manager="cacheManager" />
16   - <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
17   - <property name="caches">
18   - <set>
19   - <bean
20   - class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
21   - p:name="default" />
22   - <bean
23   - class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
24   - p:name="andCache" />
25   - </set>
26   - </property>
27   - </bean>
28   - <!--自动代理dao层 -->
29   - <bean
30   - class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
31   - <property name="beanNames" value="*Dao" />
32   - <property name="interceptorNames">
33   - <list>
34   - <value>dalInterceptor</value>
35   - </list>
36   - </property>
37   - </bean>
38   - <!-- dal层方法性能统计-->
39   - <bean id="dalInterceptor"
40   - class="com.lyms.platform.common.perf.DalMethodInterceptor">
41   - <property name="threshold" value="10" />
42   - </bean>
43   -
44   - <!-- <bean id="messageResolver" class="com.lyms.platform.common.core.resolve.MessageResolver" /> -->
45   - <import resource="spring-mongodb.xml" />
46   -</beans>
platform-biz-patient-service/src/main/resources/spring/applicationContext_biz_patient1.xml View file @ 31c2de8
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<beans xmlns="http://www.springframework.org/schema/beans"
  3 + xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
  4 + xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5 + xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task"
  6 + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  7 + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  8 + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  9 + http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
  10 + http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
  11 + <context:component-scan base-package="com.lyms.platform" />
  12 + <context:annotation-config />
  13 +
  14 + <bean id="configProperties"
  15 + class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  16 + <property name="locations">
  17 + <list>
  18 + <value>classpath:database.properties</value>
  19 + </list>
  20 + </property>
  21 + </bean>
  22 + <bean id="propertyConfigurer"
  23 + class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
  24 + <property name="properties" ref="configProperties" />
  25 + </bean>
  26 + <!-- Cache -->
  27 + <cache:annotation-driven cache-manager="cacheManager" />
  28 + <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
  29 + <property name="caches">
  30 + <set>
  31 + <bean
  32 + class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
  33 + p:name="default" />
  34 + <bean
  35 + class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
  36 + p:name="andCache" />
  37 + </set>
  38 + </property>
  39 + </bean>
  40 + <!--自动代理dao层 -->
  41 + <bean
  42 + class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
  43 + <property name="beanNames" value="*Dao" />
  44 + <property name="interceptorNames">
  45 + <list>
  46 + <value>dalInterceptor</value>
  47 + </list>
  48 + </property>
  49 + </bean>
  50 + <!-- dal层方法性能统计-->
  51 + <bean id="dalInterceptor"
  52 + class="com.lyms.platform.common.perf.DalMethodInterceptor">
  53 + <property name="threshold" value="10" />
  54 + </bean>
  55 +
  56 + <!-- <bean id="messageResolver" class="com.lyms.platform.common.core.resolve.MessageResolver" /> -->
  57 + <import resource="spring-mongodb.xml" />
  58 +</beans>
platform-biz-patient-service/src/main/resources/spring/spring-mongodb.xml View file @ 31c2de8
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<beans xmlns="http://www.springframework.org/schema/beans"
3   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mongo="http://www.springframework.org/schema/data/mongo"
4   - xsi:schemaLocation="http://www.springframework.org/schema/data/mongo
5   - http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
6   - http://www.springframework.org/schema/beans
7   - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
8   -
9   - <mongo:db-factory id="mongoDbFactory" host="${mongo.db.host}"
10   - port="${mongo.db.port}" dbname="${mongo.db.dbname}" />
11   -
12   - <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
13   - <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
14   - </bean>
15   -</beans>
platform-biz-patient-service/src/main/resources/spring/spring-mongodb1.xml View file @ 31c2de8
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<beans xmlns="http://www.springframework.org/schema/beans"
  3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mongo="http://www.springframework.org/schema/data/mongo"
  4 + xsi:schemaLocation="http://www.springframework.org/schema/data/mongo
  5 + http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
  6 + http://www.springframework.org/schema/beans
  7 + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
  8 +
  9 + <mongo:db-factory id="mongoDbFactory" host="${mongo.db.host}"
  10 + port="${mongo.db.port}" dbname="${mongo.db.dbname}" />
  11 +
  12 + <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
  13 + <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
  14 + </bean>
  15 +</beans>
platform-biz-service/pom.xml View file @ 31c2de8
... ... @@ -16,6 +16,11 @@
16 16 <artifactId>platform-common</artifactId>
17 17 <version>${project.version}</version>
18 18 </dependency>
  19 + <dependency>
  20 + <groupId>com.lyms.core</groupId>
  21 + <artifactId>platform-dal</artifactId>
  22 + <version>${project.version}</version>
  23 + </dependency>
19 24 </dependencies>
20 25 <build>
21 26 <plugins>
platform-common/com/lyms/platform/common/dao/IBasicConfigDao.java View file @ 31c2de8
  1 +package com.lyms.biz.core.dao.mongo;
  2 +
  3 +import com.lyms.biz.core.model.BasicConfig;
  4 +import com.lyms.platform.common.dao.operator.Page;
  5 +import java.util.List;
  6 +
  7 +public interface IBasicConfigDao {
  8 +public BasicConfig addBasicConfig(BasicConfig obj);
  9 +public void updateBasicConfig(BasicConfig obj,String id);
  10 +public void deleteBasicConfig (String id);
  11 +public BasicConfig getBasicConfig (String id);
  12 +public int queryBasicConfigCount (com.lyms.biz.core.dao.mongo.operator.MongoQuery query);
  13 +public List<BasicConfig> queryBasicConfig (com.lyms.biz.core.dao.mongo.operator.MongoQuery query);
  14 +public Page<BasicConfig> findPage(com.lyms.biz.core.dao.mongo.operator.MongoQuery query);
  15 +}
platform-common/com/lyms/platform/common/dao/impl/BasicConfigDaoImpl.java View file @ 31c2de8
  1 +package com.lyms.biz.core.dao.mongo.impl;
  2 +
  3 +import com.lyms.biz.core.model.BasicConfig;
  4 +import org.springframework.stereotype.Repository;
  5 +import com.lyms.platform.common.dao.BaseMongoDAOImpl;
  6 +import com.lyms.platform.common.dao.IBasicConfigDao;
  7 +import java.util.List;
  8 +import com.lyms.platform.common.dao.operator.MongoQuery;
  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.Page;
  12 +
  13 +
  14 +
  15 +@Repository("basicConfigDao")
  16 +public class BasicConfigDaoImpl extends BaseMongoDAOImpl<BasicConfig> implements IBasicConfigDao {
  17 + public BasicConfig addBasicConfig(BasicConfig obj){
  18 + return save(obj);
  19 + }
  20 + public void updateBasicConfig(BasicConfig obj,String id){
  21 + update(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery(), obj);
  22 + }
  23 + public void deleteBasicConfig(String id){
  24 + delete(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery());
  25 + }
  26 + public BasicConfig getBasicConfig (String id){
  27 + return findById(id);
  28 + }
  29 + public int queryBasicConfigCount(MongoQuery query){
  30 + return (int)count(query.convertToMongoQuery());
  31 + }
  32 + public List<BasicConfig> queryBasicConfig(MongoQuery query){
  33 + return find(query.convertToMongoQuery());
  34 + }
  35 + public Page<BasicConfig> findPage(MongoQuery query){
  36 + return findPage(query.convertToMongoQuery());
  37 +}
  38 +}
platform-common/src/main/java/com/lyms/platform/common/GAllMysql.java View file @ 31c2de8
  1 +package com.lyms.platform.common;
  2 +
  3 +import java.io.File;
  4 +import java.io.FilenameFilter;
  5 +import java.io.IOException;
  6 +
  7 +import org.apache.commons.io.FileUtils;
  8 +
  9 +/**
  10 + * Created by riecard on 15/3/26.
  11 + */
  12 +public class GAllMysql {
  13 + private static final String packageStr = "com.lyms.biz.core";
  14 + private static final String baseDir = "C:/pd/";
  15 + private static final String BASE_MONGO_DAO= "com.lyms.platform.common.dao";
  16 + private static final String BASE_MONGO_DAO1= "com/lyms/platform/common/dao";
  17 + public static void main(String[] args) {
  18 + GAllMysql g = new GAllMysql();
  19 + File file = new File(baseDir);
  20 + File[] files = file.listFiles(new FilenameFilter() {
  21 +
  22 + @Override
  23 + public boolean accept(File dir, String name) {
  24 + return name.endsWith(".java");
  25 + }
  26 + });
  27 + for(File f :files){
  28 + g.generate(f);
  29 + }
  30 + }
  31 +
  32 + public void generate(File file) {
  33 + String className = file.getName().replace(".java", "");
  34 + StringBuffer mapper = new StringBuffer();
  35 + StringBuffer daoImpl = new StringBuffer();
  36 +
  37 + daoImpl.append("package " + packageStr + ".dao.mongo.impl;\n" + "\n" + "import "
  38 + + packageStr + ".model." + className + ";"+ "\nimport org.springframework.stereotype.Repository;\nimport "+BASE_MONGO_DAO+".BaseMongoDAOImpl;\n"+"import "+BASE_MONGO_DAO+".I"+className+ "Dao;\n"
  39 + + "import java.util.List;\nimport " +BASE_MONGO_DAO+".operator.MongoQuery;\nimport "+BASE_MONGO_DAO+".operator.MongoCondition;\nimport " +BASE_MONGO_DAO+".operator.MongoOper;\nimport "+BASE_MONGO_DAO+".operator.Page;\n"+ "\n\n\n" + "@Repository(\""+className.substring(0,1).toLowerCase()+className.substring(1)+"Dao\")\npublic class "
  40 + + className + "DaoImpl extends BaseMongoDAOImpl<"+className+">"+" implements I"
  41 + + className + "Dao {\n");
  42 +
  43 +
  44 +
  45 + daoImpl.append(" public "+className+" add" + className + "(" + className
  46 + + " obj){\n").append(" return save(obj);\n").append(" }\n");
  47 +
  48 + daoImpl.append(" public void update" + className + "(" + className
  49 + + " obj,String id){\n").append(" update(new MongoQuery(new MongoCondition(\"id\", id, MongoOper.IS)).convertToMongoQuery(), obj);").append("\n }\n");
  50 +
  51 +
  52 + daoImpl.append(" public void delete" + className + "(String id){\n delete(new MongoQuery(new MongoCondition(\"id\", id, MongoOper.IS)).convertToMongoQuery());\n }\n");
  53 + daoImpl.append(" public " + className + " get" + className
  54 + + " (String id){\n").append(" return findById(id);\n }\n");
  55 + daoImpl.append(" public int query" + className + "Count("+ "MongoQuery query){\n")
  56 + .append(" return (int)count(query.convertToMongoQuery());\n }\n");
  57 +
  58 +
  59 + daoImpl.append(" public List<" + className + "> query" + className + "("
  60 + + "MongoQuery query){\n").append(" return find(query.convertToMongoQuery()); \n }\n");
  61 + daoImpl.append(" public Page<"+className+"> findPage(MongoQuery query){\n").append(" return findPage(query.convertToMongoQuery());\n}\n");
  62 + daoImpl.append("}\n");
  63 + System.out.println(daoImpl);
  64 + // dao interface
  65 + mapper.append("package " + packageStr + ".dao.mongo;\n" + "\n" + "import "
  66 + + packageStr + ".model." + className + ";\n" + "import "+BASE_MONGO_DAO+".operator.Page;\n"
  67 + + "import java.util.List;\n" + "\n" + "public interface I"
  68 + + className + "Dao {\n");
  69 + mapper.append("public "+className+" add" + className + "(" + className
  70 + + " obj);\n");
  71 + mapper.append("public void update" + className + "(" + className
  72 + + " obj,String id);\n");
  73 + mapper.append("public void delete" + className + " (String id);\n");
  74 + mapper.append("public " + className + " get" + className
  75 + + " (String id);\n");
  76 + mapper.append("public int query" + className + "Count ("+ "com.lyms.biz.core.dao.mongo.operator.MongoQuery query);\n");
  77 + mapper.append("public List<" + className + "> query" + className + " ("
  78 + + "com.lyms.biz.core.dao.mongo.operator.MongoQuery query);\n");
  79 + mapper.append("public Page<"+className+"> findPage(com.lyms.biz.core.dao.mongo.operator.MongoQuery query);\n");
  80 + mapper.append("}");
  81 +
  82 + try {
  83 + System.out.println(mapper);
  84 + FileUtils.writeStringToFile(new File(BASE_MONGO_DAO1 + "/I" + className
  85 + + "Dao.java"), mapper.toString());
  86 +
  87 + FileUtils.writeStringToFile(new File(BASE_MONGO_DAO1 + "/impl/" + className
  88 + + "DaoImpl.java"), daoImpl.toString());
  89 + } catch (IOException e) {
  90 + e.printStackTrace();
  91 + }
  92 + }
  93 +}
platform-common/src/main/java/com/lyms/platform/common/dao/BaseMongoDAO.java View file @ 31c2de8
  1 +package com.lyms.platform.common.dao;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.springframework.data.mongodb.core.query.Query;
  6 +
  7 +import com.lyms.platform.common.dao.operator.Page;
  8 +
  9 +public interface BaseMongoDAO<T> {
  10 +
  11 + /**
  12 + * 通过条件查询实体(集合)
  13 + *
  14 + * @param query
  15 + */
  16 + public List<T> find(Query query);
  17 +
  18 + /**
  19 + * 通过一定的条件查询一个实体
  20 + *
  21 + * @param query
  22 + * @return
  23 + */
  24 + public T findOne(Query query);
  25 +
  26 + /**
  27 + * 通过条件查询更新数据
  28 + *
  29 + * @param query
  30 + * @param update
  31 + * @return
  32 + */
  33 + public void update(Query query, T update);
  34 +
  35 + /**
  36 + * 保存一个对象到mongodb
  37 + *
  38 + * @param entity
  39 + * @return
  40 + */
  41 + public T save(T entity);
  42 +
  43 + /**
  44 + * 保存一个对象到mongodb的指定集合
  45 + *
  46 + * @param entity
  47 + * @return
  48 + */
  49 + public T save(T entity, String collection);
  50 +
  51 + /**
  52 + * 通过ID获取记录
  53 + *
  54 + * @param id
  55 + * @return
  56 + */
  57 + public T findById(String id);
  58 +
  59 + /**
  60 + * 通过ID获取记录,并且指定了集合名(表的意思)
  61 + *
  62 + * @param id
  63 + * @param collectionName
  64 + * 集合名
  65 + * @return
  66 + */
  67 + public T findById(String id, String collectionName);
  68 +
  69 + /**
  70 + * 分页查询
  71 + *
  72 + * @param page
  73 + * @param query
  74 + * @return
  75 + */
  76 + public Page<T> findPage(Query query);
  77 +
  78 + /**
  79 + * 求数据总和
  80 + *
  81 + * @param query
  82 + * @return
  83 + */
  84 + public long count(Query query);
  85 +
  86 + /**
  87 + * 查询某个指定集合的数量
  88 + *
  89 + * @param query
  90 + * @param collection
  91 + * @return
  92 + */
  93 + public long count(Query query, String collection);
  94 +
  95 +}
platform-common/src/main/java/com/lyms/platform/common/dao/BaseMongoDAOImpl.java View file @ 31c2de8
  1 +package com.lyms.platform.common.dao;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.data.mongodb.core.MongoTemplate;
  7 +import org.springframework.data.mongodb.core.query.Query;
  8 +import org.springframework.data.mongodb.core.query.Update;
  9 +import org.springframework.util.Assert;
  10 +
  11 +import com.lyms.platform.common.dao.operator.Page;
  12 +import com.lyms.platform.common.utils.MongoConvertHelper;
  13 +import com.lyms.platform.common.utils.ReflectionUtils;
  14 +
  15 +public class BaseMongoDAOImpl<T> implements BaseMongoDAO<T> {
  16 +
  17 + /**
  18 + * spring mongodb 集成操作类 
  19 + */
  20 + @Autowired
  21 + private MongoTemplate mongoTemplate;
  22 +
  23 + @Override
  24 + public List<T> find(Query query) {
  25 + Assert.notNull(query, "execute find method query must not null.");
  26 + return mongoTemplate.find(query, this.getEntityClass());
  27 + }
  28 +
  29 + @Override
  30 + public T findOne(Query query) {
  31 + Assert.notNull(query, "execute findOne method query must not null.");
  32 + return mongoTemplate.findOne(query, this.getEntityClass());
  33 + }
  34 +
  35 + /**
  36 + * 修改根据所有查询条件查出来的数据
  37 + */
  38 + public void update(Query query, T obj) {
  39 + Update update = MongoConvertHelper
  40 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(obj));
  41 + Assert.notNull(update, "execute update method must not null.");
  42 + mongoTemplate.updateMulti(query, update, this.getEntityClass());
  43 + }
  44 +
  45 + @Override
  46 + public T save(T entity) {
  47 + Assert.notNull(entity, "execute insert method must not null.");
  48 + mongoTemplate.insert(entity);
  49 + return entity;
  50 + }
  51 +
  52 + @Override
  53 + public T save(T entity, String collection) {
  54 + Assert.notNull(entity, "execute insert method must not null.");
  55 + mongoTemplate.insert(entity, collection);
  56 + return entity;
  57 + }
  58 +
  59 + @Override
  60 + public T findById(String id) {
  61 + return mongoTemplate.findById(id, this.getEntityClass());
  62 + }
  63 +
  64 + @Override
  65 + public T findById(String id, String collectionName) {
  66 + return mongoTemplate
  67 + .findById(id, this.getEntityClass(), collectionName);
  68 + }
  69 +
  70 + public Page<T> findPage(Query query) {
  71 + Page<T> page = new Page<T>();
  72 + page.setPage(query.getSkip());
  73 + page.setLimit(query.getLimit());
  74 +
  75 + long count = this.count(query);
  76 + page.reBuild((int) count);
  77 + List<T> rows = this.find(query);
  78 + page.setDataList(rows);
  79 + return page;
  80 + }
  81 +
  82 + @Override
  83 + public long count(Query query) {
  84 + return mongoTemplate.count(query, this.getEntityClass());
  85 + }
  86 +
  87 + public long count(Query query, String collection) {
  88 + return mongoTemplate.count(query, collection);
  89 + }
  90 +
  91 + public void delete(Query query) {
  92 + mongoTemplate.findAllAndRemove(query, this.getEntityClass());
  93 + }
  94 +
  95 + /**
  96 + * 获取需要操作的实体类class
  97 + *
  98 + * @return
  99 + */
  100 + private Class<T> getEntityClass() {
  101 + return ReflectionUtils.getSuperClassGenricType(getClass());
  102 + }
  103 +}
platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoCondition.java View file @ 31c2de8
  1 +package com.lyms.platform.common.dao.operator;
  2 +
  3 +import org.springframework.data.mongodb.core.query.Criteria;
  4 +
  5 +/**
  6 + * 封装mongo 条件属性的操作
  7 + *
  8 + * 对于模糊查询的时候 obj为一个正则表达式 如:
  9 + *
  10 + * <code>
  11 + * <ui>
  12 + * <li>1.MongoCondition.newInstance("name", "^小七测试",MongoOper.LIKE) '^小七测试' 查询名字为小七测试开头</li>
  13 + * <li>2.MongoCondition.newInstance("name", "小七测试$",MongoOper.LIKE) '小七测试$' 查询名字为小七测试结尾</li>
  14 + * </ui>
  15 + * </code>
  16 + *
  17 + *
  18 + *
  19 + * @link MongoOper
  20 + *
  21 + * @author Administrator
  22 + *
  23 + */
  24 +public class MongoCondition {
  25 +
  26 + private Criteria criteria;
  27 +
  28 + public Criteria getCriteria() {
  29 + return criteria;
  30 + }
  31 +
  32 + public static MongoCondition newInstance() {
  33 + return new MongoCondition();
  34 + }
  35 +
  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 + }
  52 +
  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 + }
  60 +
  61 + public MongoCondition() {
  62 + }
  63 +
  64 + /**
  65 + * and 条件查询
  66 + *
  67 + * @param key
  68 + * 数据库中的字段名
  69 + * @param obj
  70 + * 值
  71 + * @param oper
  72 + * 运算符 @link MongoOper
  73 + * @return
  74 + */
  75 + public MongoCondition and(String key, Object obj, MongoOper oper) {
  76 + Criteria criteria1 = criteria.and(key);
  77 + set(oper, obj, criteria1);
  78 + criteria = criteria1;
  79 + return this;
  80 + }
  81 +
  82 + /**
  83 + * 2个查询条件的交集
  84 + *
  85 + * @param con
  86 + * @return
  87 + */
  88 + public MongoCondition andCondition(MongoCondition con) {
  89 + Criteria localCriteria = con.criteria;
  90 + criteria = criteria.andOperator(localCriteria);
  91 + return this;
  92 + }
  93 +
  94 + /**
  95 + * 2个查询条件的并集
  96 + *
  97 + * @param con
  98 + * @return
  99 + */
  100 + public MongoCondition orCondition(MongoCondition con) {
  101 + criteria = criteria.orOperator(con.criteria);
  102 + return this;
  103 + }
  104 +
  105 + /**
  106 + * 如果是模糊匹配,obj则为需要匹配的正则表达式
  107 + *
  108 + * @param oper
  109 + * @param obj
  110 + * @param criteria
  111 + */
  112 + private void set(MongoOper oper, Object obj, Criteria criteria) {
  113 + if (MongoOper.GT == oper) {
  114 + criteria.gt(obj);
  115 + } else if (MongoOper.GTE == oper) {
  116 + criteria.gte(obj);
  117 + } else if (MongoOper.IS == oper) {
  118 + criteria.is(obj);
  119 + } else if (MongoOper.LIKE == oper) {
  120 + criteria.regex(String.valueOf(obj), "m");
  121 + } else if (MongoOper.LT == oper) {
  122 + criteria.lt(obj);
  123 + } else if (MongoOper.NE == oper) {
  124 + criteria.ne(obj);
  125 + }
  126 + }
  127 +
  128 + /**
  129 + * 把当前条件转成查询对象
  130 + *
  131 + * @return
  132 + */
  133 + public MongoQuery toMongoQuery() {
  134 + return new MongoQuery(this);
  135 + }
  136 +}
platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoOper.java View file @ 31c2de8
  1 +package com.lyms.platform.common.dao.operator;
  2 +/**
  3 + * 查询的操作符
  4 + *
  5 + * @author Administrator
  6 + *
  7 + */
  8 +public enum MongoOper {
  9 + // 等于
  10 + IS,
  11 + // 小于
  12 + LT,
  13 + // 小于等于
  14 + LTE,
  15 + // 大于
  16 + GT,
  17 + // 大于等于
  18 + GTE,
  19 + //不等于
  20 + NE,
  21 + //模糊
  22 + LIKE;
  23 +}
platform-common/src/main/java/com/lyms/platform/common/dao/operator/MongoQuery.java View file @ 31c2de8
  1 +package com.lyms.platform.common.dao.operator;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +import org.apache.commons.collections.CollectionUtils;
  7 +import org.springframework.data.domain.Sort;
  8 +import org.springframework.data.domain.Sort.Direction;
  9 +import org.springframework.data.mongodb.core.query.Query;
  10 +
  11 +/**
  12 + * 封装对mongodb的查询请求
  13 + *
  14 + * @author Administrator
  15 + *
  16 + */
  17 +public class MongoQuery {
  18 + // 排序的列表
  19 + private List<Sort.Order> sortList = new ArrayList<Sort.Order>();
  20 + // 查询条件
  21 + private MongoCondition coniticon;
  22 +
  23 + // 分页的开始数
  24 + private int start;
  25 + // 结束
  26 + private int end;
  27 +
  28 + /**
  29 + * 转换成spring data 的query 对象
  30 + *
  31 + * @return
  32 + */
  33 + public Query convertToMongoQuery() {
  34 + Query query = new Query();
  35 + if (null != coniticon &&coniticon.getCriteria() !=null) {
  36 + query.addCriteria(coniticon.getCriteria());
  37 + }
  38 + if (CollectionUtils.isNotEmpty(sortList)) {
  39 + query.with(new Sort(sortList));
  40 + }
  41 + if (end > 0) {
  42 + query.skip(start).limit(end);
  43 + }
  44 + return query;
  45 + }
  46 +
  47 + /**
  48 + * 增加排序的方式
  49 + *
  50 + * @param direction
  51 + * {@link Direction}
  52 + * 排序 DESC OR ASC
  53 + * @param field
  54 + * 按照那个字段进行排序
  55 + * @return 当前的实例
  56 + */
  57 + public MongoQuery addOrder(Direction direction, String field) {
  58 + sortList.add(new Sort.Order(direction, field));
  59 + return this;
  60 + }
  61 +
  62 + public MongoQuery(MongoCondition queryCondition) {
  63 + this.coniticon = queryCondition;
  64 + }
  65 +
  66 + public int getStart() {
  67 + return start;
  68 + }
  69 +
  70 + /**
  71 + * 分页条数的起始数
  72 + *
  73 + * @param start
  74 + * @return
  75 + */
  76 + public MongoQuery start(int start) {
  77 + this.start = start;
  78 + return this;
  79 + }
  80 +
  81 + public int getEnd() {
  82 + return end;
  83 + }
  84 + /**
  85 + * 取多少条
  86 + *
  87 + * @param end
  88 + * @return
  89 + */
  90 + public MongoQuery end(int end) {
  91 + this.end = end;
  92 + return this;
  93 + }
  94 +}
platform-common/src/main/java/com/lyms/platform/common/dao/operator/Page.java View file @ 31c2de8
  1 +package com.lyms.platform.common.dao.operator;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.codehaus.jackson.annotate.JsonIgnore;
  6 +
  7 +import com.lyms.platform.common.result.BaseModel;
  8 +
  9 +public class Page<T> extends BaseModel {
  10 + /**
  11 + *
  12 + */
  13 + private static final long serialVersionUID = 1L;
  14 + private Integer page;
  15 + private Integer lastPage;
  16 + private Integer count;
  17 + private Integer limit;
  18 +
  19 + @SuppressWarnings("unused")
  20 + @JsonIgnore
  21 + private int offset;
  22 + @JsonIgnore
  23 + private List<T> dataList;
  24 +
  25 + public List<T> getDataList() {
  26 + return dataList;
  27 + }
  28 +
  29 + public void setDataList(List<T> dataList) {
  30 + this.dataList = dataList;
  31 + }
  32 + public Page(){
  33 +
  34 + }
  35 + public Page(Integer page, Integer lastPage, Integer count, Integer limit) {
  36 + this.page = page;
  37 + this.lastPage = lastPage;
  38 + this.count = count;
  39 + this.limit = limit;
  40 + }
  41 +
  42 + public Integer getPage() {
  43 + return page;
  44 + }
  45 +
  46 + public void setPage(Integer page) {
  47 + this.page = page;
  48 + }
  49 +
  50 + public Integer getLastPage() {
  51 + return lastPage;
  52 + }
  53 +
  54 + public void setLastPage(Integer lastPage) {
  55 + this.lastPage = lastPage;
  56 + }
  57 +
  58 + public Integer getCount() {
  59 + return count;
  60 + }
  61 +
  62 + public void setCount(Integer count) {
  63 + this.count = count;
  64 + }
  65 +
  66 + public Integer getLimit() {
  67 + return limit;
  68 + }
  69 +
  70 + public void setLimit(Integer limit) {
  71 + this.limit = limit;
  72 + }
  73 +
  74 + public void reBuild(int count) {
  75 + this.count = count;
  76 + lastPage = count / limit;
  77 + if (count % limit > 0) {
  78 + lastPage += 1;
  79 + }
  80 + if (page < 1) {
  81 + page = 1;
  82 + }
  83 + offset = page * limit - limit;
  84 + }
  85 +}
platform-common/src/main/java/com/lyms/platform/common/result/BaseListResponse.java View file @ 31c2de8
  1 +package com.lyms.platform.common.result;
  2 +
  3 +import java.util.List;
  4 +
  5 +@SuppressWarnings("rawtypes")
  6 +public class BaseListResponse extends BaseResponse {
  7 + /**
  8 + *
  9 + */
  10 + private static final long serialVersionUID = 1L;
  11 +
  12 + protected List data;
  13 +
  14 + public List getData() {
  15 + return data;
  16 + }
  17 +
  18 + public void setData(List data) {
  19 + this.data = data;
  20 + }
  21 +}
platform-common/src/main/java/com/lyms/platform/common/utils/MongoConvertHelper.java View file @ 31c2de8
  1 +package com.lyms.platform.common.utils;
  2 +
  3 +import java.util.Iterator;
  4 +import java.util.Map;
  5 +
  6 +import org.apache.commons.collections.MapUtils;
  7 +import org.springframework.data.mongodb.core.query.Update;
  8 +
  9 +/**
  10 + * mongo的转换工具类
  11 + *
  12 + * @author Administrator
  13 + *
  14 + */
  15 +public class MongoConvertHelper {
  16 +
  17 + /**
  18 + * 将修改参数的值转换成mongo的执行对象
  19 + *
  20 + * @param updateMap
  21 + * @return
  22 + */
  23 + public static Update convertToNativeUpdate(Map<String,Object> updateMap){
  24 + if(MapUtils.isEmpty(updateMap)){
  25 + return null;
  26 + }
  27 + Update update = null;
  28 + Iterator<Map.Entry<String, Object>> it = updateMap.entrySet().iterator();
  29 + if(it.hasNext()){
  30 + Map.Entry<String, Object> currentEntry = it.next();
  31 + //首先构建update对象
  32 + update = Update.update(currentEntry.getKey(), currentEntry.getValue());
  33 + //然后在循环去设置
  34 + while(it.hasNext()){
  35 + currentEntry = it.next();
  36 + update.set(currentEntry.getKey(), currentEntry.getValue());
  37 + }
  38 + }
  39 + return update;
  40 + }
  41 +}
platform-dal/src/main/java/com/lyms/platform/pojo/BasicConfig.java View file @ 31c2de8
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import org.springframework.data.annotation.Id;
  4 +import org.springframework.data.mongodb.core.mapping.Document;
  5 +
  6 +import com.lyms.platform.common.result.BaseModel;
  7 +
  8 +@Document
  9 +public class BasicConfig extends BaseModel {
  10 +
  11 + /**
  12 + *
  13 + */
  14 + private static final long serialVersionUID = 1L;
  15 + @Id
  16 + private String id;
  17 +
  18 + private String parentId;
  19 +
  20 + private String code;
  21 +
  22 + private String name;
  23 +
  24 +
  25 + public String getName() {
  26 + return name;
  27 + }
  28 +
  29 + public void setName(String name) {
  30 + this.name = name;
  31 + }
  32 +
  33 + private int yn;
  34 +
  35 + public String getId() {
  36 + return id;
  37 + }
  38 +
  39 + public void setId(String id) {
  40 + this.id = id;
  41 + }
  42 +
  43 + public String getParentId() {
  44 + return parentId;
  45 + }
  46 +
  47 + public void setParentId(String parentId) {
  48 + this.parentId = parentId;
  49 + }
  50 +
  51 + public String getCode() {
  52 + return code;
  53 + }
  54 +
  55 + public void setCode(String code) {
  56 + this.code = code;
  57 + }
  58 +
  59 + public int getYn() {
  60 + return yn;
  61 + }
  62 +
  63 + public void setYn(int yn) {
  64 + this.yn = yn;
  65 + }
  66 +}
platform-operate-api/pom.xml View file @ 31c2de8
... ... @@ -17,16 +17,23 @@
17 17 <artifactId>platform-common</artifactId>
18 18 <version>${project.version}</version>
19 19 </dependency>
20   - <!-- <dependency>
  20 + <dependency>
21 21 <groupId>com.lyms.core</groupId>
22   - <artifactId>permission-service</artifactId>
  22 + <artifactId>platform-dal</artifactId>
23 23 <version>${project.version}</version>
24 24 </dependency>
25 25 <dependency>
26 26 <groupId>com.lyms.core</groupId>
27   - <artifactId>permission-dal</artifactId>
  27 + <artifactId>platform-biz-service</artifactId>
28 28 <version>${project.version}</version>
29   - </dependency>-->
  29 + </dependency>
  30 + <dependency>
  31 + <groupId>com.lyms.core</groupId>
  32 + <artifactId>platform-biz-patient-service</artifactId>
  33 + <version>${project.version}</version>
  34 + </dependency>
  35 +
  36 + <!---->
30 37 </dependencies>
31 38 <build>
32 39 <plugins>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BasicConfigController.java View file @ 31c2de8
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Controller;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestMethod;
  10 +import org.springframework.web.bind.annotation.ResponseBody;
  11 +
  12 +import com.lyms.platform.biz.service.BasicConfigService;
  13 +import com.lyms.platform.common.result.BaseListResponse;
  14 +import com.lyms.platform.common.result.BaseResponse;
  15 +import com.lyms.platform.operate.web.request.BasicConfigRequest;
  16 +import com.lyms.platform.pojo.BasicConfig;
  17 +
  18 +@Controller
  19 +public class BasicConfigController {
  20 + @Autowired
  21 + private BasicConfigService basicConfigService;
  22 +
  23 + @RequestMapping(method = RequestMethod.GET, value = "/basicConfig")
  24 + @ResponseBody
  25 + public BaseListResponse queryBasicConfig() {
  26 + List<BasicConfig> data = basicConfigService.queryGuides(0, 100);
  27 + BaseListResponse baseListResponse = new BaseListResponse();
  28 + baseListResponse.setData(data);
  29 + baseListResponse.setErrorcode("0");
  30 + baseListResponse.setErrormsg("成功");
  31 + return baseListResponse;
  32 + }
  33 + @RequestMapping(method = RequestMethod.POST, value = "/basicConfig")
  34 + @ResponseBody
  35 + public BaseResponse addBasicConfig(BasicConfigRequest basicConfigRequests){
  36 +// basicConfigService.addBasicConfig(basicConfigRequests);
  37 +
  38 + BaseResponse baseResponse = new BaseResponse();
  39 + baseResponse.setErrorcode("0");
  40 + baseResponse.setErrormsg("成功");
  41 + return baseResponse;
  42 + }
  43 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasicConfigRequest.java View file @ 31c2de8
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import org.hibernate.validator.constraints.NotEmpty;
  4 +
  5 +import com.lyms.platform.common.core.annotation.form.Form;
  6 +import com.lyms.platform.common.core.annotation.form.FormParam;
  7 +
  8 +@Form
  9 +public class BasicConfigRequest {
  10 + @FormParam
  11 + private String parentId;
  12 + @NotEmpty(message="名称不能为空")
  13 + private String name;
  14 + @NotEmpty(message="简码不能为空")
  15 + private String code;
  16 + public String getParentId() {
  17 + return parentId;
  18 + }
  19 + public void setParentId(String parentId) {
  20 + this.parentId = parentId;
  21 + }
  22 + public String getName() {
  23 + return name;
  24 + }
  25 + public void setName(String name) {
  26 + this.name = name;
  27 + }
  28 + public String getCode() {
  29 + return code;
  30 + }
  31 + public void setCode(String code) {
  32 + this.code = code;
  33 + }
  34 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BasicConfigResult.java View file @ 31c2de8
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +public class BasicConfigResult {
  4 + private String id;
  5 + private String code;
  6 + private int yn;
  7 + private String parentId;
  8 + public String getId() {
  9 + return id;
  10 + }
  11 + public void setId(String id) {
  12 + this.id = id;
  13 + }
  14 + public String getCode() {
  15 + return code;
  16 + }
  17 + public void setCode(String code) {
  18 + this.code = code;
  19 + }
  20 + public int getYn() {
  21 + return yn;
  22 + }
  23 + public void setYn(int yn) {
  24 + this.yn = yn;
  25 + }
  26 + public String getParentId() {
  27 + return parentId;
  28 + }
  29 + public void setParentId(String parentId) {
  30 + this.parentId = parentId;
  31 + }
  32 +}
platform-operate-api/src/main/resources/database.properties View file @ 31c2de8
  1 +mongo.db.host=localhost
  2 +mongo.db.port=27017
  3 +mongo.db.dbname=platform
platform-operate-api/src/main/resources/spring/applicationContext-mvc.xml View file @ 31c2de8
... ... @@ -8,7 +8,7 @@
8 8 default-lazy-init="true">
9 9  
10 10  
11   - <context:component-scan base-package="com.lyms.biz.core.web.controller"
  11 + <context:component-scan base-package="com.lyms.platform.operate.web.controller"
12 12 use-default-filters="false">
13 13 <context:include-filter type="annotation"
14 14 expression="org.springframework.stereotype.Controller" />
15 15  
... ... @@ -16,11 +16,11 @@
16 16  
17 17 <mvc:annotation-driven validator="localValidator">
18 18 <mvc:argument-resolvers >
19   - <bean id="annotationFormArgumentResolver" class="com.lyms.biz.core.platform.resolve.AnnotationFormArgumentResolver"/>
  19 + <bean id="annotationFormArgumentResolver" class="com.lyms.platform.common.core.resolve.AnnotationFormArgumentResolver"/>
20 20 </mvc:argument-resolvers>
21 21 <mvc:message-converters>
22 22 <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
23   - <bean class="com.lyms.biz.core.platform.converter.StringMessageConverter"/>
  23 + <bean class="com.lyms.platform.common.core.converter.StringMessageConverter"/>
24 24 <bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter"/>
25 25 <bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/>
26 26 <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
platform-operate-api/src/main/resources/spring/applicationContext.xml View file @ 31c2de8
... ... @@ -13,6 +13,11 @@
13 13 <context:annotation-config />
14 14  
15 15 <!-- 配置要扫描的包 -->
16   - <context:component-scan base-package="com.lyms.core.data.sync" />
  16 + <context:component-scan base-package="com.lyms.platform.biz.service" />
  17 + <!-- 配置要扫描的包 -->
  18 + <context:component-scan base-package="com.lyms.platform.biz.dal.impl" />
  19 +
  20 + <import resource="classpath:/spring/applicationContext_biz_patient.xml"/>
  21 + <import resource="classpath:/spring/spring-mongodb.xml"/>
17 22 </beans>
platform-operate-api/src/main/resources/spring/applicationContext_biz_patient.xml View file @ 31c2de8
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<beans xmlns="http://www.springframework.org/schema/beans"
  3 + xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
  4 + xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5 + xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task"
  6 + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  7 + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  8 + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  9 + http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
  10 + http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
  11 + <context:component-scan base-package="com.lyms.platform" />
  12 + <context:annotation-config />
  13 +
  14 + <bean id="configProperties"
  15 + class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  16 + <property name="locations">
  17 + <list>
  18 + <value>classpath:database.properties</value>
  19 + </list>
  20 + </property>
  21 + </bean>
  22 + <bean id="propertyConfigurer"
  23 + class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
  24 + <property name="properties" ref="configProperties" />
  25 + </bean>
  26 + <!-- Cache -->
  27 + <cache:annotation-driven cache-manager="cacheManager" />
  28 + <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
  29 + <property name="caches">
  30 + <set>
  31 + <bean
  32 + class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
  33 + p:name="default" />
  34 + <bean
  35 + class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
  36 + p:name="andCache" />
  37 + </set>
  38 + </property>
  39 + </bean>
  40 + <!--自动代理dao层 -->
  41 + <bean
  42 + class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
  43 + <property name="beanNames" value="*Dao" />
  44 + <property name="interceptorNames">
  45 + <list>
  46 + <value>dalInterceptor</value>
  47 + </list>
  48 + </property>
  49 + </bean>
  50 + <!-- dal层方法性能统计-->
  51 + <bean id="dalInterceptor"
  52 + class="com.lyms.platform.common.perf.DalMethodInterceptor">
  53 + <property name="threshold" value="10" />
  54 + </bean>
  55 +
  56 + <!-- <bean id="messageResolver" class="com.lyms.platform.common.core.resolve.MessageResolver" /> -->
  57 + <import resource="spring-mongodb.xml" />
  58 +</beans>
platform-operate-api/src/main/resources/spring/spring-mongodb.xml View file @ 31c2de8
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<beans xmlns="http://www.springframework.org/schema/beans"
  3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mongo="http://www.springframework.org/schema/data/mongo"
  4 + xsi:schemaLocation="http://www.springframework.org/schema/data/mongo
  5 + http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
  6 + http://www.springframework.org/schema/beans
  7 + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
  8 +
  9 + <mongo:db-factory id="mongoDbFactory" host="${mongo.db.host}"
  10 + port="${mongo.db.port}" dbname="${mongo.db.dbname}" />
  11 +
  12 + <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
  13 + <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
  14 + </bean>
  15 +</beans>
platform-operate-api/src/main/webapp/WEB-INF/cxf-servlet.xml View file @ 31c2de8
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
3   - license agreements. See the NOTICE file distributed with this work for additional
4   - information regarding copyright ownership. The ASF licenses this file to
5   - you under the Apache License, Version 2.0 (the "License"); you may not use
6   - this file except in compliance with the License. You may obtain a copy of
7   - the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
8   - by applicable law or agreed to in writing, software distributed under the
9   - License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
10   - OF ANY KIND, either express or implied. See the License for the specific
11   - language governing permissions and limitations under the License. -->
12   -<!-- START SNIPPET: beans -->
13   -<beans xmlns="http://www.springframework.org/schema/beans"
14   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
15   - xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
16   - <import resource="classpath:META-INF/cxf/cxf.xml" />
17   - <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
18   -
19   - <jaxws:endpoint id="emergenceWs"
20   - implementor="com.lyms.core.data.sync.web.ws.EmergenceController"
21   - address="/emergenceWs" />
22   -</beans>
23   -<!-- END SNIPPET: beans -->
platform-operate-api/src/main/webapp/WEB-INF/web.xml View file @ 31c2de8
... ... @@ -18,24 +18,13 @@
18 18 under the License.
19 19 -->
20 20 <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
21   - <display-name>cxf</display-name>
22 21 <context-param>
23 22 <param-name>contextConfigLocation</param-name>
24 23 <param-value>
25   - classpath*:/applicationContext.xml
  24 + classpath*:/spring/applicationContext.xml
26 25 </param-value>
27 26 </context-param>
28   - <servlet>
29   - <description>Apache CXF Endpoint</description>
30   - <display-name>cxf</display-name>
31   - <servlet-name>cxf</servlet-name>
32   - <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
33   - <load-on-startup>1</load-on-startup>
34   - </servlet>
35   - <servlet-mapping>
36   - <servlet-name>cxf</servlet-name>
37   - <url-pattern>/services/*</url-pattern>
38   - </servlet-mapping>
  27 +
39 28 <session-config>
40 29 <session-timeout>60</session-timeout>
41 30 </session-config>
... ... @@ -47,6 +36,19 @@
47 36 <param-name>log4jRefreshInterval</param-name>
48 37 <param-value>60000</param-value>
49 38 </context-param>
  39 + <servlet>
  40 + <servlet-name>dispatcher</servlet-name>
  41 + <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  42 + <init-param>
  43 + <param-name>contextConfigLocation</param-name>
  44 + <param-value>classpath*:/spring/applicationContext-mvc.xml</param-value>
  45 + </init-param>
  46 + <load-on-startup>1</load-on-startup>
  47 + </servlet>
  48 + <servlet-mapping>
  49 + <servlet-name>dispatcher</servlet-name>
  50 + <url-pattern>/</url-pattern>
  51 + </servlet-mapping>
50 52 <listener>
51 53 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
52 54 </listener>