parent
c3ad285992
commit
ca0e94cf4e
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.mashibing</groupId>
|
||||||
|
<artifactId>beacon-cloud</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>beacon-common</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.mashibing.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: Description
|
||||||
|
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||||
|
* @date 2025/6/4 20:42
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface Description {
|
||||||
|
String value();
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.mashibing.common.annotation.validParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: NotNull
|
||||||
|
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||||
|
* @date 2025/6/5 11:46
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public @interface NotNull {
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.mashibing.common.enums;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: JsonResultCodeEnum
|
||||||
|
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||||
|
* @date 2025/6/5 11:57
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum JsonResultCode {
|
||||||
|
//正常
|
||||||
|
OK(200),
|
||||||
|
//参数校验异常
|
||||||
|
PARAM_VALID_EXCEPTION(601),
|
||||||
|
//逻辑异常
|
||||||
|
LOGIC_EXCEPTION(602),
|
||||||
|
;
|
||||||
|
|
||||||
|
private int code;
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.mashibing.common.pojo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: JsonResult
|
||||||
|
* @Description: JsonResult通用接口返回值
|
||||||
|
* @date 2025/6/5 11:55
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class JsonResult {
|
||||||
|
|
||||||
|
private int code = 200;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
private Object body;
|
||||||
|
|
||||||
|
private Map<String, Object> properties;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.mashibing.common.utils;
|
||||||
|
|
||||||
|
import com.mashibing.common.enums.JsonResultCode;
|
||||||
|
import com.mashibing.common.pojo.JsonResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author heqijun
|
||||||
|
* @ClassName: JsonResultUtil
|
||||||
|
* @Description: JsonResult工具类
|
||||||
|
* @date 2025/6/5 12:19
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class JsonResultUtil {
|
||||||
|
|
||||||
|
public static JsonResult ok() {
|
||||||
|
JsonResult result = new JsonResult();
|
||||||
|
result.setCode(JsonResultCode.OK.getCode());
|
||||||
|
result.setMsg("OK");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JsonResult ok(String msg) {
|
||||||
|
JsonResult result = new JsonResult();
|
||||||
|
result.setCode(JsonResultCode.OK.getCode());
|
||||||
|
result.setMsg(msg);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JsonResult ok(Object body) {
|
||||||
|
JsonResult result = ok();
|
||||||
|
result.setBody(body);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JsonResult ok(String msg, Object body) {
|
||||||
|
JsonResult result = ok(msg);
|
||||||
|
result.setBody(body);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JsonResult error(int code, String msg) {
|
||||||
|
JsonResult result = new JsonResult();
|
||||||
|
result.setCode(code);
|
||||||
|
result.setMsg(msg);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue