diff --git a/pom.xml b/pom.xml index 54282e1..93ef0ff 100644 --- a/pom.xml +++ b/pom.xml @@ -103,7 +103,7 @@ com.baomidou mybatis-plus-generator - 3.5.3 + 3.4.1 diff --git a/run_shop_generator.sh b/run_shop_generator.sh new file mode 100755 index 0000000..38c0ebd --- /dev/null +++ b/run_shop_generator.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# 设置 JAVA_HOME(如果需要) +# export JAVA_HOME=/path/to/java + +# 构建类路径 +CLASSPATH="target/test-classes:target/classes" + +# 添加 Maven 依赖 +MAVEN_REPO="$HOME/.m2/repository" + +# 添加必要的依赖 JAR 文件 +CLASSPATH="$CLASSPATH:$MAVEN_REPO/com/baomidou/mybatis-plus-generator/3.5.3/mybatis-plus-generator-3.5.3.jar" +CLASSPATH="$CLASSPATH:$MAVEN_REPO/com/baomidou/mybatis-plus-core/3.4.3.3/mybatis-plus-core-3.4.3.3.jar" +CLASSPATH="$CLASSPATH:$MAVEN_REPO/com/baomidou/mybatis-plus-annotation/3.4.3.3/mybatis-plus-annotation-3.4.3.3.jar" +CLASSPATH="$CLASSPATH:$MAVEN_REPO/com/ibeetl/beetl/3.15.10.RELEASE/beetl-3.15.10.RELEASE.jar" +CLASSPATH="$CLASSPATH:$MAVEN_REPO/mysql/mysql-connector-java/8.0.29/mysql-connector-java-8.0.29.jar" +CLASSPATH="$CLASSPATH:$MAVEN_REPO/org/mybatis/mybatis/3.5.7/mybatis-3.5.7.jar" + +echo "运行 ShopGenerator..." +echo "类路径: $CLASSPATH" + +# 运行生成器 +java -cp "$CLASSPATH" com.gxwebsoft.generator.ShopGenerator + +echo "生成器运行完成!" diff --git a/src/main/java/com/gxwebsoft/docs/controller/DocsContentController.java b/src/main/java/com/gxwebsoft/docs/controller/DocsContentController.java deleted file mode 100644 index fbbdea1..0000000 --- a/src/main/java/com/gxwebsoft/docs/controller/DocsContentController.java +++ /dev/null @@ -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> page(DocsContentParam param) { - // 使用关联查询 - return success(docsContentService.pageRel(param)); - } - - @PreAuthorize("hasAuthority('docs:docsContent:list')") - @Operation(summary = "查询全部文档内容记录表") - @GetMapping() - public ApiResult> list(DocsContentParam param) { - // 使用关联查询 - return success(docsContentService.listRel(param)); - } - - @PreAuthorize("hasAuthority('docs:docsContent:list')") - @Operation(summary = "根据id查询文档内容记录表") - @GetMapping("/{id}") - public ApiResult 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 list) { - if (docsContentService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @PreAuthorize("hasAuthority('docs:docsContent:update')") - @OperationLog - @Operation(summary = "批量修改文档内容记录表") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam 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 ids) { - if (docsContentService.removeByIds(ids)) { - return success("删除成功"); - } - return fail("删除失败"); - } - -} diff --git a/src/main/java/com/gxwebsoft/docs/controller/DocsController.java b/src/main/java/com/gxwebsoft/docs/controller/DocsController.java deleted file mode 100644 index 65b4e1c..0000000 --- a/src/main/java/com/gxwebsoft/docs/controller/DocsController.java +++ /dev/null @@ -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> page(DocsParam param) { - // 使用关联查询 - return success(docsService.pageRel(param)); - } - - @PreAuthorize("hasAuthority('docs:docs:list')") - @Operation(summary = "查询全部知识库") - @GetMapping() - public ApiResult> list(DocsParam param) { - // 使用关联查询 - return success(docsService.listRel(param)); - } - - @PreAuthorize("hasAuthority('docs:docs:list')") - @Operation(summary = "根据id查询知识库") - @GetMapping("/{id}") - public ApiResult 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 list) { - if (docsService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @PreAuthorize("hasAuthority('docs:docs:update')") - @OperationLog - @Operation(summary = "批量修改知识库") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam 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 ids) { - if (docsService.removeByIds(ids)) { - return success("删除成功"); - } - return fail("删除失败"); - } - -} diff --git a/src/main/java/com/gxwebsoft/docs/controller/DocsUserController.java b/src/main/java/com/gxwebsoft/docs/controller/DocsUserController.java deleted file mode 100644 index c225268..0000000 --- a/src/main/java/com/gxwebsoft/docs/controller/DocsUserController.java +++ /dev/null @@ -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> page(DocsUserParam param) { - // 使用关联查询 - return success(docsUserService.pageRel(param)); - } - - @PreAuthorize("hasAuthority('docs:docsUser:list')") - @Operation(summary = "查询全部知识库成员") - @GetMapping() - public ApiResult> list(DocsUserParam param) { - // 使用关联查询 - return success(docsUserService.listRel(param)); - } - - @PreAuthorize("hasAuthority('docs:docsUser:list')") - @Operation(summary = "根据id查询知识库成员") - @GetMapping("/{id}") - public ApiResult 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 list) { - if (docsUserService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @PreAuthorize("hasAuthority('docs:docsUser:update')") - @OperationLog - @Operation(summary = "批量修改知识库成员") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam 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 ids) { - if (docsUserService.removeByIds(ids)) { - return success("删除成功"); - } - return fail("删除失败"); - } - -} diff --git a/src/main/java/com/gxwebsoft/docs/entity/Docs.java b/src/main/java/com/gxwebsoft/docs/entity/Docs.java deleted file mode 100644 index 763d783..0000000 --- a/src/main/java/com/gxwebsoft/docs/entity/Docs.java +++ /dev/null @@ -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; - -} diff --git a/src/main/java/com/gxwebsoft/docs/entity/DocsContent.java b/src/main/java/com/gxwebsoft/docs/entity/DocsContent.java deleted file mode 100644 index feb2752..0000000 --- a/src/main/java/com/gxwebsoft/docs/entity/DocsContent.java +++ /dev/null @@ -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; - -} diff --git a/src/main/java/com/gxwebsoft/docs/entity/DocsUser.java b/src/main/java/com/gxwebsoft/docs/entity/DocsUser.java deleted file mode 100644 index 4ef5925..0000000 --- a/src/main/java/com/gxwebsoft/docs/entity/DocsUser.java +++ /dev/null @@ -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; - -} diff --git a/src/main/java/com/gxwebsoft/docs/mapper/DocsContentMapper.java b/src/main/java/com/gxwebsoft/docs/mapper/DocsContentMapper.java deleted file mode 100644 index 6b62f76..0000000 --- a/src/main/java/com/gxwebsoft/docs/mapper/DocsContentMapper.java +++ /dev/null @@ -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 { - - /** - * 分页查询 - * - * @param page 分页对象 - * @param param 查询参数 - * @return List - */ - List selectPageRel(@Param("page") IPage page, - @Param("param") DocsContentParam param); - - /** - * 查询全部 - * - * @param param 查询参数 - * @return List - */ - List selectListRel(@Param("param") DocsContentParam param); - -} diff --git a/src/main/java/com/gxwebsoft/docs/mapper/DocsMapper.java b/src/main/java/com/gxwebsoft/docs/mapper/DocsMapper.java deleted file mode 100644 index a7f200a..0000000 --- a/src/main/java/com/gxwebsoft/docs/mapper/DocsMapper.java +++ /dev/null @@ -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 { - - /** - * 分页查询 - * - * @param page 分页对象 - * @param param 查询参数 - * @return List - */ - List selectPageRel(@Param("page") IPage page, - @Param("param") DocsParam param); - - /** - * 查询全部 - * - * @param param 查询参数 - * @return List - */ - List selectListRel(@Param("param") DocsParam param); - -} diff --git a/src/main/java/com/gxwebsoft/docs/mapper/DocsUserMapper.java b/src/main/java/com/gxwebsoft/docs/mapper/DocsUserMapper.java deleted file mode 100644 index 03a81ff..0000000 --- a/src/main/java/com/gxwebsoft/docs/mapper/DocsUserMapper.java +++ /dev/null @@ -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 { - - /** - * 分页查询 - * - * @param page 分页对象 - * @param param 查询参数 - * @return List - */ - List selectPageRel(@Param("page") IPage page, - @Param("param") DocsUserParam param); - - /** - * 查询全部 - * - * @param param 查询参数 - * @return List - */ - List selectListRel(@Param("param") DocsUserParam param); - -} diff --git a/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsContentMapper.xml b/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsContentMapper.xml deleted file mode 100644 index 97d1fa8..0000000 --- a/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsContentMapper.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - SELECT a.* - FROM docs_content a - - - AND a.id = #{param.id} - - - AND a.docs_id = #{param.docsId} - - - AND a.title LIKE CONCAT('%', #{param.title}, '%') - - - AND a.content LIKE CONCAT('%', #{param.content}, '%') - - - AND a.comments LIKE CONCAT('%', #{param.comments}, '%') - - - AND a.user_id = #{param.userId} - - - AND a.create_time >= #{param.createTimeStart} - - - AND a.create_time <= #{param.createTimeEnd} - - - AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') - ) - - - - - - - - - - - diff --git a/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsMapper.xml b/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsMapper.xml deleted file mode 100644 index eb0a2ea..0000000 --- a/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsMapper.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - SELECT a.*, b.nickname, b.avatar - FROM docs a - LEFT JOIN gxwebsoft_core.sys_user b ON a.user_id = b.user_id - - - AND a.book_id = #{param.bookId} - - - AND a.name LIKE CONCAT('%', #{param.name}, '%') - - - AND a.code LIKE CONCAT('%', #{param.code}, '%') - - - AND a.photo LIKE CONCAT('%', #{param.photo}, '%') - - - AND a.comments LIKE CONCAT('%', #{param.comments}, '%') - - - AND a.user_id = #{param.userId} - - - AND a.content LIKE CONCAT('%', #{param.content}, '%') - - - AND a.sort_number = #{param.sortNumber} - - - AND a.status = #{param.status} - - - AND a.deleted = #{param.deleted} - - - AND a.deleted = 0 - - - AND a.create_time >= #{param.createTimeStart} - - - AND a.create_time <= #{param.createTimeEnd} - - - AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') - ) - - - - - - - - - - - diff --git a/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsUserMapper.xml b/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsUserMapper.xml deleted file mode 100644 index 6372627..0000000 --- a/src/main/java/com/gxwebsoft/docs/mapper/xml/DocsUserMapper.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - SELECT a.* - FROM docs_user a - - - AND a.id = #{param.id} - - - AND a.docs_id = #{param.docsId} - - - AND a.user_id = #{param.userId} - - - AND a.nickname LIKE CONCAT('%', #{param.nickname}, '%') - - - AND a.avatar LIKE CONCAT('%', #{param.avatar}, '%') - - - AND a.role = #{param.role} - - - AND a.status = #{param.status} - - - AND a.create_time >= #{param.createTimeStart} - - - AND a.create_time <= #{param.createTimeEnd} - - - AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') - ) - - - - - - - - - - - diff --git a/src/main/java/com/gxwebsoft/docs/param/DocsContentParam.java b/src/main/java/com/gxwebsoft/docs/param/DocsContentParam.java deleted file mode 100644 index 1e982a3..0000000 --- a/src/main/java/com/gxwebsoft/docs/param/DocsContentParam.java +++ /dev/null @@ -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; - -} diff --git a/src/main/java/com/gxwebsoft/docs/param/DocsParam.java b/src/main/java/com/gxwebsoft/docs/param/DocsParam.java deleted file mode 100644 index b34f3cd..0000000 --- a/src/main/java/com/gxwebsoft/docs/param/DocsParam.java +++ /dev/null @@ -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; - -} diff --git a/src/main/java/com/gxwebsoft/docs/param/DocsUserParam.java b/src/main/java/com/gxwebsoft/docs/param/DocsUserParam.java deleted file mode 100644 index 3eedbf8..0000000 --- a/src/main/java/com/gxwebsoft/docs/param/DocsUserParam.java +++ /dev/null @@ -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; - -} diff --git a/src/main/java/com/gxwebsoft/docs/service/DocsContentService.java b/src/main/java/com/gxwebsoft/docs/service/DocsContentService.java deleted file mode 100644 index 1b4bf2f..0000000 --- a/src/main/java/com/gxwebsoft/docs/service/DocsContentService.java +++ /dev/null @@ -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 { - - /** - * 分页关联查询 - * - * @param param 查询参数 - * @return PageResult - */ - PageResult pageRel(DocsContentParam param); - - /** - * 关联查询全部 - * - * @param param 查询参数 - * @return List - */ - List listRel(DocsContentParam param); - - /** - * 根据id查询 - * - * @param id ID - * @return DocsContent - */ - DocsContent getByIdRel(Integer id); - -} diff --git a/src/main/java/com/gxwebsoft/docs/service/DocsService.java b/src/main/java/com/gxwebsoft/docs/service/DocsService.java deleted file mode 100644 index 31e3c43..0000000 --- a/src/main/java/com/gxwebsoft/docs/service/DocsService.java +++ /dev/null @@ -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 { - - /** - * 分页关联查询 - * - * @param param 查询参数 - * @return PageResult - */ - PageResult pageRel(DocsParam param); - - /** - * 关联查询全部 - * - * @param param 查询参数 - * @return List - */ - List listRel(DocsParam param); - - /** - * 根据id查询 - * - * @param bookId ID - * @return Docs - */ - Docs getByIdRel(Integer bookId); - -} diff --git a/src/main/java/com/gxwebsoft/docs/service/DocsUserService.java b/src/main/java/com/gxwebsoft/docs/service/DocsUserService.java deleted file mode 100644 index baf639f..0000000 --- a/src/main/java/com/gxwebsoft/docs/service/DocsUserService.java +++ /dev/null @@ -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 { - - /** - * 分页关联查询 - * - * @param param 查询参数 - * @return PageResult - */ - PageResult pageRel(DocsUserParam param); - - /** - * 关联查询全部 - * - * @param param 查询参数 - * @return List - */ - List listRel(DocsUserParam param); - - /** - * 根据id查询 - * - * @param id 自增ID - * @return DocsUser - */ - DocsUser getByIdRel(Integer id); - -} diff --git a/src/main/java/com/gxwebsoft/docs/service/impl/DocsContentServiceImpl.java b/src/main/java/com/gxwebsoft/docs/service/impl/DocsContentServiceImpl.java deleted file mode 100644 index df36038..0000000 --- a/src/main/java/com/gxwebsoft/docs/service/impl/DocsContentServiceImpl.java +++ /dev/null @@ -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 implements DocsContentService { - - @Override - public PageResult pageRel(DocsContentParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("sort_number asc, create_time desc"); - List list = baseMapper.selectPageRel(page, param); - return new PageResult<>(list, page.getTotal()); - } - - @Override - public List listRel(DocsContentParam param) { - List list = baseMapper.selectListRel(param); - // 排序 - PageParam 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)); - } - -} diff --git a/src/main/java/com/gxwebsoft/docs/service/impl/DocsServiceImpl.java b/src/main/java/com/gxwebsoft/docs/service/impl/DocsServiceImpl.java deleted file mode 100644 index 94a861b..0000000 --- a/src/main/java/com/gxwebsoft/docs/service/impl/DocsServiceImpl.java +++ /dev/null @@ -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 implements DocsService { - - @Override - public PageResult pageRel(DocsParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("sort_number asc, create_time desc"); - List list = baseMapper.selectPageRel(page, param); - return new PageResult<>(list, page.getTotal()); - } - - @Override - public List listRel(DocsParam param) { - List list = baseMapper.selectListRel(param); - // 排序 - PageParam 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)); - } - -} diff --git a/src/main/java/com/gxwebsoft/docs/service/impl/DocsUserServiceImpl.java b/src/main/java/com/gxwebsoft/docs/service/impl/DocsUserServiceImpl.java deleted file mode 100644 index f62af41..0000000 --- a/src/main/java/com/gxwebsoft/docs/service/impl/DocsUserServiceImpl.java +++ /dev/null @@ -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 implements DocsUserService { - - @Override - public PageResult pageRel(DocsUserParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("sort_number asc, create_time desc"); - List list = baseMapper.selectPageRel(page, param); - return new PageResult<>(list, page.getTotal()); - } - - @Override - public List listRel(DocsUserParam param) { - List list = baseMapper.selectListRel(param); - // 排序 - PageParam 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)); - } - -} diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopArticleController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopArticleController.java index c9ffd2d..98eb6da 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/ShopArticleController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopArticleController.java @@ -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 diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopArticle.java b/src/main/java/com/gxwebsoft/shop/entity/ShopArticle.java index 965a4d3..2a6543e 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/ShopArticle.java +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopArticle.java @@ -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) diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopMerchant.java b/src/main/java/com/gxwebsoft/shop/entity/ShopMerchant.java index 59a2af6..1915909 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/ShopMerchant.java +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopMerchant.java @@ -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; diff --git a/src/main/java/com/gxwebsoft/shop/mapper/ShopArticleMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/ShopArticleMapper.java index 868888b..72b5ef0 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/ShopArticleMapper.java +++ b/src/main/java/com/gxwebsoft/shop/mapper/ShopArticleMapper.java @@ -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 { diff --git a/src/main/java/com/gxwebsoft/shop/param/ShopArticleParam.java b/src/main/java/com/gxwebsoft/shop/param/ShopArticleParam.java index 3c0db32..9bfcec4 100644 --- a/src/main/java/com/gxwebsoft/shop/param/ShopArticleParam.java +++ b/src/main/java/com/gxwebsoft/shop/param/ShopArticleParam.java @@ -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) diff --git a/src/main/java/com/gxwebsoft/shop/service/ShopArticleService.java b/src/main/java/com/gxwebsoft/shop/service/ShopArticleService.java index 8219923..0ed617c 100644 --- a/src/main/java/com/gxwebsoft/shop/service/ShopArticleService.java +++ b/src/main/java/com/gxwebsoft/shop/service/ShopArticleService.java @@ -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 { diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ShopArticleServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ShopArticleServiceImpl.java index 82ffe42..475dfbd 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/ShopArticleServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ShopArticleServiceImpl.java @@ -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 implements ShopArticleService { diff --git a/src/test/java/com/gxwebsoft/generator/README-表格列优化.md b/src/test/java/com/gxwebsoft/generator/README-表格列优化.md new file mode 100644 index 0000000..e1fb984 --- /dev/null +++ b/src/test/java/com/gxwebsoft/generator/README-表格列优化.md @@ -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([ + { + 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. **响应式设计**:在移动端进一步减少显示列数 + +## 注意事项 + +- 修改模板后需要重新生成代码才能生效 +- 建议在生成前备份原有模板文件 +- 可以根据具体业务需求调整优先级规则 diff --git a/src/test/java/com/gxwebsoft/generator/hideInTable-方案总结.md b/src/test/java/com/gxwebsoft/generator/hideInTable-方案总结.md new file mode 100644 index 0000000..dbb12a9 --- /dev/null +++ b/src/test/java/com/gxwebsoft/generator/hideInTable-方案总结.md @@ -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([ + { + 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` 方案是表格列显示的最佳实践,它完美平衡了: +- **开发效率**:自动生成,无需手动配置 +- **用户体验**:默认简洁,按需扩展 +- **功能完整**:不丢失任何字段信息 +- **维护成本**:标准化实现,易于维护 + +这个方案让生成的表格既专业又实用,是代码生成器的理想选择! diff --git a/src/test/java/com/gxwebsoft/generator/templates/index.vue.btl b/src/test/java/com/gxwebsoft/generator/templates/index.vue.btl index f254357..a66c9e3 100644 --- a/src/test/java/com/gxwebsoft/generator/templates/index.vue.btl +++ b/src/test/java/com/gxwebsoft/generator/templates/index.vue.btl @@ -97,22 +97,56 @@ }); }; - // 表格列配置 + // 表格列配置 - 使用 hideInTable 控制默认显示 const columns = ref([ + <% 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 <% } %> }, <% } %> diff --git a/src/test/java/com/gxwebsoft/generator/templates/smart-columns.vue.btl b/src/test/java/com/gxwebsoft/generator/templates/smart-columns.vue.btl new file mode 100644 index 0000000..029afc3 --- /dev/null +++ b/src/test/java/com/gxwebsoft/generator/templates/smart-columns.vue.btl @@ -0,0 +1,89 @@ + // 智能表格列配置 - 使用 hideInTable 控制显示 + // 所有字段都会生成,但非核心字段默认隐藏,用户可通过列设置显示 + + const columns = ref([ + <% 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 // 操作列不允许隐藏 + } + ]); diff --git a/src/test/java/com/gxwebsoft/generator/templates/table-columns-config.js b/src/test/java/com/gxwebsoft/generator/templates/table-columns-config.js new file mode 100644 index 0000000..6fa72fe --- /dev/null +++ b/src/test/java/com/gxwebsoft/generator/templates/table-columns-config.js @@ -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 +}; diff --git a/src/test/java/com/gxwebsoft/generator/templates/table-with-column-settings.vue b/src/test/java/com/gxwebsoft/generator/templates/table-with-column-settings.vue new file mode 100644 index 0000000..35b0dd2 --- /dev/null +++ b/src/test/java/com/gxwebsoft/generator/templates/table-with-column-settings.vue @@ -0,0 +1,263 @@ + + + + +