KangHua 4 gadi atpakaļ
revīzija
fa590cd8e1
53 mainītis faili ar 2432 papildinājumiem un 0 dzēšanām
  1. 40 0
      .gitignore
  2. 2 0
      README.md
  3. 40 0
      edu-common/.gitignore
  4. 163 0
      edu-common/pom.xml
  5. 24 0
      edu-common/src/main/java/com/edu/common/constant/Constants.java
  6. 40 0
      edu-dao/.gitignore
  7. 19 0
      edu-dao/pom.xml
  8. 13 0
      edu-dao/src/main/java/com/edu/dao/user/UserDao.java
  9. 20 0
      edu-dao/src/main/resources/com/edu/dao/user/UserMapper.xml
  10. 40 0
      edu-dubbo/.gitignore
  11. 31 0
      edu-dubbo/pom.xml
  12. 19 0
      edu-dubbo/src/main/java/com/edu/service/user/UserService.java
  13. 40 0
      edu-model/.gitignore
  14. 62 0
      edu-model/pom.xml
  15. 89 0
      edu-model/src/main/java/com/edu/base/BaseEntity.java
  16. 36 0
      edu-model/src/main/java/com/edu/base/Entity.java
  17. 162 0
      edu-model/src/main/java/com/edu/base/Page.java
  18. 16 0
      edu-model/src/main/java/com/edu/base/Pageable.java
  19. 80 0
      edu-model/src/main/java/com/edu/base/ResponseEntity.java
  20. 93 0
      edu-model/src/main/java/com/edu/mybatis/SqlInterceptor.java
  21. 13 0
      edu-model/src/main/java/com/edu/mybatis/dialect/Dialect.java
  22. 34 0
      edu-model/src/main/java/com/edu/mybatis/dialect/MsSQLDialect.java
  23. 26 0
      edu-model/src/main/java/com/edu/mybatis/dialect/MySql5Dialect.java
  24. 73 0
      edu-model/src/main/java/com/edu/mybatis/dialect/MySql5PageHepler.java
  25. 33 0
      edu-model/src/main/java/com/edu/mybatis/dialect/OracleDialect.java
  26. 15 0
      edu-model/src/main/java/com/edu/user/pojo/User.java
  27. 40 0
      edu-service/.gitignore
  28. 115 0
      edu-service/pom.xml
  29. 51 0
      edu-service/src/main/java/com/edu/service/aspect/ExceptionAspect.java
  30. 50 0
      edu-service/src/main/java/com/edu/service/exception/BussinessException.java
  31. 33 0
      edu-service/src/main/java/com/edu/service/exception/SystemException.java
  32. 46 0
      edu-service/src/main/java/com/edu/service/user/UserServiceImpl.java
  33. 20 0
      edu-service/src/main/resources/applicationContext-service.xml
  34. 40 0
      edu-web/.gitignore
  35. 57 0
      edu-web/pom.xml
  36. 46 0
      edu-web/src/main/java/com/edu/web/UserAction.java
  37. 26 0
      edu-web/src/main/resources/applicationContext-aop.xml
  38. 24 0
      edu-web/src/main/resources/applicationContext-dubbo-provider.xml
  39. 23 0
      edu-web/src/main/resources/applicationContext-thread.xml
  40. 46 0
      edu-web/src/main/resources/applicationContext-web.xml
  41. 17 0
      edu-web/src/main/resources/applicationContext.properties
  42. 31 0
      edu-web/src/main/resources/applicationContext.xml
  43. 69 0
      edu-web/src/main/resources/dataSource.xml
  44. 79 0
      edu-web/src/main/resources/log4j2.xml
  45. 12 0
      edu-web/src/main/resources/mybatis-config.xml
  46. 49 0
      edu-web/src/main/webapp/WEB-INF/web.xml
  47. 5 0
      edu-web/src/main/webapp/index.jsp
  48. 21 0
      edu-web/src/test/java/com/edu/base/BaseControllerTest.java
  49. 18 0
      edu-web/src/test/java/com/edu/base/BaseTest.java
  50. 112 0
      edu-web/src/test/java/com/edu/controller/UserControllerTest.java
  51. 29 0
      edu-web/src/test/resources/applicationContext-test.xml
  52. 89 0
      edu-web/src/test/resources/log4j2.xml
  53. 61 0
      pom.xml

+ 40 - 0
.gitignore

@@ -0,0 +1,40 @@
+##ignore this file##
+/.idea/
+/target/
+.git/
+.classpath
+.project
+.settings
+ ##filter databfile、sln file##
+*.mdb
+*.ldb
+*.sln
+##class file##
+*.iml
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+# compression file
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+*.via
+*.tmp
+*.err
+# OS generated files #
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 2 - 0
README.md

@@ -0,0 +1,2 @@
+#demo
+基础框架-简单的Demo

+ 40 - 0
edu-common/.gitignore

@@ -0,0 +1,40 @@
+##ignore this file##
+/.idea/
+/target/
+.git/
+.classpath
+.project
+.settings
+ ##filter databfile、sln file##
+*.mdb
+*.ldb
+*.sln
+##class file##
+*.iml
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+# compression file
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+*.via
+*.tmp
+*.err
+# OS generated files #
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 163 - 0
edu-common/pom.xml

@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.edu</groupId>
+    <artifactId>edu-common</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>edu-common</name>
+    <url>http://maven.apache.org</url>
+
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.meitong</groupId>
+            <artifactId>framework-core</artifactId>
+            <version>1.0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.sf.jxls</groupId>
+            <artifactId>jxls-core</artifactId>
+            <version>1.0.5</version>
+        </dependency>
+        <!-- JWT -->
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.7.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>3.9</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper</artifactId>
+            <version>4.1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>com.belerweb</groupId>
+            <artifactId>pinyin4j</artifactId>
+            <version>2.5.1</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.4</version>
+            <classifier>jdk15</classifier>
+        </dependency>
+        <!-- 图片压缩 -->
+        <dependency>
+            <groupId>net.coobird</groupId>
+            <artifactId>thumbnailator</artifactId>
+            <version>0.4.8</version>
+        </dependency>
+        <!-- apache.....start -->
+        <dependency>
+            <groupId>ant</groupId>
+            <artifactId>ant</artifactId>
+            <version>1.6.5</version>
+        </dependency>
+        <!-- apache.....end -->
+
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>2.8.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.9.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.9.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <version>2.9.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+            <version>2.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson</artifactId>
+            <version>3.7.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun.odps</groupId>
+            <artifactId>odps-sdk-core</artifactId>
+            <version>0.24.0-public</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.wutong</groupId>
+            <artifactId>distribution-id-generator</artifactId>
+            <version>1.0.0</version>
+            <!-- 剔除logback日志包 -->
+            <exclusions>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-classic</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-email</artifactId>
+            <version>1.5</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>2.1</version>
+                <configuration>
+                    <attach>true</attach>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 24 - 0
edu-common/src/main/java/com/edu/common/constant/Constants.java

@@ -0,0 +1,24 @@
+package com.edu.common.constant;
+
+/**
+ * @author KangJellen
+ * @time 2017年5月2日10:48:54
+ */
+public interface Constants {
+
+	/**
+	 * OOO系统
+	 * OOO△△xxx
+	 * 中间三位△△预留,默认为00
+	 * 后三位xxx表示错误码
+	 * 后三位中xxx,001-099预留为公司统一使用的编码
+	 */
+	public interface demo{
+
+		// 系统异常(未定义、未捕获、未处理的统一放这里)
+		public static final String ERROR_CODE01 = "01000001";
+		public static final String ERROR_MSG01 = "系统错误,请联系管理员!";
+
+	}
+
+}

+ 40 - 0
edu-dao/.gitignore

@@ -0,0 +1,40 @@
+##ignore this file##
+/.idea/
+/target/
+.git/
+.classpath
+.project
+.settings
+ ##filter databfile、sln file##
+*.mdb
+*.ldb
+*.sln
+##class file##
+*.iml
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+# compression file
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+*.via
+*.tmp
+*.err
+# OS generated files #
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 19 - 0
edu-dao/pom.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.edu</groupId>
+    <artifactId>edu-dao</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>edu-dao</name>
+    <url>http://maven.apache.org</url>
+    <dependencies>
+        <dependency>
+            <groupId>com.edu</groupId>
+            <artifactId>edu-model</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>

