|
|
@@ -1,14 +1,12 @@
|
|
|
package com.bcn.login_mybatis_demo.controller;
|
|
|
|
|
|
+import com.bcn.login_mybatis_demo.pojo.LoginRequest;
|
|
|
import com.bcn.login_mybatis_demo.pojo.User;
|
|
|
import com.bcn.login_mybatis_demo.service.serviceImpl.UserServiceImpl;
|
|
|
import com.bcn.login_mybatis_demo.util.Result;
|
|
|
import com.bcn.login_mybatis_demo.util.ResultUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
/**
|
|
|
* @author 大白菜
|
|
|
@@ -17,13 +15,16 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@SuppressWarnings({"all"})
|
|
|
@RestController
|
|
|
@RequestMapping("/user")
|
|
|
+@CrossOrigin(origins = "http://localhost:5173", allowCredentials = "true")
|
|
|
public class UserController {
|
|
|
@Autowired
|
|
|
UserServiceImpl userServiceImpl;
|
|
|
|
|
|
- @RequestMapping("/login")
|
|
|
- public Result login(@RequestParam String uact, @RequestParam String upwd) {
|
|
|
- String msg = userServiceImpl.loginService(uact,upwd);
|
|
|
+ @PostMapping("/login")
|
|
|
+ public Result login(@RequestBody LoginRequest loginRequest) {
|
|
|
+ String username = loginRequest.getUsername();
|
|
|
+ String password = loginRequest.getPassword();
|
|
|
+ String msg = userServiceImpl.loginService(username, password);
|
|
|
if(("SUCCESS").equals(msg)){
|
|
|
return ResultUtil.success("登录成功");
|
|
|
}else{
|