Commit 3fc79968 by 朱瑞泽

代码调整

parent 3ee116bd
......@@ -45,6 +45,10 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
......
package com.gic.demo.base.api.common;
public class Constant {
/**
* EMPTY
*/
public final static String EMPTY = "";
/**
* 空格
*/
public final static String BLANK = " ";
/**
* 点
*/
public final static String DOT = ".";
/**
* / 斜杠
*/
public final static String SLASH = "/";
/**
* 数字0
*/
public final static int NUMBER_0 = 0;
/**
* 数字1
*/
public final static int NUMBER_1 = 1;
/**
* 数字2
*/
public final static int NUMBER_2 = 2;
/**
* 数字3
*/
public final static int NUMBER_3 = 3;
/**
* 数字4
*/
public final static int NUMBER_4 = 4;
/**
* 数字5
*/
public final static int NUMBER_5 = 5;
/**
* 数字6
*/
public final static int NUMBER_6 = 6;
/**
* 数字7
*/
public final static int NUMBER_7 = 7;
/**
* 数字8
*/
public final static int NUMBER_8 = 8;
/**
* 数字9
*/
public final static int NUMBER_9 = 9;
/**
* 数字10
*/
public final static int NUMBER_10 = 10;
/**
* 数字11
*/
public final static int NUMBER_11 = 11;
/**
* 数字12
*/
public final static int NUMBER_12 = 12;
/**
* 数字13
*/
public final static int NUMBER_13 = 13;
/**
* 数字14
*/
public final static int NUMBER_14 = 14;
/**
* 数字15
*/
public final static int NUMBER_15 = 15;
/**
* 字符 :0 [48 ]
*/
public final static String STRING_0 = "0";
/**
* 字符 :1 [49 ]
*/
public final static String STRING_1 = "1";
/**
* 字符 :2 [50 ]
*/
public final static String STRING_2 = "2";
/**
* 字符 :3 [51 ]
*/
public final static String STRING_3 = "3";
/**
* 字符 :4 [52 ]
*/
public final static String STRING_4 = "4";
/**
* 字符 :5 [53 ]
*/
public final static String STRING_5 = "5";
/**
* 字符 :6 [54 ]
*/
public final static String STRING_6 = "6";
/**
* 字符 :7 [55 ]
*/
public final static String STRING_7 = "7";
/**
* 字符 :8 [56 ]
*/
public final static String STRING_8 = "8";
/**
* 字符 :9 [57 ]
*/
public final static String STRING_9 = "9";
/**
* 日期年 格式
*/
public static final String YEAR_FORMAT = "yyyy";
/**
* 日期年月 格式
*/
public static final String YEAR_MONTH_FORMAT = "yyyy-MM";
/**
* 日期 格式
*/
public static final String DATE_FORMAT = "yyyy-MM-dd";
/**
* 日期 格式
*/
public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* 状态-无效
*/
public static final int STATUS_INVALID = 0;
/**
* 状态-有效
*/
public static final int STATUS_EFFECTIVE = 1;
/**
* 成功代码
*/
public static final String SUCCESS = "0000";
}
package com.gic.demo.base.api.common;
import java.io.Serializable;
/**
* 服务响应
*
* @param <T> 返回类型
* @author zhurz
*/
public class ServiceResponse<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 响应代码(成功代码固定为 {@link Constant#SUCCESS 0000})
*/
private String code;
/**
* 响应信息(可为null,不一定和code说明信息一致)
*/
private String message;
/**
* 响应结果
*/
private T result;
public static <T> ServiceResponse<T> success() {
return new ServiceResponse<>(Constant.SUCCESS, null, null);
}
public static <T> ServiceResponse<T> success(T result) {
return new ServiceResponse<>(Constant.SUCCESS, null, result);
}
public static <T> ServiceResponse<T> success(T result, String message) {
return new ServiceResponse<>(Constant.SUCCESS, message, result);
}
public static <T> ServiceResponse<T> failure(String code, String message) {
return new ServiceResponse<>(code, message, null);
}
public static <T> ServiceResponse<T> failure(String code, String message, T result) {
return new ServiceResponse<>(code, message, result);
}
public ServiceResponse() {
}
private ServiceResponse(String code, String message, T result) {
this.code = code;
this.message = message;
this.result = result;
}
/**
* @return 是否成功
*/
public boolean isSuccess() {
return Constant.SUCCESS.equals(code);
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
}
/**
* @author zhurz
*/
package com.gic.demo.base.api.common;
\ No newline at end of file
......@@ -188,6 +188,10 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
......
package com.gic.demo.common.utils;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
/**
* 密码工具
*
* @author zhurz
*/
public final class PasswordUtil {
/**
* 编码密码( base64(sha1(password)) )
*
* @param password 明文密码
* @return
*/
public static String encodePassword(String password) {
return Base64.encodeBase64String(DigestUtils.sha1(password == null ? "" : password));
}
/**
* 检查密码是否匹配
*
* @param encodePassword 编码过的密码
* @param password 明文密码
* @return
*/
public static boolean checkPassword(String encodePassword, String password) {
return (encodePassword == null ? "" : encodePassword).equals(encodePassword(password));
}
}
/**
* @author zhurz
*/
package com.gic.demo.common.utils;
\ No newline at end of file
......@@ -49,6 +49,10 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
......
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