更新至上课最新版本(24.11.10)

This commit is contained in:
JUZIZZZ 2024-11-10 15:40:00 +08:00
parent 944b62a8c1
commit f1227addfb
1 changed files with 28 additions and 0 deletions

View File

@ -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;
/**
* <p>
@ -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);
}
}