diff --git a/pom.xml b/pom.xml index bafcabc5f..6fc670595 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ ruoyi http://www.ruoyi.vip 若依管理系统 - + 4.7.4 UTF-8 @@ -36,7 +36,7 @@ - + org.springframework.boot @@ -45,14 +45,14 @@ pom import - + com.alibaba druid-spring-boot-starter ${druid.version} - + com.github.penggle @@ -219,6 +219,12 @@ + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.9.1.2184 + org.apache.maven.plugins maven-compiler-plugin @@ -257,4 +263,4 @@ - \ No newline at end of file + diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java new file mode 100644 index 000000000..69aada0eb --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java @@ -0,0 +1,182 @@ +package com.ruoyi.common.core.domain; + +import org.springframework.http.HttpStatus; + +import java.io.Serializable; +import java.util.HashMap; + +/** + * 表格分页数据对象 + * + * @author ruoyi + */ +public class Result implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 总记录数 */ + private long total; + + /** 列表数据 */ + private T data; + + /** 消息状态码 */ + private int code; + + /** 消息内容 */ + private String msg; + + /** + * 表格数据对象 + */ + public Result() + { + this.code=200; + } + /** + * 表格数据对象 + */ + public Result(int code, String msg) + { + this.code=code; + this.msg=msg; + } + /** + * 表格数据对象 + */ + public Result(T data) + { + this.code=200; + this.data=data; + } + /** + * 表格数据对象 + */ + public Result(int code) + { + this.code=code; + } + /** + * 分页 + * + * @param data 列表数据 + * @param total 总记录数 + */ + public Result(T data, int total) + { + this.data = data; + this.total = total; + } + + + + public Result(int code, String msg, T data) + { + this.code = code; + this.data = data; + this.msg = msg; + } + + public Result(int code, String msg, T data, int total) + { + this.code = code; + this.data = data; + this.msg = msg; + this.total = total; + } + + + public static Result success(){ + return new Result(); + } + public static Result success(T data){ + return new Result(data); + } + + /** + * 返回错误消息 + * + * @return + */ + public static Result error() + { + return Result.error("操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static Result error(String msg) + { + return Result.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static Result error(String msg, T data) + { + return new Result(500, msg, data); + } + + /** + * 返回错误消息 + * + * @param code 状态码 + * @param msg 返回内容 + * @return 警告消息 + */ + public static Result error(int code, String msg) + { + return new Result(code, msg, null); + } + + + public long getTotal() + { + return total; + } + + public void setTotal(long total) + { + this.total = total; + } + + public T getData() + { + return data; + } + + public void setData(T data) + { + this.data = data; + } + + public int getCode() + { + return code; + } + + public void setCode(int code) + { + this.code = code; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } + +} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..e69de29bb