diff --git a/src/main/java/com/zteits/oa/configuration/FilterRegistrationConfig.java b/src/main/java/com/zteits/oa/configuration/FilterRegistrationConfig.java new file mode 100644 index 0000000..be7d404 --- /dev/null +++ b/src/main/java/com/zteits/oa/configuration/FilterRegistrationConfig.java @@ -0,0 +1,23 @@ +package com.zteits.oa.configuration; + +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.zteits.oa.configuration.fiter.ResponseHeaderFilter; + +@Configuration +public class FilterRegistrationConfig { + /** + * 添加响应请求头Filter + * @return + * 2017年5月8日 zhaowg + */ + @Bean + public FilterRegistrationBean ResponseHeaderFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean(new ResponseHeaderFilter()); + registration.addServletRegistrationBeans(); + registration.addUrlPatterns("/*"); + return registration; + } +} diff --git a/src/main/java/com/zteits/oa/report/vo/OAuthResult.java b/src/main/java/com/zteits/oa/report/vo/OAuthResult.java new file mode 100644 index 0000000..cea9de3 --- /dev/null +++ b/src/main/java/com/zteits/oa/report/vo/OAuthResult.java @@ -0,0 +1,68 @@ +package com.zteits.oa.report.vo; + +import com.zteits.oa.api.base.constants.ErrorType; +import com.zteits.oa.api.dto.asraop.LoginOathRes; + +/** + * Copyright: Copyright (c) 2017 zteits + * + * @ClassName: com.zteits.oauth.portal.vo + * @Description: + * @version: v1.0.0 + * @author: atao + * @date: 2017/5/9 下午3:39 + * Modification History: + * Date Author Version Description + * ---------------------------------------------------------* + * 2017/5/9 atao v1.0.0 创建 + */ +public class OAuthResult { + + private String code; + private String errMsg; + private T data; + + public OAuthResult(boolean success) { + if (success) { + this.code = ErrorType.BIZ_SUCCESS.getCode(); + this.errMsg = ErrorType.BIZ_SUCCESS.getMsg(); + } + + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + + this.code = code; + } + + public String getErrMsg() { + return errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public void setErrorType(ErrorType errorType) { + this.code = errorType.getCode(); + this.errMsg = errorType.getMsg(); + } + + public void setErrorType(ErrorType errorType, String errMsg) { + this.code = errorType.getCode(); + this.errMsg = errMsg; + } + +} diff --git a/src/main/java/com/zteits/oa/report/web/OAuthController.java b/src/main/java/com/zteits/oa/report/web/OAuthController.java index 633a374..e5e258d 100644 --- a/src/main/java/com/zteits/oa/report/web/OAuthController.java +++ b/src/main/java/com/zteits/oa/report/web/OAuthController.java @@ -20,6 +20,7 @@ import com.zteits.oa.api.dto.asraop.LoginOathRes; import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq; import com.zteits.oa.api.dto.asraop.param.LoginOauthReq; import com.zteits.oa.api.service.report.query.AsraOpRueryService; +import com.zteits.oa.report.vo.OAuthResult; import com.zteits.oa.util.MD5Utils; import io.swagger.annotations.Api; @@ -39,8 +40,8 @@ public class OAuthController { @ApiOperation("用户登录") @PostMapping("/login") - public BizResult login(@RequestBody LoginOauthReq req ) throws Exception { - BizResult result = this._login(req); + public OAuthResult login(@RequestBody LoginOauthReq req ) throws Exception { + OAuthResult result = this._login(req); return result; } /** @@ -49,14 +50,14 @@ public class OAuthController { * @return * 2018年7月31日 wangfs.
*/ - private BizResult _login(LoginOauthReq req ){ - BizResult result = new BizResult(); + private OAuthResult _login(LoginOauthReq req ){ + OAuthResult result = new OAuthResult(false); LoginOathRes loginOathRes = new LoginOathRes(); String loginCode = req.getLoginCode(); String passWord = req.getPassWord(); if(StringUtils.isEmpty(loginCode) || StringUtils.isEmpty(passWord)) { logger.info("校验登录信息,用户名 或者 登录密码为空!"); - result.setErrorInfo(ErrorType.PARAMM_NULL, "用户名 或者 登录密码为空"); + result.setErrorType(ErrorType.PARAMM_NULL, "用户名 或者 登录密码为空"); } AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq(); AsraOpDTO asraOpDTO = new AsraOpDTO(); @@ -68,18 +69,18 @@ public class OAuthController { asraOpDTO = asraOpReult.getData(); if(StringUtils.isEmpty(asraOpDTO.getLoginCode())){ logger.info("{}登录账号不存在",loginCode); - result.setErrorInfo(ErrorType.AUTH_LOGIN_ERROR, "登录账号不存在!"); + result.setErrorType(ErrorType.AUTH_LOGIN_ERROR, "登录账号不存在!"); }else{ if(!asraOpDTO.getLoginPassword().equalsIgnoreCase(MD5Utils.enMD5(passWord))){ logger.info("{}登录账号输入的密码不正确",loginCode); - result.setErrorInfo(ErrorType.AUTH_PASS_ERROR, "登录密码不匹配!"); + result.setErrorType(ErrorType.AUTH_PASS_ERROR, "登录密码不匹配!"); }else{ isCheckSuccess = true; } } }else{ - result.setErrorInfo(ErrorType.BIZ_ERROR, "用户登录失败"); + result.setErrorType(ErrorType.BIZ_ERROR, "用户登录失败"); } @@ -93,8 +94,9 @@ public class OAuthController { loginOathRes.setCityId(asraOpDTO.getCityId()); loginOathRes.setCityName(asraOpDTO.getCityName()); loginOathRes.setAccessToken(session.getId()); + loginOathRes.setRoleId(asraOpDTO.getRoleId()); result.setData(loginOathRes); - result.setErrorInfo(ErrorType.BIZ_SUCCESS, "登录成功"); + result.setErrorType(ErrorType.BIZ_SUCCESS, "登录成功"); }