+ 13 - 0
edu-dao/src/main/java/com/edu/dao/user/UserDao.java

@@ -0,0 +1,13 @@
+package com.edu.dao.user;
+
+import com.edu.user.pojo.User;
+
+import java.util.List;
+
+/**
+ * Created by KangJellen on 2017/4/24.
+ */
+public interface UserDao {
+    String getNameById(Long id);
+    List<User> selectUserList(User user);
+}

+ 20 - 0
edu-dao/src/main/resources/com/edu/dao/user/UserMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+  
+  <mapper namespace="com.edu.dao.user.UserDao">
+
+	<!-- 根据手机号获取用户ID -->
+	<select id="getNameById" resultType="String" parameterType="Long">
+		SELECT user_name as name FROM t_sys_user WHERE id = #{id}
+	</select>
+
+	<select id="selectUserList" resultType="com.edu.user.pojo.User" parameterType="com.edu.user.pojo.User">
+		select user_code userCode, user_name as name FROM t_sys_user
+		<if test="page != null">
+			limit #{page.offset}, #{page.limit}
+		</if>
+	</select>
+	
+  </mapper>

+ 40 - 0
edu-dubbo/.gitignore

@@ -0,0 +1,40 @@
+##ignore this file##
+/.idea/
+/target/
+.git/
+.classpath
+.project
+.settings
+ ##filter databfile、sln file##
+*.mdb
+*.ldb
+*.sln
+##class file##
+*.iml
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+# compression file
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+*.via
+*.tmp
+*.err
+# OS generated files #
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 31 - 0
edu-dubbo/pom.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.edu</groupId>
+    <artifactId>edu-dubbo</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>edu-dubbo</name>
+    <url>http://maven.apache.org</url>
+    <dependencies>
+        <dependency>
+            <groupId>com.edu</groupId>
+            <artifactId>edu-model</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+    <distributionManagement>
+        <repository>
+            <id>deployRelease</id>
+            <name>haiyin Internal Repository</name>
+            <url>https://maven.aliyun.com/nexus/content/repositories/releases</url>
+        </repository>
+        <snapshotRepository>
+            <id>deploySnapshot</id>
+            <name>haiyin Internal Repository</name>
+            <url>https://maven.aliyun.com/nexus/content/repositories/snapshots</url>
+        </snapshotRepository>
+    </distributionManagement>
+</project>

+ 19 - 0
edu-dubbo/src/main/java/com/edu/service/user/UserService.java

@@ -0,0 +1,19 @@
+package com.edu.service.user;
+
+import com.edu.base.ResponseEntity;
+import com.edu.user.pojo.User;
+
+import java.util.List;
+
+public interface UserService {
+
+	/**
+	 * 测试框架
+	 * @param id
+	 * @return
+	 */
+	ResponseEntity getNameById(Long id);
+
+	ResponseEntity<List<User>> getUserList(User user);
+
+}

+ 40 - 0
edu-model/.gitignore

@@ -0,0 +1,40 @@
+##ignore this file##
+/.idea/
+/target/
+.git/
+.classpath
+.project
+.settings
+ ##filter databfile、sln file##
+*.mdb
+*.ldb
+*.sln
+##class file##
+*.iml
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+# compression file
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+*.via
+*.tmp
+*.err
+# OS generated files #
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 62 - 0
edu-model/pom.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.edu</groupId>
+    <artifactId>edu-model</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>edu-model</name>
+    <url>http://maven.apache.org</url>
+    <dependencies>
+
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis</artifactId>
+            <!-- <version>3.3.0</version> -->
+            <version>3.4.6</version>
+
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.49</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.7.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.persistence</groupId>
+            <artifactId>persistence-api</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.10</version>
+        </dependency>
+
+        <!-- swagger2 -->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+    </dependencies>
+</project>

+ 89 - 0
edu-model/src/main/java/com/edu/base/BaseEntity.java

@@ -0,0 +1,89 @@
+package com.edu.base;
+
+/**
+ * Created by KangJellen on 2017/4/24.
+ */
+
+import javax.persistence.Id;
+import java.io.Serializable;
+import java.util.Date;
+
+public class BaseEntity implements Serializable {
+    public static final String CREATE_DATE_PROPERTY_NAME = "createTime";
+    public static final String MODIFY_DATE_PROPERTY_NAME = "updateTime";
+
+    @Id
+    protected String id;
+    protected Date createTime;
+    protected String createUser;
+    protected Date updateTime;
+    protected String updateUser;
+
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        BaseEntity other = (BaseEntity) obj;
+        if ((this.id == null) || (other.getId() == null)) {
+            return false;
+        }
+        return this.id.equals(other.getId());
+    }
+
+    public int hashCode() {
+        int prime = 31;
+        int result = 1;
+        result = 31 * result + (this.id == null ? 0 : this.id.hashCode());
+        return result;
+    }
+
+    public String getId() {
+        return this.id;
+    }
+
+    public Date getCreateTime() {
+        return this.createTime;
+    }
+
+    public String getCreateUser() {
+        return this.createUser;
+    }
+
+    public Date getUpdateTime() {
+        return this.updateTime;
+    }
+
+    public String getUpdateUser() {
+        return this.updateUser;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public void setCreateUser(String createUser) {
+        this.createUser = createUser;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public void setUpdateUser(String updateUser) {
+        this.updateUser = updateUser;
+    }
+
+    public String toString() {
+        return "BaseEntity(id=" + getId() + ", createTime=" + getCreateTime() + ", createUser=" + getCreateUser() + ", updateTime=" + getUpdateTime() + ", updateUser=" + getUpdateUser() + ")";
+    }
+}

+ 36 - 0
edu-model/src/main/java/com/edu/base/Entity.java

@@ -0,0 +1,36 @@
+package com.edu.base;
+
+import com.alibaba.fastjson.JSON;
+
+import java.io.Serializable;
+
+public class Entity implements Pageable, Serializable {
+	private static final long serialVersionUID = -7208074780550828689L;
+	private Page page = null;
+
+	public Page setPage(Page page) {
+		this.page = page;
+		return this.getPage();
+	}
+
+	public Page getPage() {
+		return this.page;
+	}
+
+	/**
+	 * 
+	 * @return {@link #getPage()}
+	 */
+	public Page ensurePage() {
+		if (null == this.getPage()) {
+			this.setPage(new Page());
+		}
+
+		return this.getPage();
+	}
+
+	@Override
+	public String toString() {
+		return JSON.toJSONString(this);
+	}
+}

+ 162 - 0
edu-model/src/main/java/com/edu/base/Page.java

@@ -0,0 +1,162 @@
+package com.edu.base;
+
+/**
+ * @author wu youyang
+ */
+
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+@ApiModel(description = "分页对象")
+public class Page implements Serializable {
+	private static final long serialVersionUID = -4312323165564562319L;
+
+	@ApiModelProperty("页码")
+	private int page = 1;
+
+	@ApiModelProperty("每页条数")
+	private int pageSize = 10;
+	
+	/**
+	 * 总记录数, -1: 未知
+	 */
+	private int total = -1;
+
+	public int getPage() {
+		return page;
+	}
+
+	/**
+	 * 当前页码, 1-based
+	 */
+	public void setPage(int page) {
+		this.page = page;
+	}
+
+	/**
+	 * 每页记录数
+	 */
+	public int getPageSize() {
+		return pageSize;
+	}
+
+	public void setPageSize(int pageSize) {
+		this.pageSize = pageSize;
+	}
+
+	public int getTotal() {
+		return total;
+	}
+
+	public void setTotal(int total) {
+		this.total = total;
+	}
+
+	public int getPrevPage() {
+		return this.isFirstPage() ? this.getPage() : this.getPage() - 1;
+	}
+
+	public int getNextPage() {
+		return this.isLastPage() ? this.getPage() : this.getPage() + 1;
+	}
+
+	public boolean isFirstPage() {
+		return (1 == this.getPage());
+	}
+
+	public boolean isLastPage() {
+		if(-1 == this.getPageCount()){
+			return false;
+		}
+		
+		return (this.getPageCount() < 1 || this.getPageCount() <= this.getPage());
+	}
+
+	/**
+	 * 页数, 根据total和pageSize计算
+	 * -1: 未知
+	 * @return 
+	 */
+	public int getPageCount() {
+		if(-1 == total){
+			return -1;
+		}
+		
+		if (total < 1) {
+			return 0;
+		}
+		
+		if (pageSize < 1) {
+			return 1;
+		}
+
+		return (0 == total % pageSize) ? total / pageSize : total / pageSize
+				+ 1;
+	}
+
+	/**
+	 * 
+	 * mysql offset, 0-based, 根据page和pageSize计算
+	 * 
+	 * @return
+	 */
+	public int getOffset() {
+		if (page < 1) {
+			return 0;
+		}
+
+		return (page - 1) * pageSize;
+	}
+
+	/**
+	 * mysql limit, 0-based, 根据page和pageSize计算
+	 * 
+	 * @return
+	 */
+	public int getLimit() {
+		return pageSize;
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + page;
+		result = prime * result + pageSize;
+		result = prime * result + total;
+
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj){
+			return true;
+		}
+		if (obj == null){
+			return false;
+		}
+		if (getClass() != obj.getClass()){
+			return false;
+		}
+		Page other = (Page) obj;
+		if (page != other.page){
+			return false;
+		}
+		if (pageSize != other.pageSize){
+			return false;
+		}
+		if (total != other.total){
+			return false;
+		}
+		
+		return true;
+	}
+
+	public String toString() {
+		return JSON.toJSONString(this);
+	}
+}

