视频教程模块

This commit is contained in:
SjS 2025-04-29 10:46:11 +08:00
parent c7b9a3da9f
commit 0d2835beca
10 changed files with 735 additions and 0 deletions

View File

@ -0,0 +1,49 @@
package com.ruoyi.bst.help.domain;
import com.ruoyi.common.core.validate.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import javax.validation.constraints.NotBlank;
/**
* 教程列表对象 bst_help
*
* @author ruoyi
* @date 2025-04-29
*/
@Data
public class Help extends BaseEntity
{
private static final long serialVersionUID = 1L;
private Long id;
@Excel(name = "标题")
@ApiModelProperty("标题")
@NotBlank(message = "标题不能为空", groups = {ValidGroup.Create.class})
private String title;
@Excel(name = "状态", readConverterExp = "1=启用,2=禁用")
@ApiModelProperty("状态")
@NotBlank(message = "状态不能为空", groups = {ValidGroup.Create.class})
private String status;
@Excel(name = "视频url")
@ApiModelProperty("视频url")
@NotBlank(message = "视频url不能为空", groups = {ValidGroup.Create.class})
private String videoUrl;
@Excel(name = "封面url")
@ApiModelProperty("封面url")
private String coverUrl;
@Excel(name = "编码")
@ApiModelProperty("编码")
private String code;
}

View File

@ -0,0 +1,12 @@
package com.ruoyi.bst.help.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class HelpQuery extends HelpVO{
@ApiModelProperty("精准教程编码")
private String eqCode;
}

View File

