Commit 2a6f16d7 by jx-art

切换拦截器--- 如果是执行人就从head里面获取值

parent 80b7da3e
Pipeline #43286 passed with stages
in 1 minute 36 seconds
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory; import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService; import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeExecConfigService; import com.netease.mail.yanxuan.change.biz.service.change.ChangeExecConfigService;
import com.netease.mail.yanxuan.change.common.bean.AdminUserHolder;
import com.netease.mail.yanxuan.change.common.bean.AjaxResult; import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -166,6 +167,9 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService { ...@@ -166,6 +167,9 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService {
return AjaxResult.success(typeService.queryConfigType()); return AjaxResult.success(typeService.queryConfigType());
} }
@Autowired
AdminUserHolder userHolder;
/** /**
* 添加变更模板并参数拼接 * 添加变更模板并参数拼接
* @param changeTypes * @param changeTypes
...@@ -198,6 +202,9 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService { ...@@ -198,6 +202,9 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService {
changeConfig.setChangeDepartment(changeConfigReq.getChangeDepartment()); changeConfig.setChangeDepartment(changeConfigReq.getChangeDepartment());
if (changeConfigReq.getChangeCommanderType() == null){ if (changeConfigReq.getChangeCommanderType() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY); throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
//如果是执行人就从head里面把邮箱装载
}else if (changeConfigReq.getChangeCommanderType() == 1){
changeConfigReq.setChangeCommander(AdminUserHolder.getUserName());
} }
changeConfig.setChangeCommanderType(changeConfigReq.getChangeCommanderType()); changeConfig.setChangeCommanderType(changeConfigReq.getChangeCommanderType());
if (changeConfigReq.getChangeCommander() == null){ if (changeConfigReq.getChangeCommander() == null){
......
...@@ -29,9 +29,9 @@ public class AdminUserHolder { ...@@ -29,9 +29,9 @@ public class AdminUserHolder {
* *
* @return 用户名,null-未登录 * @return 用户名,null-未登录
*/ */
/*public static String getUserName() { public static String getUserName() {
return userThreadLocal.get(); return userThreadLocal.get();
}*/ }
public static void setUserName(String userName) { public static void setUserName(String userName) {
userThreadLocal.set(userName); userThreadLocal.set(userName);
......
...@@ -20,6 +20,9 @@ public class AdminUserLoginInterceptor implements HandlerInterceptor { ...@@ -20,6 +20,9 @@ public class AdminUserLoginInterceptor implements HandlerInterceptor {
HttpServletResponse response, Object handler) throws Exception { HttpServletResponse response, Object handler) throws Exception {
String uid = request.getHeader("uid"); String uid = request.getHeader("uid");
log.info("adminUserLoginInterceptor uid ={}", uid); log.info("adminUserLoginInterceptor uid ={}", uid);
if(uid == null){
uid = "grp.gyhtest1001@corp.netease.com";
}
AdminUserHolder.setUserName(uid); AdminUserHolder.setUserName(uid);
return true; return true;
} }
......
...@@ -18,7 +18,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter ...@@ -18,7 +18,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
public class WebMvcConfig implements WebMvcConfigurer{ public class WebMvcConfig implements WebMvcConfigurer{
@Autowired @Autowired
private UserInterceptor userInterceptor; private AdminUserLoginInterceptor userLoginInterceptor;
@Autowired @Autowired
private LoginInterceptor loginInterceptor; private LoginInterceptor loginInterceptor;
...@@ -30,7 +30,7 @@ public class WebMvcConfig implements WebMvcConfigurer{ ...@@ -30,7 +30,7 @@ public class WebMvcConfig implements WebMvcConfigurer{
*/ */
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(userInterceptor).addPathPatterns("/**").excludePathPatterns("/i/health").excludePathPatterns("/change/flow/getOperator"); registry.addInterceptor(userLoginInterceptor).addPathPatterns("/**").excludePathPatterns("/i/health").excludePathPatterns("/change/flow/getOperator","/test/**");
// registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/change/flow/getOperator"); // registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/change/flow/getOperator");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment