Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
Overview
Overview
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
base_platform_enterprise
gic-platform-auth
Commits
86def759
Commit
86def759
authored
Feb 24, 2021
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
联合授权资源组用户域
parent
722b8a7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
3 deletions
+78
-3
ExceptionResultAop.java
...src/main/java/com/gic/auth/config/ExceptionResultAop.java
+61
-0
ResourceGroupApiServiceImpl.java
.../auth/service/outer/impl/ResourceGroupApiServiceImpl.java
+16
-3
dubbo-gic-platform-auth-service.xml
...ce/src/main/resources/dubbo-gic-platform-auth-service.xml
+1
-0
No files found.
gic-platform-auth-service/src/main/java/com/gic/auth/config/ExceptionResultAop.java
0 → 100644
View file @
86def759
package
com
.
gic
.
auth
.
config
;
import
javax.validation.ConstraintViolationException
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.context.annotation.Configuration
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.exception.CommonException
;
/**
* api层错误全部统一返回
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/2/9 9:46 AM
*/
@Aspect
@Configuration
public
class
ExceptionResultAop
{
private
Logger
logger
=
LogManager
.
getLogger
(
ExceptionResultAop
.
class
);
/**
* 环绕通知
*
* @param joinPoint
* @return
* @throws Throwable
*/
@Around
(
value
=
"execution(* com.gic.*.service.outer.impl..*.*(..))"
)
public
Object
around
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
try
{
// 执行当前方法
return
joinPoint
.
proceed
();
}
catch
(
Throwable
throwable
)
{
logger
.
warn
(
"拦截器错误"
,
throwable
);
return
handlerException
(
throwable
);
}
}
private
ServiceResponse
handlerException
(
Throwable
e
)
{
ServiceResponse
response
=
new
ServiceResponse
();
if
(
e
instanceof
CommonException
)
{
response
.
setCode
(((
CommonException
)
e
).
getErrorCode
());
}
else
if
(
e
instanceof
ConstraintViolationException
)
{
response
.
setCode
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
());
}
else
{
response
.
setCode
(
ErrorCode
.
SYSTEM_ERROR
.
getCode
());
}
response
.
setMessage
(
e
.
getMessage
());
return
response
;
}
}
\ No newline at end of file
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/ResourceGroupApiServiceImpl.java
View file @
86def759
...
...
@@ -12,7 +12,9 @@ import com.gic.auth.dto.*;
import
com.gic.auth.entity.TabSysUser
;
import
com.gic.auth.service.UserService
;
import
com.gic.auth.utils.resourcegroup.ResourceGroupUtils
;
import
com.gic.enterprise.exception.CommonException
;
import
com.gic.enterprise.response.EnterpriseServiceResponse
;
import
com.gic.enterprise.service.UnionEnterpriseAuthApiService
;
import
com.gic.store.service.StoreWidgetApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -52,6 +54,8 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{
private
UserService
userService
;
@Autowired
private
StoreWidgetApiService
storeWidgetApiService
;
@Autowired
private
UnionEnterpriseAuthApiService
unionEnterpriseAuthApiService
;
@Override
public
ServiceResponse
<
Integer
>
saveResourceGroup
(
ResourceGroupDTO
resourceGroup
)
{
...
...
@@ -111,9 +115,10 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{
@Override
public
ServiceResponse
<
String
>
deleteResourceGroup
(
Integer
resourceGroupId
)
{
TabSysResourceGroup
record
=
resourceGroupService
.
getResourceGroup
(
resourceGroupId
);
if
(
record
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"资源组不存在"
);
TabSysResourceGroup
record
=
checkExistResourceGroup
(
resourceGroupId
);
//是否联合授权,如果是,则不允许删除
if
(
unionEnterpriseAuthApiService
.
hasUnionEnterpriseAuth
(
resourceGroupId
).
getResult
())
{
throw
new
CommonException
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"该资源组已授权给其他商户,不能删除"
);
}
//验证是否有管理员使用中
boolean
exist
=
this
.
userResourceService
.
existUserResource
(
record
.
getEnterpriseId
(),
record
.
getResourceGroupId
());
...
...
@@ -184,4 +189,12 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{
}
return
null
;
}
private
TabSysResourceGroup
checkExistResourceGroup
(
Integer
resourceGroupId
)
{
TabSysResourceGroup
record
=
resourceGroupService
.
getResourceGroup
(
resourceGroupId
);
if
(
record
==
null
)
{
throw
new
CommonException
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"资源组不存在"
);
}
return
record
;
}
}
gic-platform-auth-service/src/main/resources/dubbo-gic-platform-auth-service.xml
View file @
86def759
...
...
@@ -79,4 +79,5 @@
<dubbo:reference
interface=
"com.gic.open.api.service.EnterpriseLicenseApiService"
id=
"enterpriseLicenseApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.enterprise.service.QrCodeApiService"
id=
"qrCodeApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.enterprise.service.UnionEnterpriseAuthApiService"
id=
"unionEnterpriseAuthApiService"
timeout=
"6000"
/>
</beans>
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