doum
2 天以前 fe29cab3d9bf8ddfeb1bc93a25a79c20276d8171
server/system_gateway/src/main/java/com/doumee/api/gateway/JwtAuthController.java
@@ -1,12 +1,15 @@
package com.doumee.api.gateway;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.config.annotation.LoginNoRequired;
import com.doumee.config.jwt.JwtProperties;
import com.doumee.config.jwt.JwtTokenUtil;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.dao.system.dto.LoginCabinetDTO;
import com.doumee.dao.system.dto.LoginH5DTO;
import com.doumee.dao.system.vo.SystemConfigVo;
import com.doumee.service.business.third.model.ApiResponse;
import com.doumee.service.business.third.model.LoginUserInfo;
import com.doumee.core.utils.Constants;
@@ -43,6 +46,8 @@
    private SystemLoginService systemLoginService;
    @Autowired
    private CaptchaService captchaService;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    /**
     * @author Eva.Caesar Liu
@@ -54,6 +59,16 @@
        return ApiResponse.success(captchaService.genCaptcha());
    }
    @PreventRepeat(limit = 10, lockTime = 10000)
    @ApiOperation("获取系统配置参数")
    @GetMapping("/systemConfig")
    @LoginNoRequired
    public ApiResponse<SystemConfigVo> systemConfig ( ) {
        SystemConfigVo configVo = new SystemConfigVo();
        configVo.setSubtitle(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SYSTEM_SUBTITLE).getCode());
        configVo.setTitle(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SYSTEM_TITLE).getCode());
        return ApiResponse.success(configVo);
    }
    @PreventRepeat(limit = 10, lockTime = 10000)
    @ApiOperation("登录")
    @PostMapping("/login")
@@ -252,8 +267,6 @@
        return ApiResponse.success(null);
    }
    @PostMapping("/logoutForH5")
    @ApiOperation("退出登陆")
    public ApiResponse<String> logoutForH5(@RequestHeader(Constants.HEADER_USER_TOKEN) String oldToken){
@@ -265,7 +278,6 @@
            return ApiResponse.failed(ResponseStatus.SERVER_ERROR);
        }
        return ApiResponse.success(null);
    }
@@ -288,4 +300,23 @@
        return ApiResponse.failed( "登录已失效");
    }
    @PreventRepeat(limit = 10, lockTime = 10000)
    @ApiOperation("登录 - 钥匙柜")
    @PostMapping("/loginCabinet")
    @LoginNoRequired
    public ApiResponse<String> loginCabinet (@Validated @RequestBody LoginCabinetDTO dto, ServerWebExchange serverWebExchange) {
        try {
            ServerHttpRequest request = serverWebExchange.getRequest();
            LoginUserInfo user = systemLoginService.loginByPasswordForCabinet(dto,request);
            String token = jwtTokenUtil.generateToken(user);
            return ApiResponse.success(token);
        }catch (BusinessException e){
            return ApiResponse.failed(e.getCode(),e.getMessage());
        }catch (Exception e){
            e.printStackTrace();
            return ApiResponse.failed(ResponseStatus.SERVER_ERROR);
        }
    }
}