这是我的controller层代码
@Controller
public class UserController {
private Log log = LogFactory.getLog(UserController.class);
@Autowired
private UserService userService;
@PostMapping("/user/login")
public @ResponseBody RspData login(@RequestBody LoginUser loginUser) {
log.info("userName=" + loginUser.getUserName());
log.info("password=" + loginUser.getPassword());
Optional<User> oUser = this.userService.findUserByCode(loginUser.getUserName());
if (oUser.isPresent()) {
RspData rsp = RspData.createInstance();
rsp.putData("token", oUser.get().getCode());
return rsp;
}
return RspData.createError("301", "登录失败");
}
}