Commit 8d83a490 authored by suhuiguang's avatar suhuiguang

1.接口增加异常判断

parent 28b54d3c
package com.yeejoin.amos.maintenance.business.feign;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -18,5 +19,5 @@ public interface JCSFeignClient {
* @return ResponseModel<ReginParams.PersonIdentity>
*/
@GetMapping(value = "jcs/org-usr/{userId}/userUnit")
ResponseModel<ReginParams.PersonIdentity> getUserUnit(@PathVariable String userId);
FeignClientResult getUserUnit(@PathVariable String userId);
}
......@@ -5,6 +5,7 @@ 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.RedisUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.maintenance.business.feign.JCSFeignClient;
import com.yeejoin.amos.maintenance.exception.PermissionException;
import org.aspectj.lang.JoinPoint;
......@@ -13,9 +14,9 @@ import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
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.restful.utils.ResponseModel;
/**
* @author DELL
......@@ -31,20 +32,21 @@ public class PersonIdentifyAspect {
@Autowired
JCSFeignClient jcsFeignClient;
final int HTTP_OK_STATUS = 200;
@Before(value = "@annotation(com.yeejoin.amos.maintenance.core.framework.PersonIdentify) && @annotation(permission)")
public void personIdentity(JoinPoint joinPoint, PersonIdentify permission) throws PermissionException {
ReginParams reginParam = JSON.parseObject(redisUtils.get(buildKey(RequestContext.getToken())).toString(), ReginParams.class);
if (permission.isNeedIdentity() && reginParam != null) {
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
String userId = reginParam.getUserModel().getUserId();
ResponseModel<ReginParams.PersonIdentity> responseModel = jcsFeignClient.getUserUnit(userId);
if (responseModel != null) {
ReginParams.PersonIdentity personIdentity = responseModel.getResult();
FeignClientResult responseModel = jcsFeignClient.getUserUnit(userId);
if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HTTP_OK_STATUS) {
throw new RuntimeException(responseModel.getDevMessage());
}
ReginParams.PersonIdentity personIdentity = (ReginParams.PersonIdentity) responseModel.getResult();
reginParam.setPersonIdentity(personIdentity);
redisUtils.set(buildKey(RequestContext.getToken()), JSONObject.toJSONString(reginParam));
} else {
throw new RuntimeException("用户信息校验失败");
}
}
}
......
......@@ -35,7 +35,7 @@ equip.feign.name=AMOS-EQUIPMANAGE
equip.feign.prefix=/equip
input.custom.prefix = QYZD
input.statute.prefix = FG
jcs.fegin.name=JCS-GJQ
jcs.fegin.name=JCS
Security.fegin.name=AMOS-API-PRIVILEGE
......
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