REQ-3201: 用枚举替换字符串
This commit is contained in:
parent
5c2a5295fb
commit
cafaa674fd
@ -174,11 +174,7 @@ public class CardManager {
|
||||
}
|
||||
|
||||
RecordCursor<Card> cardsCursor(CardUpdateRequest request) {
|
||||
return cardsCursor(cardProps.getCardCursorLimit(), request);
|
||||
}
|
||||
|
||||
RecordCursor<Card> cardsCursor(int batchSize, CardUpdateRequest request) {
|
||||
return new RecordCursor<>(batchSize, Card::getId, () -> cardDao.lambdaQuery()
|
||||
return new RecordCursor<>(Card::getId, () -> cardDao.lambdaQuery()
|
||||
.eq(Card::getAppCode, request.getAppCode())
|
||||
.eq(Card::getTemplateCode, request.getTemplateCode())
|
||||
.eq(Card::getBizCode, request.getBizCode())
|
||||
|
||||
@ -17,7 +17,6 @@ import java.util.Set;
|
||||
@ConfigurationProperties(prefix = "card")
|
||||
public class CardProps {
|
||||
|
||||
private int cardCursorLimit = 500;
|
||||
private boolean debugBizBody = true;
|
||||
private boolean enableCardLog = true;
|
||||
private boolean deleteCardsWhenSendFail = true;
|
||||
|
||||
@ -3,7 +3,6 @@ package cn.axzo.msg.center.utils;
|
||||
import cn.axzo.maokai.api.util.Ref;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
@ -11,7 +10,6 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class RecordCursor<T> implements Supplier<List<T>> {
|
||||
|
||||
private final int batchSize;
|
||||
@ -19,6 +17,19 @@ public class RecordCursor<T> implements Supplier<List<T>> {
|
||||
private final Supplier<LambdaQueryChainWrapper<T>> query;
|
||||
private final Ref<Long> maxId = Ref.create(0L);
|
||||
|
||||
public RecordCursor(SFunction<T, Long> idGetter,
|
||||
Supplier<LambdaQueryChainWrapper<T>> query) {
|
||||
this(2000, idGetter, query);
|
||||
}
|
||||
|
||||
public RecordCursor(int batchSize,
|
||||
SFunction<T, Long> idGetter,
|
||||
Supplier<LambdaQueryChainWrapper<T>> query) {
|
||||
this.batchSize = batchSize;
|
||||
this.idGetter = idGetter;
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> get() {
|
||||
List<T> cards = query.get()
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
package cn.axzo.msg.center.message.service.card;
|
||||
|
||||
import cn.axzo.msg.center.MsgCenterApplication;
|
||||
import cn.axzo.msg.center.domain.entity.Card;
|
||||
import cn.axzo.msg.center.service.dto.PeerPerson;
|
||||
import cn.axzo.msg.center.service.pending.request.CardUpdateRequest;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@SpringBootTest(classes = MsgCenterApplication.class)
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
class CardManagerTest {
|
||||
|
||||
private final CardManager cardManager;
|
||||
|
||||
@Test
|
||||
void exec() {
|
||||
CardUpdateRequest request = new CardUpdateRequest();
|
||||
request.setAppCode("test");
|
||||
request.setTemplateCode("9f7e48f7c4dc44289bc8e590a0eb47ca");
|
||||
request.setBizCode("2");
|
||||
request.setReceivers(Sets.newHashSet(
|
||||
PeerPerson.newPeerPerson(9000398967L, 10496L, 4946L),
|
||||
PeerPerson.newPeerPerson(9000398967L, 10496L, 4947L)));
|
||||
Supplier<List<Card>> cursor = cardManager.cardsCursor(1, request);
|
||||
for (List<Card> cards = cursor.get(); !cards.isEmpty(); cards = cursor.get()) {
|
||||
System.out.println("---------------------> " + cards.size());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user