Przeglądaj źródła

feat(tournament): 支持赛事多类目与多标签管理

- 修改赛事类目与标签关联关系为一对多
- 更新Mapper接口支持批量查询类目与标签ID
- 新增查询类目与标签名称的方法
- 扩展DTO与VO对象以支持列表类型字段
- 实现赛事详情中类目与标签的完整信息展示
- 在Excel导出中增加类目与标签名称字段
- 优化addCategoryTag方法支持批量插入关联数据
fugui001 1 tydzień temu
rodzic
commit
74c0d4dee7

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/dto/TournamentsDto.java

@@ -108,8 +108,8 @@ public class TournamentsDto {
      */
     private  Integer qualifierValue;
 
-    private  Long tagId;
-    private  Long categoryId;
+    private  List<Long> tagId;
+    private  List<Long> categoryId;
 
     // 重复买入:<0不可重复买入,0-不限制,>0限制次数
     private Integer rebuy;

+ 10 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/vo/TournamentsVo.java

@@ -302,7 +302,15 @@ public class TournamentsVo implements Serializable {
     //0-默认不开启延迟看牌,1-开启
     private Integer delayShow;
 
-    private  Long tagId;
-    private  Long categoryId;
+    private  List<Long> tagId;
+    private  List<Long> categoryId;
 
+    private  List<String> tagName;
+    private  List<String> categoryName;
+
+
+    @ExcelProperty(value = "赛事标签")
+    private  String tagNameIds;
+    @ExcelProperty(value = "赛事类目")
+    private  String categoryNameIds;
 }

+ 8 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/TournamentCategoryTagMapper.java

@@ -7,6 +7,8 @@ import org.dromara.business.domain.TournamentCategoryTag;
 import org.dromara.business.domain.vo.TournamentCategoryTagVo;
 import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 
+import java.util.List;
+
 /**
  * 赛事与类目/标签关联Mapper接口
  *
@@ -26,6 +28,11 @@ public interface TournamentCategoryTagMapper extends BaseMapperPlus<TournamentCa
     int deleteTournamentCategoryTagByIds(@Param("tournamentId") Long tournamentId, @Param("categoryTagId") Long categoryTagId);
 
     @InterceptorIgnore(tenantLine = "true")
-    Long selectCategoryOrTagId(@Param("type") String type,@Param("tournamentId") Long tournamentId);
+    List<Long> selectCategoryOrTagId(@Param("type") String type, @Param("tournamentId") Long tournamentId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<String> selectNameCategoryOrTagId(@Param("type") String type,@Param("tournamentId") Long tournamentId);
+
+
 
 }

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

@@ -158,9 +158,9 @@ public class TournamentsServiceImpl implements ITournamentsService {
             tournamentsVo.setIsComplaints(false);
         }
         //查询类目和标签ID
-        Long category = tournamentCategoryTagMapper.selectCategoryOrTagId("CATEGORY", tournamentId);
+        List<Long> category = tournamentCategoryTagMapper.selectCategoryOrTagId("CATEGORY", tournamentId);
         tournamentsVo.setCategoryId(category);
-        Long tag = tournamentCategoryTagMapper.selectCategoryOrTagId("TAG", tournamentId);
+        List<Long> tag = tournamentCategoryTagMapper.selectCategoryOrTagId("TAG", tournamentId);
         tournamentsVo.setTagId(tag);
         return tournamentsVo;
     }
@@ -226,6 +226,12 @@ public class TournamentsServiceImpl implements ITournamentsService {
 
             int totalSignNum = participantsMapper.selectParticipantsTotal(tournamentId);
             record.setSignNum(totalSignNum);
+
+            List<String> category = tournamentCategoryTagMapper.selectNameCategoryOrTagId("CATEGORY", tournamentId);
+            List<String> tag = tournamentCategoryTagMapper.selectNameCategoryOrTagId("TAG", tournamentId);
+            record.setCategoryName(category);
+            record.setTagName(tag);
+
         }
 
         return TableDataInfo.build(result);
@@ -299,6 +305,17 @@ public class TournamentsServiceImpl implements ITournamentsService {
 
             int totalSignNum = participantsMapper.selectParticipantsTotal(tournamentId);
             record.setSignNum(totalSignNum);
+
+            List<String> category = tournamentCategoryTagMapper.selectNameCategoryOrTagId("CATEGORY", tournamentId);
+            List<String> tag = tournamentCategoryTagMapper.selectNameCategoryOrTagId("TAG", tournamentId);
+            if(!category.isEmpty()){
+                String categoryStr = String.join(",", category);
+                record.setCategoryNameIds(categoryStr);
+            }
+            if(!tag.isEmpty()){
+                String tagStr = String.join(",", tag);
+                record.setTagNameIds(tagStr);
+            }
          }
        return tournamentsVos;
     }
@@ -510,26 +527,31 @@ public class TournamentsServiceImpl implements ITournamentsService {
     }
 
     //
-    private void addCategoryTag(Long tournamentId, Long categoryId,Long tagId) {
-        // 如果 categoryId 有值,则插入一条记录
-        if (categoryId != null) {
-            TournamentCategoryTag categoryTag = new TournamentCategoryTag();
-            categoryTag.setTournamentId(tournamentId);
-            categoryTag.setCategoryTagId(categoryId);
-            tournamentCategoryTagMapper.insertTournamentCategoryTag(categoryTag);
+    private void addCategoryTag(Long tournamentId, List<Long> categoryIds, List<Long> tagIds) {
+        // 如果 categoryIds 有值,则为每个 categoryId 插入一条记录
+        if (CollectionUtils.isNotEmpty(categoryIds)) {
+            for (Long categoryId : categoryIds) {
+                TournamentCategoryTag categoryTag = new TournamentCategoryTag();
+                categoryTag.setTournamentId(tournamentId);
+                categoryTag.setCategoryTagId(categoryId);
+                tournamentCategoryTagMapper.insertTournamentCategoryTag(categoryTag);
+            }
         }
 
-        // 如果 tagId 有值,则插入一条记录
-        if (tagId != null) {
-            TournamentCategoryTag tag = new TournamentCategoryTag();
-            tag.setTournamentId(tournamentId);
-            tag.setCategoryTagId(tagId);
-            tournamentCategoryTagMapper.insertTournamentCategoryTag(tag);
+        // 如果 tagIds 有值,则为每个 tagId 插入一条记录
+        if (CollectionUtils.isNotEmpty(tagIds)) {
+            for (Long tagId : tagIds) {
+                TournamentCategoryTag tag = new TournamentCategoryTag();
+                tag.setTournamentId(tournamentId);
+                tag.setCategoryTagId(tagId);
+                tournamentCategoryTagMapper.insertTournamentCategoryTag(tag);
+            }
         }
     }
 
 
 
+
     private void processPrizeDistributions(Long tournamentId, List<ItemsPrizeDto> itemsPrizeList) {
         // 排序(按排名正序)
         Collections.sort(itemsPrizeList, Comparator.comparing(ItemsPrizeDto::getRanking));

+ 7 - 1
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentCategoryTagMapper.xml

@@ -41,4 +41,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select a.category_tag_id from tournament_category_tag  a left join  category_tag b  on a.category_tag_id=b.id  where b.type=#{type} and  a.tournament_id=#{tournamentId}
     </select>
 
- </mapper>
+
+    <select id="selectNameCategoryOrTagId" resultType="String">
+        select b.name from tournament_category_tag  a left join  category_tag b  on a.category_tag_id=b.id  where b.type=#{type} and  a.tournament_id=#{tournamentId}
+    </select>
+
+
+</mapper>