Commit 673134ddd47149d27a1b1ae86c208ee65fbd6334

Authored by jiangjiazhi
1 parent 2d1caae1c7

c

Showing 12 changed files with 103 additions and 112 deletions

platform-common/src/main/java/com/lyms/platform/common/core/resolve/MessageResolver.java View file @ 673134d
... ... @@ -36,5 +36,9 @@
36 36 public String getErrorMessage(String key) {
37 37 return messageMapHolder.getProperty(key);
38 38 }
  39 +
  40 + public void setMessageFile(String messageFile) {
  41 + this.messageFile = messageFile;
  42 + }
39 43 }
platform-operate-api/pom.xml View file @ 673134d
... ... @@ -9,9 +9,9 @@
9 9 <modelVersion>4.0.0</modelVersion>
10 10 <packaging>war</packaging>
11 11 <artifactId>platform-operate-api</artifactId>
12   -
  12 +
13 13 <dependencies>
14   -
  14 +
15 15 <dependency>
16 16 <groupId>com.lyms.core</groupId>
17 17 <artifactId>platform-common</artifactId>
18 18  
19 19  
... ... @@ -43,42 +43,27 @@
43 43 <configuration>
44 44 <source>1.7</source>
45 45 <target>1.7</target>
  46 + <encoding>${maven.compiler.encoding}</encoding>
46 47 </configuration>
47 48 </plugin>
  49 + <plugin>
  50 + <groupId>org.apache.maven.plugins</groupId>
  51 + <artifactId>maven-resources-plugin</artifactId>
  52 + <version>2.6</version>
  53 + <configuration>
  54 + <encoding>${project.build.sourceEncoding}</encoding><!-- 指定编码格式,否则在DOS下运行mvn命令时当发生文件资源copy时将使用系统默认使用GBK编码 -->
  55 + </configuration>
  56 + </plugin>
48 57 </plugins>
49 58 <finalName>platform-operate-api</finalName>
50 59 </build>
51   - <!--
52   - <profiles>
53   - <profile>
54   - <id>mysql</id>
55   - <properties>
56   - <deploy.type>mysql</deploy.type>
57   - </properties>
58   - <activation>
59   - <activeByDefault>true</activeByDefault>
60   - </activation>
61   - <dependencies>
62   - <dependency>
63   - <groupId>com.lyms.core</groupId>
64   - <artifactId>permission-dal-mysql</artifactId>
65   - <version>${project.version}</version>
66   - </dependency>
67   - </dependencies>
68   - </profile>
69   - <profile>
70   - <id>mongo</id>
71   - <properties>
72   - <deploy.type>mongo</deploy.type>
73   - </properties>
74   - <dependencies>
75   - <dependency>
76   - <groupId>com.lyms.core</groupId>
77   - <artifactId>permission-dal-mongo</artifactId>
78   - <version>${project.version}</version>
79   - </dependency>
80   - </dependencies>
81   - </profile>
82   - </profiles>-->
  60 + <!-- <profiles> <profile> <id>mysql</id> <properties> <deploy.type>mysql</deploy.type>
  61 + </properties> <activation> <activeByDefault>true</activeByDefault> </activation>
  62 + <dependencies> <dependency> <groupId>com.lyms.core</groupId> <artifactId>permission-dal-mysql</artifactId>
  63 + <version>${project.version}</version> </dependency> </dependencies> </profile>
  64 + <profile> <id>mongo</id> <properties> <deploy.type>mongo</deploy.type> </properties>
  65 + <dependencies> <dependency> <groupId>com.lyms.core</groupId> <artifactId>permission-dal-mongo</artifactId>
  66 + <version>${project.version}</version> </dependency> </dependencies> </profile>
  67 + </profiles> -->
83 68 </project>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RestController.java View file @ 673134d
... ... @@ -2,8 +2,10 @@
2 2  
3 3 import java.util.List;
4 4  
  5 +import com.lyms.platform.common.core.resolve.MessageResolver;
5 6 import com.lyms.platform.common.result.BaseResponse;
6 7 import org.apache.commons.collections.CollectionUtils;
  8 +import org.springframework.beans.factory.annotation.Autowired;
