【修改】全局处理Result,去除已放弃的类型,去掉success统一改为OK

【修改】系统公告无法查看的的问题处理
This commit is contained in:
zer0Black
2022-04-16 22:49:15 +08:00
parent 8dcbe6fd0c
commit d5c97fbd5c
38 changed files with 664 additions and 801 deletions
@@ -35,7 +35,7 @@ public class Result<T> implements Serializable {
* 返回代码
*/
@ApiModelProperty(value = "返回代码")
private Integer code = 0;
private Integer code = 200;
/**
* 返回数据对象 data
@@ -52,40 +52,6 @@ public class Result<T> implements Serializable {
public Result() {
}
public Result<T> success(String message) {
this.message = message;
this.code = CommonConstant.SC_OK_200;
this.success = true;
return this;
}
@Deprecated
public static Result<Object> ok() {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage("成功");
return r;
}
@Deprecated
public static Result<Object> ok(String msg) {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage(msg);
return r;
}
@Deprecated
public static Result<Object> ok(Object data) {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setResult(data);
return r;
}
public static<T> Result<T> OK() {
Result<T> r = new Result<T>();
@@ -95,6 +61,14 @@ public class Result<T> implements Serializable {
return r;
}
public static<T> Result<T> OK(String message) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage(message);
return r;
}
public static<T> Result<T> OK(T data) {
Result<T> r = new Result<T>();
r.setSuccess(true);
@@ -121,23 +95,24 @@ public class Result<T> implements Serializable {
return r;
}
public static Result<Object> error(String msg) {
public static<T> Result<T> error(String msg) {
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
}
public static Result<Object> error(int code, String msg) {
Result<Object> r = new Result<Object>();
public static<T> Result<T> error(int code, String msg) {
Result<T> r = new Result<T>();
r.setCode(code);
r.setMessage(msg);
r.setSuccess(false);
return r;
}
public Result<T> error500(String message) {
this.message = message;
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
this.success = false;
return this;
public static<T> Result<T> error500(String message) {
Result<T> r = new Result<T>();
r.message = message;
r.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
r.success = false;
return r;
}
/**
* 无权限访问返回结果
@@ -309,4 +309,10 @@ public interface CommonConstant {
* 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用
*/
public final static String THIRD_LOGIN_CODE = "third_login_code";
public final static String ANNOUNCEMENT_SEND_STATUS_0 = "0";
/** 系统通告消息状态:1=已发布 */
public final static String ANNOUNCEMENT_SEND_STATUS_1 = "1";
/** 系统通告消息状态:2=已撤销 */
public final static String ANNOUNCEMENT_SEND_STATUS_2 = "2";
}
@@ -133,7 +133,6 @@ public class SqlInjectionUtil {
* @param value
* @return
*/
@Deprecated
public static void specialFilterContentForOnlineReport(String value) {
String specialXssStr = " exec | insert | delete | update | drop | chr | mid | master | truncate | char | declare |";
String[] xssArr = specialXssStr.split("\\|");