Explorar o código

feat(physical): 添加赛事简介字段并优化查询逻辑

- 在 PhysicalTournaments、PhysicalTournamentsBo、PhysicalTournamentsDto 和 PhysicalTournamentsVo 中添加 tournamentsIntroduction 字段
- 更新 MyBatis XML 映射文件以支持 tournamentsIntroduction 的插入、更新和查询
- 为 PhysicalTournamentsServiceImpl 添加排序功能,支持按 startTime 排序
- 增加 flagType 时间范围查询逻辑,完善状态和删除标记过滤条件
- 修改用户参赛次数统计逻辑,从 rewardClaims 表改为 participants 表获取数据
fugui001 hai 1 mes
pai
achega
d139ac44af

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/UserServiceImpl.java

@@ -146,8 +146,8 @@ public class UserServiceImpl implements IUserService {
                     resultRecord.setLoginName(resultRecord.getPhone());
                 }
 
-                int userRewardCount = rewardClaimsMapper.selectUserRewardCount(resultRecord.getId());
-                resultRecord.setTournamentCount(userRewardCount);
+                int tournamentCount= participantsMapper.selectUserTournamentTotal(resultRecord.getId());
+                resultRecord.setTournamentCount(tournamentCount);
 
                 PlayerItemsVo playerItemsVo = playerItemsMapper.selectPlayerItemsInfo(resultRecord.getId(), 1001L);
 

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/PhysicalTournaments.java

@@ -182,4 +182,9 @@ public class PhysicalTournaments extends BaseEntity {
      * 赛事位置
      */
     private String competitionLocation;
+
+    /**
+     * 赛事简介
+     */
+    private String tournamentsIntroduction;
 }

+ 11 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/bo/PhysicalTournamentsBo.java

@@ -182,5 +182,16 @@ public class PhysicalTournamentsBo extends BaseEntity {
      */
     private Long qualifierValue;
 
+    String sortBy;
 
+    Boolean isAsc;   // true = asc, false = desc
+    /**
+     *  日周月 三天  日期
+     */
+    private String flagType;
+
+    /**
+     * 赛事简介
+     */
+    private String tournamentsIntroduction;
 }

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/dto/PhysicalTournamentsDto.java

@@ -82,4 +82,9 @@ public class PhysicalTournamentsDto {
      */
     private String competitionLocation;
 
+    /**
+     * 赛事简介
+     */
+    private String tournamentsIntroduction;
+
 }

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/vo/PhysicalTournamentsVo.java

@@ -249,4 +249,9 @@ public class PhysicalTournamentsVo implements Serializable {
 
     private String competitionLocation;
 
+    /**
+     * 赛事简介
+     */
+    private String tournamentsIntroduction;
+
 }

+ 40 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/service/impl/PhysicalTournamentsServiceImpl.java

@@ -2,6 +2,7 @@ package org.dromara.physical.service.impl;
 
 import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import org.dromara.business.domain.enums.GameStatus;
 import org.dromara.business.domain.vo.TournamentBlindStructuresVo;
 import org.dromara.business.utils.RedisKeys;
@@ -273,9 +274,48 @@ public class PhysicalTournamentsServiceImpl implements IPhysicalTournamentsServi
         return resultRecords;
     }
 
