Commit b62b8f24 by guanchen

更新errorCode 打war包

parent 1c2cd56d
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>partner</name> <name>partner</name>
<description>呼呼省钱合伙人相关服务</description> <description>呼呼省钱合伙人相关服务</description>
<packaging>jar</packaging> <packaging>war</packaging>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
...@@ -139,14 +139,16 @@ ...@@ -139,14 +139,16 @@
<properties> <properties>
<profiles.active>dev</profiles.active> <profiles.active>dev</profiles.active>
<mysql.server>jdbc:mysql://10.9.121.204:3306/huhu</mysql.server> <mysql.server>jdbc:mysql://10.9.121.204:3306/huhu</mysql.server>
<mysql.username>yanfa</mysql.username> <!--<mysql.username>yanfa</mysql.username>-->
<mysql.password>cScdKw%ZKC1i$C!1uAz3Kg$c</mysql.password> <!--<mysql.password>cScdKw%ZKC1i$C!1uAz3Kg$c</mysql.password>-->
<mysql.username>apihu</mysql.username>
<mysql.password>tqH9clYRAxZ@LV4x</mysql.password>
<redis.host>10.9.186.167</redis.host> <redis.host>10.9.186.167</redis.host>
<redis.password>passwdredis</redis.password> <redis.password>passwdredis</redis.password>
<spring.profiles.active>dev</spring.profiles.active> <spring.profiles.active>dev</spring.profiles.active>
<logfile_path>./Users/housene/Documents/lanrenkeji/huhu-partner/data/logs/huhu/lanren</logfile_path> <logfile_path>/Users/chen/Develop/workspace/partner/data/release/dev/logs</logfile_path>
<!--<providers-path>/data/java/service</providers-path>--> <!--<providers-path>/data/java/service</providers-path>-->
<providers-path>/Users/housene/Documents/lanrenkeji/huhu-partner/data/release/dev</providers-path> <providers-path>/Users/chen/Develop/workspace/partner/data/release/dev</providers-path>
</properties> </properties>
<!-- 默认是本地开发环境 --> <!-- 默认是本地开发环境 -->
<activation> <activation>
...@@ -272,7 +274,8 @@ ...@@ -272,7 +274,8 @@
<if> <if>
<equals arg1="${project.packaging}" arg2="war"/> <equals arg1="${project.packaging}" arg2="war"/>
<then> <then>
<copy file="target/${project.artifactId}.${project.packaging}" <!--<copy file="target/${project.artifactId}.${project.packaging}"-->
<copy file="target/${project.artifactId}-${project.version}-bin.zip"
todir="${todir}"/> todir="${todir}"/>
</then> </then>
<else> <else>
......
package com.lanren.huhu.partner.config; package com.lanren.huhu.partner.config;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.lanren.huhu.partner.constants.CommonStatusConstant; import com.lanren.huhu.partner.util.MessageUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
...@@ -40,10 +40,10 @@ public class AuthenticationInterceptor extends HandlerInterceptorAdapter { ...@@ -40,10 +40,10 @@ public class AuthenticationInterceptor extends HandlerInterceptorAdapter {
private void returnMsg(HttpServletResponse response) throws IOException { private void returnMsg(HttpServletResponse response) throws IOException {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("code", CommonStatusConstant.SESSION_TIMEOUT.getValue()); map.put("code", 410);
map.put("msg", CommonStatusConstant.SESSION_TIMEOUT.getDesc()); map.put("msg", MessageUtil.getMsg(410));
response.setHeader("Content-type", "application/json;charset=UTF-8"); response.setHeader("Content-type", "application/json;charset=UTF-8");
logger.info("msg :{}", CommonStatusConstant.SESSION_TIMEOUT.getDesc()); logger.info("msg :{}", MessageUtil.getMsg(410));
response.getWriter().write(JSON.toJSONString(map)); response.getWriter().write(JSON.toJSONString(map));
} }
} }
package com.lanren.huhu.partner.constants;
/**
* 改为枚举值定义
* 由于子项目的代码从10001开始,为避免重复,当前状态码应小于10000。
* MessageCodeLoader初始化时默认先加载当前枚举,然后加载msg.properties配置(实现继承关系:子项目不用再重复定义CommonStatus中已有的状态码)。
* 为避免子项目状态码重复,父类如已经定义,MessageCodeLoader不再加载子项目定义的冲突状态码(CommonStatus优先)。
*
* @author houseme
* @see com.lanren.huhu.partner.manager
* <p>
* <p>
* <p>
* 约定规则
* provider业务代码都应该在这里定义
* consumer业务代码在msg.properties定义
*/
public enum CommonStatusConstant {
OK(200, "成功!"),
CREATED(201, "已经创建!"),
DEFAULT_BIZ_ERROR(202, "业务异常!(此处应该被具体业务代码重写)"),
BAD_REQUEST(400, "请求失效,请稍后再试!"),
UNAUTHORIZED(401, "未经授权的操作,请联系系统管理员!"),
NOT_FOUND(404, "未找到资源,请稍后再试!"),
METHOD_NOT_ALLOWED(405, "该方法禁止调用,请联系系统管理员!"),
CONFLICT(409, "操作冲突,请稍后再试!"),
SESSION_TIMEOUT(410, "用户信息超时,请重新登录!"),
LOGIN_FAILD(411, "用户名或密码错误!"),
SESSION_REFRESH(412, "Token Refreshed"),
INVALID_PARAMETER(450, "参数验证未通过!"),
PERMISSION_DENIED(452, "权限拒绝,请联系系统管理员!"),
INTERNAL_SERVER_ERROR(500, "服务器内部异常,请稍后再试!"),
NO_REPLY(558, "服务器无应答,请稍后再试!!"),
UNCATCHED_EXCEPTION(553, "未捕获的异常,请稍后再试!"),
ENTITY_NOT_FOUNT(601, "数据未找到,请稍后再试!");
private Integer value;
private String desc;
private CommonStatusConstant(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return value;
}
public String getDesc() {
return desc;
}
}
package com.lanren.huhu.partner.manager; package com.lanren.huhu.partner.manager;
import com.lanren.huhu.partner.constants.CommonStatusConstant;
import com.lanren.huhu.partner.util.MessageUtil; import com.lanren.huhu.partner.util.MessageUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -19,7 +18,6 @@ import java.util.Properties; ...@@ -19,7 +18,6 @@ import java.util.Properties;
* 部分业务代码依赖CommonStatusConstant * 部分业务代码依赖CommonStatusConstant
* *
* @author houseme * @author houseme
* @see com.lanren.huhu.partner.constants.CommonStatusConstant
*/ */
@Component @Component
public class MessageCodeLoader { public class MessageCodeLoader {
...@@ -37,8 +35,6 @@ public class MessageCodeLoader { ...@@ -37,8 +35,6 @@ public class MessageCodeLoader {
try { try {
Properties p = new Properties(); Properties p = new Properties();
p.load(this.getClass().getClassLoader().getResourceAsStream(resource)); p.load(this.getClass().getClassLoader().getResourceAsStream(resource));
Map<Integer, String> comm_code = toMap(CommonStatusConstant.class);
MessageUtil.putAll(comm_code);
for (Object obj : p.keySet()) { for (Object obj : p.keySet()) {
MessageUtil.put(Integer.parseInt(obj.toString()), p.getProperty(obj.toString())); MessageUtil.put(Integer.parseInt(obj.toString()), p.getProperty(obj.toString()));
} }
......
...@@ -18,13 +18,13 @@ public class Result<T> { ...@@ -18,13 +18,13 @@ public class Result<T> {
private Long time; private Long time;
public Result() { public Result() {
this.code = 200; this.code = 0;
this.message = MessageUtil.getMsg(code); this.message = MessageUtil.getMsg(code);
this.time = System.currentTimeMillis(); this.time = System.currentTimeMillis();
} }
public Result(T data) { public Result(T data) {
this.code = 200; this.code = 0;
this.message = MessageUtil.getMsg(code); this.message = MessageUtil.getMsg(code);
this.data = data; this.data = data;
this.time = System.currentTimeMillis(); this.time = System.currentTimeMillis();
......
200=\u6210\u529F 0=\u6210\u529F
201=\u5DF2\u7ECF\u521B\u5EFA 201=\u5DF2\u7ECF\u521B\u5EFA
202=\u4E1A\u52A1\u5F02\u5E38\uFF01\uFF08\u6B64\u5904\u5E94\u8BE5\u88AB\u5177\u4F53\u4E1A\u52A1\u4EE3\u7801\u91CD\u5199\uFF09 202=\u4E1A\u52A1\u5F02\u5E38\uFF01\uFF08\u6B64\u5904\u5E94\u8BE5\u88AB\u5177\u4F53\u4E1A\u52A1\u4EE3\u7801\u91CD\u5199\uFF09
400=\u8BF7\u6C42\u5931\u6548\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF01 400=\u8BF7\u6C42\u5931\u6548\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF01
......
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