From f1227addfbd4afaa966b66e2275c694e734bf807 Mon Sep 17 00:00:00 2001 From: JUZIZZZ <2352856138@qq.com> Date: Sun, 10 Nov 2024 15:40:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=87=B3=E4=B8=8A=E8=AF=BE?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC=EF=BC=8824.11.10=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StudentController.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/com/liulingzhi/springboot/springboot/controller/StudentController.java b/src/main/java/com/liulingzhi/springboot/springboot/controller/StudentController.java index 2022df5..ca0c72a 100644 --- a/src/main/java/com/liulingzhi/springboot/springboot/controller/StudentController.java +++ b/src/main/java/com/liulingzhi/springboot/springboot/controller/StudentController.java @@ -10,8 +10,11 @@ import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import java.io.File; import java.util.List; +import java.util.UUID; /** *

@@ -77,5 +80,30 @@ public class StudentController { return Result.error(); } + @ResponseBody + @RequestMapping("login") + public Result login(String username, String password){ + //todo => 模拟数据库查询 + if (username.equals("admin") && password.equals("123456")){ + return Result.ok("登录成功"); + }else + return Result.error("登录失败"); + + } + + @ResponseBody + @RequestMapping("/uploadcommit") + public Result upload(MultipartFile file){ + //保存文件 + File file1 = new File("D:/Desktop/素材"); + //随机数 不重复 + String filename = UUID.randomUUID() + file.getOriginalFilename(); + try { + file.transferTo(new File(file1,filename)); + }catch (Exception e){ + e.printStackTrace(); + } + return Result.ok().put("data",filename); + } }