liurunyu
2024-04-15 2b34d59bb1e9b37cdecefdb9c39a27fd839a446b
pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -46,10 +46,15 @@
     */
    @PostMapping(path = "login", consumes = MediaType.APPLICATION_JSON_VALUE)//前端提交json数据
    public BaseResponse<UserVo> login(@RequestBody  @Valid LoginVo vo, BindingResult bindingResult) {
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        try {
            if(bindingResult != null && bindingResult.hasErrors()){
                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
            }
            return this.doLogin(vo) ;
        } catch (Exception e) {
            log.error("查询一个用户数据异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return this.doLogin(vo) ;
    }
    /**
@@ -59,10 +64,15 @@
     */
    @PostMapping(path = "loginForm", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)//前端提交form表单数据
    public BaseResponse<UserVo> loginForm(@RequestBody @Valid LoginVo vo, BindingResult bindingResult){
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        try{
            if(bindingResult != null && bindingResult.hasErrors()){
                return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
            }
            return this.doLogin(vo) ;
        } catch (Exception e) {
            log.error("查询一个用户数据异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return this.doLogin(vo) ;
    }
@@ -73,12 +83,17 @@
     */
    @GetMapping(path = "logout")
    public BaseResponse<Boolean> logout(HttpServletRequest hr){
        String token = hr.getHeader("token") ;
        if(token != null){
            this.sv.logout(token) ;
            return BaseResponseUtils.buildSuccess(true);
        }else{
            return BaseResponseUtils.buildFail("未从header中得到token");
        try{
            String token = hr.getHeader("token") ;
            if(token != null){
                this.sv.logout(token) ;
                return BaseResponseUtils.buildSuccess(true);
            }else{
                return BaseResponseUtils.buildFail("未从header中得到token");
            }
        } catch (Exception e) {
            log.error("查询一个用户数据异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }