Commit 86def759 by guojuxing

联合授权资源组用户域

parent 722b8a7f
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
......@@ -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;
}
}
......@@ -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>
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