소스 검색

feat(tournament): 添加比赛报名条件删除功能并优化报名条件处理逻辑

- 在TournamentEntryConditionsMapper中添加deleteByTournamentId方法用于删除比赛报名条件
- 在TournamentEntryConditionsTemplateMapper中添加deleteByTournamentId方法用于删除比赛模板报名条件
- 在TournamentsServiceImpl中添加报名条件ID空值检查,避免空值导致的错误
- 在TournamentsServiceImpl中实现比赛报名条件的删除和重新添加逻辑
- 修复TournamentsTemplateMapper.xml中重复的remark字段处理
- 优化TournamentsTemplateServiceImpl中的报名条件处理流程,添加空值检查和删除重建逻辑
fugui001 1 개월 전
부모
커밋
2985cd2acc

+ 3 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/TournamentEntryConditionsTemplateMapper.java

@@ -36,4 +36,7 @@ public interface TournamentEntryConditionsTemplateMapper extends BaseMapperPlus<
     @InterceptorIgnore(tenantLine = "true")
     TournamentEntryConditionsVo selectByTournamentInfoTemplate(Long tournamentId);
 
+    @InterceptorIgnore(tenantLine = "true")
+    int deleteByTournamentId(Long tournamentId);
+
 }

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

@@ -446,8 +446,9 @@ public class TournamentsServiceImpl implements ITournamentsService {
             bindBlindStructure(tournamentId, bo.getBlindStructureId());
 
             // 添加报名条件
-            addEntryCondition(tournamentId, bo.getItemsId(), bo.getItemsNum());
-
+            if(bo.getItemsId()!=null){
+                addEntryCondition(tournamentId, bo.getItemsId(), bo.getItemsNum());
+            }
             // 处理奖励分布
             processPrizeDistributions(tournamentId, prizeList);
 
@@ -632,12 +633,17 @@ public class TournamentsServiceImpl implements ITournamentsService {
             // 绑定盲注结构
             bindBlindStructure(tournamentId, bo.getBlindStructureId());
 
+
+            tournamentEntryConditionsMapper.deleteByTournamentId(tournamentId);
             // 修改报名条件
-            TournamentEntryConditions tournamentEntryConditions=new TournamentEntryConditions();
-            tournamentEntryConditions.setItemId(bo.getItemsId());
-            tournamentEntryConditions.setRequiredQuantity(bo.getItemsNum());
-            tournamentEntryConditions.setTournamentId(tournamentId);
-            tournamentEntryConditionsMapper.updateByTournamentId(tournamentEntryConditions);
+            if(bo.getItemsId()!=null){
+                addEntryCondition(tournamentId, bo.getItemsId(), bo.getItemsNum());
+               /* TournamentEntryConditions tournamentEntryConditions=new TournamentEntryConditions();
+                tournamentEntryConditions.setItemId(bo.getItemsId());
+                tournamentEntryConditions.setRequiredQuantity(bo.getItemsNum());
+                tournamentEntryConditions.setTournamentId(tournamentId);
+                tournamentEntryConditionsMapper.updateByTournamentId(tournamentEntryConditions);*/
+            }
 
             //删除奖励排名 同时删除奖励对应信息
             List<PrizeDistributionsVo> prizeDistributionsVos = prizeDistributionsMapper.selectByTournamentId(tournamentId);

+ 14 - 8
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/TournamentsTemplateServiceImpl.java

@@ -322,7 +322,9 @@ public class TournamentsTemplateServiceImpl implements ITournamentsTemplateServi
             bindBlindStructure(tournamentId, bo.getBlindStructureId());
 
             // 添加报名条件
-            addEntryCondition(tournamentId, bo.getItemsId(), bo.getItemsNum());
+            if(bo.getItemsId()!=null){
+                addEntryCondition(tournamentId, bo.getItemsId(), bo.getItemsNum());
+            }
 
             // 处理奖励分布
             processPrizeDistributions(tournamentId, prizeList);
@@ -493,13 +495,17 @@ public class TournamentsTemplateServiceImpl implements ITournamentsTemplateServi
 
             // 绑定盲注结构
             bindBlindStructure(tournamentId, bo.getBlindStructureId());
-
-            // 修改报名条件
-            TournamentEntryConditionsTemplate tournamentEntryConditions=new TournamentEntryConditionsTemplate();
-            tournamentEntryConditions.setItemId(bo.getItemsId());
-            tournamentEntryConditions.setRequiredQuantity(bo.getItemsNum());
-            tournamentEntryConditions.setTournamentId(tournamentId);
-            tournamentEntryConditionsMapper.updateByTournamentIdTemplate(tournamentEntryConditions);
+            tournamentEntryConditionsMapper.deleteByTournamentId(tournamentId);
+            if(bo.getItemsId()!=null){
+                // 修改报名条件
+               /* TournamentEntryConditionsTemplate tournamentEntryConditions=new TournamentEntryConditionsTemplate();
+                tournamentEntryConditions.setItemId(bo.getItemsId());
+                tournamentEntryConditions.setRequiredQuantity(bo.getItemsNum());
+                tournamentEntryConditions.setTournamentId(tournamentId);
+                tournamentEntryConditionsMapper.updateByTournamentIdTemplate(tournamentEntryConditions);
+         */
+               addEntryCondition(tournamentId, bo.getItemsId(), bo.getItemsNum());
+            }
 
             //删除奖励排名 同时删除奖励对应信息
             List<PrizeDistributionsVo> prizeDistributionsVos = prizeDistributionsMapper.selectByTournamentIdTemplate(tournamentId);

+ 5 - 1
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentEntryConditionsMapper.xml

@@ -35,7 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </set>
         WHERE tournament_id = #{tournamentId}
     </update>
-
+    <!-- 删除记录,只在id有效时删除 -->
+    <delete id="deleteByTournamentId">
+        DELETE FROM tournament_entry_conditions
+        WHERE tournament_id = #{tournamentId}
+    </delete>
     <!-- 删除记录,只在id有效时删除 -->
     <delete id="deleteById">
         DELETE FROM tournament_entry_conditions

+ 4 - 1
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentEntryConditionsTemplateMapper.xml

@@ -42,7 +42,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE id = #{id}
           AND #{id} IS NOT NULL
     </delete>
-
+    <delete id="deleteByTournamentId">
+        DELETE FROM tournament_entry_conditions_template
+        WHERE tournament_id = #{tournamentId}
+    </delete>
     <!-- 查询单条记录 -->
     <select id="selectById" resultType="org.dromara.business.domain.vo.TournamentEntryConditionsVo">
         SELECT *

+ 0 - 1
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentsTemplateMapper.xml

@@ -116,7 +116,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="qualifierValue != null">#{qualifierValue},</if>
             <if test="startBlindLevel != null">#{startBlindLevel},</if>
             <if test="rebuy != null">#{rebuy},</if>
-            <if test="remark != null">remark = #{remark},</if>
             <if test="delayShow != null">#{delayShow},</if>
             <if test="remark != null">#{remark},</if>
         </trim>