public class PrizeRanking { private Long id; private String prizeName; private Integer prizeRank; // Getters and Setters... }
时间: 2024-03-28 22:40:20 浏览: 42
这是一个 PrizeRanking 类的代码片段,包含了三个属性:id、prizeName 和 prizeRank。id 是一个 Long 类型的变量,prizeName 是一个 String 类型的变量,prizeRank 是一个 Integer 类型的变量。这个类还包含了它们的 Getter 和 Setter 方法。这个类可能是用来表示某个奖项的排名信息。
相关问题
for (Winning winning : winnings) { // 若存在物流信息 发货时间不能为空 if (winning.getPostTime() != null){ rightNow.setTime(winning.getPostTime()); //日期加1个月 rightNow.add(Calendar.MONTH,1); flg = rightNow.getTime().compareTo(new Date()); if (flg <= 0 ){ flag = true; } } if (!VtuzxUtil.isEmpty(winning.getOutState())){ // 自动收货 if(winning.getOutState().equals(String.valueOf(PrizeOutStateEnum.Sent_ENUM.value())) && flag){ // 修改发放状态为已收货 winningDao.updOutStateById(String.valueOf(winning.getId()),PrizeOutStateEnum.Receive_Goods.value()); winning.setOutState(PrizeOutStateEnum.Receive_Goods.value()); flag = false; } } dataList.add( new VtuzxMap("prizeName",winning.getPrizeName()) .append("receiptNo",winning.getReceiptNo()) .append("companyName",winning.getCompanyName()) .append("department",winning.getDepartment()) .append("prizeNum",winning.getPrizeNum()) .append("outStore",winning.getOutStore()) .append("giveOut",winning.getGiveOut()) .append("userName",winning.getUserName()) .append("activityName",winning.getActivityName()) .append("outState",winning.getOutState()) .append("mobile",winning.getMobile()) .append("activityId",winning.getAwardActivityId()) .append("prizeType",winning.getPrizeType()) .append("clearingState",winning.getClearingState()) .append("postCompany",winning.getPostCompany()) .append("storeName", winning.getStoreName()) .append("postNo",winning.getPostNo()) .append("postName",winning.getPostName()) .append("contactMobile",winning.getContactMobile()) .append("province",winning.getProvince()) .append("city",winning.getCity()) .append("area",winning.getArea()) .append("createdAt",VtuzxUtil.formatYmdHmsF(winning.getCreatedAt())) .append("addressDetail",winning.getAddressDetail()) ); }使用stream优化
可以使用 Java 8 中的 stream 来优化上述代码,具体实现如下:
```
List<Map<String, Object>> dataList = winnings.stream()
.filter(winning -> winning.getPostTime() != null)
.map(winning -> {
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(winning.getPostTime());
rightNow.add(Calendar.MONTH, 1);
boolean flag = rightNow.getTime().compareTo(new Date()) <= 0;
if (!VtuzxUtil.isEmpty(winning.getOutState()) && winning.getOutState().equals(String.valueOf(PrizeOutStateEnum.Sent_ENUM.value())) && flag) {
winningDao.updOutStateById(String.valueOf(winning.getId()), PrizeOutStateEnum.Receive_Goods.value());
winning.setOutState(PrizeOutStateEnum.Receive_Goods.value());
flag = false;
}
return new VtuzxMap("prizeName", winning.getPrizeName())
.append("receiptNo", winning.getReceiptNo())
.append("companyName", winning.getCompanyName())
.append("department", winning.getDepartment())
.append("prizeNum", winning.getPrizeNum())
.append("outStore", winning.getOutStore())
.append("giveOut", winning.getGiveOut())
.append("userName", winning.getUserName())
.append("activityName", winning.getActivityName())
.append("outState", winning.getOutState())
.append("mobile", winning.getMobile())
.append("activityId", winning.getAwardActivityId())
.append("prizeType", winning.getPrizeType())
.append("clearingState", winning.getClearingState())
.append("postCompany", winning.getPostCompany())
.append("storeName", winning.getStoreName())
.append("postNo", winning.getPostNo())
.append("postName", winning.getPostName())
.append("contactMobile", winning.getContactMobile())
.append("province", winning.getProvince())
.append("city", winning.getCity())
.append("area", winning.getArea())
.append("createdAt", VtuzxUtil.formatYmdHmsF(winning.getCreatedAt()))
.append("addressDetail", winning.getAddressDetail());
})
.collect(Collectors.toList());
```
使用 stream 可以让代码更加简洁和易于理解,同时也有更好的可读性和可维护性。
<insert id="insert" parameterType="RafflePrizeRelationEntity" useGeneratedKeys="true" keyProperty="id"> INSERT INTO <include refid="table"/> (<include refid="insert_column"/>) VALUES (#{raffleId},#{prizeNum},#{prizeId},#{prizeName},#{prizePhoto},#{prizeInstruction},#{probability},#{prizeLimit},#{isDel},#{createUserId},#{createTime},#{updateUserId},#{updateTime}) </insert>
这是一个 MyBatis 的 XML 映射文件中的插入语句,用于将 RafflePrizeRelationEntity 对象插入数据库中的表格中。其中,<include refid="table"/> 和 <include refid="insert_column"/> 都是引用了其他的 XML 片段,用于指定要插入的表格和列名。通过使用 #{} 语法,可以将 RafflePrizeRelationEntity 对象中的属性值与 SQL 语句中的占位符相对应,从而插入正确的数据。其中,keyProperty="id" 指定了自动生成的主键 ID 要赋值给 RafflePrizeRelationEntity 对象的 id 属性。
阅读全文