+ 16 - 0
edu-model/src/main/java/com/edu/base/Pageable.java

@@ -0,0 +1,16 @@
+package com.edu.base;
+
+/**
+ * 需要分页的实体实现此接口
+ * @author zhou shengzong
+ *
+ */
+public interface Pageable {
+	/**
+	 * 
+	 * @param page 
+	 * @return {@link #getPage()}
+	 */
+	Page setPage(Page page);
+	Page getPage();
+}

+ 80 - 0
edu-model/src/main/java/com/edu/base/ResponseEntity.java

@@ -0,0 +1,80 @@
+package com.edu.base;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * Created by KangJellen on 2017/4/25.
+ */
+@ApiModel(description = "通用返回对象")
+public class ResponseEntity<T> implements Serializable {
+
+    @ApiModelProperty("返回码")
+    private String code = "000000";
+
+    @ApiModelProperty("返回信息")
+    private String msg;
+
+    @ApiModelProperty("返回实体对象信息")
+    private T data;
+
+    @ApiModelProperty("总条数")
+    private long count;
+
+    public ResponseEntity() {
+    }
+
+    public ResponseEntity(T data) {
+        this.data = data;
+    }
+
+    public ResponseEntity(T data, long count) {
+        this.data = data;
+        this.count = count;
+    }
+
+    public ResponseEntity(String code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public String getMsg() {
+        return this.msg;
+    }
+
+    public ResponseEntity<T> setMsg(String msg) {
+        this.msg = msg;
+        return this;
+    }
+
+    public T getData() {
+        return this.data;
+    }
+
+    public ResponseEntity<T> setData(T data) {
+        this.data = data;
+        return this;
+    }
+
+    public long getCount() {
+        return this.count;
+    }
+
+    public void setCount(long count) {
+        this.count = count;
+    }
+
+    public String getCode() {
+        return this.code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String toString() {
+        return "ResponseEntity(super=" + super.toString() + ", msg=" + getMsg() + ", data=" + getData() + ", count=" + getCount() + ", code=" + getCode() + ")";
+    }
+}

+ 93 - 0
edu-model/src/main/java/com/edu/mybatis/SqlInterceptor.java

@@ -0,0 +1,93 @@
+package com.edu.mybatis;
+
+import com.edu.mybatis.dialect.Dialect;
+import com.edu.mybatis.dialect.MySql5Dialect;
+import com.edu.mybatis.dialect.OracleDialect;
+import org.apache.ibatis.executor.statement.StatementHandler;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.plugin.Intercepts;
+import org.apache.ibatis.plugin.Invocation;
+import org.apache.ibatis.plugin.Plugin;
+import org.apache.ibatis.reflection.DefaultReflectorFactory;
+import org.apache.ibatis.reflection.MetaObject;
+import org.apache.ibatis.reflection.SystemMetaObject;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.RowBounds;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+/**
+ * Created by KangJellen on 2017/4/24.
+ * 
+ */
+@Intercepts({@org.apache.ibatis.plugin.Signature(type=StatementHandler.class, method="prepare", args={Connection.class,Integer.class})})
+public class SqlInterceptor
+		implements Interceptor
+{
+	private static ThreadLocal<RowBounds> threadRowBounds = new ThreadLocal<RowBounds>();
+
+	private static RowBounds getRowBounds() {
+		RowBounds rowBounds = threadRowBounds.get();
+		threadRowBounds.remove();
+		return rowBounds;
+	}
+
+	public static void setRowBounds(RowBounds rowBounds) {
+		threadRowBounds.set(rowBounds);
+	}
+
+	public Object intercept(Invocation invocation) throws Throwable
+	{
+		StatementHandler statementHandler = (StatementHandler)invocation.getTarget();
+//		BoundSql boundSql = statementHandler.getBoundSql();
+		MetaObject metaStatementHandler = MetaObject.forObject(statementHandler, SystemMetaObject.DEFAULT_OBJECT_FACTORY, SystemMetaObject.DEFAULT_OBJECT_WRAPPER_FACTORY, new DefaultReflectorFactory());
+		RowBounds rowBounds = getRowBounds();
+		if (rowBounds == null) {
+			rowBounds = (RowBounds)metaStatementHandler.getValue("delegate.rowBounds");
+		}
+		Configuration configuration = (Configuration)metaStatementHandler.getValue("delegate.configuration");
+		Dialect.Type databaseType;
+		try {
+			databaseType = Dialect.Type.valueOf(configuration.getVariables().getProperty("dialect").toUpperCase());
+		}
+		catch (Exception localException) {
+			throw new RuntimeException(localException.getMessage());
+		}
+		if (databaseType == null) {
+			throw new RuntimeException("the value of the dialect property in configuration.xml is not defined : " + configuration.getVariables().getProperty("dialect"));
+		}
+		Dialect dialect = null;
+		switch (databaseType.ordinal()) {
+		case 1:
+			dialect = new MySql5Dialect();
+			break;
+		case 2:
+			dialect = new OracleDialect();
+		}
+
+		String sql = (String)metaStatementHandler.getValue("delegate.boundSql.sql");
+		if ((rowBounds != null) && (rowBounds != RowBounds.DEFAULT)) {
+			sql = dialect.getLimitString(sql, rowBounds.getOffset(), rowBounds.getLimit());
+		}
+
+		if (sql == null) {
+			throw new RuntimeException("the value of the dialect property in configuration.xml is not defined : " + configuration.getVariables().getProperty("dialect"));
+		}
+
+		metaStatementHandler.setValue("delegate.boundSql.sql", sql);
+		metaStatementHandler.setValue("delegate.rowBounds.offset", 0);
+		metaStatementHandler.setValue("delegate.rowBounds.limit", 2147483647);
+
+		return invocation.proceed();
+	}
+
+	public Object plugin(Object target)
+	{
+		return Plugin.wrap(target, this);
+	}
+
+	public void setProperties(Properties properties)
+	{
+	}
+}

+ 13 - 0
edu-model/src/main/java/com/edu/mybatis/dialect/Dialect.java

@@ -0,0 +1,13 @@
+package com.edu.mybatis.dialect;
+
+public abstract class Dialect
+{
+	public abstract String getLimitString(String paramString, int paramInt1, int paramInt2);
+
+	public abstract String addLog(String paramString);
+
+	public static enum Type
+	{
+		MYSQL, ORACLE, MSSQL;
+	}
+}

+ 34 - 0
edu-model/src/main/java/com/edu/mybatis/dialect/MsSQLDialect.java

@@ -0,0 +1,34 @@
+package com.edu.mybatis.dialect;
+
+public class MsSQLDialect extends Dialect
+{
+	@Override
+	public String getLimitString(String sql, int offset, int limit)
+	{
+		sql = sql.trim();
+		boolean isForUpdate = false;
+		if (sql.toLowerCase().endsWith(" FOR UPDATE")) {
+			sql = sql.substring(0, sql.length() - 11);
+			isForUpdate = true;
+		}
+
+		StringBuffer pagingSelect = new StringBuffer(sql.length() + 100);
+
+		pagingSelect.append("SELECT * FROM ( SELECT ROW_.*, ROWNUM ROWNUM_ FROM ( ");
+
+		pagingSelect.append(sql);
+
+		pagingSelect.append(" ) ROW_ ) WHERE ROWNUM_ > " + offset + " AND ROWNUM_ <= " + (offset + limit));
+
+		if (isForUpdate) {
+			pagingSelect.append(" FOR UPDATE");
+		}
+
+		return pagingSelect.toString();
+	}
+
+	public String addLog(String sql)
+	{
+		return null;
+	}
+}

+ 26 - 0
edu-model/src/main/java/com/edu/mybatis/dialect/MySql5Dialect.java

@@ -0,0 +1,26 @@
+package com.edu.mybatis.dialect;
+
+public class MySql5Dialect extends Dialect
+{
+	protected static final String SQL_END_DELIMITER = ";";
+
+	public String getLimitString(String sql, boolean hasOffset)
+	{
+		return MySql5PageHepler.getLimitString(sql, -1, -1);
+	}
+
+	@Override
+	public String getLimitString(String sql, int offset, int limit)
+	{
+		return MySql5PageHepler.getLimitString(sql, offset, limit);
+	}
+
+	public boolean supportsLimit() {
+		return true;
+	}
+
+	public String addLog(String sql)
+	{
+		return sql;
+	}
+}

+ 73 - 0
edu-model/src/main/java/com/edu/mybatis/dialect/MySql5PageHepler.java

@@ -0,0 +1,73 @@
+package com.edu.mybatis.dialect;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class MySql5PageHepler
+{
+	private static int getAfterFormInsertPoint(String querySelect)
+	{
+		String regex = "\\s+FROM\\s+";
+		Pattern pattern = Pattern.compile(regex, 2);
+		Matcher matcher = pattern.matcher(querySelect);
+		while (matcher.find()) {
+			int fromStartIndex = matcher.start(0);
+			String text = querySelect.substring(0, fromStartIndex);
+			if (isBracketCanPartnership(text)) {
+				return fromStartIndex;
+			}
+		}
+		return 0;
+	}
+
+	public static String getCountString(String querySelect)
+	{
+		querySelect = getLineSql(querySelect);
+		int orderIndex = getLastOrderInsertPoint(querySelect);
+
+		int formIndex = getAfterFormInsertPoint(querySelect);
+		String select = querySelect.substring(0, formIndex);
+
+		if ((select.toLowerCase().indexOf("select distinct") != -1) || (querySelect.toLowerCase().indexOf("group by") != -1)) {
+			return querySelect.length() + "select count(1) count from (" + querySelect.substring(0, orderIndex) + " ) t";
+		}
+		return querySelect.length() + "select count(1) count " + querySelect.substring(formIndex, orderIndex);
+	}
+
+	private static int getIndexOfCount(String text, char ch)
+	{
+		int count = 0;
+		for (int i = 0; i < text.length(); i++) {
+			count = text.charAt(i) == ch ? count + 1 : count;
+		}
+		return count;
+	}
+
+	private static int getLastOrderInsertPoint(String querySelect)
+	{
+		int orderIndex = querySelect.toLowerCase().lastIndexOf("order by");
+		if ((orderIndex == -1) || (!isBracketCanPartnership(querySelect.substring(orderIndex, querySelect.length())))) {
+			throw new RuntimeException("My SQL 分页必须要有Order by 语句!");
+		}
+		return orderIndex;
+	}
+
+	public static String getLimitString(String querySelect, int offset, int limit)
+	{
+		querySelect = getLineSql(querySelect);
+
+		String sql = querySelect + " limit " + offset + " ," + limit;
+
+		return sql;
+	}
+
+	private static String getLineSql(String sql)
+	{
+		return sql.replaceAll("[\r\n]", " ").replaceAll("\\s{2,}", " ");
+	}
+
+	private static boolean isBracketCanPartnership(String text)
+	{
+		return (text != null) && (getIndexOfCount(text, '(') == getIndexOfCount(text, ')'));
+	}
+}

+ 33 - 0
edu-model/src/main/java/com/edu/mybatis/dialect/OracleDialect.java

@@ -0,0 +1,33 @@
+package com.edu.mybatis.dialect;
+
+public class OracleDialect extends Dialect
+{
+	public String getLimitString(String sql, int offset, int limit)
+	{
+		sql = sql.trim();
+		boolean isForUpdate = false;
+		if (sql.toLowerCase().endsWith(" FOR UPDATE")) {
+			sql = sql.substring(0, sql.length() - 11);
+			isForUpdate = true;
+		}
+
+		StringBuffer pagingSelect = new StringBuffer(sql.length() + 100);
+
+		pagingSelect.append("SELECT * FROM ( SELECT ROW_.*, ROWNUM ROWNUM_ FROM ( ");
+
+		pagingSelect.append(sql);
+
+		pagingSelect.append(" ) ROW_ ) WHERE ROWNUM_ > " + offset + " AND ROWNUM_ <= " + (offset + limit));
+
+		if (isForUpdate) {
+			pagingSelect.append(" FOR UPDATE");
+		}
+
+		return pagingSelect.toString();
+	}
+
+	public String addLog(String sql)
+	{
+		return null;
+	}
+}

+ 15 - 0
edu-model/src/main/java/com/edu/user/pojo/User.java

@@ -0,0 +1,15 @@
+package com.edu.user.pojo;
+
+import com.edu.base.Entity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ToString(callSuper = true)
+public class User extends Entity {
+	private Long id;
+	private String userCode;
+	private String name;
+}

+ 40 - 0
edu-service/.gitignore

@@ -0,0 +1,40 @@
+##ignore this file##
+/.idea/
+/target/
+.git/
+.classpath
+.project
+.settings
+ ##filter databfile、sln file##
+*.mdb
+*.ldb
+*.sln
+##class file##
+*.iml
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+# compression file
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+*.via
+*.tmp
+*.err
+# OS generated files #
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 115 - 0
edu-service/pom.xml

@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>com.edu</groupId>
+        <artifactId>vtrt-edu</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.edu</groupId>
+    <artifactId>edu-service</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>edu-service</name>
+    <url>http://maven.apache.org</url>
+    <properties>
+        <spring-version>4.3.2.RELEASE</spring-version>
+    </properties>
+    <dependencies>
+        <!--引入spring相关的jar包-->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+            <version>${spring-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>${spring-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+            <version>${spring-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aspects</artifactId>
+            <version>${spring-version}</version>
+        </dependency>
+        <!--引入spring相关的jar包-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis-spring</artifactId>
+            <version>1.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.38</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>2.6.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>2.6.2</version>
+        </dependency>
+        <!-- log4j-slf4j-impl(用于log4j2与slf4j集成) -->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j-impl</artifactId>
+            <version>2.6.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.edu</groupId>
+            <artifactId>edu-common</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.edu</groupId>
+            <artifactId>edu-dao</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <!-- 引入DUBBO相关的JAR -->
+        <dependency>
+            <groupId>com.edu</groupId>
+            <artifactId>edu-dubbo</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>dubbo</artifactId>
+            <version>2.5.3</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>spring</artifactId>
+                    <groupId>org.springframework</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.github.sgroschupf</groupId>
+            <artifactId>zkclient</artifactId>
+            <version>0.1</version>
+        </dependency>
+        <!-- 引入DUBBO相关的JAR -->
+    </dependencies>
+</project>

+ 51 - 0
edu-service/src/main/java/com/edu/service/aspect/ExceptionAspect.java

@@ -0,0 +1,51 @@
+package com.edu.service.aspect;
+
+import com.edu.service.exception.BussinessException;
+import com.edu.service.exception.SystemException;
+import com.edu.base.ResponseEntity;
+import com.meitong.framework.constant.Constants;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.aspectj.lang.ProceedingJoinPoint;
+
+/**
+ * @author wu youyang
+ */
+
+public class ExceptionAspect
+{
+
+	private Logger logger = LogManager.getLogger(this.getClass());
+
+	private String systemCode;
+
+	public void setSystemCode(String systemCode) {
+		this.systemCode = systemCode;
+	}
+
+	/**
+	 * 处理运行异常的切面
+	 * */
+	public Object deal(ProceedingJoinPoint pjp) throws Throwable {
+		Object returnMessage = null;
+		Class<?> aClass = pjp.getTarget().getClass();
+//		logger.info(aClass.getName() + "#" + pjp.getSignature().getName() + ": request:{}", pjp.getArgs());
+		try {
+			returnMessage = pjp.proceed();
+		} catch (BussinessException e0) {
+			logger.error("",e0);
+			returnMessage = new ResponseEntity(e0.getErrCode(), e0.getMessage());
+		}  catch (IllegalArgumentException e1) {
+			logger.error("",e1);
+			returnMessage = new ResponseEntity(this.systemCode + Constants.SYS_ERROR_CODE05, Constants.SYS_ERROR_MSG05 + e1.getMessage());
+		}catch (SystemException e2) {
+			logger.error("",e2);
+			returnMessage = new ResponseEntity(this.systemCode + Constants.SYS_ERROR_CODE05, Constants.SYS_ERROR_MSG05);
+		} catch (Exception e3) {
+			logger.error("",e3);
+			returnMessage = new ResponseEntity(this.systemCode + Constants.RUN_TIME_ERROR_CODE, Constants.RUN_TIME_ERROR_MSG + e3.getMessage());
+		}
+//		logger.info(aClass.getName() + "#" + pjp.getSignature().getName() + ": response:{}", returnMessage);
+		return returnMessage;
+	}
+}

+ 50 - 0
edu-service/src/main/java/com/edu/service/exception/BussinessException.java

@@ -0,0 +1,50 @@
+package com.edu.service.exception;
+
+
+public class BussinessException extends RuntimeException {
+
+    private String errMsg;
+
+    private String errCode;
+
+    public BussinessException(String errCode, String errMsg){
+        super(errMsg);
+        this.errCode = errCode;
+        this.errMsg = errMsg;
+    }
+    public BussinessException(String errMsg){
+        super(errMsg);
+        this.errMsg = errMsg;
+    }
+    /**
+     * @param cause
+     */
+    public BussinessException(Throwable cause){
+        super(cause);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public BussinessException(String message, Throwable cause){
+        super(message, cause);
+    }
+    
+    public String getErrMsg() {
+        return errMsg;
+    }
+
+    public void setErrMsg(String errMsg) {
+        this.errMsg = errMsg;
+    }
+
+    public String getErrCode() {
+        return errCode;
+    }
+
+    public void setErrCode(String errCode) {
+        this.errCode = errCode;
+    }
+
+}

+ 33 - 0
edu-service/src/main/java/com/edu/service/exception/SystemException.java

@@ -0,0 +1,33 @@
+package com.edu.service.exception;
+
+public class SystemException extends RuntimeException {
+
+	private static final long serialVersionUID = 1L;
+
+	// 错误code
+	public String errorCode;
+
+	public SystemException() {
+
+	}
+
+	public SystemException(String message) {
+		super(message);
+	}
+
+	public SystemException(String errorCode, String message) {
+		super(message);
+		this.errorCode = errorCode;
+	}
+
+	public SystemException(String errorCode, Throwable cause) {
+		super(cause);
+		this.errorCode = errorCode;
+	}
+
+	public String getErrorCode() {
+		return errorCode;
+	}
+
+	
+}

+ 46 - 0
edu-service/src/main/java/com/edu/service/user/UserServiceImpl.java

@@ -0,0 +1,46 @@
+package com.edu.service.user;
+
+import com.alibaba.druid.util.StringUtils;
+import com.edu.dao.user.UserDao;
+import com.edu.base.ResponseEntity;
+import com.edu.user.pojo.User;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * Created by KangJellen on 2017/4/24.
+ */
+@Service
+public class UserServiceImpl implements UserService {
+    private final Logger logger = LogManager.getLogger(this.getClass());
+
+    @Autowired
+    private UserDao userDao;
+
+    @Override
+    public ResponseEntity getNameById(Long id) {
+        logger.log(Level.getLevel("BIZ"), "test biz level log message");
+        logger.error("test separate file");
+        String name = null;
+        try {
+            name = userDao.getNameById(id);
+        } catch (Exception e) {
+            logger.debug(e.getMessage());
+        }
+        return new ResponseEntity(name);
+    }
+
+    @Override
+    public ResponseEntity<List<User>> getUserList(User user) {
+        if(StringUtils.isEmpty(user.getUserCode())) {
+            throw new IllegalArgumentException("用户Code不能为空!");
+        }
+        List<User> list = userDao.selectUserList(user);
+        return new ResponseEntity(list);
+    }
+}

+ 20 - 0
edu-service/src/main/resources/applicationContext-service.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	   xmlns:context="http://www.springframework.org/schema/context"
+	   xmlns:aop="http://www.springframework.org/schema/aop"
+	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	   xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context-4.0.xsd
+		http://www.springframework.org/schema/aop
+		http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
+
+	<aop:config />
+	<!-- enable @AspectJ support with XML based configuration -->
+	<aop:aspectj-autoproxy />
+	<context:annotation-config  />
+	<!-- 启动包扫描功能,以便注册带有@Controller、@Service、@repository、@Component等注解的类成为spring的bean -->
+	<context:component-scan base-package="com.edu.service" />
+
+</beans>

+ 40 - 0
edu-web/.gitignore

@@ -0,0 +1,40 @@
+##ignore this file##
+/.idea/
+/target/
+.git/
+.classpath
+.project
+.settings
+ ##filter databfile、sln file##
+*.mdb
+*.ldb
+*.sln
+##class file##
+*.iml
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+# compression file
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+*.via
+*.tmp
+*.err
+# OS generated files #
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 57 - 0
edu-web/pom.xml

@@ -0,0 +1,57 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>com.edu</groupId>
+        <artifactId>vtrt-edu</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.edu</groupId>
+    <artifactId>edu-web</artifactId>
+    <packaging>war</packaging>
+    <name>edu-web Maven Webapp</name>
+    <url>http://maven.apache.org</url>
+    <dependencies>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <version>4.3.2.RELEASE</version>
+        </dependency>
+
+        <!-- Test -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+        </dependency>
+        <!-- mockito -->
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>1.10.19</version>
+        </dependency>
+        <!-- mockito -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <version>4.3.2.RELEASE</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.edu</groupId>
+            <artifactId>edu-service</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.jayway.jsonpath</groupId>
+            <artifactId>json-path</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+    </dependencies>
+</project>

+ 46 - 0
edu-web/src/main/java/com/edu/web/UserAction.java

@@ -0,0 +1,46 @@
+package com.edu.web;
+
+import com.edu.base.Page;
+import com.edu.service.user.UserService;
+import com.edu.base.ResponseEntity;
+import com.edu.user.pojo.User;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import java.util.List;
+/**
+ * Created by KangJellen on 2017/4/24.
+ */
+@Controller
+@RequestMapping("/user")
+public class UserAction {
+
+    @Resource
+	private UserService userServiceImpl;
+
+    @RequestMapping(value = "/getUserName/{id}", method = RequestMethod.GET, produces = "application/json")
+	@ResponseBody
+	public ResponseEntity getUserName(@PathVariable Long id) {
+		ResponseEntity ret = userServiceImpl.getNameById(id);
+		return ret;
+	}
+
+	@RequestMapping(value = "/getUserList", method = RequestMethod.GET, produces = "application/json")
+	@ResponseBody
+	public ResponseEntity<List<User>> getUserList(User user) {
+		if(user == null) {
+			user = new User();
+		}
+		Page page = user.getPage();
+		if(null == page){
+			page = new Page();
+			user.setPage(page);
+		}
+		ResponseEntity<List<User>> ret = userServiceImpl.getUserList(user);
+		return ret;
+	}
+}

+ 26 - 0
edu-web/src/main/resources/applicationContext-aop.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context-4.0.xsd
+		http://www.springframework.org/schema/aop
+		http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
+
+    <!-- 异常捕获AOP -->
+    <bean id="exceptionAspect" class="com.edu.service.aspect.ExceptionAspect">
+        <property name="systemCode" value="101" />
+    </bean>
+    <aop:config>
+        <!-- 对运行时异常的集中处理 -->
+        <aop:aspect id="exceptionAop" ref="exceptionAspect" order="0">
+            <aop:pointcut id="exceptionPointCut"
+                          expression="execution(* com.edu.service.*.*.*(..))"/>
+            <aop:around pointcut-ref="exceptionPointCut" method="deal"/>
+        </aop:aspect>
+    </aop:config>
+
+</beans>

+ 24 - 0
edu-web/src/main/resources/applicationContext-dubbo-provider.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+       http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://code.alibabatech.com/schema/dubbo
+       http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
+	<!--<dubbo:annotation/>-->
+	<!-- 提供方应用信息,用于计算依赖关系 -->
+	<dubbo:application name="demo" logger="slf4j" />
+	<!-- 用dubbo协议在20888端口暴露服务,默认端口20880, port=-1, 当默认端口被占用,在20880端口自增1,将序列化实现设置为kryo -->
+	<dubbo:protocol name="dubbo" port="-1"/>
+	<!-- 使用zookeeper注册中心暴露服务地址 -->
+	<!--<dubbo:registry address="zookeeper://192.168.1.114:2181"/>-->
+	<dubbo:registry address="${dubbo.url}" register="true"/>
+	<!-- 声明需要暴露的服务接口 -->
+	<dubbo:service interface="com.edu.service.user.UserService" ref="userService" timeout="${dubbo.timeout}">
+	</dubbo:service>
+
+	<!-- 具体的实现bean -->
+	<bean id="userService" class="com.edu.service.user.UserServiceImpl"/>
+
+</beans>

+ 23 - 0
edu-web/src/main/resources/applicationContext-thread.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
+
+    <!-- 异步线程池 -->
+    <bean id="threadPool" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
+        <!-- 核心线程数  -->
+        <property name="corePoolSize" value="10"/>
+        <!-- 最大线程数 -->
+        <property name="maxPoolSize" value="20"/>
+        <!-- 队列最大长度 >=mainExecutor.maxSize -->
+        <property name="queueCapacity" value="1000"/>
+        <!-- 线程池维护线程所允许的空闲时间 -->
+        <property name="keepAliveSeconds" value="300"/>
+        <!-- 线程池对拒绝任务(无线程可用)的处理策略 -->
+        <property name="rejectedExecutionHandler">
+            <bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy"/>
+        </property>
+    </bean>
+
+</beans>

+ 46 - 0
edu-web/src/main/resources/applicationContext-web.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	   xmlns:context="http://www.springframework.org/schema/context"
+	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	   xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context-4.0.xsd">
+<!-- action begin -->
+	<context:component-scan base-package="com.edu.web"/>
+	<!-- action end -->
+	<bean name="requestMappingHandlerMapping"
+		  class='org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping'>
+	</bean>
+
+	<bean
+		class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
+		<property name="messageConverters">
+			<list>
+				<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
+				<bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
+					<property name="supportedMediaTypes">
+						<list>
+							<!-- 这里顺序不能反,一定先写text/html,不然ie下出现下载提示 -->
+							<value>text/html;charset=UTF-8</value>
+							<value>application/json;charset=UTF-8</value>
+						</list>
+					</property>
+				</bean>
+				<bean
+						class="org.springframework.http.converter.StringHttpMessageConverter">
+				</bean>
+				<bean
+						class="org.springframework.http.converter.ByteArrayHttpMessageConverter">
+				</bean>
+				<bean
+						class="org.springframework.http.converter.xml.SourceHttpMessageConverter">
+				</bean>
+				<bean
+						class="org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter">
+				</bean>
+			</list>
+		</property>
+	</bean>
+
+</beans>

+ 17 - 0
edu-web/src/main/resources/applicationContext.properties

@@ -0,0 +1,17 @@
+jdbc.url=jdbc:mysql://127.0.0.1:3306/demo_test?useUnicode=true&characterEncoding=UTF8&autoReconnect=true&allowMultiQueries=true
+jdbc.driver=com.mysql.jdbc.Driver
+jdbc.username=root
+jdbc.password=Jellen129
+
+pool.maxPoolSize=10
+pool.removeAbandonedTimeout=180000
+pool.maxWait=10000
+pool.timeBetweenEvictionRunsMillis=60000
+pool.minEvictableIdleTimeMillis=300000
+pool.validationQuery=select 1
+
+dubbo.timeout=10000
+dubbo.url=zookeeper://10.254.62.21:2181
+
+
+

+ 31 - 0
edu-web/src/main/resources/applicationContext.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	   xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
+
+	<!-- 加载配置application.properties-->
+	<bean id="propertyConfigure"
+		  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+		<property name="locations" value="classpath:applicationContext.properties"/>
+	</bean>
+	<!-- 引入DB数据源 -->
+	<import resource="classpath:/dataSource.xml"/>
+	<!-- 引入mongo数据源 -->
+	<!-- <import resource="classpath:/applicationContext-mongo.xml"/> -->
+	<!-- 引入业务核心域 -->
+	<!-- 引入业务集成域 -->
+	<import resource="classpath:/applicationContext-service.xml"/>
+	<!-- 引入spring动作跳转 -->
+	<import resource="classpath:/applicationContext-web.xml"/>
+	<!-- 引入系统级切面 -->
+	<import resource="classpath:/applicationContext-aop.xml"/>
+	<!-- 引入系统线程池 -->
+	<import resource="classpath:/applicationContext-thread.xml"/>
+	<!-- 引入客服rabbitmq -->
+	<!--<import resource="classpath:/applicationContext-rabbitmq.xml"/>-->
+	<!--<import resource="classpath:/applicationContext-rabbitmq-consumer.xml"/>-->
+	<!--<import resource="classpath:/applicationContext-rabbitmq-producer.xml"/>-->
+	<!-- 引入dubbo -->
+	<import resource="classpath:/applicationContext-dubbo-provider.xml"/>
+</beans>

+ 69 - 0
edu-web/src/main/resources/dataSource.xml

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	   xmlns:tx="http://www.springframework.org/schema/tx"
+	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	   xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+		http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
+
+	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
+		<property name="url" value="${jdbc.url}" />
+		<property name="driverClassName" value="${jdbc.driver}" />
+		<property name="maxActive" value="${pool.maxPoolSize}" />
+		<property name="username" value="${jdbc.username}" />
+		<property name="password" value="${jdbc.password}" />
+		<!-- 超过时间限制是否回收 -->
+		<property name="removeAbandoned" value="true" />
+		<!-- 超时时间;单位为秒。180秒=3分钟 -->
+		<property name="removeAbandonedTimeout" value="${pool.removeAbandonedTimeout}" />
+		<!-- 配置获取连接等待超时的时间 -->
+		<property name="maxWait" value="${pool.maxWait}" />
+		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
+		<property name="timeBetweenEvictionRunsMillis" value="${pool.timeBetweenEvictionRunsMillis}" />
+		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
+		<property name="minEvictableIdleTimeMillis" value="${pool.minEvictableIdleTimeMillis}" />
+		<property name="validationQuery" value="${pool.validationQuery} " />
+		<property name="testWhileIdle" value="true" />
+		<property name="testOnBorrow" value="false" />
+		<property name="testOnReturn" value="false" />
+	</bean>
+	
+	
+	<!-- 事务 控制 begin -->
+	<bean name="transactionManager"
+		  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+		<property name="dataSource" ref="dataSource"></property>
+	</bean>
+	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" order="10"/>
+	<!-- 事务 控制 end -->
+
+	<!-- 自动扫描mapping文件 start -->
+	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+		<property name="dataSource" ref="dataSource" />
+		<property name="configLocation" value="classpath:mybatis-config.xml" />
+		<!--<property name="mapperLocations" value="classpath*:com/edu/dao/**/*Mapper.xml"/>-->
+		<property name="mapperLocations">
+			<list>
+				<!-- 表示在com/hywin包或以下所有目录中,以-Mapper.xml结尾所有文件 -->
+				<value>classpath*:com/edu/dao/**/*.xml</value>
+			</list>
+		</property>
+		<property name="typeAliasesSuperType" value="com.edu.base.BaseEntity" />
+		<property name="configurationProperties">
+			<props>
+				<prop key="dialect">mysql</prop>
+			</props>
+		</property>
+		<property name="plugins">
+			<list>
+				<bean class="com.edu.mybatis.SqlInterceptor" />
+			</list>
+		</property>
+	</bean>
+	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+		<property name="basePackage" value="com.edu.dao" />
+		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
+	</bean>
+	<!-- 自动扫描mapping文件 end -->
+</beans>

+ 79 - 0
edu-web/src/main/resources/log4j2.xml

@@ -0,0 +1,79 @@
+<configuration status="OFF" monitorInterval="60">
+	<Properties>
+		<!-- 配置日志文件输出目录 -->
+		<Property name="LOG_DEBUG">/home/edu/logs/debug</Property>
+		<Property name="LOG_BIZ">/home/edu/logs/biz</Property>
+	</Properties>
+	<CustomLevels>
+		<CustomLevel name="BIZ" intLevel="50" />
+	</CustomLevels>
+	<Appenders>
+		<!--这个输出控制台的配置-->
+		<Console name="Console" target="SYSTEM_OUT">
+			<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
+		</Console>
+
+		<!-- DEBUG日志格式 -->
+		<RollingRandomAccessFile name="ROLLING_DEBUG"
+								 fileName="${LOG_DEBUG}/edu.log"
+								 filePattern="${LOG_DEBUG}/%d{yyyy-MM-dd-HH}-%i.log">
+			<!--
+                %d{yyyy-MM-dd HH:mm:ss, SSS} : 日志生产时间
+                %p : 日志输出格式
+                %c : logger的名称
+                %m : 日志内容,即 logger.info("message")
+                %n : 换行符
+                %C : Java类名
+                %L : 日志输出所在行数
+                %M : 日志输出所在方法名
+                hostName : 本地机器名
+                hostAddress : 本地ip地址
+             -->
+			<!--<PatternLayout pattern="%d %p %c{1.} [%t] %m%n"/>-->
+			<!-- 输出日志的格式 -->
+			<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
+			<Policies>
+				<TimeBasedTriggeringPolicy interval="1" modulate="true" />
+				<SizeBasedTriggeringPolicy size="10 MB"/>
+			</Policies>
+			<Filters>
+				<ThresholdFilter level="BIZ" onMatch="DENY" onMismatch="NEUTRAL"/>
+				<!--<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>-->
+			</Filters>
+			<DefaultRolloverStrategy max="20"/>
+		</RollingRandomAccessFile>
+
+		<!-- INFO日志格式 -->
+		<RollingRandomAccessFile name="ROLLING_BIZ"
+								 fileName="${LOG_BIZ}/biz.log"
+								 filePattern="${LOG_BIZ}/%d{yyyy-MM-dd-HH}-%i.log">
+			<!-- 输出日志的格式 -->
+			<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
+			<Policies>
+				<TimeBasedTriggeringPolicy interval="1" modulate="true" />
+				<SizeBasedTriggeringPolicy size="10 MB"/>
+			</Policies>
+			<Filters>
+				<ThresholdFilter level="BIZ" onMatch="ACCEPT" onMismatch="DENY"/>
+			</Filters>
+			<DefaultRolloverStrategy max="20"/>
+		</RollingRandomAccessFile>
+	</Appenders>
+
+	<Loggers>
+		<!-- 配置日志的根节点 -->
+		<root level="debug">
+			<appender-ref ref="Console"/>
+			<appender-ref ref="ROLLING_DEBUG"/>
+			<appender-ref ref="ROLLING_BIZ"/>
+		</root>
+	</Loggers>
+
+	<!-- 第三方日志系统 -->
+		<!--<logger name="org.springframework.core" level="info"/>-->
+		<!--<logger name="org.springframework.beans" level="info"/>-->
+		<!--<logger name="org.springframework.context" level="info"/>-->
+		<!--<logger name="org.springframework.web" level="info"/>-->
+		<!--<logger name="org.apache.http" level="warn"/>-->
+
+</configuration>

+ 12 - 0
edu-web/src/main/resources/mybatis-config.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE configuration
+    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+    "http://mybatis.org/dtd/mybatis-3-config.dtd">
+
+<configuration>
+    <settings>
+		<setting name="mapUnderscoreToCamelCase" value="true" />
+		<setting name="lazyLoadingEnabled" value="true"/>
+		<setting name="aggressiveLazyLoading" value="false"/>  <!-- 按需加载对象 -->
+	</settings>
+</configuration>

+ 49 - 0
edu-web/src/main/webapp/WEB-INF/web.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
+  <filter>
+    <filter-name>characterEncodingFilter</filter-name>
+    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
+    <init-param>
+      <param-name>encoding</param-name>
+      <param-value>UTF-8</param-value>
+    </init-param>
+    <init-param>
+      <param-name>forceEncoding</param-name>
+      <param-value>true</param-value>
+    </init-param>
+  </filter>
+  <!--<filter>-->
+    <!--<filter-name>tidFilter</filter-name>-->
+    <!--<filter-class>com.mobanker.core.web.spring.filter.HttpTransactionFilter</filter-class>-->
+  <!--</filter>-->
+  <filter-mapping>
+    <filter-name>characterEncodingFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+  <!--<filter-mapping>-->
+    <!--<filter-name>tidFilter</filter-name>-->
+    <!--<url-pattern>/*</url-pattern>-->
+  <!--</filter-mapping>-->
+  <servlet>
+    <servlet-name>dispatcherServlet</servlet-name>
+    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+    <init-param>
+      <param-name>contextConfigLocation</param-name>
+      <param-value>classpath:applicationContext.xml</param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>dispatcherServlet</servlet-name>
+    <url-pattern>/*</url-pattern>
+  </servlet-mapping>
+  <display-name>demoapi</display-name>
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+    <welcome-file>default.html</welcome-file>
+    <welcome-file>default.htm</welcome-file>
+    <welcome-file>default.jsp</welcome-file>
+  </welcome-file-list>
+</web-app>

+ 5 - 0
edu-web/src/main/webapp/index.jsp

@@ -0,0 +1,5 @@
+<html>
+<body>
+<h2>Hello World!</h2>
+</body>
+</html>

+ 21 - 0
edu-web/src/test/java/com/edu/base/BaseControllerTest.java

@@ -0,0 +1,21 @@
+package com.edu.base;
+
+import org.junit.Before;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Created by KangJellen on 2017/5/4.
+ */
+public class BaseControllerTest extends BaseTest {
+    public MockMvc mockMvc;
+    @Autowired
+    private WebApplicationContext wac;
+    @Before()
+    public void setUp() {
+        mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+    }
+
+}

+ 18 - 0
edu-web/src/test/java/com/edu/base/BaseTest.java

@@ -0,0 +1,18 @@
+package com.edu.base;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(locations = {"classpath:applicationContext-test.xml"})
+public abstract class BaseTest extends AbstractTransactionalJUnit4SpringContextTests {
+
+    protected final Logger logger = LogManager.getLogger(this.getClass());
+
+}

+ 112 - 0
edu-web/src/test/java/com/edu/controller/UserControllerTest.java

@@ -0,0 +1,112 @@
+package com.edu.controller;
+
+import com.edu.service.user.UserService;
+import com.edu.base.BaseControllerTest;
+import com.edu.base.ResponseEntity;
+import com.edu.user.pojo.User;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.Rollback;
+
+import java.util.LinkedList;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+/**
+ *
+ */
+public class UserControllerTest extends BaseControllerTest {
+
+//    @Mock
+    @Autowired
+    private UserService userService;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        super.setUp();
+    }
+
+    @Test
+    public void getUser() {
+        ResponseEntity resp = userService.getNameById(1L);
+        super.logger.info("用户数据:", resp);
+    }
+
+
+    @Test
+    public void testAdd() {
+        Long id = 1L;
+        String name = "test";
+
+        User user = new User();
+        user.setId(id);
+        user.setName(name);
+
+//        when(userService.getNameById(id)).thenReturn(new ResponseEntity("test"));
+
+        ResponseEntity retDa = userService.getNameById(id);
+        //assertEquals("test1", retDa.getData());
+
+        //verify(userService).getNameById(id);
+        // 模拟LinkedList 的一个对象
+        LinkedList mockedList = mock(LinkedList.class);
+        System.out.println(mockedList.get(999));
+        when(mockedList.get(0)).thenReturn("first");
+        System.out.println(mockedList.get(0));
+
+        // anyInt()匹配任何int参数,这意味着参数为任意值,其返回值均是element
+        when(mockedList.get(anyInt())).thenReturn("element");
+
+        // 此时打印是element
+        System.out.println(mockedList.get(999));
+        System.out.println(mockedList.get(909));
+
+        // 调用add一次
+        mockedList.add("once");
+        verify(mockedList).add("once");
+//		verify(mockedList, times(1)).add("once");
+    }
+
+    @Test
+    @Rollback(false)
+    public void getUserName() {
+        try {
+//			MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
+//					.get("/user/getUserName");
+//
+//			requestBuilder.param("id", "5");
+//			requestBuilder.characterEncoding("UTF-8");
+
+//			MvcResult result = mockMvc.perform(get("/user/getUserName/{id}", 5)).andReturn();
+//			mockMvc.perform(get("/user/getUserName/{id}", 5))
+//			.andDo(print())
+//					.andExpect(status().isOk())
+//					.andExpect(jsonPath("code").value("000000"));
+
+            mockMvc.perform(get("/user/getUserList?userCode=ex"))
+                    .andDo(print())
+                    .andExpect(status().isOk())
+                    .andExpect(jsonPath("code").value("000000"))
+            ;
+
+//			ResponseEntity ret = new ResponseEntity("test");
+//			when(userService.getNameById(5L)).thenReturn(ret);
+
+
+//			String content = result.getResponse().getContentAsString();
+//			System.out.println("test--------------" + content);
+//			logger.debug("result :{}" + result.getResponse().getContentAsString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 29 - 0
edu-web/src/test/resources/applicationContext-test.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	   xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
+
+	<!-- 加载配置application.properties-->
+	<bean id="propertyConfigure"
+		  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+		<property name="locations" value="classpath:applicationContext.properties"/>
+	</bean>
+	<!-- 引入DB数据源 -->
+	<import resource="classpath:/dataSource.xml"/>
+	<!-- 引入mongo数据源 -->
+	<!-- <import resource="classpath:/applicationContext-mongo.xml"/> -->
+	<!-- 引入业务核心域 -->
+	<!-- 引入业务集成域 -->
+	<import resource="classpath:/applicationContext-service.xml"/>
+	<!-- 引入spring动作跳转 -->
+	<import resource="classpath:/applicationContext-web.xml"/>
+	<!-- 引入系统级切面 -->
+	<import resource="classpath:/applicationContext-aop.xml"/>
+	<!-- 引入系统线程池 -->
+	<import resource="classpath:/applicationContext-thread.xml"/>
+	<!-- 引入客服rabbitmq -->
+	<!--<import resource="classpath:/applicationContext-rabbitmq.xml"/>-->
+	<!--<import resource="classpath:/applicationContext-rabbitmq-consumer.xml"/>-->
+	<!--<import resource="classpath:/applicationContext-rabbitmq-producer.xml"/>-->
+</beans>

+ 89 - 0
edu-web/src/test/resources/log4j2.xml

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    status : 这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,会看到log4j2内部各种详细输出
+    monitorInterval : Log4j能够自动检测修改配置文件和重新配置本身, 设置间隔秒数。
+-->
+<Configuration status="WARN" monitorInterval="600">
+
+	<Properties>
+		<!-- 配置日志文件输出目录 -->
+		<Property name="LOG_HOME">/Users/edu/logs</Property>
+	</Properties>
+
+	<Appenders>
+
+		<!--这个输出控制台的配置-->
+		<Console name="Console" target="SYSTEM_OUT">
+			<!-- 控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
+			<ThresholdFilter level="trace" onMatch="ACCEPT" onMismatch="DENY"/>
+			<!-- 输出日志的格式 -->
+			<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
+		</Console>
+
+		<!-- 设置日志格式并配置日志压缩格式(service.log.年份.gz) -->
+		<RollingRandomAccessFile name="service_appender"
+								 immediateFlush="false" fileName="${LOG_HOME}/service.log"
+								 filePattern="${LOG_HOME}/service.log.%d{yyyy-MM-dd}.log.gz">
+			<!--
+                %d{yyyy-MM-dd HH:mm:ss, SSS} : 日志生产时间
+                %p : 日志输出格式
+                %c : logger的名称
+                %m : 日志内容,即 logger.info("message")
+                %n : 换行符
+                %C : Java类名
+                %L : 日志输出所在行数
+                %M : 日志输出所在方法名
+                hostName : 本地机器名
+                hostAddress : 本地ip地址
+             -->
+			<PatternLayout>
+				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M -- %msg%xEx%n</pattern>
+			</PatternLayout>
+			<Policies>
+				<TimeBasedTriggeringPolicy interval="1" modulate="true" />
+			</Policies>
+		</RollingRandomAccessFile>
+
+
+		<!-- DEBUG日志格式 -->
+		<RollingRandomAccessFile name="service_debug_appender"
+								 immediateFlush="true" fileName="${LOG_HOME}/service.log"
+								 filePattern="${LOG_HOME}/service.log.%d{yyyy-MM-dd}.debug.gz">
+			<PatternLayout>
+				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M -- %msg%xEx%n</pattern>
+			</PatternLayout>
+			<Policies>
+				<TimeBasedTriggeringPolicy interval="1" modulate="true" />
+			</Policies>
+		</RollingRandomAccessFile>
+	</Appenders>
+
+	<Loggers>
+		<!-- 配置日志的根节点 -->
+		<root level="debug">
+			<appender-ref ref="Console"/>
+		</root>
+
+		<!-- 第三方日志系统 -->
+		<logger name="org.springframework.core" level="info"/>
+		<logger name="org.springframework.beans" level="info"/>
+		<logger name="org.springframework.context" level="info"/>
+		<logger name="org.springframework.web" level="info"/>
+		<logger name="org.jboss.netty" level="warn"/>
+		<logger name="org.apache.http" level="warn"/>
+
+		<!-- 日志实例(info),其中'service-log'继承root,但是root将日志输出控制台,而'service-log'将日志输出到文件,通过属性'additivity="false"'将'service-log'的
+             的日志不再输出到控制台 -->
+		<!--<logger name="service_log" level="info" includeLocation="true" additivity="false">-->
+			<!--<appender-ref ref="service_appender"/>-->
+		<!--</logger>-->
+
+		<!-- 日志实例(debug) -->
+		<logger name="service_log" level="debug" includeLocation="true" additivity="true">
+			<appender-ref ref="service_debug_appender"/>
+		</logger>
+
+	</Loggers>
+
+</Configuration>

+ 61 - 0
pom.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.edu</groupId>
+    <artifactId>vtrt-edu</artifactId>
+    <packaging>pom</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <modules>
+        <module>edu-web</module>
+        <module>edu-service</module>
+        <module>edu-dao</module>
+        <module>edu-dubbo</module>
+        <module>edu-common</module>
+        <module>edu-model</module>
+    </modules>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>2.1</version>
+                <configuration>
+                    <attach>true</attach>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- maven打包跳过test包 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.18.1</version>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>