Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
857eb218
Commit
857eb218
authored
Aug 20, 2021
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.权限接口
parent
d453edfd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
19 deletions
+66
-19
FeignConfiguration.java
...n/amos/maintenance/business/feign/FeignConfiguration.java
+6
-0
FeignErrorDecoder.java
...in/amos/maintenance/business/feign/FeignErrorDecoder.java
+25
-0
JCSFeignClient.java
...ejoin/amos/maintenance/business/feign/JCSFeignClient.java
+22
-0
PersonIdentifyAspect.java
...amos/maintenance/core/framework/PersonIdentifyAspect.java
+13
-19
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/business/feign/FeignConfiguration.java
View file @
857eb218
package
com
.
yeejoin
.
amos
.
maintenance
.
business
.
feign
;
package
com
.
yeejoin
.
amos
.
maintenance
.
business
.
feign
;
import
feign.codec.Encoder
;
import
feign.codec.Encoder
;
import
feign.codec.ErrorDecoder
;
import
feign.form.spring.SpringFormEncoder
;
import
feign.form.spring.SpringFormEncoder
;
import
org.springframework.beans.factory.ObjectFactory
;
import
org.springframework.beans.factory.ObjectFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -22,4 +23,9 @@ public class FeignConfiguration {
...
@@ -22,4 +23,9 @@ public class FeignConfiguration {
public
FeignBasicAuthRequestInterceptor
basicAuthRequestInterceptor
()
{
public
FeignBasicAuthRequestInterceptor
basicAuthRequestInterceptor
()
{
return
new
FeignBasicAuthRequestInterceptor
();
return
new
FeignBasicAuthRequestInterceptor
();
}
}
@Bean
public
FeignErrorDecoder
errorDecoder
(){
return
new
FeignErrorDecoder
();
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/business/feign/FeignErrorDecoder.java
0 → 100644
View file @
857eb218
package
com
.
yeejoin
.
amos
.
maintenance
.
business
.
feign
;
import
feign.Response
;
import
feign.Util
;
import
feign.codec.ErrorDecoder
;
import
java.io.IOException
;
/**
* @author DELL
*/
public
class
FeignErrorDecoder
implements
ErrorDecoder
{
@Override
public
Exception
decode
(
String
s
,
Response
response
)
{
String
msg
=
null
;
try
{
msg
=
Util
.
toString
(
response
.
body
().
asReader
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
throw
new
RuntimeException
(
msg
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/business/feign/JCSFeignClient.java
0 → 100644
View file @
857eb218
package
com
.
yeejoin
.
amos
.
maintenance
.
business
.
feign
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
/**
* @author DELL
*/
@FeignClient
(
name
=
"${jcs.fegin.name}"
,
configuration
=
FeignConfiguration
.
class
)
public
interface
JCSFeignClient
{
/**
* 查询用户单位信息
* @param userId 用户id
* @return ResponseModel<ReginParams.PersonIdentity>
*/
@GetMapping
(
value
=
"jcs/org-usr/{userId}/userUnit"
)
ResponseModel
<
ReginParams
.
PersonIdentity
>
getUserUnit
(
@PathVariable
String
userId
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/core/framework/PersonIdentifyAspect.java
View file @
857eb218
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.maintenance.business.feign.JCSFeignClient
;
import
com.yeejoin.amos.maintenance.exception.PermissionException
;
import
com.yeejoin.amos.maintenance.exception.PermissionException
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Aspect
;
...
@@ -14,6 +15,7 @@ import org.springframework.core.annotation.Order;
...
@@ -14,6 +15,7 @@ import org.springframework.core.annotation.Order;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
/**
/**
* @author DELL
* @author DELL
...
@@ -26,31 +28,23 @@ public class PersonIdentifyAspect {
...
@@ -26,31 +28,23 @@ public class PersonIdentifyAspect {
@Autowired
@Autowired
RedisUtils
redisUtils
;
RedisUtils
redisUtils
;
@Autowired
JCSFeignClient
jcsFeignClient
;
@Before
(
value
=
"@annotation(com.yeejoin.amos.maintenance.core.framework.PersonIdentify) && @annotation(permission)"
)
@Before
(
value
=
"@annotation(com.yeejoin.amos.maintenance.core.framework.PersonIdentify) && @annotation(permission)"
)
public
void
personIdentity
(
JoinPoint
joinPoint
,
PersonIdentify
permission
)
throws
PermissionException
{
public
void
personIdentity
(
JoinPoint
joinPoint
,
PersonIdentify
permission
)
throws
PermissionException
{
ReginParams
reginParam
=
JSON
.
parseObject
(
redisUtils
.
get
(
buildKey
(
RequestContext
.
getToken
())).
toString
(),
ReginParams
.
class
);
ReginParams
reginParam
=
JSON
.
parseObject
(
redisUtils
.
get
(
buildKey
(
RequestContext
.
getToken
())).
toString
(),
ReginParams
.
class
);
if
(
permission
.
isNeedIdentity
()
&&
reginParam
!=
null
)
{
if
(
permission
.
isNeedIdentity
()
&&
reginParam
!=
null
)
{
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
// JSONObject result = new JSONObject();
String
userId
=
reginParam
.
getUserModel
().
getUserId
();
// String identityType = result.get("identityType").toString();
ResponseModel
<
ReginParams
.
PersonIdentity
>
responseModel
=
jcsFeignClient
.
getUserUnit
(
userId
);
// String personSeq = result.get("personSeq").toString();
if
(
responseModel
!=
null
)
{
// String personName = result.get("personName").toString();
ReginParams
.
PersonIdentity
personIdentity
=
responseModel
.
getResult
();
// String companyId = result.get("companyId").toString();
reginParam
.
setPersonIdentity
(
personIdentity
);
// String companyName = result.get("companyName").toString();
redisUtils
.
set
(
buildKey
(
RequestContext
.
getToken
()),
JSONObject
.
toJSONString
(
reginParam
));
String
identityType
=
"1"
;
}
else
{
String
personSeq
=
"1421016571081420802"
;
throw
new
RuntimeException
(
"用户信息校验失败"
);
String
personName
=
"SHG"
;
}
String
companyId
=
"1420727427956502529"
;
String
companyName
=
"机电公司"
;
ReginParams
.
PersonIdentity
personIdentity
=
new
ReginParams
.
PersonIdentity
();
personIdentity
.
setIdentityType
(
identityType
);
personIdentity
.
setPersonSeq
(
personSeq
);
personIdentity
.
setPersonName
(
personName
);
personIdentity
.
setCompanyId
(
companyId
);
personIdentity
.
setCompanyName
(
companyName
);
reginParam
.
setPersonIdentity
(
new
ReginParams
.
PersonIdentity
());
redisUtils
.
set
(
buildKey
(
RequestContext
.
getToken
()),
JSONObject
.
toJSONString
(
reginParam
));
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment