Răsfoiți Sursa

活动介绍

wenkai 3 săptămâni în urmă
părinte
comite
6c5065d995

+ 1 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -217,6 +217,7 @@ xss:
   # 排除链接(多个用逗号分隔)
   excludeUrls:
     - /system/notice
+    - /system/article
 
 # 全局线程池相关配置
 # 如使用JDK21请直接使用虚拟线程 不要开启此配置

+ 105 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/ArticleController.java

@@ -0,0 +1,105 @@
+package org.dromara.system.controller;
+
+import java.util.List;
+
+import lombok.RequiredArgsConstructor;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.constraints.*;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.dromara.common.idempotent.annotation.RepeatSubmit;
+import org.dromara.common.log.annotation.Log;
+import org.dromara.common.web.core.BaseController;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import org.dromara.common.log.enums.BusinessType;
+import org.dromara.common.excel.utils.ExcelUtil;
+import org.dromara.system.domain.vo.ArticleVo;
+import org.dromara.system.domain.bo.ArticleBo;
+import org.dromara.system.service.IArticleService;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+
+/**
+ * 文章(可用于活动预热)
+ *
+ * @author Lion Li
+ * @date 2025-08-08
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/system/article")
+public class ArticleController extends BaseController {
+
+    private final IArticleService articleService;
+
+    /**
+     * 查询文章(可用于活动预热)列表
+     */
+    @SaCheckPermission("system:article:list")
+    @GetMapping("/list")
+    public TableDataInfo<ArticleVo> list(ArticleBo bo, PageQuery pageQuery) {
+        return articleService.queryPageList(bo, pageQuery);
+    }
+
+    /**
+     * 导出文章(可用于活动预热)列表
+     */
+    @SaCheckPermission("system:article:export")
+    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(ArticleBo bo, HttpServletResponse response) {
+        List<ArticleVo> list = articleService.queryList(bo);
+        ExcelUtil.exportExcel(list, "文章(可用于活动预热)", ArticleVo.class, response);
+    }
+
+    /**
+     * 获取文章(可用于活动预热)详细信息
+     *
+     * @param id 主键
+     */
+    @SaCheckPermission("system:article:query")
+    @GetMapping("/{id}")
+    public R<ArticleVo> getInfo(@NotNull(message = "主键不能为空")
+                                     @PathVariable Long id) {
+        return R.ok(articleService.queryById(id));
+    }
+
+    /**
+     * 新增文章(可用于活动预热)
+     */
+    @SaCheckPermission("system:article:add")
+    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping()
+    public R<Void> add(@Validated(AddGroup.class) @RequestBody ArticleBo bo) {
+        return toAjax(articleService.insertByBo(bo));
+    }
+
+    /**
+     * 修改文章(可用于活动预热)
+     */
+    @SaCheckPermission("system:article:edit")
+    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PutMapping()
+    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ArticleBo bo) {
+        return toAjax(articleService.updateByBo(bo));
+    }
+
+    /**
+     * 删除文章(可用于活动预热)
+     *
+     * @param ids 主键串
+     */
+    @SaCheckPermission("system:article:remove")
+    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public R<Void> remove(@NotEmpty(message = "主键不能为空")
+                          @PathVariable Long[] ids) {
+        return toAjax(articleService.deleteWithValidByIds(List.of(ids), true));
+    }
+}

+ 10 - 1
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameEventController.java

@@ -1,6 +1,7 @@
 package org.dromara.system.controller;
 
 import java.util.List;
+import java.util.Map;
 
 import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
@@ -64,7 +65,7 @@ public class GameEventController extends BaseController {
     @SaCheckPermission("system:gameEvent:query")
     @GetMapping("/{eventId}")
     public R<GameEventVo> getInfo(@NotNull(message = "主键不能为空")
-                                     @PathVariable Long eventId) {
+                                  @PathVariable Long eventId) {
         return R.ok(gameEventService.queryById(eventId));
     }
 
@@ -102,4 +103,12 @@ public class GameEventController extends BaseController {
                           @PathVariable Long[] eventIds) {
         return toAjax(gameEventService.deleteWithValidByIds(List.of(eventIds), true));
     }
+
+    /**
+     * 查询赛事名称和id的map
+     */
+    @GetMapping("/map")
+    public R<Map<String, Long>> getEventIdNameMap() {
+        return R.ok(gameEventService.getEventIdNameMap());
+    }
 }

