Commit 5af88485 by gechengyang

init

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="src/main/webapp/WEB-INF/lib/ojdbc6-12.1.0.2.jar"/>
<classpathentry kind="lib" path="src/main/webapp/WEB-INF/lib/orai18n-12.1.0.2.jar"/>
<classpathentry kind="lib" path="src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.44.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
target
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>remit</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="src/main/webapp"/>
<classpathentry kind="src" path="target/m2e-wtp/web-resources"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
eclipse.preferences.version=1
org.eclipse.m2e.wtp.enabledProjectSpecificPrefs=false
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="remit">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="java-output-path" value="/remit/target/classes"/>
<property name="context-root" value="remit"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.8"/>
</faceted-project>
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Window
\ No newline at end of file
disabled=06target
eclipse.preferences.version=1
eclipse.preferences.version=1
org.eclipse.wst.ws.service.policy.projectEnabled=false
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="context1">
<!-- connectionURL="jdbc:mysql://114.115.138.98:3306/health?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false" -->
<jdbcConnection
connectionURL="jdbc:mysql://114.115.138.98:3306/health?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false"
driverClass="com.mysql.jdbc.Driver" password="666666" userId="root" />
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL
和 NUMERIC 类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:生成PO类的位置 -->
<javaModelGenerator targetPackage="com.brilliance.remit.db.model"
targetProject="remit/src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<!-- <property name="enableSubPackages" value="false" /> -->
<!-- 从数据库返回的值被清理前后的空格 -->
<!-- <property name="trimStrings" value="true" /> -->
</javaModelGenerator>
<!-- targetProject:mapper映射文件生成的位置 -->
<sqlMapGenerator targetPackage="com.brilliance.remit.db.mapper"
targetProject="remit/src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- targetPackage:mapper接口生成的位置 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.brilliance.remit.db.dao" targetProject="remit/src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- 指定数据库表 -->
<table enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false" tableName="fam_health_record">
<property name="useActualColumnNames" value="true" />
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.brilliance</groupId>
<artifactId>remit</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>remit</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- spring版本号 -->
<spring.version>5.1.3.RELEASE</spring.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<!-- dbcp数据库连接池  -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>52.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-jmx</artifactId>
<version>4.2.2.GA</version>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-system</artifactId>
<version>4.2.2.GA</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.2.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.21.0-GA</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</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-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>business</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.brilliance.remit.common;
public class Constants {
public final static String PARAMS = "params";
public final static String DATA = "data";
public final static String USERNAME = "username";
public final static String PASSWORD = "password";
public final static String MAPPING_PRE = "_";
}
package com.brilliance.remit.common.exception;
@SuppressWarnings("serial")
public class RemitException extends RuntimeException {
private String errorCode;
public RemitException() {
super();
}
public RemitException(String message, Throwable cause) {
super(message, cause);
}
public RemitException(String message) {
super(message);
}
public RemitException(Throwable cause) {
super(cause);
}
public RemitException(Throwable cause, String errorCode) {
super(cause);
this.errorCode = errorCode;
}
public RemitException(String message, String errorCode) {
super(message);
this.errorCode = errorCode;
}
public RemitException(String message, Throwable cause, String errorCode) {
super(message, cause);
this.errorCode = errorCode;
}
public String getErrorCode() {
return errorCode;
}
}
package com.brilliance.remit.common.filter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
public class Cors extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.addHeader("Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept");
return true;
}
}
package com.brilliance.remit.common.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
public class CorsFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.addHeader("Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept");
chain.doFilter(req, res);
}
public void init(FilterConfig filterConfig) {}
public void destroy() {}
}
package com.brilliance.remit.common.jwt;
import java.util.HashMap;
import java.util.Map;
import com.auth0.jwt.JWTSigner;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.internal.com.fasterxml.jackson.databind.ObjectMapper;
public class JWT {
private static final String SECRET = "XX#$%()(#*!()!KL<><MQLMNQNQJQK sdfkjsdrow32234545fdf>?N<:{LWPW";
private static final String EXP = "exp";
private static final String PAYLOAD = "payload";
// 加密,传入一个对象和有效期
public static <T> String sign(T object, long maxAge) {
try {
final JWTSigner signer = new JWTSigner(SECRET);
final Map<String, Object> claims = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(object);
claims.put(PAYLOAD, jsonString);
claims.put(EXP, System.currentTimeMillis() + maxAge);
return signer.sign(claims);
} catch (Exception e) {
return null;
}
}
// 解密,传入一个加密后的token字符串和解密后的类型
public static <T> T unsign(String jwt, Class<T> classT) {
final JWTVerifier verifier = new JWTVerifier(SECRET);
try {
final Map<String, Object> claims = verifier.verify(jwt);
if (claims.containsKey(EXP) && claims.containsKey(PAYLOAD)) {
long exp = (Long) claims.get(EXP);
long currentTimeMillis = System.currentTimeMillis();
if (exp > currentTimeMillis) {
String json = (String) claims.get(PAYLOAD);
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(json, classT);
}
}
return null;
} catch (Exception e) {
return null;
}
}
}
package com.brilliance.remit.common.jwt;
public class JwtLogin {
private String userId;
private String password;
private String token;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
package com.brilliance.remit.common.jwt;
import java.io.Serializable;
public class RedisLoginInfo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 8116817810829835862L;
/**
* 用户id
*/
private String userId;
/**
* jwt生成的token信息
*/
private String token;
/**
* 登录或刷新应用的时间
*/
private long expiredTime;
private Object sysmod;
public RedisLoginInfo() {
}
public RedisLoginInfo(String userId, String token, long expiredTime, Object sysmod) {
this.userId = userId;
this.token = token;
this.expiredTime = expiredTime;
this.sysmod = sysmod;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getUserId() {
return userId;
}
public long getExpiredTime() {
return expiredTime;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setExpiredTime(long expiredTime) {
this.expiredTime = expiredTime;
}
public Object getSysmod() {
return sysmod;
}
public void setSysmod(Object sysmod) {
this.sysmod = sysmod;
}
}
\ No newline at end of file
package com.brilliance.remit.common.jwt;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.brilliance.remit.common.response.ErrorCodes;
import com.brilliance.remit.common.response.Result;
import com.brilliance.remit.common.util.NumericUtil;
import com.brilliance.remit.common.util.RedisUtil;
import com.brilliance.remit.common.util.StringUtil;
import com.google.gson.Gson;
public class TokenInterceptor implements HandlerInterceptor {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception arg3) throws Exception {
}
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView model) throws Exception {
}
// 拦截每个请求
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
response.setCharacterEncoding("utf-8");
String token = request.getHeader("token");
String userId = request.getHeader("userId");
String terminalType = request.getHeader("terminalType");
// token不存在
if (StringUtil.isEmpty(token)) {
Result rt = new Result(ErrorCodes.ERROR, "登录token不能为空", null);
responseMessage(response, response.getWriter(), rt);
return false;
}
// userId不存在
if (StringUtil.isEmpty(token)) {
Result rt = new Result(ErrorCodes.ERROR, "用户id不能为空", null);
responseMessage(response, response.getWriter(), rt);
return false;
}
JwtLogin login = JWT.unsign(token, JwtLogin.class);
if (login == null || (!userId.equals((login.getUserId())))) {
Result rt = new Result(ErrorCodes.ERROR, "用户token或ID验证不通过", null);
responseMessage(response, response.getWriter(), rt);
return false;
}
RedisLoginInfo redisLoginInfo = (RedisLoginInfo) RedisUtil.get(StringUtil.userUniqueId(userId, terminalType));
if (redisLoginInfo == null) {
Result rt = new Result(ErrorCodes.ERROR, "登陆异常", null);
responseMessage(response, response.getWriter(), rt);
return false;
}
// 验证登录时间
if (System.currentTimeMillis() > redisLoginInfo.getExpiredTime()) {
Result rt = new Result(ErrorCodes.ERROR, "登录时间超长,请重新登录", null);
responseMessage(response, response.getWriter(), rt);
return false;
}
// 重新刷入登陆时间
RedisLoginInfo nweRedisLoginInfo = new RedisLoginInfo(userId, token, NumericUtil.sessionTimeOut(), redisLoginInfo.getSysmod());
RedisUtil.set(userId + "." + terminalType, nweRedisLoginInfo);
return true;
}
// 请求不通过,返回错误信息给客户端
private void responseMessage(HttpServletResponse response, PrintWriter out, Result result) {
response.setContentType("application/json; charset=utf-8");
String json = new Gson().toJson(result);
out.print(json);
out.flush();
out.close();
}
}
\ No newline at end of file
package com.brilliance.remit.common.response;
public class ErrorCodes {
public static final String SUCCESS = "00000";
public static final String SUCCESS_INFO = "success";
public static final String NOT_LOGIN = "R0001";
// public static final String NO_SESSION = "R0002";
public static final String LOGIN_ERROR = "R0003";
public static final String NOT_FOUND_DATA = "R0004";
public static final String DATA_TYPE_ERROR = "R0005";
public static final String CHAIN_ERROR = "R0006";
public static final String INPUT_ERROR = "R0007";
public static final String LOGOUT_ERROR = "R0008";
public static final String MESSAGE_ERROR = "R0009";
public static final String ON_CLICK_ERROR = "R0010";
public static final String ON_DbCLICK_ERROR = "R0011";
public static final String ON_UPLOAD_ERROR = "R0012";
public static final String PROMPT_ERROR = "R0013";
public static final String DISPLAY_ERROR = "R0014";
public static final String UNCORRECT_DATA_FORMAT = "R0015";
public static final String UNSUPPORTED_DATA_TYPE = "R0016";
public static final String INTERRUPTED_ERROR = "R9997";
public static final String REDIS_CONNECTION_ERROR = "R9998";
public static final String ERROR = "R9999";
}
package com.brilliance.remit.common.response;
import java.util.Map;
public class Result {
private String retcod;
private String retmsg;
private Map<String, Object> error;// 错误信息
private Map<String, Object> codetable;
private Object data;
public Result(String retcod, String retmsg, Object data) {
this.retcod = retcod;
this.retmsg = retmsg;
this.data = data;
}
public Result(String retcod, String retmsg, Map<String, Object> error, Map<String, Object> codetable, Object data) {
this.retcod = retcod;
this.retmsg = retmsg;
this.error = error;
this.codetable = codetable;
this.data = data;
}
public String getRetcod() {
return retcod;
}
public String getRetmsg() {
return retmsg;
}
public void setRetcod(String retcod) {
this.retcod = retcod;
}
public void setRetmsg(String retmsg) {
this.retmsg = retmsg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public Map<String, Object> getError() {
return error;
}
public Map<String, Object> getCodetable() {
return codetable;
}
public void setError(Map<String, Object> error) {
this.error = error;
}
public void setCodetable(Map<String, Object> codetable) {
this.codetable = codetable;
}
}
package com.brilliance.remit.common.response;
import java.util.Map;
public class ResultUtil {
public static Result result(String retcod, String retmsg, Object data) {
return new Result(retcod, retmsg, data);
}
public static Result result(String retcod, String retmsg, Map<String, Object> data, Map<String, Object> error, Map<String, Object> codetable) {
return new Result(retcod, retmsg, error, codetable, data);
}
}
package com.brilliance.remit.common.util;
public class NumericUtil {
public static long sessionTimeOut() {
return System.currentTimeMillis() + RedisUtil.getSessionTimeOut() * 1000;
}
}
package com.brilliance.remit.common.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.io.IOUtils;
/**
* Properties文件工具
*
* @author xiaoyuanzhen
*
*/
public class PropertyUtil {
/**
* 从properties文件中获取指定属性名对应的值
*
* @param propertyFile
* @param propertyName
* @return
*/
private static Map<String, Properties> map = new HashMap<String, Properties>();
public static String getProperty(String propertyFile, String propertyName) {
String propertyValue = "";
InputStream is = null;
try {
Properties propertie = new Properties();
if (!map.containsKey(propertyFile)) {
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFile);
propertie.load(is);
map.put(propertyFile, propertie);
}
propertyValue = map.get(propertyFile).getProperty(propertyName);
} catch (Exception e) {
e.printStackTrace();
propertyValue = "";
} finally {
try {
IOUtils.closeQuietly(is);
} catch (Exception e) {
e.printStackTrace();
}
}
return propertyValue;
}
/**
* 设置properties文件的某个属性值
*
* @param propertyFile
* @param propertyName
* @param propertyValue
* @return
*/
public synchronized static boolean setProperty(String propertyFile, String propertyName, String propertyValue) {
boolean sav = false;
InputStream is = null;
OutputStream os = null;
try {
Properties propertie = new Properties();
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFile);
propertie.load(is);
propertie.setProperty(propertyName, propertyValue);
String path = Thread.currentThread().getContextClassLoader().getResource(propertyFile).getPath();
os = new FileOutputStream(new File(path));
propertie.store(os, "");
os.flush();
sav = true;
} catch (Exception e) {
e.printStackTrace();
sav = false;
} finally {
try {
is.close();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return sav;
}
public synchronized static boolean setPropertyValue(String propertyFile, String propertyName, String propertyValue) {
boolean sav = false;
OutputStream os = null;
InputStream is = null;
try {
Properties propertie = new Properties();
is = new FileInputStream(new File(propertyFile));
propertie.load(is);
propertie.setProperty(propertyName, propertyValue);
os = new FileOutputStream(new File(propertyFile));
propertie.store(os, "");
os.flush();
sav = true;
} catch (Exception e) {
e.printStackTrace();
propertyValue = "";
} finally {
try {
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return sav;
}
private static Properties load(File f, String encoding) throws IOException {
Properties propertie = new Properties();
InputStreamReader is = new InputStreamReader(new FileInputStream(f), encoding);
propertie.load(is);
is.close();
return propertie;
}
private static Properties load(File f) throws IOException {
return load(f, "GBK");
}
public static Properties load(String name) throws IOException {
InputStream is = null;
Properties propertie = new Properties();
try {
if (!map.containsKey(name)) {
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
propertie.load(is);
map.put(name, propertie);
} else {
return map.get(name);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
IOUtils.closeQuietly(is);
} catch (Exception e) {
e.printStackTrace();
}
}
return propertie;
}
public static Properties getProperties(String propertyFile) throws IOException {
return getProperties(propertyFile, "GBK");
}
public static Properties getProperties(String propertyFile, String encoding) throws IOException {
return load(new File(propertyFile), encoding);
}
public static String getPropertyValue(String propertyFile, String propertyName) {
String propertyValue = "";
// InputStream is = null;
try {
Properties propertie = load(new File(propertyFile));
propertyValue = propertie.getProperty(propertyName);
} catch (Exception e) {
e.printStackTrace();
propertyValue = "";
}
return propertyValue;
}
}
package com.brilliance.remit.common.util;
import java.util.Properties;
import com.brilliance.remit.common.jwt.RedisLoginInfo;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
* Redis连接池工具类
*/
public class RedisUtil {
private static JedisPool jedisPool = null;
private static String redisConfigFile = "redis.properties";
// 把redis连接对象放到本地线程中
private static int sessionTimeOut = 1800;
static {
initialPool();
}
public static int getSessionTimeOut() {
return sessionTimeOut;
}
/**
* 初始化Redis连接池
*/
private static void initialPool() {
try {
Properties props = new Properties();
// 加载连接池配置文件
props.load(RedisUtil.class.getClassLoader().getResourceAsStream(redisConfigFile));
sessionTimeOut = Integer.valueOf(props.getProperty("sessionTimeOut"));
// 创建jedis池配置实例
JedisPoolConfig config = new JedisPoolConfig();
// 设置池配置项值
config.setMaxTotal(Integer.valueOf(props.getProperty("jedis.pool.maxActive")));
config.setMaxIdle(Integer.valueOf(props.getProperty("jedis.pool.maxIdle")));
config.setMaxWaitMillis(Long.valueOf(props.getProperty("jedis.pool.maxWait")));
config.setTestOnBorrow(Boolean.valueOf(props.getProperty("jedis.pool.testOnBorrow")));
config.setTestOnReturn(Boolean.valueOf(props.getProperty("jedis.pool.testOnReturn")));
// 根据配置实例化jedis池
String password = props.getProperty("redis.passWord");
if (StringUtil.isEmpty(password))
jedisPool = new JedisPool(config, props.getProperty("redis.ip"), Integer.valueOf(props.getProperty("redis.port")),
Integer.valueOf(props.getProperty("redis.timeout")));
else
jedisPool = new JedisPool(config, props.getProperty("redis.ip"), Integer.valueOf(props.getProperty("redis.port")),
Integer.valueOf(props.getProperty("redis.timeout")), password);
System.out.println("线程池被成功初始化");
} catch (Exception e) {
e.printStackTrace();
}
}
public static void set(String key, Object value) {
Jedis jedis = jedisPool.getResource();
jedis.set(key.getBytes(), SerializeUtil.serialize(value));
jedis.expire(key, sessionTimeOut);
jedis.close();
}
public static Object get(String key) {
Jedis jedis = jedisPool.getResource();
Object getObj = jedis.get(key.getBytes());
Object obj = SerializeUtil.unserialize((byte[]) getObj);
jedis.close();
return obj;
}
public static void main(String[] args) {
RedisLoginInfo info = new RedisLoginInfo();
info.setExpiredTime(1000);
info.setSysmod(null);
info.setToken("123");
info.setUserId("zz");
RedisUtil.set("ABC", info);
System.out.println(RedisUtil.get("ABC"));
}
}
\ No newline at end of file
package com.brilliance.remit.common.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.apache.commons.io.IOUtils;
public class SerializeUtil {
public static byte[] serialize(Object object) {
ObjectOutputStream oos = null;
ByteArrayOutputStream baos = null;
byte[] bytes = null;
try {
// 序列化
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(object);
bytes = baos.toByteArray();
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(oos);
}
return bytes;
}
public static Object unserialize(byte[] bytes) {
ByteArrayInputStream bais = null;
ObjectInputStream ois = null;
Object obj = null;
try {
// 反序列化
bais = new ByteArrayInputStream(bytes);
ois = new ObjectInputStream(bais);
obj = ois.readObject();
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(ois);
}
return obj;
}
}
package com.brilliance.remit.common.util;
public class StringUtil {
public static boolean isEmpty(String str) {
if (str == null || str.trim().equals(""))
return true;
return false;
}
public static String userUniqueId(String userId, String terminalType) {
return userId + "." + terminalType;
}
}
package com.brilliance.remit.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.brilliance.remit.common.Constants;
import com.brilliance.remit.common.exception.RemitException;
import com.brilliance.remit.common.jwt.JWT;
import com.brilliance.remit.common.jwt.JwtLogin;
import com.brilliance.remit.common.jwt.RedisLoginInfo;
import com.brilliance.remit.common.response.ErrorCodes;
import com.brilliance.remit.common.response.ResultUtil;
import com.brilliance.remit.common.util.NumericUtil;
import com.brilliance.remit.common.util.RedisUtil;
import com.brilliance.remit.common.util.StringUtil;
@Controller
public class LoginController {
private static final Log log = LogFactory.getLog(LoginController.class);
@ResponseBody
@RequestMapping(value = "/login", method = RequestMethod.POST)
public Object login(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) {
System.out.println(dataMap);
Map<String, Object> map = new HashMap<String, Object>();
String userId = dataMap.get(Constants.USERNAME).toString();
String terminalType = request.getHeader("terminalType");
String password = dataMap.get(Constants.PASSWORD).toString();
boolean loginSuccess = true;
try {
if (loginSuccess) {
JwtLogin login = new JwtLogin();
login.setUserId(userId);
login.setPassword(password);
// 给用户jwt加密生成token
String token = JWT.sign(login, 60L * 1000L * 30L);
Map<String, Object> retDatamap = new HashMap<String, Object>();
retDatamap.put("token", token);
// redis中存储用户相关信息
RedisLoginInfo redisLoginInfo = new RedisLoginInfo(userId, token, NumericUtil.sessionTimeOut(), null);
RedisUtil.set(StringUtil.userUniqueId(userId, terminalType), redisLoginInfo);
return ResultUtil.result(ErrorCodes.SUCCESS, ErrorCodes.SUCCESS_INFO, retDatamap);
}
} catch (Exception e) {
log.error("Login command error", e);
throw new RemitException("Login command error", e);
}
log.debug("Login command is finished");
return ResultUtil.result(ErrorCodes.ERROR, "login failed", null);
}
}
package com.brilliance.remit.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.brilliance.remit.common.response.ErrorCodes;
import com.brilliance.remit.common.response.ResultUtil;
import com.brilliance.remit.service.RemitService;
@Controller
public class RemitController {
@Autowired
private RemitService remitService;
private static final Log log = LogFactory.getLog(RemitController.class);
@ResponseBody
@RequestMapping(value = "/test", method = RequestMethod.GET)
public Object login(HttpServletRequest request, HttpSession session) {
remitService.test();
return ResultUtil.result(ErrorCodes.SUCCESS, "ok", null);
}
@ResponseBody
@RequestMapping(value = "/tet1", method = RequestMethod.GET)
public Object login(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) {
System.out.println(dataMap);
remitService.test();
return ResultUtil.result(ErrorCodes.SUCCESS, "ok", null);
}
}
package com.brilliance.remit.db.dao;
import com.brilliance.remit.db.model.FamHealthRecord;
public interface FamHealthRecordMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table fam_health_record
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
int deleteByPrimaryKey(String FAM_HEALTH_RECORD_ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table fam_health_record
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
int insert(FamHealthRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table fam_health_record
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
int insertSelective(FamHealthRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table fam_health_record
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
FamHealthRecord selectByPrimaryKey(String FAM_HEALTH_RECORD_ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table fam_health_record
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
int updateByPrimaryKeySelective(FamHealthRecord record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table fam_health_record
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
int updateByPrimaryKey(FamHealthRecord record);
}
\ No newline at end of file
<?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.brilliance.remit.db.dao.FamHealthRecordMapper">
<resultMap id="BaseResultMap" type="com.brilliance.remit.db.model.FamHealthRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
<id column="FAM_HEALTH_RECORD_ID" jdbcType="CHAR" property="FAM_HEALTH_RECORD_ID" />
<result column="USR_ID" jdbcType="CHAR" property="USR_ID" />
<result column="ENV_HOS" jdbcType="VARCHAR" property="ENV_HOS" />
<result column="LOW_TYP" jdbcType="CHAR" property="LOW_TYP" />
<result column="LOC_STA" jdbcType="VARCHAR" property="LOC_STA" />
<result column="AVG_MONEY" jdbcType="VARCHAR" property="AVG_MONEY" />
<result column="HOS_SIZE" jdbcType="VARCHAR" property="HOS_SIZE" />
<result column="OIL" jdbcType="VARCHAR" property="OIL" />
<result column="SOLT" jdbcType="VARCHAR" property="SOLT" />
<result column="DOCTOR_ID" jdbcType="VARCHAR" property="DOCTOR_ID" />
<result column="UPLOAD_FLG" jdbcType="CHAR" property="UPLOAD_FLG" />
<result column="CRE_DAT" jdbcType="VARCHAR" property="CRE_DAT" />
<result column="DATAFLG" jdbcType="CHAR" property="DATAFLG" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
FAM_HEALTH_RECORD_ID, USR_ID, ENV_HOS, LOW_TYP, LOC_STA, AVG_MONEY, HOS_SIZE, OIL,
SOLT, DOCTOR_ID, UPLOAD_FLG, CRE_DAT, DATAFLG
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
select
<include refid="Base_Column_List" />
from fam_health_record
where FAM_HEALTH_RECORD_ID = #{FAM_HEALTH_RECORD_ID,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
delete from fam_health_record
where FAM_HEALTH_RECORD_ID = #{FAM_HEALTH_RECORD_ID,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="com.brilliance.remit.db.model.FamHealthRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
insert into fam_health_record (FAM_HEALTH_RECORD_ID, USR_ID, ENV_HOS,
LOW_TYP, LOC_STA, AVG_MONEY,
HOS_SIZE, OIL, SOLT,
DOCTOR_ID, UPLOAD_FLG, CRE_DAT,
DATAFLG)
values (#{FAM_HEALTH_RECORD_ID,jdbcType=CHAR}, #{USR_ID,jdbcType=CHAR}, #{ENV_HOS,jdbcType=VARCHAR},
#{LOW_TYP,jdbcType=CHAR}, #{LOC_STA,jdbcType=VARCHAR}, #{AVG_MONEY,jdbcType=VARCHAR},
#{HOS_SIZE,jdbcType=VARCHAR}, #{OIL,jdbcType=VARCHAR}, #{SOLT,jdbcType=VARCHAR},
#{DOCTOR_ID,jdbcType=VARCHAR}, #{UPLOAD_FLG,jdbcType=CHAR}, #{CRE_DAT,jdbcType=VARCHAR},
#{DATAFLG,jdbcType=CHAR})
</insert>
<insert id="insertSelective" parameterType="com.brilliance.remit.db.model.FamHealthRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
insert into fam_health_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="FAM_HEALTH_RECORD_ID != null">
FAM_HEALTH_RECORD_ID,
</if>
<if test="USR_ID != null">
USR_ID,
</if>
<if test="ENV_HOS != null">
ENV_HOS,
</if>
<if test="LOW_TYP != null">
LOW_TYP,
</if>
<if test="LOC_STA != null">
LOC_STA,
</if>
<if test="AVG_MONEY != null">
AVG_MONEY,
</if>
<if test="HOS_SIZE != null">
HOS_SIZE,
</if>
<if test="OIL != null">
OIL,
</if>
<if test="SOLT != null">
SOLT,
</if>
<if test="DOCTOR_ID != null">
DOCTOR_ID,
</if>
<if test="UPLOAD_FLG != null">
UPLOAD_FLG,
</if>
<if test="CRE_DAT != null">
CRE_DAT,
</if>
<if test="DATAFLG != null">
DATAFLG,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="FAM_HEALTH_RECORD_ID != null">
#{FAM_HEALTH_RECORD_ID,jdbcType=CHAR},
</if>
<if test="USR_ID != null">
#{USR_ID,jdbcType=CHAR},
</if>
<if test="ENV_HOS != null">
#{ENV_HOS,jdbcType=VARCHAR},
</if>
<if test="LOW_TYP != null">
#{LOW_TYP,jdbcType=CHAR},
</if>
<if test="LOC_STA != null">
#{LOC_STA,jdbcType=VARCHAR},
</if>
<if test="AVG_MONEY != null">
#{AVG_MONEY,jdbcType=VARCHAR},
</if>
<if test="HOS_SIZE != null">
#{HOS_SIZE,jdbcType=VARCHAR},
</if>
<if test="OIL != null">
#{OIL,jdbcType=VARCHAR},
</if>
<if test="SOLT != null">
#{SOLT,jdbcType=VARCHAR},
</if>
<if test="DOCTOR_ID != null">
#{DOCTOR_ID,jdbcType=VARCHAR},
</if>
<if test="UPLOAD_FLG != null">
#{UPLOAD_FLG,jdbcType=CHAR},
</if>
<if test="CRE_DAT != null">
#{CRE_DAT,jdbcType=VARCHAR},
</if>
<if test="DATAFLG != null">
#{DATAFLG,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.brilliance.remit.db.model.FamHealthRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
update fam_health_record
<set>
<if test="USR_ID != null">
USR_ID = #{USR_ID,jdbcType=CHAR},
</if>
<if test="ENV_HOS != null">
ENV_HOS = #{ENV_HOS,jdbcType=VARCHAR},
</if>
<if test="LOW_TYP != null">
LOW_TYP = #{LOW_TYP,jdbcType=CHAR},
</if>
<if test="LOC_STA != null">
LOC_STA = #{LOC_STA,jdbcType=VARCHAR},
</if>
<if test="AVG_MONEY != null">
AVG_MONEY = #{AVG_MONEY,jdbcType=VARCHAR},
</if>
<if test="HOS_SIZE != null">
HOS_SIZE = #{HOS_SIZE,jdbcType=VARCHAR},
</if>
<if test="OIL != null">
OIL = #{OIL,jdbcType=VARCHAR},
</if>
<if test="SOLT != null">
SOLT = #{SOLT,jdbcType=VARCHAR},
</if>
<if test="DOCTOR_ID != null">
DOCTOR_ID = #{DOCTOR_ID,jdbcType=VARCHAR},
</if>
<if test="UPLOAD_FLG != null">
UPLOAD_FLG = #{UPLOAD_FLG,jdbcType=CHAR},
</if>
<if test="CRE_DAT != null">
CRE_DAT = #{CRE_DAT,jdbcType=VARCHAR},
</if>
<if test="DATAFLG != null">
DATAFLG = #{DATAFLG,jdbcType=CHAR},
</if>
</set>
where FAM_HEALTH_RECORD_ID = #{FAM_HEALTH_RECORD_ID,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.brilliance.remit.db.model.FamHealthRecord">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Dec 13 17:33:42 CST 2018.
-->
update fam_health_record
set USR_ID = #{USR_ID,jdbcType=CHAR},
ENV_HOS = #{ENV_HOS,jdbcType=VARCHAR},
LOW_TYP = #{LOW_TYP,jdbcType=CHAR},
LOC_STA = #{LOC_STA,jdbcType=VARCHAR},
AVG_MONEY = #{AVG_MONEY,jdbcType=VARCHAR},
HOS_SIZE = #{HOS_SIZE,jdbcType=VARCHAR},
OIL = #{OIL,jdbcType=VARCHAR},
SOLT = #{SOLT,jdbcType=VARCHAR},
DOCTOR_ID = #{DOCTOR_ID,jdbcType=VARCHAR},
UPLOAD_FLG = #{UPLOAD_FLG,jdbcType=CHAR},
CRE_DAT = #{CRE_DAT,jdbcType=VARCHAR},
DATAFLG = #{DATAFLG,jdbcType=CHAR}
where FAM_HEALTH_RECORD_ID = #{FAM_HEALTH_RECORD_ID,jdbcType=CHAR}
</update>
</mapper>
\ No newline at end of file
package com.brilliance.remit.db.model;
public class FamHealthRecord {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.FAM_HEALTH_RECORD_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String FAM_HEALTH_RECORD_ID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.USR_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String USR_ID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.ENV_HOS
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String ENV_HOS;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.LOW_TYP
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String LOW_TYP;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.LOC_STA
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String LOC_STA;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.AVG_MONEY
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String AVG_MONEY;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.HOS_SIZE
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String HOS_SIZE;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.OIL
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String OIL;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.SOLT
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String SOLT;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.DOCTOR_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String DOCTOR_ID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.UPLOAD_FLG
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String UPLOAD_FLG;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.CRE_DAT
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String CRE_DAT;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column fam_health_record.DATAFLG
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
private String DATAFLG;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.FAM_HEALTH_RECORD_ID
*
* @return the value of fam_health_record.FAM_HEALTH_RECORD_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getFAM_HEALTH_RECORD_ID() {
return FAM_HEALTH_RECORD_ID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.FAM_HEALTH_RECORD_ID
*
* @param FAM_HEALTH_RECORD_ID the value for fam_health_record.FAM_HEALTH_RECORD_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setFAM_HEALTH_RECORD_ID(String FAM_HEALTH_RECORD_ID) {
this.FAM_HEALTH_RECORD_ID = FAM_HEALTH_RECORD_ID;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.USR_ID
*
* @return the value of fam_health_record.USR_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getUSR_ID() {
return USR_ID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.USR_ID
*
* @param USR_ID the value for fam_health_record.USR_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setUSR_ID(String USR_ID) {
this.USR_ID = USR_ID;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.ENV_HOS
*
* @return the value of fam_health_record.ENV_HOS
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getENV_HOS() {
return ENV_HOS;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.ENV_HOS
*
* @param ENV_HOS the value for fam_health_record.ENV_HOS
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setENV_HOS(String ENV_HOS) {
this.ENV_HOS = ENV_HOS;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.LOW_TYP
*
* @return the value of fam_health_record.LOW_TYP
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getLOW_TYP() {
return LOW_TYP;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.LOW_TYP
*
* @param LOW_TYP the value for fam_health_record.LOW_TYP
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setLOW_TYP(String LOW_TYP) {
this.LOW_TYP = LOW_TYP;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.LOC_STA
*
* @return the value of fam_health_record.LOC_STA
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getLOC_STA() {
return LOC_STA;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.LOC_STA
*
* @param LOC_STA the value for fam_health_record.LOC_STA
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setLOC_STA(String LOC_STA) {
this.LOC_STA = LOC_STA;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.AVG_MONEY
*
* @return the value of fam_health_record.AVG_MONEY
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getAVG_MONEY() {
return AVG_MONEY;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.AVG_MONEY
*
* @param AVG_MONEY the value for fam_health_record.AVG_MONEY
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setAVG_MONEY(String AVG_MONEY) {
this.AVG_MONEY = AVG_MONEY;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.HOS_SIZE
*
* @return the value of fam_health_record.HOS_SIZE
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getHOS_SIZE() {
return HOS_SIZE;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.HOS_SIZE
*
* @param HOS_SIZE the value for fam_health_record.HOS_SIZE
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setHOS_SIZE(String HOS_SIZE) {
this.HOS_SIZE = HOS_SIZE;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.OIL
*
* @return the value of fam_health_record.OIL
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getOIL() {
return OIL;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.OIL
*
* @param OIL the value for fam_health_record.OIL
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setOIL(String OIL) {
this.OIL = OIL;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.SOLT
*
* @return the value of fam_health_record.SOLT
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getSOLT() {
return SOLT;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.SOLT
*
* @param SOLT the value for fam_health_record.SOLT
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setSOLT(String SOLT) {
this.SOLT = SOLT;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.DOCTOR_ID
*
* @return the value of fam_health_record.DOCTOR_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getDOCTOR_ID() {
return DOCTOR_ID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.DOCTOR_ID
*
* @param DOCTOR_ID the value for fam_health_record.DOCTOR_ID
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setDOCTOR_ID(String DOCTOR_ID) {
this.DOCTOR_ID = DOCTOR_ID;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.UPLOAD_FLG
*
* @return the value of fam_health_record.UPLOAD_FLG
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getUPLOAD_FLG() {
return UPLOAD_FLG;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.UPLOAD_FLG
*
* @param UPLOAD_FLG the value for fam_health_record.UPLOAD_FLG
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setUPLOAD_FLG(String UPLOAD_FLG) {
this.UPLOAD_FLG = UPLOAD_FLG;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.CRE_DAT
*
* @return the value of fam_health_record.CRE_DAT
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getCRE_DAT() {
return CRE_DAT;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.CRE_DAT
*
* @param CRE_DAT the value for fam_health_record.CRE_DAT
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setCRE_DAT(String CRE_DAT) {
this.CRE_DAT = CRE_DAT;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column fam_health_record.DATAFLG
*
* @return the value of fam_health_record.DATAFLG
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public String getDATAFLG() {
return DATAFLG;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column fam_health_record.DATAFLG
*
* @param DATAFLG the value for fam_health_record.DATAFLG
*
* @mbggenerated Thu Dec 13 17:33:42 CST 2018
*/
public void setDATAFLG(String DATAFLG) {
this.DATAFLG = DATAFLG;
}
}
\ No newline at end of file
package com.brilliance.remit.service;
public interface RemitService {
public void test();
}
package com.brilliance.remit.service.imp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.brilliance.remit.db.dao.FamHealthRecordMapper;
import com.brilliance.remit.service.RemitService;
@Service
public class RemitServiceImp implements RemitService {
@Autowired
private FamHealthRecordMapper dao;
@Override
public void test() {
System.out.println("this is a test !!!");
}
}
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="Threshold" value="ERROR" />
<param name="Encoding" value="UTF-8" />
<param name="File" value="../logs/eibs.log" />
<param name="Append" value="true" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
</layout>
<filter class="log.PatternFilter" >
<param name="Pattern" value="org.sss.*" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="TRACE" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%-10t][%c{1}] %m%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMax" value="ERROR" />
<param name="LevelMin" value="TRACE" />
</filter>
</appender>
<category name="org.sss">
<priority value="INFO" />
</category>
<category name="org.hibernate">
<priority value="ERROR" />
</category>
<category name="org.apache">
<priority value="ERROR" />
</category>
<category name="com.opensymphony">
<priority value="ERROR" />
</category>
<root>
<level value="WARN" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</log4j:configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<File name="File" fileName="log/eibs-designer.log">
<PatternLayout pattern="%d %-5p %C{2} [%t] %m%n"/>
</File>
</Appenders>
<Loggers>
<Logger name="org.sss" level="DEBUG"/>
<Logger name="org.hibernate" level="ERROR"/>
<Logger name="org.apache" level="ERROR"/>
<Logger name="com.opensymphony" level="ERROR"/>
<Root level="DEBUG">
<AppenderRef ref="Console"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
#*****************jedis\u8FDE\u63A5\u53C2\u6570\u8BBE\u7F6E*********************
#redis\u670D\u52A1\u5668ip
redis.ip=172.17.2.110
#redis\u670D\u52A1\u5668\u7AEF\u53E3\u53F7
redis.port=6379
#redis\u8BBF\u95EE\u5BC6\u7801
redis.passWord=
#\u4E0E\u670D\u52A1\u5668\u5EFA\u7ACB\u8FDE\u63A5\u7684\u8D85\u65F6\u65F6\u95F4
redis.timeout=3000
#************************jedis\u6C60\u53C2\u6570\u8BBE\u7F6E*******************
#jedis\u7684\u6700\u5927\u6D3B\u8DC3\u8FDE\u63A5\u6570
jedis.pool.maxActive=100
#jedis\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\u6570
jedis.pool.maxIdle=50
#jedis\u6C60\u6CA1\u6709\u8FDE\u63A5\u5BF9\u8C61\u8FD4\u56DE\u65F6\uFF0C\u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002
#\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
jedis.pool.maxWait=1500
#\u4ECE\u6C60\u4E2D\u83B7\u53D6\u8FDE\u63A5\u7684\u65F6\u5019\uFF0C\u662F\u5426\u8FDB\u884C\u6709\u6548\u68C0\u67E5
jedis.pool.testOnBorrow=true
#\u5F52\u8FD8\u8FDE\u63A5\u7684\u65F6\u5019\uFF0C\u662F\u5426\u8FDB\u884C\u6709\u6548\u68C0\u67E5
sessionTimeOut=1800
\ No newline at end of file
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 自动扫描注解的bean  -->
<context:component-scan base-package="com.brilliance.remit.service"/>
<!-- 配置数据源  -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://114.115.138.98:3306/health?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false"/>
<property name="username" value="root"/>
<property name="password" value="1111"/>
<property name="maxActive" value="60"/>
<property name="maxIdle" value="60"/>
<property name="minIdle" value="5"/>
<property name="initialSize" value="1"/>
<property name="maxWait" value="30000"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- mapperLocations配置**Mapper.xml文件位置  -->
<property name="mapperLocations" value="classpath*:com./brilliance/remit/db/mapper/**/*.xml"/>
</bean>
<!-- 配置mapper对应的dao和mybatis工厂  -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.brilliance.remit.db.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>
\ No newline at end of file
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**/*" />
<bean class="com.brilliance.remit.common.filter.Cors" />
</mvc:interceptor>
<!-- <mvc:interceptor>
<mvc:mapping path="/**" />
<mvc:exclude-mapping path="/login" />
<bean class="org.sss.presentation.noui.jwt.TokenInterceptor"></bean>
</mvc:interceptor> -->
</mvc:interceptors>
<!-- 配置自动扫描的包 -->
<context:component-scan base-package="com.brilliance.remit.controller"></context:component-scan>
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<description>remit</description>
<display-name>remit</display-name>
<!-- Spring配置文件  -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-applicationContext.xml</param-value>
</context-param>
<!-- 启动Web容器时,自动装配ApplicationContext.xml的配置信息  -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- spring处理中文乱码的一个过滤器配置  -->
<filter>
<filter-name>SpringEncodingFilter</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>cors</filter-name>
<filter-class>com.brilliance.remit.common.filter.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SpringEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>cors</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置Spring mvc下的配置文件的位置和名称 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file></welcome-file>
</welcome-file-list>
</web-app>
\ No newline at end of file
package org.sss.presentation.noui.api.servlet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
public class HttpTest {
public static void main(String[] args) {
String userId = "tst1";
String terminalType = "WEB";
Map<String, Object> map1 = login(userId, terminalType);
Map<String, Object> map2 = (Map<String, Object>) map1.get("data");
String token = (String) map2.get("token");
// pxiadd(token, userId, terminalType);
// pxisel(token, userId, terminalType);
// pxiame(token, userId, terminalType);
// check(token, userId, terminalType);
upload(token, userId, terminalType);
}
public static void upload(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxiadd/_upload");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("nam", "gcy");
map.put("major", "M");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
String str = "1234";
// System.out.println(JSON.toJSON(student));
out.print(str);
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void check(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxisel/check");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("nam", "gcy");
map.put("major", "M");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void pxisel(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxisel/_sel");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("nam", "gechengyang");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void pxiame(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxiame/init");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("pxiinr", "00000023");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("params", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void pxiadd(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxiadd/_save");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("nam", "gechengyang");
map.put("sex", "F");
map.put("univer", "湖北大学");
map.put("major", "计算机");
map.put("headimg", "NO IMAGE");
map.put("age", 20);
map.put("tel", "18912345678");
map.put("balance", 10000);
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static Map<String, Object> login(String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/login");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
conn.addRequestProperty("username", "421182199008062952");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, String> map = new HashMap<String, String>();
map.put("username", "tst1");
map.put("password", "1");
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
return new Gson().fromJson(result, Map.class);
}
}
package org.sss.test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.sss.common.model.IBaseObject;
import org.sss.common.model.IDatafield;
import org.sss.common.model.IModule;
import org.sss.common.model.IModuleList;
import org.sss.common.model.IParent;
public class GsonTest {
public String baseObject2Json(IBaseObject baseObject) {
com.google.gson.Gson gson = new com.google.gson.Gson();
if (baseObject instanceof IModuleList<?>) {
IModuleList<?> moduleList = (IModuleList<?>) baseObject;
List<Map<String, Object>> lst = new ArrayList<Map<String, Object>>();
for (IModule module : moduleList) {
if (null == module) continue;
Map<String, Object> m = new HashMap<String, Object>();
for (IDatafield<?> datafield : module.getDatafields()) {
Object value = datafield.getValue();
m.put(datafield.getName(), value == null ? "" : value);
}
lst.add(m);
}
return gson.toJson(lst);
}
if (baseObject instanceof IModule) {
Map<String, Object> m = new HashMap<String, Object>();
IModule module = (IModule) baseObject;
for (IDatafield<?> datafield : module.getDatafields()) {
Object value = datafield.getValue();
m.put(datafield.getName(), value == null ? "" : value);
}
return gson.toJson(m);
}
if (baseObject instanceof IDatafield<?>) {
IDatafield<?> datafield = (IDatafield<?>) baseObject;
return "{ " + datafield.getName() + ": " + datafield.getValue() == null
? ""
: datafield.getValue() + " }";
}
return null;
}
public String parent2Json(IParent parent) {
com.google.gson.Gson gson = new com.google.gson.Gson();
return gson.toJson(expandParent(parent));
}
private Object expandParent(IParent parent) {
if (parent instanceof IModuleList<?>) {
IModuleList<?> moduleList = (IModuleList<?>) parent;
List<Object> lst = new ArrayList<Object>();
for (IModule module : moduleList) {
if (null == module) continue;
lst.add(expandParent(module));
}
return lst;
}
if (parent instanceof IModule) {
Map<String, Object> m = new HashMap<String, Object>();
IModule module = (IModule) parent;
for (IDatafield<?> datafield : module.getDatafields()) {
Object value = datafield.getValue();
if (value == null) continue;
m.put(datafield.getUrl().replaceAll("\\\\", "_"), value);
}
for (Iterator<IParent> it = module.getModules().iterator(); it.hasNext();) {
IParent parent2 = it.next();
m.put(parent2.getUrl().replaceAll("\\\\", "_"), expandParent(parent2));
}
return m;
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment