From 5000b8decc4214fc690fcd7af9a8ee9f140fd1f9 Mon Sep 17 00:00:00 2001 From: xinsibo Date: Mon, 23 May 2022 15:02:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=B3=9B=E5=9E=8B=E3=80=81=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5=E3=80=81=E6=94=AF=E6=8C=81?= =?UTF-8?q?put=E6=93=8D=E4=BD=9C=EF=BC=88=E9=9C=80=E8=A6=81=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=89=80=E6=9C=89=E7=B1=BB=E4=BC=BCres.imgUrl?= =?UTF-8?q?=E6=94=B9=E4=B8=BAres.mapimgUrl=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/core/domain/Result.java | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Result.java 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; + } + +} From 2e5b374b3f0fa7e801560f222e60d8339694cc73 Mon Sep 17 00:00:00 2001 From: xinsibo Date: Tue, 24 May 2022 13:42:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0sonar=E6=89=AB=E6=8F=8Fma?= =?UTF-8?q?ven=E6=8F=92=E4=BB=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 16 +++++++++++----- sonar-project.properties | 0 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 sonar-project.properties diff --git a/pom.xml b/pom.xml index 57c1ff10e..2163d7d35 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ ruoyi http://www.ruoyi.vip 若依管理系统 - + 4.7.3 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/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..e69de29bb