Commit 47a8db29 by guojuxing

资源组编辑,如果已经授权给联合商户,则需要验证码

parent 9ae5fad9
......@@ -75,6 +75,13 @@ public interface UnionEnterpriseAuthApiService {
*/
ServiceResponse<List<UnionEnterpriseAuthDTO>> listUnionEnterpriseAuth(@NotNull Integer ownEnterpriseId);
/**
* 产销联合商户数据
* @param resourceGroupId
* @return
*/
ServiceResponse<UnionEnterpriseAuthDTO> getUnionEnterpriseAuthByResourceGroupId(@NotNull Integer resourceGroupId);
/**************应用策略************************/
......
......@@ -107,4 +107,11 @@ public interface TabSysUnionEnterpriseAuthMapper {
* @return
*/
int countUnionEnterpriseAuth(@Param("resourceGroupId") Integer resourceGroupId);
/**
* 资源组授权给的商户
* @param resourceGroupId
* @return
*/
List<TabSysUnionEnterpriseAuth> listUnionEnterpriseAuthByResourceGroupId(@Param("resourceGroupId") Integer resourceGroupId);
}
\ No newline at end of file
......@@ -76,4 +76,11 @@ public interface UnionEnterpriseAuthService {
* @return
*/
Boolean hasUnionEnterpriseAuth(Integer resourceGroupId);
/**
* 资源组授权商户
* @param resourceGroupId
* @return
*/
List<TabSysUnionEnterpriseAuth> listUnionEnterpriseAuthByResourceGroupId(Integer resourceGroupId);
}
......@@ -81,4 +81,9 @@ public class UnionEnterpriseAuthServiceImpl implements UnionEnterpriseAuthServic
return false;
}
@Override
public List<TabSysUnionEnterpriseAuth> listUnionEnterpriseAuthByResourceGroupId(Integer resourceGroupId) {
return tabSysUnionEnterpriseAuthMapper.listUnionEnterpriseAuthByResourceGroupId(resourceGroupId);
}
}
......@@ -83,8 +83,20 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
@Transactional(rollbackFor = Exception.class)
public ServiceResponse<Void> authResource(@Validated UnionEnterpriseAuthResDTO dto) {
TabSysUnionEnterpriseAuth old = checkExistUnionEnterprise(dto.getOwnEnterpriseId(), dto.getUnionEnterpriseId());
//授权数据
UnionEnterpriseAuthDTO data = EntityUtil.changeEntityNew(UnionEnterpriseAuthDTO.class, dto);
data.setUnionEnterpriseAuthId(old.getUnionEnterpriseAuthId());
//同一个资源组只能授权给一个商户
List<TabSysUnionEnterpriseAuth> listByResourceGroup = unionEnterpriseAuthService.listUnionEnterpriseAuthByResourceGroupId(dto.getResourceGroupId());
if (CollectionUtils.isNotEmpty(listByResourceGroup)) {
if (listByResourceGroup.stream().filter(e -> !e.getUnionEnterpriseAuthId().equals(old.getUnionEnterpriseAuthId())).count() > 0) {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "资源组不能授权给不同商户");
}
}
//是否是编辑。编辑和新增授权同步资源处理不同
boolean isEdit = old.getResourceGroupId() != null;
boolean isEdit = !dto.getResourceGroupId().equals(old.getResourceGroupId());
//todo starrynight 通知业务方,同步数据
Integer resourceGroupId = dto.getResourceGroupId();
ServiceResponse<ResourceGroupDTO> resourceResponse = resourceGroupApiService.getResourceGroup(resourceGroupId);
......@@ -105,8 +117,7 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
storeAuthorizationApiService.authStore(resourceGroupDTO.getStoreResource().intValue(), dto.getUnionEnterpriseId(), dto.getOwnEnterpriseId());
}
UnionEnterpriseAuthDTO data = EntityUtil.changeEntityNew(UnionEnterpriseAuthDTO.class, dto);
data.setUnionEnterpriseAuthId(old.getUnionEnterpriseAuthId());
unionEnterpriseAuthService.update(data);
//初始化未授权资源数据
......@@ -241,6 +252,15 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
}
@Override
public ServiceResponse<UnionEnterpriseAuthDTO> getUnionEnterpriseAuthByResourceGroupId(@NotNull Integer resourceGroupId) {
List<TabSysUnionEnterpriseAuth> listByResourceGroup = unionEnterpriseAuthService.listUnionEnterpriseAuthByResourceGroupId(resourceGroupId);
if (CollectionUtils.isNotEmpty(listByResourceGroup)) {
return ServiceResponse.success(EntityUtil.changeEntityNew(UnionEnterpriseAuthDTO.class, listByResourceGroup.get(0)));
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> saveOrUpdateUnionEnterpriseAuthApp(@Valid UnionEnterpriseAuthAppDTO dto) {
Integer unionEnterpriseAuthAppId = dto.getUnionEnterpriseAuthAppId();
......
......@@ -326,4 +326,13 @@
and status_flag != 3
and resource_group_id = #{resourceGroupId}
</select>
<select id="listUnionEnterpriseAuthByResourceGroupId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_sys_union_enterprise_auth
where delete_flag = 0
and status_flag != 3
and resource_group_id = #{resourceGroupId}
</select>
</mapper>
\ No newline at end of file
......@@ -119,7 +119,7 @@ public class UnionEnterpriseAuthController {
//生成6位数字验证码
String authCode = CreateRandomUtils.generateNumberStr(6);
authCodeDTO.setAuthCode(authCode);
authCodeDTO.setExpirationTime(AuthCodeExpireTimeUtils.setAuthCodeExpireTime(1));
authCodeDTO.setExpirationTime(AuthCodeExpireTimeUtils.setAuthCodeExpireTime(2));
ServiceResponse<Integer> result = authCodeApiService.saveAuth(authCodeDTO);
if (result.isSuccess()) {
Integer authCodeId = result.getResult();
......
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