mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
新增帮助文档管理
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package com.gitee.sop.website.dao.entity;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Column;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Table(name = "help_doc", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class HelpDoc {
|
||||
/**
|
||||
* 主键ID,唯一标识每条帮助文档记录
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文档名称,显示用的标题或标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 排序字段,用于控制文档在列表中的显示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
@Column(logicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 状态字段,表示文档是否启用
|
||||
* 1:启用,2:禁用
|
||||
*/
|
||||
private Byte status;
|
||||
|
||||
/**
|
||||
* 内容字段,存储文档的具体内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 内容类型,区分内容的格式
|
||||
* 1:Markdown,2:富文本
|
||||
*/
|
||||
private Byte contentType;
|
||||
|
||||
/**
|
||||
* 父级ID,用于构建文档的层级结构
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 添加时间,记录文档首次创建的时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 更新时间,记录文档最后一次修改的时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID,记录创建该文档的用户ID
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人ID,记录最后一次修改该文档的用户ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.gitee.sop.website.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.website.dao.entity.HelpDoc;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface HelpDocMapper extends BaseMapper<HelpDoc> {
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.gitee.sop.website.service.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum StatusEnum {
|
||||
NONE(0),
|
||||
ENABLE(1),
|
||||
DISABLE(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
public static StatusEnum of(Number number) {
|
||||
if (number == null) {
|
||||
return NONE;
|
||||
}
|
||||
for (StatusEnum value : StatusEnum.values()) {
|
||||
if (value.value == number.intValue()) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.gitee.sop.website.service.help;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.website.common.util.CopyUtil;
|
||||
import com.gitee.sop.website.dao.entity.HelpDoc;
|
||||
import com.gitee.sop.website.dao.mapper.HelpDocMapper;
|
||||
import com.gitee.sop.website.service.common.StatusEnum;
|
||||
import com.gitee.sop.website.service.help.dto.HelpDocDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class HelpDocService implements LambdaService<HelpDoc, HelpDocMapper> {
|
||||
|
||||
public List<HelpDocDTO> listTree() {
|
||||
|
||||
return this.query()
|
||||
.select(HelpDoc::getId, HelpDoc::getLabel, HelpDoc::getParentId,
|
||||
HelpDoc::getAddTime,
|
||||
HelpDoc::getUpdateTime)
|
||||
.eq(HelpDoc::getStatus, StatusEnum.ENABLE.getValue())
|
||||
.orderByAsc(HelpDoc::getSort)
|
||||
.list(data -> CopyUtil.copyBean(data, HelpDocDTO::new));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.gitee.sop.website.service.help.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class HelpDocDTO {
|
||||
/**
|
||||
* 主键ID,唯一标识每条帮助文档记录
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文档名称,显示用的标题或标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 排序字段,用于控制文档在列表中的显示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态字段,表示文档是否启用
|
||||
* 1:启用,2:禁用
|
||||
*/
|
||||
private Byte status;
|
||||
|
||||
/**
|
||||
* 内容字段,存储文档的具体内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 内容类型,区分内容的格式
|
||||
* 1:Markdown,2:富文本
|
||||
*/
|
||||
private Byte contentType;
|
||||
|
||||
/**
|
||||
* 父级ID,用于构建文档的层级结构
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 添加时间,记录文档首次创建的时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 更新时间,记录文档最后一次修改的时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID,记录创建该文档的用户ID
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人ID,记录最后一次修改该文档的用户ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package com.gitee.sop.website.controller.website;
|
||||
|
||||
import com.gitee.sop.website.common.resp.Result;
|
||||
import com.gitee.sop.website.common.util.CopyUtil;
|
||||
import com.gitee.sop.website.controller.website.vo.HelpDocVO;
|
||||
import com.gitee.sop.website.dao.entity.HelpDoc;
|
||||
import com.gitee.sop.website.service.common.StatusEnum;
|
||||
import com.gitee.sop.website.service.help.HelpDocService;
|
||||
import com.gitee.sop.website.service.help.dto.HelpDocDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("website/help/doc")
|
||||
public class WebsiteHelpController {
|
||||
|
||||
@Autowired
|
||||
private HelpDocService helpDocService;
|
||||
|
||||
/**
|
||||
* 查询帮助文档树状结构
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("tree")
|
||||
public Result<List<HelpDocVO>> listTree() {
|
||||
List<HelpDocDTO> list = helpDocService.listTree();
|
||||
List<HelpDocVO> retList = CopyUtil.copyList(list, HelpDocVO::new);
|
||||
return Result.ok(retList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询帮助文档
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public Result<HelpDocVO> doc(Long id) {
|
||||
HelpDoc helpDoc = helpDocService.getById(id);
|
||||
if (Objects.equals(helpDoc.getStatus(), StatusEnum.DISABLE.getValue())) {
|
||||
throw new RuntimeException("文档不存在");
|
||||
}
|
||||
HelpDocVO helpDocVO = CopyUtil.copyBean(helpDoc, HelpDocVO::new);
|
||||
return Result.ok(helpDocVO);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.gitee.sop.website.controller.website.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class HelpDocVO {
|
||||
/**
|
||||
* 主键ID,唯一标识每条帮助文档记录
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文档名称,显示用的标题或标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 排序字段,用于控制文档在列表中的显示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态字段,表示文档是否启用
|
||||
* 1:启用,2:禁用
|
||||
*/
|
||||
private Byte status;
|
||||
|
||||
/**
|
||||
* 内容字段,存储文档的具体内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 内容类型,区分内容的格式
|
||||
* 1:Markdown,2:富文本
|
||||
*/
|
||||
private Byte contentType;
|
||||
|
||||
/**
|
||||
* 父级ID,用于构建文档的层级结构
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 添加时间,记录文档首次创建的时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 更新时间,记录文档最后一次修改的时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID,记录创建该文档的用户ID
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人ID,记录最后一次修改该文档的用户ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
}
|
Reference in New Issue
Block a user