bigint conversion fixes
All checks were successful
Deploy to VPS / deploy (push) Successful in 1m15s
All checks were successful
Deploy to VPS / deploy (push) Successful in 1m15s
This commit is contained in:
@@ -43,8 +43,8 @@ public class OpenApiExamplesCustomizer implements GlobalOpenApiCustomizer {
|
||||
value.put("screenName", "The Boy");
|
||||
value.put("dateReg", 1772897273);
|
||||
value.put("ip", "165.165.165.165");
|
||||
value.put("balanceA", 100000);
|
||||
value.put("balanceB", 100000);
|
||||
value.put("balanceA", 10000);
|
||||
value.put("balanceB", 10000);
|
||||
value.put("avatarUrl", "/avatars/0/0/1/06c98267.png?v=1772897273");
|
||||
value.put("languageCode", "EN");
|
||||
value.put("paymentEnabled", true);
|
||||
|
||||
@@ -24,6 +24,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
/** Divisor for converting balance bigint to display value (backend sends display value only). */
|
||||
private static final double BALANCE_DISPLAY_DIVISOR = 1_000_000.0;
|
||||
|
||||
private final UserService userService;
|
||||
private final UserBRepository userBRepository;
|
||||
private final AvatarService avatarService;
|
||||
@@ -37,10 +40,12 @@ public class UserController {
|
||||
// Convert IP from byte[] to string for display
|
||||
String ipAddress = IpUtils.bytesToIp(user.getIp());
|
||||
|
||||
// Get balances from UserB
|
||||
// Get balances from UserB; convert to display value (divide by 1_000_000)
|
||||
var userBOpt = userBRepository.findById(user.getId());
|
||||
Long balanceA = userBOpt.map(UserB::getBalanceA).orElse(0L);
|
||||
Long balanceB = userBOpt.map(UserB::getBalanceB).orElse(0L);
|
||||
long rawBalanceA = userBOpt.map(UserB::getBalanceA).orElse(0L);
|
||||
long rawBalanceB = userBOpt.map(UserB::getBalanceB).orElse(0L);
|
||||
Double balanceA = rawBalanceA / BALANCE_DISPLAY_DIVISOR;
|
||||
Double balanceB = rawBalanceB / BALANCE_DISPLAY_DIVISOR;
|
||||
Integer depositCount = userBOpt.map(UserB::getDepositCount).orElse(0);
|
||||
|
||||
// Generate avatar URL on-the-fly (deterministic from userId)
|
||||
|
||||
@@ -10,8 +10,16 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReferralDto {
|
||||
private String name; // screen_name from db_users_a
|
||||
private Long commission; // to_referer_1/2/3 from db_users_d (bigint, needs to be divided by 1,000,000 on frontend)
|
||||
private String name; // screen_name from db_users_d
|
||||
private Double commission; // display value (raw bigint / 1_000_000), sent ready for display
|
||||
|
||||
/** Constructor for JPQL: converts raw commission bigint to display value. Accepts Number so Hibernate can pass Long or BigInteger. */
|
||||
public ReferralDto(String name, Number commissionRaw) {
|
||||
this.name = name;
|
||||
this.commission = commissionRaw != null ? commissionRaw.longValue() / COMMISSION_DISPLAY_DIVISOR : 0.0;
|
||||
}
|
||||
|
||||
private static final double COMMISSION_DISPLAY_DIVISOR = 1_000_000.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ public class UserDto {
|
||||
private String screenName; // User's screen name
|
||||
private Integer dateReg; // Registration date (Unix timestamp in seconds)
|
||||
private String ip;
|
||||
private Long balanceA; // Balance (stored as bigint, represents number with 6 decimal places)
|
||||
private Long balanceB; // Second balance (stored as bigint)
|
||||
private Double balanceA; // Balance for display (raw bigint / 1_000_000)
|
||||
private Double balanceB; // Second balance for display (raw bigint / 1_000_000)
|
||||
private String avatarUrl; // Public URL of user's avatar
|
||||
private String languageCode; // User's language preference (EN, RU, DE, IT, NL, PL, FR, ES, ID, TR)
|
||||
private Boolean paymentEnabled; // Runtime toggle: deposits (Store, Payment Options, etc.) allowed
|
||||
|
||||
Reference in New Issue
Block a user