@ -0,0 +1,7 @@
package com.ruoyi.bst.help.domain;
import lombok.Data;
@Data
public class HelpVO extends Help{
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.bst.help.domain.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum HelpStatus {
ENABLED("1", "启用"),
DISABLED("2", "禁用");
private final String code;
private final String name;
}

View File

@ -0,0 +1,74 @@
package com.ruoyi.bst.help.mapper;
import java.util.List;
import com.ruoyi.bst.help.domain.Help;
import com.ruoyi.bst.help.domain.HelpVO;
import com.ruoyi.bst.help.domain.HelpQuery;
import org.apache.ibatis.annotations.Param;
/**
* 教程列表Mapper接口
*
* @author ruoyi
* @date 2025-04-29
*/
public interface HelpMapper
{
/**
* 查询教程列表
*
* @param id 教程列表主键
* @return 教程列表
*/
HelpVO selectHelpById(Long id);
/**
* 查询教程列表列表
*
* @param query 教程列表
* @return 教程列表集合
*/
List<HelpVO> selectHelpList(@Param("query")HelpQuery query);
/**
* 新增教程列表
*
* @param help 教程列表
* @return 结果
*/
int insertHelp(Help help);
/**
* 批量新增教程列表
*/
int batchInsert(@Param("list") List<? extends Help> list);
/**
* 批量修改教程列表
*/
int batchUpdate(@Param("list") List<? extends Help> list);
/**
* 修改教程列表
*
* @param help 教程列表
* @return 结果
*/
public int updateHelp(@Param("data") Help help);
/**
* 删除教程列表
*
* @param id 教程列表主键
* @return 结果
*/
int deleteHelpById(Long id);
/**
* 批量删除教程列表
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteHelpByIds(Long[] ids);
}

View File

@ -0,0 +1,234 @@
<?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="com.ruoyi.bst.help.mapper.HelpMapper">
<resultMap type="HelpVO" id="HelpResult" autoMapping="true">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="status" column="status" />
<result property="videoUrl" column="video_url" />
<result property="coverUrl" column="cover_url" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="code" column="code" />
</resultMap>
<sql id="selectHelpVo">
select
bh.id,
bh.title,
bh.status,
bh.video_url,
bh.cover_url,
bh.create_time,
bh.update_time,
bh.remark,
bh.code
from bst_help bh
</sql>
<sql id="searchCondition">
<if test="query.id != null "> and bh.id = #{query.id}</if>
<if test="query.title != null and query.title != ''"> and bh.title like concat('%', #{query.title}, '%')</if>
<if test="query.status != null and query.status != ''"> and bh.status = #{query.status}</if>
<if test="query.videoUrl != null and query.videoUrl != ''"> and bh.video_url = #{query.videoUrl}</if>
<if test="query.coverUrl != null and query.coverUrl != ''"> and bh.cover_url = #{query.coverUrl}</if>
<if test="query.code != null and query.code != ''">and bh.code like concat('%', #{query.code}, '%')</if>
<if test="query.eqCode != null and query.eqCode != ''"> and bh.code = #{query.eqCode}</if>
${query.params.dataScope}
</sql>
<select id="selectHelpList" parameterType="HelpQuery" resultMap="HelpResult">
<include refid="selectHelpVo"/>
<where>
<include refid="searchCondition"/>
</where>
</select>
<select id="selectHelpById" parameterType="Long" resultMap="HelpResult">
<include refid="selectHelpVo"/>
where id = #{id}
</select>
<insert id="insertHelp" parameterType="Help" useGeneratedKeys="true" keyProperty="id">
insert into bst_help
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">title,</if>
<if test="status != null and status != ''">status,</if>
<if test="videoUrl != null and videoUrl != ''">video_url,</if>
<if test="coverUrl != null">cover_url,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="code != null">code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="videoUrl != null and videoUrl != ''">#{videoUrl},</if>
<if test="coverUrl != null">#{coverUrl},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="code != null">#{code},</if>
</trim>
</insert>
<insert id="batchInsert" parameterType="Help" useGeneratedKeys="true" keyProperty="id">
insert into bst_help
<trim prefix="(" suffix=")" suffixOverrides=",">
title,
status,
video_url,
cover_url,
create_time,
update_time,
remark,
code,
</trim>
values
<foreach collection="list" item="i" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="i.title != null and i.title != ''">#{i.title},</if>
<if test="i.title == null or i.title == ''">default,</if>
<if test="i.status != null and i.status != ''">#{i.status},</if>
<if test="i.status == null or i.status == ''">default,</if>
<if test="i.videoUrl != null and i.videoUrl != ''">#{i.videoUrl},</if>
<if test="i.videoUrl == null or i.videoUrl == ''">default,</if>
<if test="i.coverUrl != null ">#{i.coverUrl},</if>
<if test="i.coverUrl == null ">default,</if>
<if test="i.createTime != null ">#{i.createTime},</if>
<if test="i.createTime == null ">default,</if>
<if test="i.updateTime != null ">#{i.updateTime},</if>
<if test="i.updateTime == null ">default,</if>
<if test="i.remark != null ">#{i.remark},</if>
<if test="i.remark == null ">default,</if>
<if test="i.code != null ">#{i.code},</if>
<if test="i.code == null ">default,</if>
</trim>
</foreach>
</insert>
<update id="batchUpdate">
update bst_help
<trim prefix="SET" suffixOverrides=",">
<foreach open="title = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.title != null and item.title != ''">
WHEN #{item.id} THEN #{item.title}
</when>
<otherwise>
WHEN #{item.id} THEN `title`
</otherwise>
</choose>
</foreach>
<foreach open="status = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.status != null and item.status != ''">
WHEN #{item.id} THEN #{item.status}
</when>
<otherwise>
WHEN #{item.id} THEN `status`
</otherwise>
</choose>
</foreach>
<foreach open="video_url = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.videoUrl != null and item.videoUrl != ''">
WHEN #{item.id} THEN #{item.videoUrl}
</when>
<otherwise>
WHEN #{item.id} THEN `video_url`
</otherwise>
</choose>
</foreach>
<foreach open="cover_url = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.coverUrl != null ">
WHEN #{item.id} THEN #{item.coverUrl}
</when>
<otherwise>
WHEN #{item.id} THEN `cover_url`
</otherwise>
</choose>
</foreach>
<foreach open="create_time = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.createTime != null ">
WHEN #{item.id} THEN #{item.createTime}
</when>
<otherwise>
WHEN #{item.id} THEN `create_time`
</otherwise>
</choose>
</foreach>
<foreach open="update_time = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.updateTime != null ">
WHEN #{item.id} THEN #{item.updateTime}
</when>
<otherwise>
WHEN #{item.id} THEN `update_time`
</otherwise>
</choose>
</foreach>
<foreach open="remark = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.remark != null ">
WHEN #{item.id} THEN #{item.remark}
</when>
<otherwise>
WHEN #{item.id} THEN `remark`
</otherwise>
</choose>
</foreach>
<foreach open="code = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.code != null ">
WHEN #{item.id} THEN #{item.code}
</when>
<otherwise>
WHEN #{item.id} THEN `code`
</otherwise>
</choose>
</foreach>
</trim>
where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>
<update id="updateHelp" parameterType="Help">
update bst_help
<trim prefix="SET" suffixOverrides=",">
<include refid="updateColumns"/>
</trim>
where id = #{data.id}
</update>
<sql id="updateColumns">
<if test="data.title != null and data.title != ''">title = #{data.title},</if>
<if test="data.status != null and data.status != ''">status = #{data.status},</if>
<if test="data.videoUrl != null and data.videoUrl != ''">video_url = #{data.videoUrl},</if>
<if test="data.coverUrl != null">cover_url = #{data.coverUrl},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.updateTime != null">update_time = #{data.updateTime},</if>
<if test="data.remark != null">remark = #{data.remark},</if>
<if test="data.code != null">code = #{data.code},</if>
</sql>
<delete id="deleteHelpById" parameterType="Long">
delete from bst_help where id = #{id}
</delete>
<delete id="deleteHelpByIds" parameterType="String">
delete from bst_help where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,71 @@
package com.ruoyi.bst.help.service;
import java.util.List;
import com.ruoyi.bst.help.domain.Help;
import com.ruoyi.bst.help.domain.HelpVO;
import com.ruoyi.bst.help.domain.HelpQuery;
/**
* 教程列表Service接口
*
* @author ruoyi
* @date 2025-04-29
*/
public interface HelpService
{
/**
* 查询教程列表
*
* @param id 教程列表主键
* @return 教程列表
*/
public HelpVO selectHelpById(Long id);
/**
* 查询教程列表列表
*
* @param help 教程列表
* @return 教程列表集合
*/
public List<HelpVO> selectHelpList(HelpQuery help);
/**
* 新增教程列表
*
* @param help 教程列表
* @return 结果
*/
public int insertHelp(Help help);
/**
* 修改教程列表
*
* @param help 教程列表
* @return 结果
*/
public int updateHelp(Help help);
/**
* 批量删除教程列表
*
* @param ids 需要删除的教程列表主键集合
* @return 结果
*/
public int deleteHelpByIds(Long[] ids);
/**
* 删除教程列表信息
*
* @param id 教程列表主键
* @return 结果
*/
public int deleteHelpById(Long id);
/**
* 通过教程编码获取教程详情
*
* @param code 教程编码
* @return 教程详情
*/
public HelpVO selectByCode(String code);
}

View File

@ -0,0 +1,118 @@
package com.ruoyi.bst.help.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.help.mapper.HelpMapper;
import com.ruoyi.bst.help.domain.Help;
import com.ruoyi.bst.help.domain.HelpVO;
import com.ruoyi.bst.help.domain.HelpQuery;
import com.ruoyi.bst.help.service.HelpService;
/**
* 教程列表Service业务层处理
*
* @author ruoyi
* @date 2025-04-29
*/
@Service
public class HelpServiceImpl implements HelpService
{
@Autowired
private HelpMapper helpMapper;
/**
* 查询教程列表
*
* @param id 教程列表主键
* @return 教程列表
*/
@Override
public HelpVO selectHelpById(Long id)
{
return helpMapper.selectHelpById(id);
}
/**
* 查询教程列表列表
*
* @param help 教程列表
* @return 教程列表
*/
@Override
public List<HelpVO> selectHelpList(HelpQuery help)
{
return helpMapper.selectHelpList(help);
}
/**
* 新增教程列表
*
* @param help 教程列表
* @return 结果
*/
@Override
public int insertHelp(Help help)
{
help.setCreateTime(DateUtils.getNowDate());
return helpMapper.insertHelp(help);
}
/**
* 修改教程列表
*
* @param help 教程列表
* @return 结果
*/
@Override
public int updateHelp(Help help)
{
help.setUpdateTime(DateUtils.getNowDate());
return helpMapper.updateHelp(help);
}
/**
* 批量删除教程列表
*
* @param ids 需要删除的教程列表主键
* @return 结果
*/
@Override
public int deleteHelpByIds(Long[] ids)
{
return helpMapper.deleteHelpByIds(ids);
}
/**
* 删除教程列表信息
*
* @param id 教程列表主键
* @return 结果
*/
@Override
public int deleteHelpById(Long id)
{
return helpMapper.deleteHelpById(id);
}
@Override
public HelpVO selectByCode(String code) {
if (StringUtils.isBlank(code)) {
return null;
}
HelpQuery query = new HelpQuery();
query.setEqCode(code);
return this.selectOne(query);
}
private HelpVO selectOne(HelpQuery query) {
List<HelpVO> list = this.selectHelpList(query);
if (CollectionUtils.isEmpty(list)) {
return null;
}
return list.get(0);
}
}

View File

@ -0,0 +1,52 @@
package com.ruoyi.web.controller.app;
import java.util.List;
import com.ruoyi.bst.help.service.HelpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.bst.help.domain.HelpQuery;
import com.ruoyi.bst.help.domain.HelpVO;
import com.ruoyi.bst.help.domain.enums.HelpStatus;
import com.ruoyi.bst.help.service.HelpService;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/app/help")
public class AppHelpController extends BaseController {
@Autowired
private HelpService helpService;
@ApiOperation("获取教程列表")
@GetMapping("list")
@Anonymous
public TableDataInfo list(HelpQuery query) {
startPage();
query.setStatus(HelpStatus.ENABLED.getCode());
List<HelpVO> list = helpService.selectHelpList(query);
return getDataTable(list);
}
@ApiOperation("获取教程详情")
@GetMapping("/detail")
@Anonymous
public AjaxResult detail(@RequestParam(required = false) String code, @RequestParam(required = false) Long id) {
if (StringUtils.hasText(code)) {
return success(helpService.selectByCode(code));
} else if (id != null) {
return success(helpService.selectHelpById(id));
}
return success(null);
}
}

View File

@ -0,0 +1,103 @@
package com.ruoyi.web.bst;
import com.ruoyi.bst.help.domain.Help;
import com.ruoyi.bst.help.domain.HelpQuery;
import com.ruoyi.bst.help.domain.HelpVO;
import com.ruoyi.bst.help.service.HelpService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.ValidGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 教程列表Controller
*
* @author ruoyi
* @date 2025-04-29
*/
@RestController
@RequestMapping("/bst/help")
public class HelpController extends BaseController
{
@Autowired
private HelpService helpService;
/**
* 查询教程列表列表
*/
@PreAuthorize("@ss.hasPermi('bst:help:list')")
@GetMapping("/list")
public TableDataInfo list(HelpQuery query)
{
startPage();
startOrderBy();
List<HelpVO> list = helpService.selectHelpList(query);
return getDataTable(list);
}
/**
* 导出教程列表列表
*/
@PreAuthorize("@ss.hasPermi('bst:help:export')")
@Log(title = "教程列表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HelpQuery query)
{
List<HelpVO> list = helpService.selectHelpList(query);
ExcelUtil<HelpVO> util = new ExcelUtil<HelpVO>(HelpVO.class);
util.exportExcel(response, list, "教程列表数据");
}
/**
* 获取教程列表详细信息
*/
@PreAuthorize("@ss.hasPermi('bst:help:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(helpService.selectHelpById(id));
}
/**
* 新增教程列表
*/
@PreAuthorize("@ss.hasPermi('bst:help:add')")
@Log(title = "教程列表", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Help help)
{
return toAjax(helpService.insertHelp(help));
}
/**
* 修改教程列表
*/
@PreAuthorize("@ss.hasPermi('bst:help:edit')")
@Log(title = "教程列表", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody@Validated(ValidGroup.Update.class) Help help)
{
return toAjax(helpService.updateHelp(help));
}
/**
* 删除教程列表
*/
@PreAuthorize("@ss.hasPermi('bst:help:remove')")
@Log(title = "教程列表", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(helpService.deleteHelpByIds(ids));
}
}