TASK:限制同一个管理员不允许绑定不同组织的订阅计划
This commit is contained in:
@@ -70,7 +70,7 @@ public class SubscriptionPlan extends BaseEntity{
|
||||
/**
|
||||
* 国家或地区
|
||||
*/
|
||||
private String CountryOrRegion;
|
||||
private String countryOrRegion;
|
||||
|
||||
// 在类内部定义的枚举
|
||||
@Getter
|
||||
|
||||
@@ -32,4 +32,7 @@ public class UpdateSubscriptionPlanDTO {
|
||||
@Schema(description = "订阅重命名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "国家或地区")
|
||||
private String countryOrRegion;
|
||||
|
||||
}
|
||||
|
||||
@@ -104,6 +104,20 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
||||
if (account.getSystemUser().equals(8) || account.getSystemUser().equals(6)) {
|
||||
throw new BusinessException("Sub-accounts.cannot.be.admins");
|
||||
}
|
||||
|
||||
// 保证订阅计划绑定的管理员所属组织的唯一性
|
||||
checkAdminCrossOrg(subscriptionPlanDTO.getAdminAccId(), subscriptionPlanDTO.getOrganizationId());
|
||||
}
|
||||
|
||||
// 判断指定的管理员是否已绑定其他组织的订阅计划
|
||||
private void checkAdminCrossOrg(Long adminAccId, Long organizationId) {
|
||||
QueryWrapper<SubscriptionPlan> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SubscriptionPlan::getAdminAccId, adminAccId)
|
||||
.ne(SubscriptionPlan::getOrganizationId, organizationId);
|
||||
Long count = baseMapper.selectCount(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException("administrator.user.is.already.bound.to.different.organization");
|
||||
}
|
||||
}
|
||||
|
||||
// 更新 到期时间、积分总量、已使用积分量
|
||||
@@ -217,6 +231,8 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
||||
private void handleBasicInfo(UpdateSubscriptionPlanDTO dto, SubscriptionPlan plan) {
|
||||
if (dto.getAdminAccId() != null
|
||||
&& !dto.getAdminAccId().equals(plan.getAdminAccId())) {
|
||||
// 保证订阅计划绑定的管理员所属组织的唯一性
|
||||
checkAdminCrossOrg(dto.getAdminAccId(), plan.getOrganizationId());
|
||||
plan.setAdminAccId(dto.getAdminAccId());
|
||||
}
|
||||
|
||||
@@ -224,6 +240,11 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
||||
&& !dto.getName().equals(plan.getName())) {
|
||||
plan.setName(dto.getName());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(dto.getCountryOrRegion())
|
||||
&& !dto.getCountryOrRegion().equals(plan.getCountryOrRegion())) {
|
||||
plan.setCountryOrRegion(dto.getCountryOrRegion());
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== 更新后处理 =====================
|
||||
|
||||
@@ -213,6 +213,7 @@ only.subscription.plans.with.a.PENDING.status.can.have.their.start.time.modified
|
||||
the.subscription.end.date.can.be.extended.only.not.reduced=The subscription end date can be extended only, not reduced.
|
||||
total.sub-account.quota.cannot.be.lower.than.existing.sub-accounts=Total sub-account quota cannot be lower than existing sub-accounts.
|
||||
the.credit.limit.set.cannot.be.lower.than.the.amount.of.credits.already.used=The credit limit set cannot be lower than the amount of credits already used.
|
||||
administrator.user.is.already.bound.to.different.organization=This administrator user is already bound to a subscription plan of a different organization.
|
||||
|
||||
# 可能会报异常
|
||||
# Informative:
|
||||
|
||||
@@ -209,6 +209,7 @@ only.subscription.plans.with.a.PENDING.status.can.have.their.start.time.modified
|
||||
the.subscription.end.date.can.be.extended.only.not.reduced=订阅的到期时间不能缩短,只能延长
|
||||
total.sub-account.quota.cannot.be.lower.than.existing.sub-accounts=设置的子账号总数量不能低于现存已添加的子账号数量
|
||||
the.credit.limit.set.cannot.be.lower.than.the.amount.of.credits.already.used=设置的积分上限不能低于已使用的积分量
|
||||
administrator.user.is.already.bound.to.different.organization=该管理员用户已与其他组织的订阅计划绑定
|
||||
|
||||
# 可能会报异常
|
||||
# Informative:
|
||||
|
||||
Reference in New Issue
Block a user