fix(ff-base): 校验成本比例

- 在创建租户密钥时,增加对成本比例的校验
- 如果成本比例小于平台最低成本,则抛出异常
main-cf
shi 2025-03-24 17:11:23 +08:00
parent 03ca9de286
commit 173d40de55
1 changed files with 8 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import com.ff.base.enums.LoginType;
import com.ff.base.enums.OperationType; import com.ff.base.enums.OperationType;
import com.ff.base.enums.QuotaType; import com.ff.base.enums.QuotaType;
import com.ff.base.exception.ServiceException; import com.ff.base.exception.ServiceException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.exception.user.UserPasswordNotMatchException; import com.ff.base.exception.user.UserPasswordNotMatchException;
import com.ff.base.manager.AsyncManager; import com.ff.base.manager.AsyncManager;
import com.ff.base.manager.factory.AsyncFactory; import com.ff.base.manager.factory.AsyncFactory;
@ -218,6 +219,13 @@ public class TenantSecretKeyServiceImpl implements ITenantSecretKeyService {
int insertedTenantSecretKey = this.insertTenantSecretKey(tenantSecretKey); int insertedTenantSecretKey = this.insertTenantSecretKey(tenantSecretKey);
if (insertedTenantSecretKey > 0) { if (insertedTenantSecretKey > 0) {
for (TenantPlatform tenantPlatform : createTenantDTO.getTenantPlatforms()) { for (TenantPlatform tenantPlatform : createTenantDTO.getTenantPlatforms()) {
TenantPlatform platformById = tenantPlatformService.selectTenantPlatformById(tenantPlatform.getId());
// 成本比平台成本大
if (platformById.getCost().compareTo(tenantPlatform.getCost())>0){
throw new BaseException("成本比例不允许比最低比例小");
}
tenantPlatform.setTenantId(tenantSecretKey.getId()); tenantPlatform.setTenantId(tenantSecretKey.getId());
tenantPlatform.setCreateBy(createTenantDTO.getAccount()); tenantPlatform.setCreateBy(createTenantDTO.getAccount());
tenantPlatformService.insertTenantPlatform(tenantPlatform); tenantPlatformService.insertTenantPlatform(tenantPlatform);