+    private static final Map<String, SFunction<PhysicalTournaments, ?>> ORDER_FIELD_MAP = new HashMap<>();
+    static {
+        ORDER_FIELD_MAP.put("startTime", PhysicalTournaments::getStartTime);
+        // 可以继续添加其他支持排序的字段
+    }
     private LambdaQueryWrapper<PhysicalTournaments> buildQueryWrapper(PhysicalTournamentsBo bo) {
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<PhysicalTournaments> lqw = Wrappers.lambdaQuery();
+
+        // 获取排序字段和方式
+        String sortBy = bo.getSortBy();
+        Boolean isAsc = bo.getIsAsc();
+
+        // 如果有排序字段,并且该字段支持排序
+        if (sortBy != null && ORDER_FIELD_MAP.containsKey(sortBy)) {
+            SFunction<PhysicalTournaments, ?> columnFunc = ORDER_FIELD_MAP.get(sortBy);
+            if (Boolean.TRUE.equals(isAsc)) {
+                lqw.orderBy(true, true, columnFunc); // 升序
+            } else {
+                lqw.orderBy(true, false, columnFunc); // 降序
+            }
+        } else {
+            // 默认排序(比如按开始时间降序)
+            lqw.orderByDesc(PhysicalTournaments::getStartTime);
+        }
+       if(StringUtils.isNotBlank(bo.getFlagType())){
+            // 修改为时间范围查询:
+            if (bo.getStartTime() != null) {
+                lqw.ge(PhysicalTournaments::getStartTime, bo.getStartTime()); // 大于等于开始时间
+                lqw.le(PhysicalTournaments::getStartTime,  bo.getEndTime()); // 小于等于结束时间
+            }
+        /*    if (bo.getEndTime() != null) {
+                lqw.le(Tournaments::getStartTime,  bo.getEndTime()); // 小于等于结束时间
+            }*/
+            lqw.notIn(PhysicalTournaments::getStatus, Arrays.asList(0L, 5L));
+            // 添加 is_delete=false 条件,过滤已删除的记录
+            lqw.eq(PhysicalTournaments::getIsDelete, false);
+        }else{
+            lqw.like(bo.getStartTime() != null, PhysicalTournaments::getStartTime, bo.getStartTime());
+            lqw.eq(bo.getStatus() != null, PhysicalTournaments::getStatus, bo.getStatus());
+        }
+
         lqw.orderByAsc(PhysicalTournaments::getId);
         lqw.like(StringUtils.isNotBlank(bo.getName()), PhysicalTournaments::getName, bo.getName());
         lqw.eq(bo.getStartTime() != null, PhysicalTournaments::getStartTime, bo.getStartTime());

+ 7 - 4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/physical/PhysicalTournamentsMapper.xml

@@ -11,11 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectPhysicalTournamentsVoList" resultType="org.dromara.physical.domain.vo.PhysicalTournamentsVo">
-        SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete,delay_card_time,delay_card_num,action_time,competition_bg,min_players,competition_location FROM physical_tournaments  ${ew.customSqlSegment}
+        SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete,delay_card_time,delay_card_num,action_time,competition_bg,min_players,competition_location,tournaments_introduction FROM physical_tournaments  ${ew.customSqlSegment}
     </select>
 
     <select id="selectPhysicalTournamentsByIdInfo" resultType="org.dromara.physical.domain.vo.PhysicalTournamentsVo">
-        SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete,delay_card_time,delay_card_num,action_time,competition_bg,min_players,competition_location FROM physical_tournaments WHERE id =  #{id}
+        SELECT id, name, start_time, end_time,game_type, starting_chips, level_duration, late_registration_level, max_players, status, created_at, updated_at,sign_time,competition_icon,tournaments_bi_id,robot_count,is_delete,delay_card_time,delay_card_num,action_time,competition_bg,min_players,competition_location,tournaments_introduction FROM physical_tournaments WHERE id =  #{id}
     </select>
 
 
@@ -42,8 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="actionTime != null">action_time = #{actionTime},</if>
             <if test="robotCount != null">robot_count = #{robotCount},</if>
             <if test="competitionBg != null">competition_bg = #{competitionBg},</if>
-            <if test="minPlayers != null">min_players = #{minPlayers}</if>
-            <if test="competitionLocation != null">competition_location = #{competitionLocation}</if>
+            <if test="minPlayers != null">min_players = #{minPlayers},</if>
+            <if test="competitionLocation != null">competition_location = #{competitionLocation},</if>
+            <if test="tournamentsIntroduction != null">tournaments_introduction = #{tournamentsIntroduction}</if>
         </set>
         WHERE id = #{id}
     </update>
@@ -73,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="competitionBg != null">competition_bg,</if>
             <if test="minPlayers != null">min_players,</if>
             <if test="competitionLocation != null">competition_location,</if>
+            <if test="tournamentsIntroduction != null">tournaments_introduction,</if>
         </trim>
         VALUES
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -97,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="competitionBg != null">#{competitionBg},</if>
             <if test="minPlayers != null">#{minPlayers},</if>
             <if test="competitionLocation != null">#{competitionLocation},</if>
+            <if test="tournamentsIntroduction != null">#{tournamentsIntroduction},</if>
         </trim>
     </insert>