Commit c4528541 authored by zhangyingbin's avatar zhangyingbin

新增公用注解,获取当前登陆人的业务库信息

parent 21db5e3d
package com.yeejoin.amos.boot.module.ugp.biz.framework;
import java.lang.annotation.*;
/**
* @author Dell
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface BusinessIdentify {
/**
* 将业务信息提取存放
* @return
*/
boolean isNeedIdentity() default true;
}
package com.yeejoin.amos.boot.module.ugp.biz.framework;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.core.framework.PersonIdentify;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.exception.PermissionException;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.OrgServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.ResponseBody;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.Map;
/**
* @author DELL
*/
@Aspect
@Component
@ResponseBody
@Order(value = 1)
public class BusinessIdentifyAspect {
@Autowired
RedisUtils redisUtils;
@Autowired
OrgUsrServiceImpl orgUsrService;
@Before(value = "@annotation(com.yeejoin.amos.boot.module.ugp.biz.framework.BusinessIdentify) && @annotation(permission)")
public void personIdentity(JoinPoint joinPoint, BusinessIdentify permission) throws PermissionException {
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (permission.isNeedIdentity() && reginParam != null) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
//company
Long amosBizCode = reginParams.getCompany().getSequenceNbr();
OrgUsr companyOrgUsr = orgUsrService.getById(amosBizCode);
String companyName = companyOrgUsr.getBizOrgName();
Long companySequenceNbr = companyOrgUsr.getSequenceNbr();
String companyType = companyOrgUsr.getOrgExpandAttr1();
if (ValidationUtil.isEmpty(companyType)) {
companyType = companyOrgUsr.getBizOrgType();
}
BusinessInfo.amosBizCode = amosBizCode;
BusinessInfo.companySequenceNbr = companySequenceNbr;
BusinessInfo.companyName = companyName;
BusinessInfo.companyType = companyType;
//User
Long amosUserCode = reginParams.getUserModel().getSequenceNbr();
OrgUsr userOrgUsr = orgUsrService.getById(amosUserCode);
String userName = userOrgUsr.getBizOrgName();
Long userSequenceNbr = userOrgUsr.getSequenceNbr();
String userType = userOrgUsr.getOrgExpandAttr1();
if (ValidationUtil.isEmpty(userType)) {
userType = userOrgUsr.getBizOrgType();
}
BusinessInfo.amosUserCode = amosUserCode;
BusinessInfo.userName = userName;
BusinessInfo.userSequenceNbr = userSequenceNbr;
BusinessInfo.userType = userType;
}
}
}
package com.yeejoin.amos.boot.module.ugp.biz.framework;
import lombok.Data;
/**
* 当前登陆人的业务库信息
* @author Dell
*/
@Data
public class BusinessInfo {
/**
* 公司
* 平台存储的sequenceNbr
*/
public static Long amosBizCode;
/**
* 公司
* 业务存储的名称
*/
public static String companyName;
/**
* 公司
* 业务存储的sequenceNbr
*/
public static Long companySequenceNbr;
/**
* 公司
* 业务存储的类型
*/
public static String companyType;
/**
* 人员
* 平台存储的sequenceNbr
*/
public static Long amosUserCode;
/**
* 人员
* 业务存储的名称
*/
public static String userName;
/**
* 人员
* 业务存储的sequenceNbr
*/
public static Long userSequenceNbr;
/**
* 人员
* 业务存储的类型
*/
public static String userType;
}
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