add: 登录

This commit is contained in:
jsh
2025-10-12 16:13:04 +08:00
parent 23ff4c814d
commit 68474c0c80
11 changed files with 188 additions and 1 deletions

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