修改登录API逻辑
This commit is contained in:
@@ -4,26 +4,40 @@ import com.guo.learningprogresstracker.domain.entity.CommonResult;
|
||||
import com.guo.learningprogresstracker.domain.model.LoginBody;
|
||||
import com.guo.learningprogresstracker.exception.AppException;
|
||||
import com.guo.learningprogresstracker.service.LoginService;
|
||||
import com.guo.learningprogresstracker.service.UserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class LoginController {
|
||||
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
private final LoginService loginService;
|
||||
private final UserService userServiceImpl;
|
||||
|
||||
@Operation(summary = "登录API")
|
||||
@PostMapping("/login")
|
||||
public CommonResult<Object> login(@RequestBody LoginBody loginBody) throws AppException {
|
||||
String token = loginService.login(loginBody.getUsername(),loginBody.getPassword());
|
||||
return CommonResult.success("登录成功!",token);
|
||||
String userId = userServiceImpl.authenticate(loginBody.getUsername(), loginBody.getPassword());
|
||||
String token = loginService.login(userId);
|
||||
//todo 参数传递未加密
|
||||
return CommonResult.success("登录成功!", token);
|
||||
}
|
||||
|
||||
@Operation(summary = "退出登录API-功能未完成")
|
||||
@PostMapping("/loingOut")
|
||||
public CommonResult loingOut(@RequestBody LoginBody loginBody) throws AppException {
|
||||
//todo loginOut 退出登录API
|
||||
// loginService.loginOut();
|
||||
return CommonResult.success("已登出");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user