7 9 import org.springframework.http.HttpStatus;
8 10 import org.springframework.validation.BindException;
9 11 import org.springframework.validation.BindingResult;
... ... @@ -16,7 +18,10 @@
16 18 public class RestController {
17 19  
18 20 private static final int ARG_ERROR = 4039;
19   -
  21 +
  22 + @Autowired
  23 + private MessageResolver messageResolver;
  24 +
20 25 @ExceptionHandler(MethodArgumentNotValidException.class)
21 26 @ResponseStatus(HttpStatus.OK)
22 27 @ResponseBody
... ... @@ -41,8 +46,8 @@
41 46 .get(0);
42 47  
43 48 error.setErrorcode(ARG_ERROR );
44   - error.setErrormsg(fieldError
45   - .getDefaultMessage());
  49 + error.setErrormsg(messageResolver.getErrorMessage(fieldError
  50 + .getDefaultMessage()));
46 51 }
47 52 return error;
48 53 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyManagerQueryRequest.java View file @ 673134d
... ... @@ -4,7 +4,6 @@
4 4  
5 5 import com.lyms.platform.common.core.annotation.form.Form;
6 6 import com.lyms.platform.common.core.annotation.form.FormParam;
7   -import com.lyms.platform.common.result.BaseModel;
8 7  
9 8 /**
10 9 * 新生儿管理请求
... ... @@ -12,7 +11,7 @@
12 11 * @author Administrator
13 12 */
14 13 @Form
15   -public class BabyManagerQueryRequest extends BaseModel {
  14 +public class BabyManagerQueryRequest extends BasePageQueryRequest {
16 15  
17 16 /**
18 17 *
19 18  
20 19  
... ... @@ -44,19 +43,8 @@
44 43 @FormParam
45 44 private Date dEnd;
46 45  
47   - /**
48   - * 页数
49   - */
50   - @FormParam
51   - private int page;
52 46  
53   - /**
54   - * 行数
55   - */
56   - @FormParam
57   - private int limit;
58 47  
59   -
60 48 public String getKeyword() {
61 49 return keyword;
62 50 }
63 51  
... ... @@ -89,17 +77,8 @@
89 77 this.dEnd = new Date(dEnd * 1000);
90 78 }
91 79  
92   -
93   - public int getPage() {
94   - return page;
95   - }
96   -
97 80 public void setPage(int page) {
98 81 this.page = page;
99   - }
100   -
101   - public int getLimit() {
102   - return limit;
103 82 }
104 83  
105 84 public void setLimit(int limit) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasePageQueryRequest.java View file @ 673134d
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import javax.validation.constraints.Max;
  4 +import javax.validation.constraints.Min;
  5 +import javax.validation.constraints.NotNull;
  6 +
  7 +import com.lyms.platform.common.core.annotation.form.FormParam;
  8 +import com.lyms.platform.common.result.BaseModel;
  9 +
  10 +/**
  11 + *
  12 + * 分页查询的基础请求
  13 + *
  14 + * @author Administrator
  15 + *
  16 + */
  17 +public class BasePageQueryRequest extends BaseModel {
  18 +
  19 + /**
  20 + *
  21 + */
  22 + private static final long serialVersionUID = 1L;
  23 +
  24 + @Min(value=1,message="page.min")
  25 + @FormParam
  26 + @NotNull(message="page.must.not.null")
  27 + protected Integer page;
  28 + @NotNull(message="page.limit.must.not.null")
  29 + @Min(value=1,message="page.min")
  30 + @Max(value=40,message="page.max")
  31 + @FormParam
  32 + protected Integer limit;
  33 + public Integer getPage() {
  34 + return page;
  35 + }
  36 + public void setPage(Integer page) {
  37 + this.page = page;
  38 + }
  39 + public Integer getLimit() {
  40 + return limit;
  41 + }
  42 + public void setLimit(Integer limit) {
  43 + this.limit = limit;
  44 + }
  45 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasicConfigAddRequest.java View file @ 673134d
... ... @@ -11,7 +11,6 @@
11 11 public class BasicConfigAddRequest implements IBasicRequestConvert<BasicConfig>{
12 12 @FormParam
13 13 private String parentId;
14   -
15 14 @FormParam
16 15 private String name;
17 16  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BasicConfigQueryRequest.java View file @ 673134d
1 1 package com.lyms.platform.operate.web.request;
2 2  
3   -import javax.validation.constraints.Min;
4   -
5 3 import com.lyms.platform.common.core.annotation.form.Form;
6 4 import com.lyms.platform.common.core.annotation.form.FormParam;
7 5  
8 6  
9 7  
... ... @@ -12,32 +10,20 @@
12 10 *
13 11 */
14 12 @Form
15   -public class BasicConfigQueryRequest {
  13 +public class BasicConfigQueryRequest extends BasePageQueryRequest {
  14 + /**
  15 + *
  16 + */
  17 + private static final long serialVersionUID = 1L;
  18 +
16 19 @FormParam
17 20 private String keywords;
18   - @Min(value=1,message="page不能小于1.")
19   - @FormParam
20   - private int page;
21   - @Min(value=1,message="limit不能小于1.")
22   - @FormParam
23   - private int limit;
  21 +
24 22 public String getKeywords() {
25 23 return keywords;
26 24 }
27 25 public void setKeywords(String keywords) {
28 26 this.keywords = keywords;
29   - }
30   - public int getPage() {
31   - return page;
32   - }
33   - public void setPage(int page) {
34   - this.page = page;
35   - }
36   - public int getLimit() {
37   - return limit;
38   - }
39   - public void setLimit(int limit) {
40   - this.limit = limit;
41 27 }
42 28 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/PuerperaManagerQueryRequest.java View file @ 673134d
... ... @@ -4,7 +4,6 @@
4 4  
5 5 import com.lyms.platform.common.core.annotation.form.Form;
6 6 import com.lyms.platform.common.core.annotation.form.FormParam;
7   -import com.lyms.platform.common.result.BaseModel;
8 7  
9 8 /**
10 9 * 产妇管理请求
... ... @@ -12,7 +11,7 @@
12 11 * @author Administrator
13 12 */
14 13 @Form
15   -public class PuerperaManagerQueryRequest extends BaseModel {
  14 +public class PuerperaManagerQueryRequest extends BasePageQueryRequest {
16 15  
17 16 /**
18 17 *
19 18  
... ... @@ -49,18 +48,7 @@
49 48 @FormParam
50 49 private Date dueDateEnd;
51 50  
52   - /**
53   - * 页数
54   - */
55   - @FormParam
56   - private int page;
57 51  
58   - /**
59   - * 行数
60   - */
61   - @FormParam
62   - private int limit;
63   -
64 52 public String getCommunityId() {
65 53 return communityId;
66 54 }
... ... @@ -99,22 +87,6 @@
99 87  
100 88 public void setDueDateEnd(long dueDateEnd) {
101 89 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 90 }
119 91 }
platform-operate-api/src/main/resources/database.properties View file @ 673134d
... ... @@ -5,4 +5,6 @@
5 5 mongo.db.host=localhost
6 6 mongo.db.port=27017
7 7 mongo.db.dbname=platform
  8 +mongo.db.username=root
  9 +mongo.db.password=root
platform-operate-api/src/main/resources/message.properties View file @ 673134d
  1 +page.min=\u5206\u9875\u6570\u636E\u4E0D\u80FD\u5C0F\u4E8E1.
  2 +page.max=\u6BCF\u9875\u663E\u793A\u7684\u6570\u636E\u4E0D\u80FD\u5927\u4E8E40\u6761
  3 +page.must.not.null=page\u4E0D\u80FD\u4E3A\u7A7A
  4 +page.limit.must.not.null=limit\u4E0D\u80FD\u4E3A\u7A7A
platform-operate-api/src/main/resources/spring/applicationContext.xml View file @ 673134d
... ... @@ -17,6 +17,11 @@
17 17 <!-- 配置要扫描的包 -->
18 18 <context:component-scan base-package="com.lyms.platform.biz.dal.impl" />
19 19 <context:component-scan base-package="com.lyms.platform.operate.web.facade" />
  20 +
  21 + <!-- 提示信息加载类 -->
  22 + <bean class="com.lyms.platform.common.core.resolve.MessageResolver">
  23 + <property name="messageFile" value="message.properties"/>
  24 + </bean>
20 25 <import resource="classpath:/spring/applicationContext_biz_patient.xml"/>
21 26 <import resource="classpath:/spring/spring-mongodb.xml"/>
22 27 </beans>
... ... @@ -29,6 +29,11 @@
29 29 <org.springframework.version>3.2.4.RELEASE</org.springframework.version>
30 30 <org.spring.data-mongodb>1.5.6.RELEASE</org.spring.data-mongodb>
31 31 <lyms.modelVersion>1.0.0</lyms.modelVersion>
  32 + <!-- 文件拷贝时的编码 -->
  33 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  34 + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  35 + <!-- 编译时的编码 -->
  36 + <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
32 37 </properties>
33 38  
34 39 <dependencies>