- 新增认证控制器 AuthController,提供登录和注册接口 - 创建 LoginForm 记录类用于接收登录/注册参数 - 定义 User 实体类映射数据库用户表结构 - 添加 UserMapper 接口继承 MyBatis-Plus 的 BaseMapper - 实现 AuthService 接口,完成登录与注册业务逻辑 - 集成 Sa-Token 框架进行权限认证管理 - 配置拦截器排除 /auth/login 路径的认证检查 - 引入 ServiceException 自定义服务异常类 - 增加全局异常处理器 ExceptionFilter 处理认证相关异常 - 创建统一响应模型 R 封装接口返回数据格式 - 在主应用类上添加 Mapper 扫描注解支持 MyBatis 映射 - 更新 application.yml 配置文件,加入数据源及 MyBatis-Plus 设置 - 修改 pom.xml 添加 MyBatis-Plus 和 Sa-Token 相关依赖项
107 lines
2.8 KiB
XML
107 lines
2.8 KiB
XML
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
<modelVersion>4.0.0</modelVersion>
|
|
<parent>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-starter-parent</artifactId>
|
|
<version>3.5.7</version>
|
|
<relativePath/> <!-- lookup parent from repository -->
|
|
</parent>
|
|
<groupId>com.kane</groupId>
|
|
<artifactId>Animo</artifactId>
|
|
<version>0.0.1-SNAPSHOT</version>
|
|
<name>Animo</name>
|
|
<description>Animo</description>
|
|
<url/>
|
|
<licenses>
|
|
<license/>
|
|
</licenses>
|
|
<developers>
|
|
<developer/>
|
|
</developers>
|
|
<scm>
|
|
<connection/>
|
|
<developerConnection/>
|
|
<tag/>
|
|
<url/>
|
|
</scm>
|
|
<properties>
|
|
<java.version>17</java.version>
|
|
</properties>
|
|
<dependencies>
|
|
<dependency>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-starter-web</artifactId>
|
|
</dependency>
|
|
|
|
<dependency>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-devtools</artifactId>
|
|
<scope>runtime</scope>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
<!-- <dependency>-->
|
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
<!-- <artifactId>spring-boot-docker-compose</artifactId>-->
|
|
<!-- <scope>runtime</scope>-->
|
|
<!-- <optional>true</optional>-->
|
|
<!-- </dependency>-->
|
|
<dependency>
|
|
<groupId>com.mysql</groupId>
|
|
<artifactId>mysql-connector-j</artifactId>
|
|
<scope>runtime</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.projectlombok</groupId>
|
|
<artifactId>lombok</artifactId>
|
|
<optional>true</optional>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-starter-test</artifactId>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>com.baomidou</groupId>
|
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
|
<version>3.5.10.1</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>cn.dev33</groupId>
|
|
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
|
<version>1.39.0</version>
|
|
</dependency>
|
|
</dependencies>
|
|
|
|
<build>
|
|
<plugins>
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-compiler-plugin</artifactId>
|
|
<configuration>
|
|
<annotationProcessorPaths>
|
|
<path>
|
|
<groupId>org.projectlombok</groupId>
|
|
<artifactId>lombok</artifactId>
|
|
</path>
|
|
</annotationProcessorPaths>
|
|
</configuration>
|
|
</plugin>
|
|
<plugin>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
<configuration>
|
|
<excludes>
|
|
<exclude>
|
|
<groupId>org.projectlombok</groupId>
|
|
<artifactId>lombok</artifactId>
|
|
</exclude>
|
|
</excludes>
|
|
</configuration>
|
|
</plugin>
|
|
</plugins>
|
|
</build>
|
|
|
|
</project>
|