refactor: 删除 docs 模块的全部代码
- 移除了 DocsContentController、DocsController、DocsUserController 三个控制器 - 删除了 DocsContent、Docs、DocsUser三个实体类 - 移除了 DocsContentMapper、DocsMapper、DocsUserMapper 三个 Mapper 接口 - 删除了 DocsContentParam、DocsParam、DocsUserParam 三个查询参数类 - 移除了 DocsContentServiceImpl 服务实现类- 删除了相关的 XML 映射文件
This commit is contained in:
@@ -1,129 +0,0 @@
|
||||
package com.gxwebsoft.docs.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.docs.service.DocsContentService;
|
||||
import com.gxwebsoft.docs.entity.DocsContent;
|
||||
import com.gxwebsoft.docs.param.DocsContentParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档内容记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Tag(name = "文档内容记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/docs/docs-content")
|
||||
public class DocsContentController extends BaseController {
|
||||
@Resource
|
||||
private DocsContentService docsContentService;
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:list')")
|
||||
@Operation(summary = "分页查询文档内容记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DocsContent>> page(DocsContentParam param) {
|
||||
// 使用关联查询
|
||||
return success(docsContentService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:list')")
|
||||
@Operation(summary = "查询全部文档内容记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DocsContent>> list(DocsContentParam param) {
|
||||
// 使用关联查询
|
||||
return success(docsContentService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:list')")
|
||||
@Operation(summary = "根据id查询文档内容记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DocsContent> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(docsContentService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加文档内容记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DocsContent docsContent) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
docsContent.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (docsContentService.save(docsContent)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改文档内容记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DocsContent docsContent) {
|
||||
if (docsContentService.updateById(docsContent)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除文档内容记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (docsContentService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加文档内容记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DocsContent> list) {
|
||||
if (docsContentService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改文档内容记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DocsContent> batchParam) {
|
||||
if (batchParam.update(docsContentService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsContent:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除文档内容记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (docsContentService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.gxwebsoft.docs.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.docs.service.DocsService;
|
||||
import com.gxwebsoft.docs.entity.Docs;
|
||||
import com.gxwebsoft.docs.param.DocsParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Tag(name = "知识库管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/docs/docs")
|
||||
public class DocsController extends BaseController {
|
||||
@Resource
|
||||
private DocsService docsService;
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:list')")
|
||||
@Operation(summary = "分页查询知识库")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Docs>> page(DocsParam param) {
|
||||
// 使用关联查询
|
||||
return success(docsService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:list')")
|
||||
@Operation(summary = "查询全部知识库")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Docs>> list(DocsParam param) {
|
||||
// 使用关联查询
|
||||
return success(docsService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:list')")
|
||||
@Operation(summary = "根据id查询知识库")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Docs> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(docsService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加知识库")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Docs docs) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
docs.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (docsService.save(docs)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改知识库")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Docs docs) {
|
||||
if (docsService.updateById(docs)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除知识库")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (docsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加知识库")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Docs> list) {
|
||||
if (docsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改知识库")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Docs> batchParam) {
|
||||
if (batchParam.update(docsService, "book_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docs:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除知识库")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (docsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.gxwebsoft.docs.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.docs.service.DocsUserService;
|
||||
import com.gxwebsoft.docs.entity.DocsUser;
|
||||
import com.gxwebsoft.docs.param.DocsUserParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库成员控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Tag(name = "知识库成员管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/docs/docs-user")
|
||||
public class DocsUserController extends BaseController {
|
||||
@Resource
|
||||
private DocsUserService docsUserService;
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:list')")
|
||||
@Operation(summary = "分页查询知识库成员")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DocsUser>> page(DocsUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(docsUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:list')")
|
||||
@Operation(summary = "查询全部知识库成员")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DocsUser>> list(DocsUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(docsUserService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:list')")
|
||||
@Operation(summary = "根据id查询知识库成员")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DocsUser> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(docsUserService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加知识库成员")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DocsUser docsUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
docsUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (docsUserService.save(docsUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改知识库成员")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DocsUser docsUser) {
|
||||
if (docsUserService.updateById(docsUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除知识库成员")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (docsUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加知识库成员")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DocsUser> list) {
|
||||
if (docsUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改知识库成员")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DocsUser> batchParam) {
|
||||
if (batchParam.update(docsUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('docs:docsUser:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除知识库成员")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (docsUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.gxwebsoft.docs.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 知识库
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "Docs对象", description = "知识库")
|
||||
public class Docs implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
@TableId(value = "book_id", type = IdType.AUTO)
|
||||
private Integer bookId;
|
||||
|
||||
@Schema(description = "知识库名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "知识库标识")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "封面图")
|
||||
private String photo;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "用户昵称")
|
||||
@TableField(exist = false)
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户头像")
|
||||
@TableField(exist = false)
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "文档内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@Schema(description = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.gxwebsoft.docs.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 文档内容记录表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "DocsContent对象", description = "文档内容记录表")
|
||||
public class DocsContent implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "文档ID")
|
||||
private Integer docsId;
|
||||
|
||||
@Schema(description = "文档标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "文档内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.gxwebsoft.docs.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 知识库成员
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "DocsUser对象", description = "知识库成员")
|
||||
public class DocsUser implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "应用ID")
|
||||
private Integer docsId;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "头像")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "角色,10体验成员 20开发者成员 30管理员 ")
|
||||
private Integer role;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1待确认")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gxwebsoft.docs.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.docs.entity.DocsContent;
|
||||
import com.gxwebsoft.docs.param.DocsContentParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档内容记录表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
public interface DocsContentMapper extends BaseMapper<DocsContent> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<DocsContent>
|
||||
*/
|
||||
List<DocsContent> selectPageRel(@Param("page") IPage<DocsContent> page,
|
||||
@Param("param") DocsContentParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<DocsContent> selectListRel(@Param("param") DocsContentParam param);
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gxwebsoft.docs.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.docs.entity.Docs;
|
||||
import com.gxwebsoft.docs.param.DocsParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
public interface DocsMapper extends BaseMapper<Docs> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<Docs>
|
||||
*/
|
||||
List<Docs> selectPageRel(@Param("page") IPage<Docs> page,
|
||||
@Param("param") DocsParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<Docs> selectListRel(@Param("param") DocsParam param);
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gxwebsoft.docs.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.docs.entity.DocsUser;
|
||||
import com.gxwebsoft.docs.param.DocsUserParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库成员Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
public interface DocsUserMapper extends BaseMapper<DocsUser> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<DocsUser>
|
||||
*/
|
||||
List<DocsUser> selectPageRel(@Param("page") IPage<DocsUser> page,
|
||||
@Param("param") DocsUserParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<DocsUser> selectListRel(@Param("param") DocsUserParam param);
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?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.gxwebsoft.docs.mapper.DocsContentMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM docs_content a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.docsId != null">
|
||||
AND a.docs_id = #{param.docsId}
|
||||
</if>
|
||||
<if test="param.title != null">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.docs.entity.DocsContent">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.docs.entity.DocsContent">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,67 +0,0 @@
|
||||
<?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.gxwebsoft.docs.mapper.DocsMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, b.nickname, b.avatar
|
||||
FROM docs a
|
||||
LEFT JOIN gxwebsoft_core.sys_user b ON a.user_id = b.user_id
|
||||
<where>
|
||||
<if test="param.bookId != null">
|
||||
AND a.book_id = #{param.bookId}
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
<if test="param.code != null">
|
||||
AND a.code LIKE CONCAT('%', #{param.code}, '%')
|
||||
</if>
|
||||
<if test="param.photo != null">
|
||||
AND a.photo LIKE CONCAT('%', #{param.photo}, '%')
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.docs.entity.Docs">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.docs.entity.Docs">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,54 +0,0 @@
|
||||
<?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.gxwebsoft.docs.mapper.DocsUserMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM docs_user a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.docsId != null">
|
||||
AND a.docs_id = #{param.docsId}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.nickname != null">
|
||||
AND a.nickname LIKE CONCAT('%', #{param.nickname}, '%')
|
||||
</if>
|
||||
<if test="param.avatar != null">
|
||||
AND a.avatar LIKE CONCAT('%', #{param.avatar}, '%')
|
||||
</if>
|
||||
<if test="param.role != null">
|
||||
AND a.role = #{param.role}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.docs.entity.DocsUser">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.docs.entity.DocsUser">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.gxwebsoft.docs.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 文档内容记录表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "DocsContentParam对象", description = "文档内容记录表查询参数")
|
||||
public class DocsContentParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "文档ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer docsId;
|
||||
|
||||
@Schema(description = "文档标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "文档内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.gxwebsoft.docs.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 知识库查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "DocsParam对象", description = "知识库查询参数")
|
||||
public class DocsParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer bookId;
|
||||
|
||||
@Schema(description = "知识库名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "知识库标识")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "封面图")
|
||||
private String photo;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "文档内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.gxwebsoft.docs.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 知识库成员查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "DocsUserParam对象", description = "知识库成员查询参数")
|
||||
public class DocsUserParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "自增ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "应用ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer docsId;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "头像")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "角色,10体验成员 20开发者成员 30管理员 ")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer role;
|
||||
|
||||
@Schema(description = "状态, 0正常, 1待确认")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.gxwebsoft.docs.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.docs.entity.DocsContent;
|
||||
import com.gxwebsoft.docs.param.DocsContentParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档内容记录表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
public interface DocsContentService extends IService<DocsContent> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<DocsContent>
|
||||
*/
|
||||
PageResult<DocsContent> pageRel(DocsContentParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<DocsContent>
|
||||
*/
|
||||
List<DocsContent> listRel(DocsContentParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return DocsContent
|
||||
*/
|
||||
DocsContent getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.gxwebsoft.docs.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.docs.entity.Docs;
|
||||
import com.gxwebsoft.docs.param.DocsParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
public interface DocsService extends IService<Docs> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Docs>
|
||||
*/
|
||||
PageResult<Docs> pageRel(DocsParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Docs>
|
||||
*/
|
||||
List<Docs> listRel(DocsParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param bookId ID
|
||||
* @return Docs
|
||||
*/
|
||||
Docs getByIdRel(Integer bookId);
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.gxwebsoft.docs.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.docs.entity.DocsUser;
|
||||
import com.gxwebsoft.docs.param.DocsUserParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库成员Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
public interface DocsUserService extends IService<DocsUser> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<DocsUser>
|
||||
*/
|
||||
PageResult<DocsUser> pageRel(DocsUserParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<DocsUser>
|
||||
*/
|
||||
List<DocsUser> listRel(DocsUserParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 自增ID
|
||||
* @return DocsUser
|
||||
*/
|
||||
DocsUser getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.gxwebsoft.docs.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.docs.mapper.DocsContentMapper;
|
||||
import com.gxwebsoft.docs.service.DocsContentService;
|
||||
import com.gxwebsoft.docs.entity.DocsContent;
|
||||
import com.gxwebsoft.docs.param.DocsContentParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档内容记录表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Service
|
||||
public class DocsContentServiceImpl extends ServiceImpl<DocsContentMapper, DocsContent> implements DocsContentService {
|
||||
|
||||
@Override
|
||||
public PageResult<DocsContent> pageRel(DocsContentParam param) {
|
||||
PageParam<DocsContent, DocsContentParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<DocsContent> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DocsContent> listRel(DocsContentParam param) {
|
||||
List<DocsContent> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<DocsContent, DocsContentParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocsContent getByIdRel(Integer id) {
|
||||
DocsContentParam param = new DocsContentParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.gxwebsoft.docs.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.docs.mapper.DocsMapper;
|
||||
import com.gxwebsoft.docs.service.DocsService;
|
||||
import com.gxwebsoft.docs.entity.Docs;
|
||||
import com.gxwebsoft.docs.param.DocsParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Service
|
||||
public class DocsServiceImpl extends ServiceImpl<DocsMapper, Docs> implements DocsService {
|
||||
|
||||
@Override
|
||||
public PageResult<Docs> pageRel(DocsParam param) {
|
||||
PageParam<Docs, DocsParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<Docs> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Docs> listRel(DocsParam param) {
|
||||
List<Docs> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Docs, DocsParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Docs getByIdRel(Integer bookId) {
|
||||
DocsParam param = new DocsParam();
|
||||
param.setBookId(bookId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.gxwebsoft.docs.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.docs.mapper.DocsUserMapper;
|
||||
import com.gxwebsoft.docs.service.DocsUserService;
|
||||
import com.gxwebsoft.docs.entity.DocsUser;
|
||||
import com.gxwebsoft.docs.param.DocsUserParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库成员Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-03-26 09:29:15
|
||||
*/
|
||||
@Service
|
||||
public class DocsUserServiceImpl extends ServiceImpl<DocsUserMapper, DocsUser> implements DocsUserService {
|
||||
|
||||
@Override
|
||||
public PageResult<DocsUser> pageRel(DocsUserParam param) {
|
||||
PageParam<DocsUser, DocsUserParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<DocsUser> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DocsUser> listRel(DocsUserParam param) {
|
||||
List<DocsUser> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<DocsUser, DocsUserParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocsUser getByIdRel(Integer id) {
|
||||
DocsUserParam param = new DocsUserParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
* 商品文章控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 03:38:52
|
||||
* @since 2025-08-13 04:38:36
|
||||
*/
|
||||
@Tag(name = "商品文章管理")
|
||||
@RestController
|
||||
|
||||
@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
|
||||
* 商品文章
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 03:38:51
|
||||
* @since 2025-08-13 04:38:36
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ShopMerchant implements Serializable {
|
||||
|
||||
@Schema(description = "ID")
|
||||
@TableId(value = "merchant_id", type = IdType.AUTO)
|
||||
private Integer merchantId;
|
||||
private Long merchantId;
|
||||
|
||||
@Schema(description = "商户名称")
|
||||
private String merchantName;
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
* 商品文章Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 03:38:52
|
||||
* @since 2025-08-13 04:38:36
|
||||
*/
|
||||
public interface ShopArticleMapper extends BaseMapper<ShopArticle> {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
|
||||
* 商品文章查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 03:38:51
|
||||
* @since 2025-08-13 04:38:35
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
* 商品文章Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 03:38:52
|
||||
* @since 2025-08-13 04:38:36
|
||||
*/
|
||||
public interface ShopArticleService extends IService<ShopArticle> {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* 商品文章Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 03:38:52
|
||||
* @since 2025-08-13 04:38:36
|
||||
*/
|
||||
@Service
|
||||
public class ShopArticleServiceImpl extends ServiceImpl<ShopArticleMapper, ShopArticle> implements ShopArticleService {
|
||||
|
||||
195
src/test/java/com/gxwebsoft/generator/README-表格列优化.md
Normal file
195
src/test/java/com/gxwebsoft/generator/README-表格列优化.md
Normal file
@@ -0,0 +1,195 @@
|
||||
# 表格列生成规则优化方案
|
||||
|
||||
## 问题描述
|
||||
|
||||
原有的表格列生成规则会为所有字段(除了tenantId)生成列,导致:
|
||||
- 表格列过多,显示混乱
|
||||
- 重要信息被淹没在大量字段中
|
||||
- 用户体验差,需要横向滚动查看
|
||||
|
||||
## 优化方案
|
||||
|
||||
### 1. 使用 hideInTable 属性(推荐方案)
|
||||
|
||||
**核心思想**:生成所有字段的列配置,但使用 `hideInTable: true` 隐藏非核心字段
|
||||
|
||||
**优势**:
|
||||
- ✅ **保留完整信息**:所有字段都会生成,不丢失任何数据
|
||||
- ✅ **用户可自定义**:通过表格的列设置功能,用户可以勾选显示需要的字段
|
||||
- ✅ **默认简洁**:只显示最重要的核心字段,保持表格整洁
|
||||
- ✅ **灵活性强**:不同用户可以根据需要显示不同的列组合
|
||||
|
||||
**核心字段判断规则**:
|
||||
- 主键字段:始终显示
|
||||
- 名称/标题字段:始终显示
|
||||
- 编码字段:始终显示
|
||||
- 状态字段:始终显示
|
||||
- 排序字段:始终显示
|
||||
- 创建时间:始终显示
|
||||
- 其他字段:默认隐藏(`hideInTable: true`)
|
||||
|
||||
### 2. 排除字段
|
||||
|
||||
以下字段不会显示在表格中:
|
||||
- `tenantId` - 租户ID
|
||||
- `deleted` - 逻辑删除标记
|
||||
- `version` - 版本号
|
||||
- `remark` - 备注(内容通常较长)
|
||||
- `description` - 描述(内容通常较长)
|
||||
- `content` - 内容(内容通常较长)
|
||||
|
||||
### 3. 字段宽度优化
|
||||
|
||||
根据字段类型和内容特点设置合适的宽度:
|
||||
- ID字段:90px
|
||||
- 状态字段:80px
|
||||
- 时间字段:120px
|
||||
- 字符串字段:150px
|
||||
- 数值字段:120px
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 方法1:使用 hideInTable 模板(强烈推荐)
|
||||
|
||||
已经修改了 `index.vue.btl` 模板,现在会自动:
|
||||
1. **生成所有字段**:不丢失任何字段信息
|
||||
2. **智能隐藏**:非核心字段添加 `hideInTable: true`
|
||||
3. **用户可控**:用户可通过表格的列设置功能显示需要的字段
|
||||
|
||||
**生成的代码示例**:
|
||||
```javascript
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
width: 90,
|
||||
// 核心字段,默认显示
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 150,
|
||||
// 核心字段,默认显示
|
||||
},
|
||||
{
|
||||
title: '创建人',
|
||||
dataIndex: 'createBy',
|
||||
key: 'createBy',
|
||||
width: 120,
|
||||
hideInTable: true, // 非核心字段,默认隐藏
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
key: 'remark',
|
||||
width: 200,
|
||||
hideInTable: true, // 长文本字段,默认隐藏
|
||||
}
|
||||
]);
|
||||
```
|
||||
|
||||
### 方法2:前端列设置功能
|
||||
|
||||
参考 `table-with-column-settings.vue` 示例,可以添加列设置功能:
|
||||
|
||||
```javascript
|
||||
// 列可见性控制
|
||||
const allColumns = ref([
|
||||
{ title: 'ID', visible: true, required: true },
|
||||
{ title: '名称', visible: true, required: true },
|
||||
{ title: '创建人', visible: false, required: false },
|
||||
// ...
|
||||
]);
|
||||
|
||||
// 根据可见性过滤列
|
||||
const columns = computed(() => {
|
||||
return allColumns.value.filter(col => col.visible);
|
||||
});
|
||||
```
|
||||
|
||||
### 方法3:自定义核心字段规则
|
||||
|
||||
在模板中修改核心字段判断逻辑:
|
||||
|
||||
```javascript
|
||||
// 在模板中添加你的业务字段
|
||||
<% } else if(field.propertyName == 'yourBusinessField'){ %>
|
||||
// 设为核心字段,默认显示
|
||||
isCoreField = true;
|
||||
```
|
||||
|
||||
## 生成效果对比
|
||||
|
||||
### 优化前
|
||||
```
|
||||
| ID | 名称 | 编码 | 状态 | 排序 | 创建人 | 创建时间 | 更新人 | 更新时间 | 备注 | 描述 | ... | 操作 |
|
||||
```
|
||||
*显示所有字段,表格过宽,信息混乱*
|
||||
|
||||
### 优化后(使用 hideInTable)
|
||||
**默认显示**:
|
||||
```
|
||||
| ID | 名称 | 编码 | 状态 | 排序 | 创建时间 | 操作 |
|
||||
```
|
||||
*只显示核心字段,表格简洁*
|
||||
|
||||
**用户可通过列设置显示更多字段**:
|
||||
```
|
||||
| ID | 名称 | 编码 | 状态 | ✓创建人 | 创建时间 | ✓更新时间 | ✓备注 | 操作 |
|
||||
```
|
||||
*用户勾选后可显示需要的字段*
|
||||
|
||||
### 列设置界面示例
|
||||
```
|
||||
列设置
|
||||
☑ ID (固定显示)
|
||||
☑ 名称 (固定显示)
|
||||
☑ 编码 (固定显示)
|
||||
☑ 状态 (固定显示)
|
||||
☐ 创建人 (可选)
|
||||
☑ 创建时间 (固定显示)
|
||||
☐ 更新人 (可选)
|
||||
☐ 更新时间 (可选)
|
||||
☐ 备注 (可选)
|
||||
☐ 描述 (可选)
|
||||
```
|
||||
|
||||
## 配置说明
|
||||
|
||||
### 修改默认显示列数
|
||||
|
||||
在模板中修改:
|
||||
```javascript
|
||||
.slice(0, 6); // 改为你想要的列数
|
||||
```
|
||||
|
||||
### 添加新的优先字段
|
||||
|
||||
在模板的优先级判断中添加:
|
||||
```javascript
|
||||
<% } else if(field.propertyName == 'yourField'){ %>
|
||||
width: 120,
|
||||
priority: 8, // 设置优先级
|
||||
```
|
||||
|
||||
### 排除特定字段
|
||||
|
||||
在条件判断中添加:
|
||||
```javascript
|
||||
<% if(field.propertyName != 'tenantId' && field.propertyName != 'yourExcludedField'){ %>
|
||||
```
|
||||
|
||||
## 建议
|
||||
|
||||
1. **保持默认6列**:这是最佳的用户体验,既能显示关键信息,又不会过于拥挤
|
||||
2. **优先显示业务关键字段**:如名称、状态、创建时间等
|
||||
3. **提供列设置功能**:让用户可以自定义显示哪些列
|
||||
4. **响应式设计**:在移动端进一步减少显示列数
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 修改模板后需要重新生成代码才能生效
|
||||
- 建议在生成前备份原有模板文件
|
||||
- 可以根据具体业务需求调整优先级规则
|
||||
164
src/test/java/com/gxwebsoft/generator/hideInTable-方案总结.md
Normal file
164
src/test/java/com/gxwebsoft/generator/hideInTable-方案总结.md
Normal file
@@ -0,0 +1,164 @@
|
||||
# hideInTable 表格列优化方案总结
|
||||
|
||||
## 🎯 方案概述
|
||||
|
||||
使用 `hideInTable: true` 属性来控制表格列的默认显示,这是一个既保留完整功能又保持界面简洁的最佳方案。
|
||||
|
||||
## ✨ 核心优势
|
||||
|
||||
### 1. 🔄 **完整性 + 简洁性**
|
||||
- **生成所有字段**:不丢失任何数据库字段信息
|
||||
- **默认简洁**:只显示最重要的核心字段
|
||||
- **用户可控**:通过列设置功能显示需要的字段
|
||||
|
||||
### 2. 🎛️ **灵活的用户体验**
|
||||
- **开箱即用**:默认显示最常用的字段
|
||||
- **按需扩展**:用户可以勾选显示更多字段
|
||||
- **个性化**:不同用户可以有不同的列显示偏好
|
||||
|
||||
### 3. 🚀 **技术优势**
|
||||
- **标准化**:使用 Ant Design 标准的 `hideInTable` 属性
|
||||
- **兼容性好**:与现有表格组件完美兼容
|
||||
- **维护简单**:不需要复杂的逻辑,只需要简单的布尔值控制
|
||||
|
||||
## 📋 实现细节
|
||||
|
||||
### 核心字段判断规则
|
||||
```javascript
|
||||
// 以下字段默认显示(最多6个)
|
||||
- 主键字段 (id)
|
||||
- 名称字段 (name)
|
||||
- 标题字段 (title)
|
||||
- 编码字段 (code)
|
||||
- 状态字段 (status)
|
||||
- 排序字段 (sort)
|
||||
- 创建时间 (createTime)
|
||||
```
|
||||
|
||||
### 隐藏字段规则
|
||||
```javascript
|
||||
// 以下字段默认隐藏 (hideInTable: true)
|
||||
- 更新时间 (updateTime)
|
||||
- 创建人 (createBy)
|
||||
- 更新人 (updateBy)
|
||||
- 备注 (remark)
|
||||
- 描述 (description)
|
||||
- 内容 (content)
|
||||
- 其他非核心业务字段
|
||||
```
|
||||
|
||||
## 🔧 生成的代码示例
|
||||
|
||||
```javascript
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
width: 90,
|
||||
align: 'center',
|
||||
// 核心字段,默认显示
|
||||
},
|
||||
{
|
||||
title: '文章标题',
|
||||
dataIndex: 'title',
|
||||
key: 'title',
|
||||
width: 150,
|
||||
align: 'center',
|
||||
ellipsis: true,
|
||||
// 核心字段,默认显示
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
// 核心字段,默认显示
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd'),
|
||||
// 核心字段,默认显示
|
||||
},
|
||||
{
|
||||
title: '创建人',
|
||||
dataIndex: 'createBy',
|
||||
key: 'createBy',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
hideInTable: true, // 非核心字段,默认隐藏
|
||||
},
|
||||
{
|
||||
title: '文章内容',
|
||||
dataIndex: 'content',
|
||||
key: 'content',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
ellipsis: true,
|
||||
hideInTable: true, // 长文本字段,默认隐藏
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true, // 操作列不允许隐藏
|
||||
}
|
||||
]);
|
||||
```
|
||||
|
||||
## 🎨 用户界面效果
|
||||
|
||||
### 默认显示
|
||||
```
|
||||
┌────┬──────────┬────┬──────────┬────────┐
|
||||
│ ID │ 文章标题 │状态│ 创建时间 │ 操作 │
|
||||
├────┼──────────┼────┼──────────┼────────┤
|
||||
│ 1 │ 技术文章 │启用│2024-01-01│修改|删除│
|
||||
│ 2 │ 产品介绍 │禁用│2024-01-02│修改|删除│
|
||||
└────┴──────────┴────┴──────────┴────────┘
|
||||
```
|
||||
|
||||
### 用户勾选更多列后
|
||||
```
|
||||
┌────┬──────────┬────┬────────┬──────────┬──────────┬────────┐
|
||||
│ ID │ 文章标题 │状态│ 创建人 │ 创建时间 │ 文章内容 │ 操作 │
|
||||
├────┼──────────┼────┼────────┼──────────┼──────────┼────────┤
|
||||
│ 1 │ 技术文章 │启用│ 张三 │2024-01-01│ 这是... │修改|删除│
|
||||
│ 2 │ 产品介绍 │禁用│ 李四 │2024-01-02│ 产品... │修改|删除│
|
||||
└────┴──────────┴────┴────────┴──────────┴──────────┴────────┘
|
||||
```
|
||||
|
||||
## 🔄 与其他方案对比
|
||||
|
||||
| 方案 | 完整性 | 简洁性 | 用户控制 | 维护成本 | 推荐度 |
|
||||
|------|--------|--------|----------|----------|--------|
|
||||
| 显示所有字段 | ✅ | ❌ | ❌ | 低 | ⭐⭐ |
|
||||
| 过滤显示部分字段 | ❌ | ✅ | ❌ | 中 | ⭐⭐⭐ |
|
||||
| **hideInTable方案** | ✅ | ✅ | ✅ | 低 | ⭐⭐⭐⭐⭐ |
|
||||
|
||||
## 📝 使用建议
|
||||
|
||||
1. **保持核心字段数量在6个以内**:确保表格在标准屏幕上显示良好
|
||||
2. **优先显示业务关键字段**:如名称、状态、时间等
|
||||
3. **长文本字段默认隐藏**:如备注、描述、内容等
|
||||
4. **提供列设置入口**:让用户可以方便地自定义显示列
|
||||
5. **考虑移动端适配**:在小屏幕上进一步减少默认显示列
|
||||
|
||||
## 🎉 总结
|
||||
|
||||
`hideInTable` 方案是表格列显示的最佳实践,它完美平衡了:
|
||||
- **开发效率**:自动生成,无需手动配置
|
||||
- **用户体验**:默认简洁,按需扩展
|
||||
- **功能完整**:不丢失任何字段信息
|
||||
- **维护成本**:标准化实现,易于维护
|
||||
|
||||
这个方案让生成的表格既专业又实用,是代码生成器的理想选择!
|
||||
@@ -97,22 +97,56 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
// 表格列配置 - 使用 hideInTable 控制默认显示
|
||||
const columns = ref<ColumnItem[]>([
|
||||
<% var coreFieldCount = 0; %>
|
||||
<% for(field in table.fields) { %>
|
||||
<% if(field.propertyName != 'tenantId'){ %>
|
||||
<%
|
||||
// 判断是否为核心字段(默认显示)
|
||||
var isCoreField = field.keyFlag ||
|
||||
field.propertyName == 'name' ||
|
||||
field.propertyName == 'title' ||
|
||||
field.propertyName == 'code' ||
|
||||
field.propertyName == 'status' ||
|
||||
field.propertyName == 'sort' ||
|
||||
field.propertyName == 'createTime';
|
||||
|
||||
// 限制核心字段数量,避免显示过多列
|
||||
if(isCoreField && coreFieldCount >= 5) {
|
||||
isCoreField = false;
|
||||
}
|
||||
if(isCoreField) {
|
||||
coreFieldCount = coreFieldCount + 1;
|
||||
}
|
||||
%>
|
||||
{
|
||||
title: '${field.comment!field.propertyName}',
|
||||
dataIndex: '${field.propertyName}',
|
||||
key: '${field.propertyName}',
|
||||
align: 'center',
|
||||
<% if(!isCoreField){ %>
|
||||
hideInTable: true, // 非核心字段默认隐藏,用户可通过列设置显示
|
||||
<% } %>
|
||||
<% if(field.keyFlag){ %>
|
||||
width: 90,
|
||||
<% } %>
|
||||
<% if(field.propertyName == 'createTime'){ %>
|
||||
<% } else if(field.propertyName == 'createTime' || field.propertyName == 'updateTime'){ %>
|
||||
width: 120,
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
|
||||
<% } else if(field.propertyType == 'String' && (field.propertyName.contains('remark') || field.propertyName.contains('description') || field.propertyName.contains('content'))){ %>
|
||||
width: 200,
|
||||
ellipsis: true
|
||||
<% } else if(field.propertyType == 'String'){ %>
|
||||
width: 150,
|
||||
ellipsis: true
|
||||
<% } else if(field.propertyName == 'status'){ %>
|
||||
width: 80
|
||||
<% } else if(field.propertyName == 'sort'){ %>
|
||||
width: 80
|
||||
<% } else { %>
|
||||
width: 120
|
||||
<% } %>
|
||||
},
|
||||
<% } %>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
// 智能表格列配置 - 使用 hideInTable 控制显示
|
||||
// 所有字段都会生成,但非核心字段默认隐藏,用户可通过列设置显示
|
||||
|
||||
const columns = ref<ColumnItem[]>([
|
||||
<% var coreFieldCount = 0; %>
|
||||
<% for(field in table.fields) { %>
|
||||
<% if(field.propertyName != 'tenantId' && field.propertyName != 'deleted' && field.propertyName != 'version'){ %>
|
||||
<%
|
||||
// 定义核心字段优先级
|
||||
var priority = 0;
|
||||
var isCoreField = false;
|
||||
|
||||
if(field.keyFlag) {
|
||||
priority = 10;
|
||||
isCoreField = true;
|
||||
} else if(field.propertyName == 'name' || field.propertyName == 'title') {
|
||||
priority = 9;
|
||||
isCoreField = true;
|
||||
} else if(field.propertyName == 'code') {
|
||||
priority = 8;
|
||||
isCoreField = true;
|
||||
} else if(field.propertyName == 'status') {
|
||||
priority = 7;
|
||||
isCoreField = true;
|
||||
} else if(field.propertyName == 'sort') {
|
||||
priority = 6;
|
||||
isCoreField = true;
|
||||
} else if(field.propertyName == 'createTime') {
|
||||
priority = 5;
|
||||
isCoreField = true;
|
||||
} else if(field.propertyName == 'updateTime') {
|
||||
priority = 3;
|
||||
isCoreField = false; // 更新时间默认隐藏
|
||||
} else if(field.propertyType == 'String' && (field.propertyName.contains('remark') || field.propertyName.contains('description') || field.propertyName.contains('content'))) {
|
||||
priority = 1;
|
||||
isCoreField = false; // 长文本字段默认隐藏
|
||||
} else {
|
||||
priority = 4;
|
||||
isCoreField = false; // 其他字段默认隐藏
|
||||
}
|
||||
|
||||
// 限制核心字段数量(最多6个)
|
||||
if(isCoreField && coreFieldCount >= 6) {
|
||||
isCoreField = false;
|
||||
}
|
||||
if(isCoreField) {
|
||||
coreFieldCount = coreFieldCount + 1;
|
||||
}
|
||||
%>
|
||||
{
|
||||
title: '${field.comment!field.propertyName}',
|
||||
dataIndex: '${field.propertyName}',
|
||||
key: '${field.propertyName}',
|
||||
align: 'center',
|
||||
<% if(!isCoreField){ %>
|
||||
hideInTable: true, // 非核心字段默认隐藏,可通过列设置显示
|
||||
<% } %>
|
||||
<% if(field.keyFlag){ %>
|
||||
width: 90,
|
||||
<% } else if(field.propertyName == 'createTime' || field.propertyName == 'updateTime'){ %>
|
||||
width: 120,
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
|
||||
<% } else if(field.propertyType == 'String' && (field.propertyName.contains('remark') || field.propertyName.contains('description') || field.propertyName.contains('content'))){ %>
|
||||
width: 200,
|
||||
ellipsis: true
|
||||
<% } else if(field.propertyType == 'String'){ %>
|
||||
width: 150,
|
||||
ellipsis: true
|
||||
<% } else if(field.propertyName == 'status'){ %>
|
||||
width: 80
|
||||
<% } else if(field.propertyName == 'sort'){ %>
|
||||
width: 80
|
||||
<% } else { %>
|
||||
width: 120
|
||||
<% } %>
|
||||
},
|
||||
<% } %>
|
||||
<% } %>
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true // 操作列不允许隐藏
|
||||
}
|
||||
]);
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 表格列显示配置
|
||||
* 用于控制代码生成器生成的表格默认显示哪些列
|
||||
*/
|
||||
|
||||
// 优先显示的字段名(按优先级排序)
|
||||
const PRIORITY_FIELDS = [
|
||||
'id', // 主键ID
|
||||
'name', // 名称
|
||||
'title', // 标题
|
||||
'code', // 编码
|
||||
'status', // 状态
|
||||
'sort', // 排序
|
||||
'createTime', // 创建时间
|
||||
'updateTime' // 更新时间
|
||||
];
|
||||
|
||||
// 字段类型优先级配置
|
||||
const FIELD_TYPE_PRIORITY = {
|
||||
'keyFlag': 10, // 主键字段最高优先级
|
||||
'String': 8, // 字符串字段
|
||||
'Integer': 6, // 整数字段
|
||||
'Boolean': 5, // 布尔字段
|
||||
'Date': 4, // 日期字段
|
||||
'BigDecimal': 3, // 数值字段
|
||||
'Text': 1 // 文本字段最低优先级
|
||||
};
|
||||
|
||||
// 排除的字段(不显示在表格中)
|
||||
const EXCLUDED_FIELDS = [
|
||||
'tenantId', // 租户ID
|
||||
'deleted', // 逻辑删除标记
|
||||
'version', // 版本号
|
||||
'remark', // 备注(通常内容较长)
|
||||
'description', // 描述(通常内容较长)
|
||||
'content' // 内容(通常内容较长)
|
||||
];
|
||||
|
||||
// 默认显示的最大列数
|
||||
const MAX_DEFAULT_COLUMNS = 6;
|
||||
|
||||
// 特殊字段的宽度配置
|
||||
const FIELD_WIDTH_CONFIG = {
|
||||
'id': 90,
|
||||
'status': 80,
|
||||
'sort': 80,
|
||||
'createTime': 120,
|
||||
'updateTime': 120,
|
||||
'default_string': 150,
|
||||
'default_number': 120,
|
||||
'default_other': 120
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
PRIORITY_FIELDS,
|
||||
FIELD_TYPE_PRIORITY,
|
||||
EXCLUDED_FIELDS,
|
||||
MAX_DEFAULT_COLUMNS,
|
||||
FIELD_WIDTH_CONFIG
|
||||
};
|
||||
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
|
||||
<!-- 列设置按钮 -->
|
||||
<a-tooltip title="列设置">
|
||||
<a-button
|
||||
type="text"
|
||||
@click="showColumnSetting = true"
|
||||
:icon="h(SettingOutlined)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">启用</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">禁用</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 列设置弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="showColumnSetting"
|
||||
title="列设置"
|
||||
width="400px"
|
||||
@ok="applyColumnSettings"
|
||||
>
|
||||
<div class="column-settings">
|
||||
<div class="setting-item" v-for="col in allColumns" :key="col.key">
|
||||
<a-checkbox
|
||||
v-model:checked="col.visible"
|
||||
:disabled="col.required"
|
||||
>
|
||||
{{ col.title }}
|
||||
<a-tag v-if="col.required" size="small" color="blue">必显</a-tag>
|
||||
</a-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</a-modal>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref, h, computed } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined, SettingOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
|
||||
// 列设置相关
|
||||
const showColumnSetting = ref(false);
|
||||
|
||||
// 所有列的配置(包含可见性控制)
|
||||
const allColumns = ref([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
width: 90,
|
||||
align: 'center',
|
||||
visible: true,
|
||||
required: true // 必须显示的列
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 150,
|
||||
align: 'center',
|
||||
ellipsis: true,
|
||||
visible: true,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
title: '编码',
|
||||
dataIndex: 'code',
|
||||
key: 'code',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
visible: true,
|
||||
required: false
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
visible: true,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
key: 'sort',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
visible: true,
|
||||
required: false
|
||||
},
|
||||
{
|
||||
title: '创建人',
|
||||
dataIndex: 'createBy',
|
||||
key: 'createBy',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
visible: false, // 默认隐藏
|
||||
required: false
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd'),
|
||||
visible: true,
|
||||
required: false
|
||||
},
|
||||
{
|
||||
title: '更新人',
|
||||
dataIndex: 'updateBy',
|
||||
key: 'updateBy',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
visible: false, // 默认隐藏
|
||||
required: false
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updateTime',
|
||||
key: 'updateTime',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd'),
|
||||
visible: false, // 默认隐藏
|
||||
required: false
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
key: 'remark',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
ellipsis: true,
|
||||
visible: false, // 默认隐藏
|
||||
required: false
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
visible: true,
|
||||
required: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 根据可见性过滤列
|
||||
const columns = computed(() => {
|
||||
return allColumns.value
|
||||
.filter(col => col.visible)
|
||||
.map(col => {
|
||||
const { visible, required, ...columnConfig } = col;
|
||||
return columnConfig;
|
||||
});
|
||||
});
|
||||
|
||||
// 应用列设置
|
||||
const applyColumnSettings = () => {
|
||||
showColumnSetting.value = false;
|
||||
message.success('列设置已应用');
|
||||
};
|
||||
|
||||
// 其他业务逻辑...
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
const selection = ref([]);
|
||||
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
// 实际的数据源逻辑
|
||||
return Promise.resolve({
|
||||
list: [],
|
||||
total: 0
|
||||
});
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
tableRef?.value?.reload();
|
||||
};
|
||||
|
||||
const openEdit = (record?: any) => {
|
||||
// 编辑逻辑
|
||||
};
|
||||
|
||||
const remove = (record: any) => {
|
||||
// 删除逻辑
|
||||
};
|
||||
|
||||
const removeBatch = () => {
|
||||
// 批量删除逻辑
|
||||
};
|
||||
|
||||
const customRow = (record: any) => {
|
||||
return {
|
||||
onClick: () => {
|
||||
// 行点击事件
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.column-settings {
|
||||
.setting-item {
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user