Skip to content

Commit

Permalink
去掉枚举依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanggaofeng committed Aug 2, 2023
1 parent d950067 commit 2e739cf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ public boolean doFilter(MvcContext mvcContext) {
mockAcc = "test";
}
String mockAccType = mvcContext.getHeaders().get("userType");
UserTypeEnum userType = UserTypeEnum.getEnum(mockAccType);
if (userType == null) {
userType = UserTypeEnum.CAS_TYPE;
if (StringUtils.isBlank(mockAccType)) {
mockAccType = UserTypeEnum.CAS_TYPE.getCode() + "";
}
AuthUserVo authUserVo = new AuthUserVo();
authUserVo.setUserType(userType.getCode());
authUserVo.setUserType(Integer.parseInt(mockAccType));
authUserVo.setAccount(mockAcc);
authUserVo.setName(mockAcc);
mvcContext.session().setAttribute(ConstUtil.TPC_USER, authUserVo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ public void doFilter(ServletRequest var1, ServletResponse var2, FilterChain var3
mockAcc = "test";
}
String mockAccType = ((HttpServletRequest)var1).getHeader("userType");
UserTypeEnum userType = UserTypeEnum.getEnum(mockAccType);
if (userType == null) {
userType = UserTypeEnum.CAS_TYPE;
if (StringUtils.isBlank(mockAccType)) {
mockAccType = UserTypeEnum.CAS_TYPE.getCode() + "";
}
try {
AuthUserVo authUserVo = new AuthUserVo();
authUserVo.setUserType(userType.getCode());
authUserVo.setUserType(Integer.parseInt(mockAccType));
authUserVo.setAccount(mockAcc);
authUserVo.setName(mockAcc);
UserUtil.setUser(authUserVo);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xiaomi.mone.tpc.login.vo;

import com.xiaomi.mone.tpc.login.enums.UserTypeEnum;
import com.xiaomi.mone.tpc.login.util.UserUtil;

public class AuthUserVo {
private String account;
Expand Down Expand Up @@ -131,12 +131,7 @@ public void setState(String state) {
}

public String genFullAccount() {
if (UserTypeEnum.CAS_TYPE.getCode().equals(userType)) {
return account;
}
StringBuilder fullAccount = new StringBuilder();
fullAccount.append(account).append("#").append(userType);
return fullAccount.toString();
return UserUtil.getFullAccount(account, userType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public AuthUserVo getUserVo(String code, String pageUrl, String vcode, String st
ResponseEntity<Map> responseEntity = restTemplate.exchange(getUserUrl(), HttpMethod.GET, entity, Map.class);
log.info("userInfo.feishu={}", responseEntity);
if (responseEntity.getBody().get("email") == null) {
log.error("feishu没有拿到user_id字段, responseEntity={}", responseEntity);
log.error("feishu没有拿到email字段, responseEntity={}", responseEntity);
return null;
}
String account = responseEntity.getBody().get("email").toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public class NodeChangeVo {
private int appType = 0;
private int delete = 0;
private List<String> joinedMembers;
private Integer iamTreeId;
private Integer iamTreeType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public void init() throws MQClientException {
@Override
void realChange(NodeChangeEnum nodeChange, NodeVo nodeVo) throws Throwable {
NodeChangeVo eventVo = new NodeChangeVo();
eventVo.setIamTreeType(1);//0-米IAM;1-TPC
eventVo.setIamTreeId(nodeVo.getId().intValue());
eventVo.setId(nodeVo.getOutId() != null && nodeVo.getOutId() > 0L ? nodeVo.getOutId() : nodeVo.getId());
eventVo.setAppName(nodeVo.getNodeName());
eventVo.setDelete(NodeChangeEnum.DEL.equals(nodeChange) ? 1 : 0);
Expand Down

0 comments on commit 2e739cf

Please sign in to comment.