mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-11-15 07:20:40 +00:00
feat: add coding harness runtime and CMS module
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package org.ruoyi.system.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.domain.R;
|
||||
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.ruoyi.common.log.annotation.Log;
|
||||
import org.ruoyi.common.log.enums.BusinessType;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.web.core.BaseController;
|
||||
import org.ruoyi.system.domain.bo.CmsContentBo;
|
||||
import org.ruoyi.system.domain.vo.CmsContentVo;
|
||||
import org.ruoyi.system.service.ICmsContentService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 内容管理 信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cms/content")
|
||||
public class CmsContentController extends BaseController {
|
||||
|
||||
private final ICmsContentService cmsContentService;
|
||||
|
||||
/**
|
||||
* 获取内容管理列表
|
||||
*/
|
||||
@SaCheckPermission("cms:content:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<CmsContentVo> list(CmsContentBo bo, PageQuery pageQuery) {
|
||||
return cmsContentService.selectPageCmsContentList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据内容编号获取详细信息
|
||||
*/
|
||||
@SaCheckPermission("cms:content:query")
|
||||
@GetMapping(value = "/{contentId}")
|
||||
public R<CmsContentVo> getInfo(@PathVariable Long contentId) {
|
||||
return R.ok(cmsContentService.selectCmsContentById(contentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增内容
|
||||
*/
|
||||
@SaCheckPermission("cms:content:add")
|
||||
@Log(title = "内容管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody CmsContentBo bo) {
|
||||
return toAjax(cmsContentService.insertCmsContent(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改内容
|
||||
*/
|
||||
@SaCheckPermission("cms:content:edit")
|
||||
@Log(title = "内容管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody CmsContentBo bo) {
|
||||
return toAjax(cmsContentService.updateCmsContent(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除内容
|
||||
*/
|
||||
@SaCheckPermission("cms:content:remove")
|
||||
@Log(title = "内容管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{contentIds}")
|
||||
public R<Void> remove(@PathVariable Long[] contentIds) {
|
||||
return toAjax(cmsContentService.deleteCmsContentByIds(contentIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import org.ruoyi.common.tenant.core.TenantEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 内容管理表 cms_content
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("cms_content")
|
||||
public class CmsContent extends TenantEntity {
|
||||
|
||||
/**
|
||||
* 内容ID
|
||||
*/
|
||||
@TableId(value = "content_id")
|
||||
private Long contentId;
|
||||
|
||||
/**
|
||||
* 内容标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
private String summary;
|
||||
|
||||
/**
|
||||
* 正文内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 封面图片
|
||||
*/
|
||||
private String coverImage;
|
||||
|
||||
/**
|
||||
* 状态(0草稿 1已发布 2下架)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private Date publishTime;
|
||||
|
||||
/**
|
||||
* 排序顺序
|
||||
*/
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.ruoyi.system.domain.bo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.xss.Xss;
|
||||
import org.ruoyi.common.mybatis.core.domain.BaseEntity;
|
||||
import org.ruoyi.system.domain.CmsContent;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 内容管理业务对象 cms_content
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = CmsContent.class, reverseConvertGenerate = false)
|
||||
public class CmsContentBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 内容ID
|
||||
*/
|
||||
private Long contentId;
|
||||
|
||||
/**
|
||||
* 内容标题
|
||||
*/
|
||||
@Xss(message = "内容标题不能包含脚本字符")
|
||||
@NotBlank(message = "内容标题不能为空")
|
||||
@Size(min = 0, max = 200, message = "内容标题不能超过{max}个字符")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
@Size(min = 0, max = 500, message = "摘要不能超过{max}个字符")
|
||||
private String summary;
|
||||
|
||||
/**
|
||||
* 正文内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 封面图片
|
||||
*/
|
||||
@Size(min = 0, max = 255, message = "封面图片路径不能超过{max}个字符")
|
||||
private String coverImage;
|
||||
|
||||
/**
|
||||
* 状态(0草稿 1已发布 2下架)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private Date publishTime;
|
||||
|
||||
/**
|
||||
* 排序顺序
|
||||
*/
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Size(min = 0, max = 500, message = "备注不能超过{max}个字符")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人名称
|
||||
*/
|
||||
private String createByName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.ruoyi.system.domain.vo;
|
||||
|
||||
import org.ruoyi.common.translation.annotation.Translation;
|
||||
import org.ruoyi.common.translation.constant.TransConstant;
|
||||
import org.ruoyi.system.domain.CmsContent;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 内容管理视图对象 cms_content
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@AutoMapper(target = CmsContent.class)
|
||||
public class CmsContentVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 内容ID
|
||||
*/
|
||||
private Long contentId;
|
||||
|
||||
/**
|
||||
* 内容标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
private String summary;
|
||||
|
||||
/**
|
||||
* 正文内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 封面图片
|
||||
*/
|
||||
private String coverImage;
|
||||
|
||||
/**
|
||||
* 状态(0草稿 1已发布 2下架)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
private Date publishTime;
|
||||
|
||||
/**
|
||||
* 排序顺序
|
||||
*/
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建人名称
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "createBy")
|
||||
private String createByName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.ruoyi.system.mapper;
|
||||
|
||||
import org.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.ruoyi.system.domain.CmsContent;
|
||||
import org.ruoyi.system.domain.vo.CmsContentVo;
|
||||
|
||||
/**
|
||||
* 内容管理表 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface CmsContentMapper extends BaseMapperPlus<CmsContent, CmsContentVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.ruoyi.system.service;
|
||||
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.system.domain.bo.CmsContentBo;
|
||||
import org.ruoyi.system.domain.vo.CmsContentVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 内容管理 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ICmsContentService {
|
||||
|
||||
/**
|
||||
* 分页查询内容管理列表
|
||||
*/
|
||||
TableDataInfo<CmsContentVo> selectPageCmsContentList(CmsContentBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询内容信息
|
||||
*/
|
||||
CmsContentVo selectCmsContentById(Long contentId);
|
||||
|
||||
/**
|
||||
* 查询内容列表
|
||||
*/
|
||||
List<CmsContentVo> selectCmsContentList(CmsContentBo bo);
|
||||
|
||||
/**
|
||||
* 新增内容
|
||||
*/
|
||||
int insertCmsContent(CmsContentBo bo);
|
||||
|
||||
/**
|
||||
* 修改内容
|
||||
*/
|
||||
int updateCmsContent(CmsContentBo bo);
|
||||
|
||||
/**
|
||||
* 删除内容信息
|
||||
*/
|
||||
int deleteCmsContentById(Long contentId);
|
||||
|
||||
/**
|
||||
* 批量删除内容信息
|
||||
*/
|
||||
int deleteCmsContentByIds(Long[] contentIds);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.ruoyi.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.system.domain.CmsContent;
|
||||
import org.ruoyi.system.domain.bo.CmsContentBo;
|
||||
import org.ruoyi.system.domain.vo.CmsContentVo;
|
||||
import org.ruoyi.system.mapper.CmsContentMapper;
|
||||
import org.ruoyi.system.service.ICmsContentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 内容管理 服务层实现
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class CmsContentServiceImpl implements ICmsContentService {
|
||||
|
||||
private final CmsContentMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<CmsContentVo> selectPageCmsContentList(CmsContentBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<CmsContent> lqw = buildQueryWrapper(bo);
|
||||
Page<CmsContentVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CmsContentVo selectCmsContentById(Long contentId) {
|
||||
return baseMapper.selectVoById(contentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsContentVo> selectCmsContentList(CmsContentBo bo) {
|
||||
LambdaQueryWrapper<CmsContent> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<CmsContent> buildQueryWrapper(CmsContentBo bo) {
|
||||
LambdaQueryWrapper<CmsContent> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getTitle()), CmsContent::getTitle, bo.getTitle());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), CmsContent::getStatus, bo.getStatus());
|
||||
lqw.eq(bo.getPublishTime() != null, CmsContent::getPublishTime, bo.getPublishTime());
|
||||
lqw.orderByAsc(CmsContent::getSortOrder);
|
||||
lqw.orderByDesc(CmsContent::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertCmsContent(CmsContentBo bo) {
|
||||
CmsContent content = MapstructUtils.convert(bo, CmsContent.class);
|
||||
return baseMapper.insert(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCmsContent(CmsContentBo bo) {
|
||||
CmsContent content = MapstructUtils.convert(bo, CmsContent.class);
|
||||
return baseMapper.updateById(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteCmsContentById(Long contentId) {
|
||||
return baseMapper.deleteById(contentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteCmsContentByIds(Long[] contentIds) {
|
||||
return baseMapper.deleteByIds(Arrays.asList(contentIds));
|
||||
}
|
||||
}
|
||||
@@ -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.ruoyi.system.mapper.CmsContentMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user