diff --git a/pom.xml b/pom.xml
index a6fb3a7..dbb6027 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,7 +61,11 @@
org.springframework.boot
spring-boot-starter-data-redis
-
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ 3.17.4
+
org.projectlombok
diff --git a/src/main/java/icu/sunway/ai_spring_example/Common/Utils/OSSUtil.java b/src/main/java/icu/sunway/ai_spring_example/Common/Utils/OSSUtil.java
new file mode 100644
index 0000000..2300aa6
--- /dev/null
+++ b/src/main/java/icu/sunway/ai_spring_example/Common/Utils/OSSUtil.java
@@ -0,0 +1,78 @@
+package icu.sunway.ai_spring_example.Common.Utils;
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.model.PutObjectRequest;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.UUID;
+
+@Component
+public class OSSUtil {
+
+ @Value("${aliyun.oss.endpoint}")
+ private String endpoint;
+ @Value("${aliyun.oss.accessKeyId}")
+ private String accessKeyId;
+ @Value("${aliyun.oss.accessKeySecret}")
+ private String accessKeySecret;
+ @Value("${aliyun.oss.bucketName}")
+ private String bucketName;
+ @Value("${aliyun.oss.urlPrefix}")
+ private String urlPrefix;
+
+ /**
+ * 生成预签名上传 URL(前端直传)
+ */
+ public String generatePresignedUrl(String fileName) {
+ OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+
+ String key = "images/" + LocalDate.now() + "/" + UUID.randomUUID() + getFileExtension(fileName);
+ Date expiration = new Date(System.currentTimeMillis() + 30 * 60 * 1000); // 30分钟过期
+
+ URL url = ossClient.generatePresignedUrl(bucketName, key, expiration);
+ ossClient.shutdown();
+
+ return url.toString();
+ }
+
+ /**
+ * 获取文件访问 URL
+ */
+ public String getFileUrl(String fileName) {
+ String key = "images/" + LocalDate.now() + "/" + UUID.randomUUID() + getFileExtension(fileName);
+ return urlPrefix + key;
+ }
+
+ /**
+ * 后端直接上传文件到 OSS
+ */
+ public String uploadFile(String originalFilename, InputStream inputStream) {
+ OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+
+ String key = "images/" + LocalDate.now() + "/" + UUID.randomUUID() + getFileExtension(originalFilename);
+
+ try {
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, inputStream);
+ ossClient.putObject(putObjectRequest);
+ return urlPrefix + key;
+ } finally {
+ ossClient.shutdown();
+ }
+ }
+
+ /**
+ * 获取文件扩展名
+ */
+ private String getFileExtension(String fileName) {
+ if (fileName == null || !fileName.contains(".")) {
+ return "";
+ }
+ return fileName.substring(fileName.lastIndexOf("."));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/icu/sunway/ai_spring_example/Controllers/Admin.java b/src/main/java/icu/sunway/ai_spring_example/Controllers/Admin.java
deleted file mode 100644
index 057b0da..0000000
--- a/src/main/java/icu/sunway/ai_spring_example/Controllers/Admin.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package icu.sunway.ai_spring_example.Controllers;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import icu.sunway.ai_spring_example.Common.Response.ResponseEntity;
-
-/**
- * 用户管理后台接口
- * 提供用户管理相关的功能
- */
-@RestController
-public class Admin {
-
- /**
- * 获取用户列表
- *
- * @param params 查询参数,包含page、size、username、status等字段
- * @return 用户列表数据
- */
- @GetMapping("/admin/users")
- public ResponseEntity> getUserList(@RequestParam Map params) {
- // 从Map中获取查询参数
- Integer page = Integer.valueOf((String) params.getOrDefault("page", "1"));
- Integer size = Integer.valueOf((String) params.getOrDefault("size", "10"));
- String username = (String) params.get("username");
- Integer status = params.get("status") != null ? Integer.valueOf((String) params.get("status")) : null;
-
- // TODO: 实现查询逻辑
- // 1. 根据条件查询用户列表
- // 2. 处理分页
-
- // 模拟返回用户列表
- List