feat(chaos-api): 初始化项目基础结构
- 新增 ApiResult 类用于统一返回结果 - 添加应用配置文件和日志配置文件 - 配置 MyBatis-Plus 和 Druid 数据源 - 实现基本的安全配置,包括未授权和权限不足的处理 - 引入必要的依赖,如 lombok、fastjson2、MariaDB驱动等
This commit is contained in:
@@ -19,5 +19,15 @@
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.nopj.chaos_api.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ApiResult<T> {
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
|
||||
|
||||
public static <T> ApiResult<T> success(T data) {
|
||||
return new ApiResult<>(200, "success", data);
|
||||
}
|
||||
public static <T> ApiResult<T> success(String msg, T data) {
|
||||
return new ApiResult<>(200, msg, data);
|
||||
}
|
||||
public static <T> ApiResult<T> failed(int code, String msg) {
|
||||
return new ApiResult<>(code, msg, null);
|
||||
}
|
||||
public static <T> ApiResult<T> failed(String msg) {
|
||||
return new ApiResult<>(500, msg, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user