+ 62 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/Article.java

@@ -0,0 +1,62 @@
+package org.dromara.system.domain;
+
+import org.dromara.common.tenant.core.TenantEntity;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+/**
+ * 文章(可用于活动预热)对象 article
+ *
+ * @author Lion Li
+ * @date 2025-08-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("article")
+public class Article extends TenantEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 赛事id
+     */
+    private Long eventId;
+
+    /**
+     * 标题
+     */
+    private String title;
+
+    /**
+     * 内容
+     */
+    private String content;
+
+    /**
+     * 文章类型
+     */
+    private Long type;
+
+    /**
+     * 是否展示 0:展示 1:隐藏
+     */
+    private String status;
+
+    /**
+     * 是否删除 0:未删除 1:删除
+     */
+    @TableLogic
+    private String delFlag;
+
+
+}

+ 57 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/ArticleBo.java

@@ -0,0 +1,57 @@
+package org.dromara.system.domain.bo;
+
+import org.dromara.system.domain.Article;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import jakarta.validation.constraints.*;
+
+/**
+ * 文章业务对象 article
+ *
+ * @author Lion Li
+ * @date 2025-08-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = Article.class, reverseConvertGenerate = false)
+public class ArticleBo extends BaseEntity {
+
+    /**
+     *
+     */
+    private Long id;
+
+    /**
+     * 赛事id
+     */
+    private Long eventId;
+
+    private String eventName;
+
+    /**
+     * 标题
+     */
+    private String title;
+
+    /**
+     * 内容
+     */
+    private String content;
+
+    /**
+     * 文章类型
+     */
+    @NotNull(message = "文章类型不能为空", groups = { AddGroup.class, EditGroup.class })
+    private Long type;
+
+    /**
+     * 是否展示 0:展示 1:隐藏
+     */
+    private String status;
+
+
+}

+ 74 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/ArticleVo.java

@@ -0,0 +1,74 @@
+package org.dromara.system.domain.vo;
+
+import org.dromara.system.domain.Article;
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import org.dromara.common.excel.annotation.ExcelDictFormat;
+import org.dromara.common.excel.convert.ExcelDictConvert;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+
+
+/**
+ * 文章(可用于活动预热)视图对象 article
+ *
+ * @author Lion Li
+ * @date 2025-08-08
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = Article.class)
+public class ArticleVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long id;
+
+    /**
+     * 赛事id
+     */
+    @ExcelProperty(value = "赛事id")
+    private Long eventId;
+
+    /**
+     * 赛事标题
+     */
+    private String eventName;
+
+    /**
+     * 标题
+     */
+    @ExcelProperty(value = "标题")
+    private String title;
+
+    /**
+     * 内容
+     */
+    @ExcelProperty(value = "内容")
+    private String content;
+
+    /**
+     * 文章类型
+     */
+    @ExcelProperty(value = "文章类型", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "article_type")
+    private Long type;
+
+    /**
+     * 是否展示 0:展示 1:隐藏
+     */
+    @ExcelProperty(value = "是否展示 0:展示 1:隐藏")
+    private String status;
+
+
+}

+ 15 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/mapper/ArticleMapper.java

@@ -0,0 +1,15 @@
+package org.dromara.system.mapper;
+
+import org.dromara.system.domain.Article;
+import org.dromara.system.domain.vo.ArticleVo;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+
+/**
+ * 文章(可用于活动预热)Mapper接口
+ *
+ * @author Lion Li
+ * @date 2025-08-08
+ */
+public interface ArticleMapper extends BaseMapperPlus<Article, ArticleVo> {
+
+}

+ 68 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IArticleService.java

