add set user limits
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-02-09 11:06:50 +07:00
parent 5b73fd2c39
commit a5003958a8
3 changed files with 6 additions and 4 deletions
@@ -41,6 +41,7 @@ public enum MessageCode {
INTERNAL_ERROR(4, "Internal server error"),
COMPANY_NOT_FOUND(4, "Company not found"),
COMPANY_ALREADY_EXISTS(2, "Company already exists"),
USER_LIMIT_IS_OVER(2, "Over user limits"),
ERROR_TARIFF_INFO(2, "Erorr with tariff info");
private final Integer code;
@@ -65,8 +65,7 @@ public class RegRequestHandler implements RequestHandler {
referralLink, new BaseResponse(request.getMsgId(),
MessageCode.REFERRAL_LINK_IS_NOT_EXIST.getCode(),
MessageCode.REFERRAL_LINK_IS_NOT_EXIST.getDescription(), Map.of(
"referralLink", referralLink
)));
"referralLink", referralLink)));
}
}
@@ -197,8 +197,10 @@ public class AuthService {
long currentCountUsers = userRepository.countByCompanyId(company.getId());
if (currentCountUsers >= maxUsers) {
throw new MaxUserCountIsOver(
String.format("Max user is over. " + "Has: %d, current count: %d", maxUsers, currentCountUsers));
throw new NotValidFieldException("Max user is over.", new BaseResponse(20002,
MessageCode.USER_LIMIT_IS_OVER.getCode(),
MessageCode.USER_LIMIT_IS_OVER.getDescription(), Map.of(
"limit", maxUsers, "countUser", currentCountUsers)));
}
user.setCompany(company);