From cb1352b3ff2382a77af16f7dfddc8f28cec16661 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=88=90=E7=AD=B1=E7=AD=B1?= <1851433261@qq.com>
Date: Thu, 9 Jul 2026 23:17:25 +0800
Subject: [PATCH] 1
---
"Redis\344\275\234\344\270\232/.gitignore" | 33 -
.../.idea/.gitignore" | 10 +
.../.idea/claudeCodeTabState.xml" | 20 +
.../.idea/compiler.xml" | 15 +
.../.idea/dataSources.xml" | 17 +
.../.idea/encodings.xml" | 7 +
.../.idea/jarRepositories.xml" | 20 +
.../.idea/misc.xml" | 67 ++
"Redis\344\275\234\344\270\232/.idea/vcs.xml" | 6 +
"Redis\344\275\234\344\270\232/1.txt" | 0
"Redis\344\275\234\344\270\232/HELP.md" | 20 +
"Redis\344\275\234\344\270\232/openapi.json" | 392 ------------
"Redis\344\275\234\344\270\232/pom.xml" | 134 ----
.../chenghao/student/StudentApplication.java" | 13 -
.../student/annotation/Loggable.java" | 11 -
.../annotation/MonitorPerformance.java" | 12 -
.../student/aspect/LoggingAspect.java" | 24 -
.../student/aspect/PerformanceAspect.java" | 33 -
.../student/common/BusinessException.java" | 28 -
.../common/GlobalExceptionHandler.java" | 90 ---
.../com/chenghao/student/common/Result.java" | 44 --
.../chenghao/student/config/RedisConfig.java" | 26 -
.../student/controller/DemoController.java" | 20 -
.../controller/StudentController.java" | 53 --
.../student/dto/StudentCreateDTO.java" | 24 -
.../chenghao/student/dto/StudentQuery.java" | 20 -
.../com/chenghao/student/entity/Student.java" | 18 -
.../student/mapper/StudentMapper.java" | 32 -
.../student/service/StudentService.java" | 15 -
.../student/service/impl/DemoService.java" | 20 -
.../service/impl/StudentServiceImpl.java" | 108 ----
.../com/chenghao/student/util/RedisUtil.java" | 374 ------------
.../com/chenghao/student/vo/StudentVO.java" | 15 -
.../student/IocApplicationTests.java" | 13 -
.../target/classes/application.yml" | 38 --
.../student/StudentApplication.class" | Bin 0 -> 720 bytes
.../student/annotation/Loggable.class" | Bin 0 -> 401 bytes
.../annotation/MonitorPerformance.class" | Bin 0 -> 421 bytes
.../student/aspect/LoggingAspect.class" | Bin 0 -> 1662 bytes
.../student/aspect/PerformanceAspect.class" | Bin 0 -> 2062 bytes
.../student/common/BusinessException.class" | Bin 0 -> 1126 bytes
.../common/GlobalExceptionHandler.class" | Bin 0 -> 7292 bytes
.../com/chenghao/student/common/Result.class" | Bin 0 -> 4587 bytes
.../controller/StudentController.class" | Bin 0 -> 3825 bytes
.../student/dto/StudentCreateDTO.class" | Bin 0 -> 2821 bytes
.../chenghao/student/dto/StudentQuery.class" | Bin 0 -> 3318 bytes
.../chenghao/student/entity/Student.class" | Bin 0 -> 4203 bytes
.../student/mapper/StudentMapper.class" | Bin 0 -> 1178 bytes
.../student/service/StudentService.class" | Bin 0 -> 638 bytes
.../service/impl/StudentServiceImpl.class" | Bin 0 -> 6373 bytes
.../com/chenghao/student/vo/StudentVO.class" | Bin 0 -> 3748 bytes
.../target/classes/mapper/StudentMapper.xml" | 0
.../compile/default-compile/createdFiles.lst" | 10 +
.../compile/default-compile/inputFiles.lst" | 10 +
.../student/IocApplicationTests.class" | Bin 0 -> 536 bytes
...347\273\237API\346\226\207\346\241\243.md" | 573 ------------------
56 files changed, 202 insertions(+), 2163 deletions(-)
delete mode 100644 "Redis\344\275\234\344\270\232/.gitignore"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/.gitignore"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/claudeCodeTabState.xml"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/compiler.xml"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/dataSources.xml"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/encodings.xml"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/jarRepositories.xml"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/misc.xml"
create mode 100644 "Redis\344\275\234\344\270\232/.idea/vcs.xml"
create mode 100644 "Redis\344\275\234\344\270\232/1.txt"
create mode 100644 "Redis\344\275\234\344\270\232/HELP.md"
delete mode 100644 "Redis\344\275\234\344\270\232/openapi.json"
delete mode 100644 "Redis\344\275\234\344\270\232/pom.xml"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/StudentApplication.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/Loggable.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/MonitorPerformance.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/LoggingAspect.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/PerformanceAspect.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/BusinessException.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/GlobalExceptionHandler.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/Result.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/config/RedisConfig.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/DemoController.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/StudentController.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentCreateDTO.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentQuery.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/entity/Student.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/mapper/StudentMapper.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/StudentService.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/DemoService.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/StudentServiceImpl.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/util/RedisUtil.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/vo/StudentVO.java"
delete mode 100644 "Redis\344\275\234\344\270\232/src/test/java/com/chenghao/student/IocApplicationTests.java"
rename "Redis\344\275\234\344\270\232/src/main/resources/application.yml" => "Redis\344\275\234\344\270\232/target/classes/application.yml" (65%)
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/StudentApplication.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/annotation/Loggable.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/annotation/MonitorPerformance.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/aspect/LoggingAspect.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/aspect/PerformanceAspect.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/common/BusinessException.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/common/GlobalExceptionHandler.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/common/Result.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/controller/StudentController.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/dto/StudentCreateDTO.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/dto/StudentQuery.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/entity/Student.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/mapper/StudentMapper.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/service/StudentService.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/service/impl/StudentServiceImpl.class"
create mode 100644 "Redis\344\275\234\344\270\232/target/classes/com/chenghao/student/vo/StudentVO.class"
rename "Redis\344\275\234\344\270\232/src/main/resources/mapper/StudentMapper.xml" => "Redis\344\275\234\344\270\232/target/classes/mapper/StudentMapper.xml" (100%)
create mode 100644 "Redis\344\275\234\344\270\232/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst"
create mode 100644 "Redis\344\275\234\344\270\232/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst"
create mode 100644 "Redis\344\275\234\344\270\232/target/test-classes/com/chenghao/student/IocApplicationTests.class"
delete mode 100644 "Redis\344\275\234\344\270\232/\345\255\246\347\224\237\347\256\241\347\220\206\347\263\273\347\273\237API\346\226\207\346\241\243.md"
diff --git "a/Redis\344\275\234\344\270\232/.gitignore" "b/Redis\344\275\234\344\270\232/.gitignore"
deleted file mode 100644
index 549e00a..0000000
--- "a/Redis\344\275\234\344\270\232/.gitignore"
+++ /dev/null
@@ -1,33 +0,0 @@
-HELP.md
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**/target/
-!**/src/test/**/target/
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-!**/src/main/**/build/
-!**/src/test/**/build/
-
-### VS Code ###
-.vscode/
diff --git "a/Redis\344\275\234\344\270\232/.idea/.gitignore" "b/Redis\344\275\234\344\270\232/.idea/.gitignore"
new file mode 100644
index 0000000..30cf57e
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/.gitignore"
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git "a/Redis\344\275\234\344\270\232/.idea/claudeCodeTabState.xml" "b/Redis\344\275\234\344\270\232/.idea/claudeCodeTabState.xml"
new file mode 100644
index 0000000..1b85f06
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/claudeCodeTabState.xml"
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/.idea/compiler.xml" "b/Redis\344\275\234\344\270\232/.idea/compiler.xml"
new file mode 100644
index 0000000..2f1aeac
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/compiler.xml"
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/.idea/dataSources.xml" "b/Redis\344\275\234\344\270\232/.idea/dataSources.xml"
new file mode 100644
index 0000000..b6625b1
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/dataSources.xml"
@@ -0,0 +1,17 @@
+
+
+
+
+ mysql.8
+ true
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://localhost:3306/spring_ioc_demo
+
+
+
+
+
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/.idea/encodings.xml" "b/Redis\344\275\234\344\270\232/.idea/encodings.xml"
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/encodings.xml"
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/.idea/jarRepositories.xml" "b/Redis\344\275\234\344\270\232/.idea/jarRepositories.xml"
new file mode 100644
index 0000000..abb532a
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/jarRepositories.xml"
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/.idea/misc.xml" "b/Redis\344\275\234\344\270\232/.idea/misc.xml"
new file mode 100644
index 0000000..c50f98b
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/misc.xml"
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ CastNumeric issuesJava
+
+
+ Compiler issuesJava
+
+
+ EmbeddedPerformanceJava
+
+
+ Java
+
+
+ Java 5Java language level migration aidsJava
+
+
+ Java 9Java language level migration aidsJava
+
+
+ Java interop issuesKotlin
+
+
+ Java language level migration aidsJava
+
+
+ Kotlin
+
+
+ Numeric issuesJava
+
+
+ PerformanceJava
+
+
+ Probable bugsKotlin
+
+
+ Style issuesKotlin
+
+
+
+
+ User defined
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/.idea/vcs.xml" "b/Redis\344\275\234\344\270\232/.idea/vcs.xml"
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/.idea/vcs.xml"
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/1.txt" "b/Redis\344\275\234\344\270\232/1.txt"
new file mode 100644
index 0000000..e69de29
diff --git "a/Redis\344\275\234\344\270\232/HELP.md" "b/Redis\344\275\234\344\270\232/HELP.md"
new file mode 100644
index 0000000..5a8c912
--- /dev/null
+++ "b/Redis\344\275\234\344\270\232/HELP.md"
@@ -0,0 +1,20 @@
+# Getting Started
+
+### Reference Documentation
+
+For further reference, please consider the following sections:
+
+* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
+* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.7.6/maven-plugin/reference/html/)
+* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.7.6/maven-plugin/reference/html/#build-image)
+* [Spring Web](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#web)
+* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/2.7.6/reference/htmlsingle/#using.devtools)
+
+### Guides
+
+The following guides illustrate how to use some features concretely:
+
+* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
+* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
+* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
+
diff --git "a/Redis\344\275\234\344\270\232/openapi.json" "b/Redis\344\275\234\344\270\232/openapi.json"
deleted file mode 100644
index e30fa59..0000000
--- "a/Redis\344\275\234\344\270\232/openapi.json"
+++ /dev/null
@@ -1,392 +0,0 @@
-{
- "openapi": "3.0.1",
- "info": {
- "title": "学生管理系统API",
- "description": "学生信息管理系统的RESTful API接口文档",
- "version": "1.0.0"
- },
- "servers": [
- {
- "url": "http://localhost:8080",
- "description": "本地开发环境"
- }
- ],
- "tags": [
- {
- "name": "学生管理",
- "description": "学生信息的增删改查操作"
- }
- ],
- "paths": {
- "/api/student/{id}": {
- "get": {
- "tags": ["学生管理"],
- "summary": "根据ID查询学生",
- "operationId": "getStudentById",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "example": 200
- },
- "message": {
- "type": "string",
- "example": "成功"
- },
- "data": {
- "type": "object",
- "properties": {
- "id": {
- "type": "integer",
- "format": "int64"
- },
- "name": {
- "type": "string"
- },
- "phone": {
- "type": "string"
- },
- "email": {
- "type": "string"
- },
- "status": {
- "type": "integer"
- },
- "createdAt": {
- "type": "string",
- "format": "date-time"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- },
- "put": {
- "tags": ["学生管理"],
- "summary": "更新学生信息",
- "operationId": "updateStudent",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- }
- ],
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "required": ["name", "phone"],
- "properties": {
- "name": {
- "type": "string",
- "minLength": 2,
- "maxLength": 20,
- "example": "张三"
- },
- "phone": {
- "type": "string",
- "pattern": "^1[3-9]\\d{9}$",
- "example": "13800138000"
- },
- "email": {
- "type": "string",
- "format": "email",
- "example": "zhangsan@example.com"
- }
- }
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "example": 200
- },
- "message": {
- "type": "string",
- "example": "更新成功"
- },
- "data": {
- "type": "object",
- "nullable": true
- }
- }
- }
- }
- }
- }
- }
- },
- "delete": {
- "tags": ["学生管理"],
- "summary": "删除学生",
- "operationId": "deleteStudent",
- "parameters": [
- {
- "name": "id",
- "in": "path",
- "required": true,
- "schema": {
- "type": "integer",
- "format": "int64"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "example": 200
- },
- "message": {
- "type": "string",
- "example": "删除成功"
- },
- "data": {
- "type": "object",
- "nullable": true
- }
- }
- }
- }
- }
- }
- }
- }
- },
- "/api/student": {
- "post": {
- "tags": ["学生管理"],
- "summary": "创建学生",
- "operationId": "createStudent",
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "required": ["name", "phone"],
- "properties": {
- "name": {
- "type": "string",
- "minLength": 2,
- "maxLength": 20,
- "example": "王五"
- },
- "phone": {
- "type": "string",
- "pattern": "^1[3-9]\\d{9}$",
- "example": "13900139000"
- },
- "email": {
- "type": "string",
- "format": "email",
- "example": "wangwu@example.com"
- }
- }
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "example": 200
- },
- "message": {
- "type": "string",
- "example": "创建成功"
- },
- "data": {
- "type": "integer",
- "format": "int64",
- "example": 3
- }
- }
- }
- }
- }
- }
- }
- }
- },
- "/api/student/page": {
- "get": {
- "tags": ["学生管理"],
- "summary": "分页查询学生列表",
- "operationId": "pageStudent",
- "parameters": [
- {
- "name": "pageNum",
- "in": "query",
- "required": true,
- "schema": {
- "type": "integer",
- "minimum": 1,
- "default": 1
- }
- },
- {
- "name": "pageSize",
- "in": "query",
- "required": true,
- "schema": {
- "type": "integer",
- "minimum": 1,
- "default": 10
- }
- },
- {
- "name": "keyword",
- "in": "query",
- "required": false,
- "schema": {
- "type": "string"
- }
- },
- {
- "name": "status",
- "in": "query",
- "required": false,
- "schema": {
- "type": "integer",
- "enum": [0, 1]
- }
- }
- ],
- "responses": {
- "200": {
- "description": "成功",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "example": 200
- },
- "message": {
- "type": "string",
- "example": "成功"
- },
- "data": {
- "type": "object",
- "properties": {
- "total": {
- "type": "integer",
- "format": "int64"
- },
- "list": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "id": {
- "type": "integer",
- "format": "int64"
- },
- "name": {
- "type": "string"
- },
- "phone": {
- "type": "string"
- },
- "email": {
- "type": "string"
- },
- "status": {
- "type": "integer"
- },
- "createdAt": {
- "type": "string",
- "format": "date-time"
- }
- }
- }
- },
- "pageNum": {
- "type": "integer"
- },
- "pageSize": {
- "type": "integer"
- },
- "size": {
- "type": "integer"
- },
- "pages": {
- "type": "integer"
- },
- "isFirstPage": {
- "type": "boolean"
- },
- "isLastPage": {
- "type": "boolean"
- },
- "hasPreviousPage": {
- "type": "boolean"
- },
- "hasNextPage": {
- "type": "boolean"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/pom.xml" "b/Redis\344\275\234\344\270\232/pom.xml"
deleted file mode 100644
index 07e2da4..0000000
--- "a/Redis\344\275\234\344\270\232/pom.xml"
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
- 4.0.0
- com.chenghao
- student
- 0.0.1-SNAPSHOT
- IOC
- IOC
-
- 1.8
- UTF-8
- UTF-8
- 2.7.18
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
-
- org.springframework.boot
- spring-boot-devtools
- runtime
- true
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- org.springframework.boot
- spring-boot-starter-aop
-
-
-
-
- org.projectlombok
- lombok
-
-
-
- org.mybatis.spring.boot
- mybatis-spring-boot-starter
- 2.3.0
-
-
-
-
- com.mysql
- mysql-connector-j
- runtime
-
-
-
-
- org.springframework.boot
- spring-boot-starter-jdbc
-
-
-
- com.alibaba
- druid-spring-boot-starter
- 1.2.1
-
-
- org.springframework.boot
- spring-boot-starter-validation
-
-
-
- com.github.pagehelper
- pagehelper-spring-boot-starter
- 1.4.7
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-dependencies
- ${spring-boot.version}
- pom
- import
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
-
- 1.8
- 1.8
- UTF-8
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- ${spring-boot.version}
-
- com.chenghao.student.StudentApplication
- true
-
-
-
- repackage
-
- repackage
-
-
-
-
-
-
-
\ No newline at end of file
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/StudentApplication.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/StudentApplication.java"
deleted file mode 100644
index 14c9558..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/StudentApplication.java"
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.chenghao.student;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class StudentApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(StudentApplication.class, args);
- }
-
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/Loggable.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/Loggable.java"
deleted file mode 100644
index 140923f..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/Loggable.java"
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.chenghao.student.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Loggable {
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/MonitorPerformance.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/MonitorPerformance.java"
deleted file mode 100644
index 145ef6b..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/annotation/MonitorPerformance.java"
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.chenghao.student.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface MonitorPerformance {
-
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/LoggingAspect.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/LoggingAspect.java"
deleted file mode 100644
index 0c30e97..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/LoggingAspect.java"
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.chenghao.student.aspect;
-
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.springframework.stereotype.Component;
-
-@Aspect
-@Component
-@Slf4j
-public class LoggingAspect {
-
- @Around("@annotation(com.chenghao.student.annotation.Loggable)")
- public Object logMethod(ProceedingJoinPoint joinPoint) throws Throwable{
- String methodName = joinPoint.getSignature().toShortString();
- Object[] args = joinPoint.getArgs();
- log.info("[调用开始] 方法:{},参数:{}",methodName,args);
-
- Object result = joinPoint.proceed();
- log.info("[调用结束] 方法:{},返回值:{}",methodName,result);
- return result;
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/PerformanceAspect.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/PerformanceAspect.java"
deleted file mode 100644
index 89400ba..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/aspect/PerformanceAspect.java"
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.chenghao.student.aspect;
-
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.springframework.stereotype.Component;
-
-@Component
-@Aspect
-@Slf4j
-public class PerformanceAspect {
-
- @Around("@annotation(com.chenghao.student.annotation.MonitorPerformance)")
- public Object monitorPerformance(ProceedingJoinPoint joinPoint) throws Throwable{
- long startTime = System.currentTimeMillis();
- String methodName = joinPoint.getSignature().getName();
-
- try {
- Object result = joinPoint.proceed();
- long endTime = System.currentTimeMillis();
- long duration = endTime- startTime;
-
- log.info("执行时间为:{}",duration);
- return result;
- }catch (Exception e){
- long endTime = System.currentTimeMillis();
- log.error("方法{}执行失败,耗时{}ms,错误{}",
- methodName,endTime-startTime,e.getMessage());
- throw e;
- }
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/BusinessException.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/BusinessException.java"
deleted file mode 100644
index 504b6c5..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/BusinessException.java"
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.chenghao.student.common;
-
-import lombok.Getter;
-
-@Getter
-public class BusinessException extends RuntimeException {
- private Integer code;
-
- public BusinessException(String message) {
- super(message);
- this.code = 400;
- }
-
- public BusinessException(Integer code, String message) {
- super(message);
- this.code = code;
- }
-
- public BusinessException(String message, Throwable cause) {
- super(message, cause);
- this.code = 400;
- }
-
- public BusinessException(Integer code, String message, Throwable cause) {
- super(message, cause);
- this.code = code;
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/GlobalExceptionHandler.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/GlobalExceptionHandler.java"
deleted file mode 100644
index ce49fd2..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/GlobalExceptionHandler.java"
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.chenghao.student.common;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.HttpStatus;
-import org.springframework.validation.BindException;
-import org.springframework.validation.FieldError;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.stream.Collectors;
-
-@Slf4j
-@RestControllerAdvice
-public class GlobalExceptionHandler {
-
- /**
- * 业务异常处理
- */
- @ExceptionHandler(BusinessException.class)
- public Result handleBusinessException(BusinessException e, HttpServletRequest request) {
- log.warn("业务异常: uri={}, message={}", request.getRequestURI(), e.getMessage());
- return Result.error(e.getCode(), e.getMessage());
- }
-
- /**
- * 参数校验异常(@Valid 注解校验失败)
- */
- @ExceptionHandler(MethodArgumentNotValidException.class)
- public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException e, HttpServletRequest request) {
- String errorMessage = e.getBindingResult().getFieldErrors().stream()
- .map(FieldError::getDefaultMessage)
- .collect(Collectors.joining(", "));
- log.warn("参数校验失败: uri={}, message={}", request.getRequestURI(), errorMessage);
- return Result.error(400, "参数校验失败: " + errorMessage);
- }
-
- /**
- * 参数绑定异常(表单提交校验失败)
- */
- @ExceptionHandler(BindException.class)
- public Result handleBindException(BindException e, HttpServletRequest request) {
- String errorMessage = e.getBindingResult().getFieldErrors().stream()
- .map(FieldError::getDefaultMessage)
- .collect(Collectors.joining(", "));
- log.warn("参数绑定失败: uri={}, message={}", request.getRequestURI(), errorMessage);
- return Result.error(400, "参数错误: " + errorMessage);
- }
-
- /**
- * 参数类型不匹配异常
- */
- @ExceptionHandler(MethodArgumentTypeMismatchException.class)
- public Result handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) {
- log.warn("参数类型不匹配: uri={}, param={}, message={}",
- request.getRequestURI(), e.getName(), e.getMessage());
- return Result.error(400, "参数类型错误: " + e.getName());
- }
-
- /**
- * 空指针异常
- */
- @ExceptionHandler(NullPointerException.class)
- public Result handleNullPointerException(NullPointerException e, HttpServletRequest request) {
- log.error("空指针异常: uri={}", request.getRequestURI(), e);
- return Result.error(500, "系统内部错误");
- }
-
- /**
- * 非法参数异常
- */
- @ExceptionHandler(IllegalArgumentException.class)
- public Result handleIllegalArgumentException(IllegalArgumentException e, HttpServletRequest request) {
- log.warn("非法参数异常: uri={}, message={}", request.getRequestURI(), e.getMessage());
- return Result.error(400, e.getMessage());
- }
-
- /**
- * 通用异常处理(兜底)
- */
- @ExceptionHandler(Exception.class)
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- public Result handleException(Exception e, HttpServletRequest request) {
- log.error("系统异常: uri={}, message={}", request.getRequestURI(), e.getMessage(), e);
- return Result.error(500, "系统异常,请联系管理员");
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/Result.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/Result.java"
deleted file mode 100644
index 0278795..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/common/Result.java"
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.chenghao.student.common;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class Result {
-
- private Integer code;
- private String message;
- private T data;
-
- public Result(int code, String message) {
- this.code = code;
- this.message = message;
- }
-
- public static Result success() {
- return new Result<>(200, "成功", null);
- }
-
- public static Result success(T data) {
- return new Result<>(200, "成功", data);
- }
- public static Result success(String message) {
- return new Result<>(200, message);
- }
-
- public static Result error(String message) {
- return new Result<>(400, message, null);
- }
-
- public static Result error(Integer code, String message) {
- return new Result<>(code, message, null);
- }
- public static Result success(String message, T data) {
- return new Result<>( 200 ,message, data);
- }
-
-
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/config/RedisConfig.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/config/RedisConfig.java"
deleted file mode 100644
index 2156890..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/config/RedisConfig.java"
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.chenghao.student.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-@Configuration
-public class RedisConfig {
-
- @Bean
- public RedisTemplate redisTemplate(RedisConnectionFactory factory){
- RedisTemplate template = new RedisTemplate<>();
- template.setConnectionFactory(factory);
-
- template.setKeySerializer(new StringRedisSerializer());
- template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
- template.setHashKeySerializer(new StringRedisSerializer());
- template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
-
- template.afterPropertiesSet();
- return template;
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/DemoController.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/DemoController.java"
deleted file mode 100644
index 1a19517..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/DemoController.java"
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.chenghao.student.controller;
-
-import com.chenghao.student.common.Result;
-import com.chenghao.student.service.impl.DemoService;
-import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.*;
-
-@RestController
-@RequestMapping("/api/demo")
-@AllArgsConstructor
-public class DemoController {
-
- private final DemoService demoService;
-
- @GetMapping("/test")
- public Result test() {
- demoService.demo();
- return Result.success("Redis 操作完成");
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/StudentController.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/StudentController.java"
deleted file mode 100644
index 047f3f0..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/controller/StudentController.java"
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.chenghao.student.controller;
-
-import com.chenghao.student.common.Result;
-import com.chenghao.student.dto.StudentCreateDTO;
-import com.chenghao.student.dto.StudentQuery;
-import com.chenghao.student.entity.Student;
-import com.chenghao.student.service.StudentService;
-import com.chenghao.student.vo.StudentVO;
-import com.github.pagehelper.PageInfo;
-import lombok.AllArgsConstructor;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-
-@RestController
-@RequestMapping("/api/student")
-@AllArgsConstructor
-public class StudentController {
-
- private final StudentService studentService;
-
- @GetMapping("/{id}")
- Result getById(@PathVariable Long id){
- StudentVO studentVO = studentService.getById(id);
- return Result.success(studentVO);
- }
-
- @GetMapping("/page")
- Result> page(@Valid StudentQuery query){
- PageInfo pageInfo = studentService.page(query);
- return Result.success(pageInfo);
- }
-
- @PostMapping
- Result create(@Valid @RequestBody StudentCreateDTO dto){
- Long id = studentService.create(dto);
- return Result.success("创建成功",id);
- }
-
- @PutMapping("/{id}")
- public Result update(@PathVariable Long id,
- @Valid @RequestBody StudentCreateDTO dto){
- studentService.update(id,dto);
- return Result.success("更新成功");
- }
-
- @DeleteMapping("/{id}")
- Result delete(@PathVariable Long id){
- studentService.delete(id);
- return Result.success("删除成功");
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentCreateDTO.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentCreateDTO.java"
deleted file mode 100644
index 7dbf685..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentCreateDTO.java"
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.chenghao.student.dto;
-
-import lombok.Data;
-
-import javax.validation.constraints.Email;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.Pattern;
-import javax.validation.constraints.Size;
-import java.math.BigDecimal;
-
-@Data
-public class StudentCreateDTO {
-
- @NotBlank(message = "姓名不能为空")
- @Size(min = 2 ,max = 20,message = "姓名长度为2-20个字符")
- private String name;
-
- @NotBlank(message = "手机号不能为空")
- @Pattern(regexp = "^1[3-9]\\d{9}$",message = "手机号格式不正确")
- private String phone;
-
- @Email(message = "邮箱格式不正确")
- private String email;
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentQuery.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentQuery.java"
deleted file mode 100644
index 016c821..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/dto/StudentQuery.java"
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.chenghao.student.dto;
-
-import lombok.Data;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-
-@Data
-public class StudentQuery {
- private String keyword;
- private Integer status;
-
- @NotNull(message = "页码不能为空")
- @Min(value = 1, message = "页码最小为1")
- private Integer pageNum = 1;
-
- @NotNull(message = "每页大小不能为空")
- @Min(value = 1,message = "每页大小最小为1")
- private Integer pageSize = 10;
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/entity/Student.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/entity/Student.java"
deleted file mode 100644
index 4e9cde1..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/entity/Student.java"
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.chenghao.student.entity;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-
-import java.time.LocalDateTime;
-
-
-@Data
-public class Student {
- private Long id;
- private String name;
- private String phone;
- private String email;
- private Integer status;
- private LocalDateTime createdAt;
- private LocalDateTime updatedAt;
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/mapper/StudentMapper.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/mapper/StudentMapper.java"
deleted file mode 100644
index 3cfff4b..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/mapper/StudentMapper.java"
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.chenghao.student.mapper;
-
-import com.chenghao.student.entity.Student;
-import com.chenghao.student.vo.StudentVO;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-
-@Mapper
-public interface StudentMapper {
-
-
- Student selectById(@Param("id") Long id);
-
- List selectList(@Param("status")Integer status,@Param("keyword")String keyword);
-
- int insert(Student student);
-
- int update(Student student);
-
- List selectByIds(List idsList);
-
- void insertBatch(List studentsList);
-
- int deleteById(@Param("id") Long id);
-
- int softDeleteById(@Param("id") Long id);
-
- int countByPhone(@Param("phone") String phone);
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/StudentService.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/StudentService.java"
deleted file mode 100644
index 047101e..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/StudentService.java"
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.chenghao.student.service;
-
-import com.chenghao.student.dto.StudentCreateDTO;
-import com.chenghao.student.dto.StudentQuery;
-import com.chenghao.student.entity.Student;
-import com.chenghao.student.vo.StudentVO;
-import com.github.pagehelper.PageInfo;
-
-public interface StudentService {
- StudentVO getById(Long id);
- PageInfo page(StudentQuery query);
- Long create(StudentCreateDTO dto);
- void update(Long id,StudentCreateDTO dto);
- void delete(Long id);
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/DemoService.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/DemoService.java"
deleted file mode 100644
index b2e4dbc..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/DemoService.java"
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.chenghao.student.service.impl;
-
-import com.chenghao.student.util.RedisUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service
-public class DemoService {
-
- @Autowired
- private RedisUtil redisUtil;
- public void demo(){
- redisUtil.set("name","张三");
- Object name = redisUtil.get("name");
- System.out.println("name = " + name);
- redisUtil.hSet("user:1","name","zhangsan");
- Object username = redisUtil.hGet("user:1", "name");
-
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/StudentServiceImpl.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/StudentServiceImpl.java"
deleted file mode 100644
index a890362..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/service/impl/StudentServiceImpl.java"
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.chenghao.student.service.impl;
-
-import com.chenghao.student.common.BusinessException;
-import com.chenghao.student.dto.StudentCreateDTO;
-import com.chenghao.student.dto.StudentQuery;
-import com.chenghao.student.entity.Student;
-import com.chenghao.student.mapper.StudentMapper;
-import com.chenghao.student.service.StudentService;
-import com.chenghao.student.vo.StudentVO;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import lombok.AllArgsConstructor;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.StringUtils;
-
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Service
-@AllArgsConstructor
-public class StudentServiceImpl implements StudentService {
-
- private final StudentMapper studentMapper;
- @Override
- public StudentVO getById(Long id) {
- Student student = studentMapper.selectById(id);
- if (student == null){
- throw new BusinessException("学生不存在!");
- }
- return toVO(student);
- }
-
- @Override
- public PageInfo page(StudentQuery query) {
- PageHelper.startPage(query.getPageNum(),query.getPageSize());
- List students = studentMapper.selectList(query.getStatus(), query.getKeyword());
- List voList = students.stream().map(this::toVO).collect(Collectors.toList());
- PageInfo pageInfo = new PageInfo<>(voList);
- return pageInfo;
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Long create(StudentCreateDTO dto) {
- if (studentMapper.countByPhone(dto.getPhone())>0){
- throw new BusinessException("手机号已被注册!");
- }
- Student student = new Student();
- BeanUtils.copyProperties(dto,student);
- student.setStatus(1);
- studentMapper.insert(student);
- return student.getId();
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void update(Long id, StudentCreateDTO dto) {
- Student existing = studentMapper.selectById(id);
- if (existing == null){
- throw new BusinessException("学生不存在!");
- }
- if (StringUtils.hasText(dto.getPhone())
- && !existing.getPhone().equals(dto.getPhone())
- && studentMapper.countByPhone(dto.getPhone())>0){
- throw new BusinessException("手机号已经被其他学生使用!");
- }
- Student student = new Student();
- BeanUtils.copyProperties(dto,student);
- student.setId(id);
- studentMapper.update(student);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void delete(Long id) {
- if (studentMapper.selectById(id)==null){
- throw new BusinessException("学生不存在!");
- }
- studentMapper.deleteById(id);
- }
-
- void testCRUD(){
- Student student = new Student();
- student.setName("张三");
- student.setPhone("13800138000");
- student.setStatus(1);
- int rows = studentMapper.insert(student);
- System.out.println("插入行数:"+ rows);
- System.out.println("自增id:"+student.getId());
-
- Student found = studentMapper.selectById(student.getId());
- System.out.println("查询结果:"+found.getName());
-
- found.setName("张三(已修改)");
- found.setUpdatedAt(LocalDateTime.now());
- int updateRows = studentMapper.update(found);
- System.out.println("更新行数:"+ updateRows);
-
- }
- private StudentVO toVO(Student student){
- StudentVO studentVO = new StudentVO();
- BeanUtils.copyProperties(student,studentVO);
- return studentVO;
- }
-}
diff --git "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/util/RedisUtil.java" "b/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/util/RedisUtil.java"
deleted file mode 100644
index 5827673..0000000
--- "a/Redis\344\275\234\344\270\232/src/main/java/com/chenghao/student/util/RedisUtil.java"
+++ /dev/null
@@ -1,374 +0,0 @@
-package com.chenghao.student.util;
-
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.data.redis.core.*;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-@Slf4j
-@Component
-@RequiredArgsConstructor
-public class RedisUtil {
-
- private final RedisTemplate redisTemplate;
-
- // ==================== Key ====================
-
- public boolean hasKey(String key) {
- try {
- return Boolean.TRUE.equals(redisTemplate.hasKey(key));
- } catch (Exception e) {
- log.error("redis hasKey error, key: {}", key, e);
- return false;
- }
- }
-
- public boolean expire(String key, long timeout, TimeUnit unit) {
- try {
- return Boolean.TRUE.equals(redisTemplate.expire(key, timeout, unit));
- } catch (Exception e) {
- log.error("redis expire error, key: {}, timeout: {}, unit: {}", key, timeout, unit, e);
- return false;
- }
- }
-
- public long getExpire(String key, TimeUnit unit) {
- Long expire = redisTemplate.getExpire(key, unit);
- return expire != null ? expire : -2;
- }
-
- public boolean delete(String key) {
- try {
- return Boolean.TRUE.equals(redisTemplate.delete(key));
- } catch (Exception e) {
- log.error("redis delete error, key: {}", key, e);
- return false;
- }
- }
-
- public long delete(Collection keys) {
- try {
- Long count = redisTemplate.delete(keys);
- return count != null ? count : 0;
- } catch (Exception e) {
- log.error("redis batch delete error, keys: {}", keys, e);
- return 0;
- }
- }
-
- public Set keys(String pattern) {
- try {
- return redisTemplate.keys(pattern);
- } catch (Exception e) {
- log.error("redis keys error, pattern: {}", pattern, e);
- return Collections.emptySet();
- }
- }
-
- // ==================== String ====================
-
- public void set(String key, Object value) {
- try {
- redisTemplate.opsForValue().set(key, value);
- log.debug("redis set, key: {}, value: {}", key, value);
- } catch (Exception e) {
- log.error("redis set error, key: {}, value: {}", key, value, e);
- }
- }
-
- public void set(String key, Object value, long timeout, TimeUnit unit) {
- try {
- redisTemplate.opsForValue().set(key, value, timeout, unit);
- log.debug("redis set with timeout, key: {}, value: {}, timeout: {}, unit: {}", key, value, timeout, unit);
- } catch (Exception e) {
- log.error("redis set error, key: {}, value: {}, timeout: {}, unit: {}", key, value, timeout, unit, e);
- }
- }
-
- public boolean setIfAbsent(String key, Object value) {
- try {
- return Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(key, value));
- } catch (Exception e) {
- log.error("redis setIfAbsent error, key: {}, value: {}", key, value, e);
- return false;
- }
- }
-
- public Object get(String key) {
- try {
- return key == null ? null : redisTemplate.opsForValue().get(key);
- } catch (Exception e) {
- log.error("redis get error, key: {}", key, e);
- return null;
- }
- }
-
- @SuppressWarnings("unchecked")
- public T get(String key, Class clazz) {
- Object value = get(key);
- if (value == null) {
- return null;
- }
- if (clazz.isInstance(value)) {
- return (T) value;
- }
- log.warn("redis get type mismatch, key: {}, expected: {}, actual: {}", key, clazz.getSimpleName(), value.getClass().getSimpleName());
- return null;
- }
-
- public long incr(String key, long delta) {
- try {
- Long result = redisTemplate.opsForValue().increment(key, delta);
- return result != null ? result : 0;
- } catch (Exception e) {
- log.error("redis incr error, key: {}, delta: {}", key, delta, e);
- return 0;
- }
- }
-
- // ==================== Hash ====================
-
- public void hSet(String key, String hashKey, Object value) {
- try {
- redisTemplate.opsForHash().put(key, hashKey, value);
- log.debug("redis hSet, key: {}, hashKey: {}, value: {}", key, hashKey, value);
- } catch (Exception e) {
- log.error("redis hSet error, key: {}, hashKey: {}, value: {}", key, hashKey, value, e);
- }
- }
-
- public void hSetAll(String key, Map map) {
- try {
- redisTemplate.opsForHash().putAll(key, map);
- log.debug("redis hSetAll, key: {}, map: {}", key, map);
- } catch (Exception e) {
- log.error("redis hSetAll error, key: {}, map: {}", key, map, e);
- }
- }
-
- public Object hGet(String key, String hashKey) {
- try {
- return redisTemplate.opsForHash().get(key, hashKey);
- } catch (Exception e) {
- log.error("redis hGet error, key: {}, hashKey: {}", key, hashKey, e);
- return null;
- }
- }
-
- public Map