ソースを参照

feat(Tournaments): 添加赛事软删除标志并优化时间解析

- 在 Tournaments 模型中添加 isDelete 字段,用于软删除标记
- 更新 TournamentsMapper.xml,增加 isDelete 字段的映射
- 修改 TournamentsServiceImpl: - 新增赛事时默认设置 isDelete 为 false
  -优化时间解析方法,支持可选的秒字段
fugui001 3 ヶ月 前
コミット
35e71d5c94

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/Tournaments.java

@@ -104,4 +104,6 @@ public class Tournaments extends BaseEntity {
 
     private int robotCount;
 
+    private Boolean isDelete;
+
 }

+ 12 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/TournamentsServiceImpl.java

@@ -37,6 +37,8 @@ import java.text.ParseException;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.temporal.ChronoField;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -298,6 +300,7 @@ public class TournamentsServiceImpl implements ITournamentsService {
             if(blindLevelsVos.size()>0){
                 add.setLevelDuration(blindLevelsVos.get(0).getDurationMinutes());
             }
+            add.setIsDelete(false);
             // 插入赛事主表
             boolean flag = baseMapper.insertTournament(add) > 0;
             if (!flag) {
@@ -564,7 +567,15 @@ public class TournamentsServiceImpl implements ITournamentsService {
             throw new IllegalArgumentException("startTime 不能为空");
         }
 
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+        // 构建一个可选秒的格式器
+        DateTimeFormatter formatter = new DateTimeFormatterBuilder()
+            .appendPattern("yyyy-MM-dd HH:mm")
+            .optionalStart()
+            .appendLiteral(':')
+            .appendValue(ChronoField.SECOND_OF_MINUTE, 2)
+            .optionalEnd()
+            .toFormatter();
+
         LocalDateTime localDateTime = LocalDateTime.parse(dateTimeStr, formatter);
         return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
     }

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentsMapper.xml

@@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="endTime != null">end_time,</if>
             <if test="tournamentsBiId != null">tournaments_bi_id,</if>
             <if test="robotCount != null">robot_count,</if>
+            <if test="isDelete != null">is_delete,</if>
         </trim>
         VALUES
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -77,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="endTime != null">#{endTime},</if>
             <if test="tournamentsBiId != null">#{tournamentsBiId},</if>
             <if test="robotCount != null">#{robotCount},</if>
+            <if test="isDelete != null">#{isDelete},</if>
         </trim>
     </insert>