🎨 代码优化

This commit is contained in:
ronger 2022-06-06 11:55:31 +08:00
parent ef22670d1a
commit 8cdcdfeff0
3 changed files with 9 additions and 16 deletions

View File

@ -24,7 +24,7 @@ public class Sponsor implements Serializable, Cloneable {
/** /**
* 数据类型 * 数据类型
*/ */
private String dataType; private Integer dataType;
/** /**
* 数据主键 * 数据主键
*/ */

View File

@ -7,29 +7,22 @@ import java.util.Arrays;
*/ */
public enum TransactionEnum { public enum TransactionEnum {
ArticleSponsor("0", 20, "文章赞赏"), ArticleSponsor(20, "文章赞赏"),
Answer("1", 30, "答题奖励"), Answer(30, "答题奖励"),
CorrectAnswer("2", 50, "答题奖励"), CorrectAnswer(50, "答题奖励"),
NewbieRewards("3", 200, "新手奖励"); NewbieRewards(200, "新手奖励");
private String dataType;
private Integer money; private Integer money;
private String description; private String description;
TransactionEnum(String dataType, Integer money, String description) { TransactionEnum(Integer money, String description) {
this.dataType = dataType;
this.money = money; this.money = money;
this.description = description; this.description = description;
} }
public static TransactionEnum findTransactionEnum(String dataType) { public static TransactionEnum findTransactionEnum(int dataType) {
return Arrays.stream(TransactionEnum.values()).filter(transactionEnum -> transactionEnum.getDataType().equals(dataType)).findFirst().orElse(TransactionEnum.ArticleSponsor); return Arrays.stream(TransactionEnum.values()).filter(transactionEnum -> transactionEnum.ordinal() == dataType).findFirst().orElse(TransactionEnum.ArticleSponsor);
}
public String getDataType() {
return this.dataType;
} }
public Integer getMoney() { public Integer getMoney() {

View File

@ -57,7 +57,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
@Override @Override
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount, String startDate, String endDate) { public List<TransactionRecordDTO> findTransactionRecords(String bankAccount, String startDate, String endDate) {
List<TransactionRecordDTO> list = transactionRecordMapper.selectTransactionRecords(bankAccount, startDate, endDate); List<TransactionRecordDTO> list = transactionRecordMapper.selectTransactionRecords(bankAccount, startDate, endDate);
list.forEach(transactionRecordDTO -> genTransactionRecord(transactionRecordDTO)); list.forEach(this::genTransactionRecord);
return list; return list;
} }