@@ -0,0 +1,68 @@
+package org.dromara.system.service;
+
+import org.dromara.system.domain.vo.ArticleVo;
+import org.dromara.system.domain.bo.ArticleBo;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 文章(可用于活动预热)Service接口
+ *
+ * @author Lion Li
+ * @date 2025-08-08
+ */
+public interface IArticleService {
+
+    /**
+     * 查询文章(可用于活动预热)
+     *
+     * @param id 主键
+     * @return 文章(可用于活动预热)
+     */
+    ArticleVo queryById(Long id);
+
+    /**
+     * 分页查询文章(可用于活动预热)列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 文章(可用于活动预热)分页列表
+     */
+    TableDataInfo<ArticleVo> queryPageList(ArticleBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的文章(可用于活动预热)列表
+     *
+     * @param bo 查询条件
+     * @return 文章(可用于活动预热)列表
+     */
+    List<ArticleVo> queryList(ArticleBo bo);
+
+    /**
+     * 新增文章(可用于活动预热)
+     *
+     * @param bo 文章(可用于活动预热)
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(ArticleBo bo);
+
+    /**
+     * 修改文章(可用于活动预热)
+     *
+     * @param bo 文章(可用于活动预热)
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(ArticleBo bo);
+
+    /**
+     * 校验并批量删除文章(可用于活动预热)信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

+ 9 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameEventService.java

@@ -1,5 +1,6 @@
 package org.dromara.system.service;
 
+import org.dromara.common.core.domain.R;
 import org.dromara.system.domain.vo.GameEventVo;
 import org.dromara.system.domain.bo.GameEventBo;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -7,6 +8,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 赛事基本信息Service接口
@@ -65,4 +67,11 @@ public interface IGameEventService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 获取赛事ID与名称的映射关系
+     *
+     * @return 赛事ID与名称的映射关系
+     */
+    Map<String, Long> getEventIdNameMap();
 }

+ 174 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/ArticleServiceImpl.java

@@ -0,0 +1,174 @@
+package org.dromara.system.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.system.domain.GameEvent;
+import org.dromara.system.domain.bo.GameEventBo;
+import org.dromara.system.domain.vo.GameEventVo;
+import org.dromara.system.service.IGameEventService;
+import org.springframework.stereotype.Service;
+import org.dromara.system.domain.bo.ArticleBo;
+import org.dromara.system.domain.vo.ArticleVo;
+import org.dromara.system.domain.Article;
+import org.dromara.system.mapper.ArticleMapper;
+import org.dromara.system.service.IArticleService;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+/**
+ * 文章(可用于活动预热)Service业务层处理
+ *
+ * @author Lion Li
+ * @date 2025-08-08
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class ArticleServiceImpl implements IArticleService {
+
+    private final ArticleMapper baseMapper;
+
+    private final IGameEventService gameEventService;
+
+    /**
+     * 查询文章(可用于活动预热)
+     *
+     * @param id 主键
+     * @return 文章(可用于活动预热)
+     */
+    @Override
+    public ArticleVo queryById(Long id) {
+        return baseMapper.selectVoById(id);
+    }
+
+    /**
+     * 分页查询文章(可用于活动预热)列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 文章(可用于活动预热)分页列表
+     */
+    @Override
+    public TableDataInfo<ArticleVo> queryPageList(ArticleBo bo, PageQuery pageQuery) {
+        LambdaQueryWrapper<Article> lqw = buildQueryWrapper(bo);
+        Page<ArticleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        // 查询赛事相关信息
+        result.getRecords().stream()
+            .filter(articleVo -> ObjectUtil.isNotNull(articleVo.getEventId()))
+            .map(vo -> {
+                GameEventVo gameEventVo = gameEventService.queryById(vo.getEventId());
+                if (ObjectUtil.isNotNull(gameEventVo)) {
+                    vo.setEventName(gameEventVo.getEventName());
+                }
+                return vo;
+            }).collect(Collectors.toList());
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的文章(可用于活动预热)列表
+     *
+     * @param bo 查询条件
+     * @return 文章(可用于活动预热)列表
+     */
+    @Override
+    public List<ArticleVo> queryList(ArticleBo bo) {
+        LambdaQueryWrapper<Article> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectVoList(lqw);
+    }
+
+    private LambdaQueryWrapper<Article> buildQueryWrapper(ArticleBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<Article> lqw = Wrappers.lambdaQuery();
+        lqw.orderByAsc(Article::getId);
+        lqw.eq(bo.getEventId() != null, Article::getEventId, bo.getEventId());
+
+        // 通过名称模糊查询
+        if (StringUtils.isNotBlank(bo.getEventName())) {
+            GameEventBo gameEventBo = new GameEventBo();
+            gameEventBo.setEventName(bo.getEventName());
+            List<GameEventVo> vos = gameEventService.queryList(gameEventBo);
+            List<Long> ids = vos.stream()
+                .map(GameEventVo::getEventId)
+                .collect(Collectors.toList());
+            if (CollectionUtils.isNotEmpty(ids)) {
+                lqw.in(Article::getEventId, ids);
+            } else {
+                lqw.apply("1=0");
+            }
+        }
+
+        lqw.eq(StringUtils.isNotBlank(bo.getTitle()), Article::getTitle, bo.getTitle());
+        lqw.eq(StringUtils.isNotBlank(bo.getContent()), Article::getContent, bo.getContent());
+        lqw.eq(bo.getType() != null, Article::getType, bo.getType());
+        lqw.eq(StringUtils.isNotBlank(bo.getStatus()), Article::getStatus, bo.getStatus());
+        return lqw;
+    }
+
+    /**
+     * 新增文章(可用于活动预热)
+     *
+     * @param bo 文章(可用于活动预热)
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(ArticleBo bo) {
+        Article add = MapstructUtils.convert(bo, Article.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insert(add) > 0;
+        if (flag) {
+            bo.setId(add.getId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改文章(可用于活动预热)
+     *
+     * @param bo 文章(可用于活动预热)
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(ArticleBo bo) {
+        Article update = MapstructUtils.convert(bo, Article.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(Article entity) {
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 校验并批量删除文章(可用于活动预热)信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if (isValid) {
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteByIds(ids) > 0;
+    }
+
+}

+ 21 - 3
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventServiceImpl.java

@@ -1,5 +1,6 @@
 package org.dromara.system.service.impl;
 
+import org.dromara.common.core.domain.R;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -19,6 +20,7 @@ import org.dromara.system.service.IGameEventService;
 import java.util.List;
 import java.util.Map;
 import java.util.Collection;
+import java.util.stream.Collectors;
 
 /**
  * 赛事基本信息Service业务层处理
@@ -40,7 +42,7 @@ public class GameEventServiceImpl implements IGameEventService {
      * @return 赛事基本信息
      */
     @Override
-    public GameEventVo queryById(Long eventId){
+    public GameEventVo queryById(Long eventId) {
         return baseMapper.selectVoById(eventId);
     }
 
@@ -117,7 +119,7 @@ public class GameEventServiceImpl implements IGameEventService {
     /**
      * 保存前的数据校验
      */
-    private void validEntityBeforeSave(GameEvent entity){
+    private void validEntityBeforeSave(GameEvent entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
@@ -130,9 +132,25 @@ public class GameEventServiceImpl implements IGameEventService {
      */
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+
+    /**
+     * 获取赛事ID与名称的映射关系
+     *
+     * @return 赛事ID与名称的映射关系
+     */
+    @Override
+    public Map<String, Long> getEventIdNameMap() {
+        List<GameEvent> idNameList = this.baseMapper.selectList(
+            new LambdaQueryWrapper<GameEvent>()
+                .select(GameEvent::getEventId, GameEvent::getEventName)
+        );
+        Map<String, Long> idNameMap = idNameList.stream()
+            .collect(Collectors.toMap(GameEvent::getEventName, GameEvent::getEventId));
+        return idNameMap;
+    }
 }

+ 7 - 0
ruoyi-modules/ruoyi-game-event/src/main/resources/mapper/system/ArticleMapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.dromara.system.mapper.ArticleMapper">
+
+</mapper>