conflict resolved by mohd arham
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.billpaymentservice.bbps.util;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -10,12 +11,23 @@ import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.entites.BBPSMastersData;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.BBPSMasterDataRepo;
|
||||
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MerchantRequestModel;
|
||||
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Component
|
||||
public class Helper {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Helper.class);
|
||||
|
||||
private static final String CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
private static final SecureRandom secureRandom = new SecureRandom();
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private final BBPSMasterDataRepo bbpsMasterDataRepo;
|
||||
|
||||
// Constructor Injection
|
||||
@@ -148,4 +160,26 @@ public class Helper {
|
||||
// Agar exception nahi throw hua, merchant valid hai
|
||||
}
|
||||
|
||||
public static String generateTxnId(int n) {
|
||||
StringBuilder sb = new StringBuilder(n);
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
int index = secureRandom.nextInt(CHARACTERS.length());
|
||||
sb.append(CHARACTERS.charAt(index));
|
||||
}
|
||||
return sb.toString(); // Prefix
|
||||
}
|
||||
|
||||
public String convertObjectToJson(Object obj) {
|
||||
if (obj == null)
|
||||
return "null";
|
||||
try {
|
||||
return new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(obj);
|
||||
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
|
||||
// log appropriately (use your existing logger)
|
||||
System.err.println("JSON conversion failed: " + e.getMessage());
|
||||
return "{}"; // or "N/A" depending on your needs
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user