feat: uuid 生成加锁
parent
8919703be4
commit
4edcc0bca2
|
|
@ -7,6 +7,7 @@ import java.util.UUID;
|
|||
* @since 2.0.0
|
||||
*/
|
||||
public class Nonce {
|
||||
private static final Object lock = new Object();
|
||||
|
||||
private Nonce() {
|
||||
}
|
||||
|
|
@ -15,6 +16,8 @@ public class Nonce {
|
|||
* @return nonce 随机串
|
||||
*/
|
||||
public static String ofNonce() {
|
||||
return UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||
synchronized (lock) {
|
||||
return UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,25 @@ package com.czcb.scfs.api.core.util;
|
|||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
class NonceTest {
|
||||
|
||||
|
||||
@Test
|
||||
void ofNonce() {
|
||||
Assertions.assertEquals(32, Nonce.ofNonce().length());
|
||||
}
|
||||
|
||||
@Test
|
||||
void ifNonceTest() {
|
||||
Set<String> strings = new HashSet<>();
|
||||
for (int j = 0; j < 1000000; j++) {
|
||||
String s = Nonce.ofNonce();
|
||||
strings.add(s);
|
||||
}
|
||||
|
||||
Assertions.assertEquals(1000000, strings.size());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
package com.czcb.scfs.api.test.service;
|
||||
|
||||
import com.czcb.scfs.api.service.v2.invoice.InvoiceService;
|
||||
import com.czcb.scfs.api.service.v2.invoice.model.InvoiceDepositQueryRequest;
|
||||
import com.czcb.scfs.api.service.v2.invoice.model.InvoiceDepositQueryResponse;
|
||||
import com.czcb.scfs.api.service.v2.invoice.model.InvoiceInfoSaveRequest;
|
||||
import com.czcb.scfs.api.service.v2.invoice.model.InvoiceSettleMatchRequest;
|
||||
import org.junit.jupiter.api.ClassOrderer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -26,8 +26,9 @@ class InvoiceServiceTest {
|
|||
void addTest() {
|
||||
invoiceService.add(new InvoiceInfoSaveRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchTest(){
|
||||
void matchTest() {
|
||||
InvoiceSettleMatchRequest request = new InvoiceSettleMatchRequest();
|
||||
request.setChannelNo("1039");
|
||||
request.setAppNo("21");
|
||||
|
|
@ -46,4 +47,17 @@ class InvoiceServiceTest {
|
|||
request.setMatchType("1");
|
||||
invoiceService.settleMatch(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
void invoiceDepositQuery() {
|
||||
InvoiceDepositQueryRequest request = new InvoiceDepositQueryRequest();
|
||||
request.setChannelNo("1039");
|
||||
request.setAppNo("21");
|
||||
request.setSerialNo("123456");
|
||||
request.setTransDate("2024-07-24");
|
||||
request.setTransTradeTime("2024-07-24 15:52:11");
|
||||
|
||||
InvoiceDepositQueryResponse response = invoiceService.invoiceDepositQuery(request);
|
||||
System.out.println(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue