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); + } }