Просмотр исходного кода

feat(business): 新增新闻分类功能

- 添加新闻分类相关的实体类、BO、VO
- 实现新闻分类的 CRUD 接口和控制器
- 编写新闻分类的 Mapper 接口和 XML 文件
- 开发新闻分类的服务实现类
fugui001 3 месяцев назад
Родитель
Сommit
d2654d3e23

+ 105 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/NewsCategoryController.java

@@ -0,0 +1,105 @@
+package org.dromara.business.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.dromara.business.domain.bo.NewsCategoryBo;
+import org.dromara.business.domain.vo.NewsCategoryVo;
+import org.dromara.business.service.INewsCategoryService;
+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.common.mybatis.core.page.TableDataInfo;
+
+/**
+ * 新闻分类
+ *
+ * @author Lion Li
+ * @date 2025-09-12
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/business/category")
+public class NewsCategoryController extends BaseController {
+
+    private final INewsCategoryService newsCategoryService;
+
+    /**
+     * 查询新闻分类列表
+     */
+    @SaCheckPermission("business:category:list")
+    @GetMapping("/list")
+    public TableDataInfo<NewsCategoryVo> list(NewsCategoryBo bo, PageQuery pageQuery) {
+        return newsCategoryService.queryPageList(bo, pageQuery);
+    }
+
+    /**
+     * 导出新闻分类列表
+     */
+    @SaCheckPermission("business:category:export")
+    @Log(title = "新闻分类", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(NewsCategoryBo bo, HttpServletResponse response) {
+        List<NewsCategoryVo> list = newsCategoryService.queryList(bo);
+        ExcelUtil.exportExcel(list, "新闻分类", NewsCategoryVo.class, response);
+    }
+
+    /**
+     * 获取新闻分类详细信息
+     *
+     * @param id 主键
+     */
+    @SaCheckPermission("business:category:query")
+    @GetMapping("/{id}")
+    public R<NewsCategoryVo> getInfo(@NotNull(message = "主键不能为空")
+                                     @PathVariable Long id) {
+        return R.ok(newsCategoryService.queryById(id));
+    }
+
+    /**
+     * 新增新闻分类
+     */
+    @SaCheckPermission("business:category:add")
+    @Log(title = "新闻分类", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping()
+    public R<Void> add(@Validated(AddGroup.class) @RequestBody NewsCategoryBo bo) {
+        return toAjax(newsCategoryService.insertByBo(bo));
+    }
+
+    /**
+     * 修改新闻分类
+     */
+    @SaCheckPermission("business:category:edit")
+    @Log(title = "新闻分类", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PutMapping()
+    public R<Void> edit(@Validated(EditGroup.class) @RequestBody NewsCategoryBo bo) {
+        return toAjax(newsCategoryService.updateByBo(bo));
+    }
+
+    /**
+     * 删除新闻分类
+     *
+     * @param ids 主键串
+     */
+    @SaCheckPermission("business:category:remove")
+    @Log(title = "新闻分类", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public R<Void> remove(@NotEmpty(message = "主键不能为空")
+                          @PathVariable Long[] ids) {
+        return toAjax(newsCategoryService.deleteWithValidByIds(List.of(ids), true));
+    }
+}

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/ScheduleConfigController.java

@@ -151,7 +151,7 @@ public class ScheduleConfigController extends BaseController {
         MDC.put("traceId", traceId); // 用于链路追踪
 
         log.info("【排期创建请求updateScheduleConfig】收到创建排期请求, traceId={}, 请求参数: {}", traceId, request);
-
+        //R<String> result = scheduleConfigService.updateScheduleConfig(request.getConfigId(),request);
         try {
             // 🌟 2. 提交异步任务
             CompletableFuture<R<String>> future = scheduleConfigAsyncService.updateScheduleConfigAsync(request.getConfigId(),request);

+ 62 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/NewsCategory.java

@@ -0,0 +1,62 @@
+package org.dromara.business.domain;
+
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serial;
+
+/**
+ * 新闻分类对象 news_category
+ *
+ * @author Lion Li
+ * @date 2025-09-12
+ */
+@Data
+@TableName("news_category")
+public class NewsCategory{
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @TableId(value = "id")
+    private Long id;
+
+    /**
+     * 分类名称,如"热点"
+     */
+    private String name;
+
+    /**
+     * 唯一编码,用于前端请求,如 hot/sports
+     */
+    private String code;
+
+    /**
+     * 排序权重,越大越靠前
+     */
+    private Long sort;
+
+    /**
+     * 是否显示:1=是,0=否
+     */
+    private Long isShow;
+
+    /**
+     *
+     */
+    private Date createdAt;
+
+    /**
+     *
+     */
+    private Date updatedAt;
+
+
+}

+ 64 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/bo/NewsCategoryBo.java

@@ -0,0 +1,64 @@
+package org.dromara.business.domain.bo;
+
+import org.dromara.business.domain.NewsCategory;
+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.*;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+/**
+ * 新闻分类业务对象 news_category
+ *
+ * @author Lion Li
+ * @date 2025-09-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = NewsCategory.class, reverseConvertGenerate = false)
+public class NewsCategoryBo extends BaseEntity {
+
+    /**
+     *
+     */
+    @NotNull(message = "不能为空", groups = { EditGroup.class })
+    private Long id;
+
+    /**
+     * 分类名称,如"热点"
+     */
+    @NotBlank(message = "分类名称,不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String name;
+
+    /**
+     * 唯一编码,用于前端请求,如 hot/sports
+     */
+    @NotBlank(message = "唯一编码,用于前端请求,如 hot/sports不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String code;
+
+    /**
+     * 排序权重,越大越靠前
+     */
+    private Long sort;
+
+    /**
+     * 是否显示:1=是,0=否
+     */
+    private Long isShow;
+
+    /**
+     *
+     */
+    private Date createdAt;
+
+    /**
+     *
+     */
+    private Date updatedAt;
+
+
+}

+ 68 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/vo/NewsCategoryVo.java

@@ -0,0 +1,68 @@
+package org.dromara.business.domain.vo;
+
+import java.util.Date;
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import lombok.Data;
+import java.io.Serial;
+import java.io.Serializable;
+
+
+
+/**
+ * 新闻分类视图对象 news_category
+ *
+ * @author Lion Li
+ * @date 2025-09-12
+ */
+@Data
+@ExcelIgnoreUnannotated
+public class NewsCategoryVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long id;
+
+    /**
+     * 分类名称,如"热点"
+     */
+    @ExcelProperty(value = "分类名称")
+    private String name;
+
+    /**
+     * 唯一编码,用于前端请求,如 hot/sports
+     */
+    @ExcelProperty(value = "唯一编码,用于前端请求,如 hot/sports")
+    private String code;
+
+    /**
+     * 排序权重,越大越靠前
+     */
+    @ExcelProperty(value = "排序权重,越大越靠前")
+    private Long sort;
+
+    /**
+     * 是否显示:1=是,0=否
+     */
+    @ExcelProperty(value = "是否显示:1=是,0=否")
+    private Long isShow;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Date createdAt;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Date updatedAt;
+
+
+}

+ 45 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/NewsCategoryMapper.java

@@ -0,0 +1,45 @@
+package org.dromara.business.mapper;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import org.dromara.business.domain.NewsCategory;
+import org.dromara.business.domain.vo.NewsCategoryVo;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 新闻分类Mapper接口
+ *
+ * @author Lion Li
+ * @date 2025-09-12
+ */
+@DS("mysql2")
+public interface NewsCategoryMapper extends BaseMapperPlus<NewsCategory, NewsCategoryVo> {
+
+
+    @InterceptorIgnore(tenantLine = "true")
+    Page<NewsCategoryVo> selectCategoryPage(@Param("page") Page<NewsCategory> page, @Param("ew") Wrapper<NewsCategory> wrapper);
+
+    @InterceptorIgnore(tenantLine = "true")
+    NewsCategoryVo selectCategoryById(Long id);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int updateCategoryById(NewsCategory update);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int insertCategory(NewsCategory insert);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int deleteCategoryById(@Param("ids") Collection<Long> ids);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<NewsCategoryVo> selectCategoryList(@Param("ew") Wrapper<NewsCategory> wrapper);
+
+
+
+}

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

@@ -40,6 +40,9 @@ public interface ScheduleConfigMapper extends BaseMapperPlus<ScheduleConfig, Sch
     @InterceptorIgnore(tenantLine = "true")
     ScheduleConfigVo selectScheduleConfigById(Long id);
 
+    @InterceptorIgnore(tenantLine = "true")
+    ScheduleConfigVo selectScheduleConfigById2(Long id);
+
     @InterceptorIgnore(tenantLine = "true")
     List<ScheduleConfigVo> selectAllScheduleConfigsList(@Param("ew") Wrapper<ScheduleConfig> wrapper);
 

+ 68 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/INewsCategoryService.java

@@ -0,0 +1,68 @@
+package org.dromara.business.service;
+
+import org.dromara.business.domain.bo.NewsCategoryBo;
+import org.dromara.business.domain.vo.NewsCategoryVo;
+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-09-12
+ */
+public interface INewsCategoryService {
+
+    /**
+     * 查询新闻分类
+     *
+     * @param id 主键
+     * @return 新闻分类
+     */
+    NewsCategoryVo queryById(Long id);
+
+    /**
+     * 分页查询新闻分类列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 新闻分类分页列表
+     */
+    TableDataInfo<NewsCategoryVo> queryPageList(NewsCategoryBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的新闻分类列表
+     *
+     * @param bo 查询条件
+     * @return 新闻分类列表
+     */
+    List<NewsCategoryVo> queryList(NewsCategoryBo bo);
+
+    /**
+     * 新增新闻分类
+     *
+     * @param bo 新闻分类
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(NewsCategoryBo bo);
+
+    /**
+     * 修改新闻分类
+     *
+     * @param bo 新闻分类
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(NewsCategoryBo bo);
+
+    /**
+     * 校验并批量删除新闻分类信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

+ 137 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/NewsCategoryServiceImpl.java

@@ -0,0 +1,137 @@
+package org.dromara.business.service.impl;
+
+import org.dromara.business.domain.NewsCategory;
+import org.dromara.business.domain.bo.NewsCategoryBo;
+import org.dromara.business.domain.vo.NewsCategoryVo;
+import org.dromara.business.mapper.NewsCategoryMapper;
+import org.dromara.business.service.INewsCategoryService;
+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.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * 新闻分类Service业务层处理
+ *
+ * @author Lion Li
+ * @date 2025-09-12
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class NewsCategoryServiceImpl implements INewsCategoryService {
+
+    private final NewsCategoryMapper baseMapper;
+
+    /**
+     * 查询新闻分类
+     *
+     * @param id 主键
+     * @return 新闻分类
+     */
+    @Override
+    public NewsCategoryVo queryById(Long id){
+        return baseMapper.selectCategoryById(id);
+    }
+
+    /**
+     * 分页查询新闻分类列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 新闻分类分页列表
+     */
+    @Override
+    public TableDataInfo<NewsCategoryVo> queryPageList(NewsCategoryBo bo, PageQuery pageQuery) {
+        LambdaQueryWrapper<NewsCategory> lqw = buildQueryWrapper(bo);
+        Page<NewsCategoryVo> result = baseMapper.selectCategoryPage(pageQuery.build(), lqw);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的新闻分类列表
+     *
+     * @param bo 查询条件
+     * @return 新闻分类列表
+     */
+    @Override
+    public List<NewsCategoryVo> queryList(NewsCategoryBo bo) {
+        LambdaQueryWrapper<NewsCategory> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectCategoryList(lqw);
+    }
+
+    private LambdaQueryWrapper<NewsCategory> buildQueryWrapper(NewsCategoryBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<NewsCategory> lqw = Wrappers.lambdaQuery();
+        lqw.orderByAsc(NewsCategory::getId);
+        lqw.like(StringUtils.isNotBlank(bo.getName()), NewsCategory::getName, bo.getName());
+        lqw.eq(StringUtils.isNotBlank(bo.getCode()), NewsCategory::getCode, bo.getCode());
+        lqw.eq(bo.getSort() != null, NewsCategory::getSort, bo.getSort());
+        lqw.eq(bo.getIsShow() != null, NewsCategory::getIsShow, bo.getIsShow());
+        lqw.eq(bo.getCreatedAt() != null, NewsCategory::getCreatedAt, bo.getCreatedAt());
+        lqw.eq(bo.getUpdatedAt() != null, NewsCategory::getUpdatedAt, bo.getUpdatedAt());
+        return lqw;
+    }
+
+    /**
+     * 新增新闻分类
+     *
+     * @param bo 新闻分类
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(NewsCategoryBo bo) {
+        NewsCategory add = MapstructUtils.convert(bo, NewsCategory.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insertCategory(add) > 0;
+        if (flag) {
+            bo.setId(add.getId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改新闻分类
+     *
+     * @param bo 新闻分类
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(NewsCategoryBo bo) {
+        NewsCategory update = MapstructUtils.convert(bo, NewsCategory.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateCategoryById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(NewsCategory entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 校验并批量删除新闻分类信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteCategoryById(ids) > 0;
+    }
+}

+ 4 - 4
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/ScheduleConfigServiceImpl.java

@@ -180,7 +180,7 @@ public class ScheduleConfigServiceImpl implements IScheduleConfigService {
         // 2. 计算开始和结束日期
         LocalDate startDate = calculateStartDate(dto.getCreationSchemeCode());
         LocalDate endDate = calculateEndDate(dto.getCreationSchemeCode(), startDate);
-
+        log.info("----------endDate-----------"+endDate);
         // 3. 保存主配置
         ScheduleConfig config = new ScheduleConfig();
         config.setTemplateId(dto.getTemplateId());
@@ -241,7 +241,7 @@ public class ScheduleConfigServiceImpl implements IScheduleConfigService {
         LocalDate endDate,
         List<String> repeatTypes,
         List<LocalTime> execTimes) {
-
+        log.info("Starting schedule generation: configId={}, start={}, end={}", configId, startDate, endDate);
         switch (schemeCode.toUpperCase()) {
             case "DAILY":
                 // 初始化为特定日期
@@ -478,7 +478,7 @@ public class ScheduleConfigServiceImpl implements IScheduleConfigService {
             return R.fail("该配置已经分配过赛事!");
         }*/
         // 1. 检查配置是否存在
-        ScheduleConfigVo existingConfig = baseMapper.selectScheduleConfigById(configId);
+        ScheduleConfigVo existingConfig = baseMapper.selectScheduleConfigById2(configId);
         if (existingConfig == null) {
             log.info("Schedule config not found for id: {}", configId);
             return R.fail("该配置不存在!");
@@ -542,7 +542,7 @@ public class ScheduleConfigServiceImpl implements IScheduleConfigService {
     public R<String> deleteScheduleConfig(Long configId) {
 
         // 1. 检查配置是否存在
-        ScheduleConfigVo existingConfig = baseMapper.selectScheduleConfigById(configId);
+        ScheduleConfigVo existingConfig = baseMapper.selectScheduleConfigById2(configId);
 
     /*    int selectByScheduleRelationExit = scheduleTournamentsReletionMapper.selectByScheduleRelationExit(existingConfig.getTemplateId());
         if(selectByScheduleRelationExit>0){

+ 5 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/job/business/ScheduleTask.java

@@ -63,7 +63,7 @@ public class ScheduleTask {
     /**
      * 每天  00:10 执行
      */
-    @Scheduled(cron = "0 10 00 * * ?")
+    @Scheduled(cron = "0 05 00 * * ?")
     public void generateMatchesForToday() {
         LocalDate today = LocalDate.now();
         log.info("开始生成今日比赛: {}", today);
@@ -218,6 +218,10 @@ public class ScheduleTask {
     public Boolean autowiredTournamentData(Long execId,Long templateId,LocalDateTime triggerTime,Long configId) {
         try {
                 TournamentsVo tournamentsVo = tournamentsTemplateMapper.selectVoByIdInfoTemplate(templateId);
+                if(tournamentsVo==null){
+                    log.error("创建比赛失败,模版数据为空:templateId={}",templateId);
+                    return false;
+                }
                 // 模拟构造 TournamentsDto 数据
                 TournamentsDto bo = new TournamentsDto();
                 // 定义你想要的日期时间格式

+ 97 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/NewsCategoryMapper.xml

@@ -0,0 +1,97 @@
+<?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.business.mapper.NewsCategoryMapper">
+
+    <select id="selectCategoryPage" resultType="org.dromara.business.domain.vo.NewsCategoryVo">
+        SELECT
+            `id`,
+            `name`,
+            `code`,
+            `sort`,
+            `is_show`,
+            `created_at`,
+            `updated_at`
+        FROM news_category  ${ew.customSqlSegment}
+    </select>
+
+
+    <select id="selectCategoryList" resultType="org.dromara.business.domain.vo.NewsCategoryVo">
+        SELECT
+            `id`,
+            `name`,
+            `code`,
+            `sort`,
+            `is_show`,
+            `created_at`,
+            `updated_at`
+        FROM news_category  ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectCategoryById" resultType="org.dromara.business.domain.vo.NewsCategoryVo">
+        SELECT
+            `id`,
+            `name`,
+            `code`,
+            `sort`,
+            `is_show`,
+            `created_at`,
+            `updated_at`
+        FROM news_category WHERE id =  #{id}
+    </select>
+
+    <update id="updateCategoryById">
+        UPDATE news_category
+        <set>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="code != null and code != ''">
+                code = #{code},
+            </if>
+            <if test="sort != null and sort != ''">
+                sort = #{sort},
+            </if>
+            <if test="isShow != null and isShow != ''">
+                is_show = #{isShow},
+            </if>
+            updated_at = NOW()
+        </set>
+        WHERE id = #{id}
+    </update>
+
+
+    <insert id="insertCategory" useGeneratedKeys="true" keyProperty="id">
+        INSERT INTO news_category
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="name != null and name != ''">name,</if>
+            <if test="code != null and code != ''">code,</if>
+            <if test="sort != null and sort != ''">sort,</if>
+            <if test="isShow != null and isShow != ''">is_show,</if>
+            created_at
+        </trim>
+        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
+            <if test="name != null and name != ''">#{name},</if>
+            <if test="code != null and code != ''">#{code},</if>
+            <if test="sort != null and sort != ''">#{sort},</if>
+            <if test="isShow != null and isShow != ''">#{isShow},</if>
+            NOW()
+        </trim>
+    </insert>
+
+
+    <delete id="deleteCategoryById">
+        DELETE FROM news_category
+        <where>
+            id IN
+            <foreach item="id" collection="ids" open="(" separator="," close=")">
+                <if test="id > 0">
+                    #{id}
+                </if>
+            </foreach>
+        </where>
+    </delete>
+
+
+</mapper>

+ 6 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/ScheduleConfigMapper.xml

@@ -17,6 +17,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE a.id =  #{id}  and a.enabled=TRUE
    </select>
 
+    <!-- 根据 id 查询单条记录 -->
+    <select id="selectScheduleConfigById2" parameterType="long" resultType="org.dromara.business.domain.vo.ScheduleConfigVo">
+        SELECT a.id, a.template_id,a.creation_scheme_id, a.start_date, a.end_date, a.enabled, a.created_at, a.updated_at
+        FROM schedule_config  a left join tournaments_template b  on a.template_id=b.id
+        WHERE a.id =  #{id}
+    </select>
 
     <!-- 查询所有字段 -->
     <select id="selectAllScheduleConfigsList" resultType="org.dromara.business.domain.vo.ScheduleConfigVo">