add: 登录
This commit is contained in:
28
src/main/java/com/dota/nexus/controller/UserController.java
Normal file
28
src/main/java/com/dota/nexus/controller/UserController.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.dota.nexus.controller;
|
||||
|
||||
import com.dota.nexus.entity.LoginDTO;
|
||||
import com.dota.nexus.entity.R;
|
||||
import com.dota.nexus.service.UserService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("user")
|
||||
public class UserController {
|
||||
UserService userService;
|
||||
|
||||
public UserController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@PostMapping("login")
|
||||
public R login(LoginDTO loginDTO) throws Exception {
|
||||
var res = userService.login(loginDTO.username(), loginDTO.password());
|
||||
if (res==null) {
|
||||
return R.error("用户不存在或者密码错误");
|
||||
}
|
||||
|
||||
return R.ok(res);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user