diff --git a/src/main/java/com/gxwebsoft/pwl/controller/PwlProjectLibraryController.java b/src/main/java/com/gxwebsoft/pwl/controller/PwlProjectLibraryController.java new file mode 100644 index 0000000..072543c --- /dev/null +++ b/src/main/java/com/gxwebsoft/pwl/controller/PwlProjectLibraryController.java @@ -0,0 +1,123 @@ +package com.gxwebsoft.pwl.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.pwl.service.PwlProjectLibraryService; +import com.gxwebsoft.pwl.entity.PwlProjectLibrary; +import com.gxwebsoft.pwl.param.PwlProjectLibraryParam; +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.system.entity.User; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 材料库资料库表控制器 + * + * @author 科技小王子 + * @since 2025-09-28 09:38:17 + */ +@Tag(name = "材料库资料库表管理") +@RestController +@RequestMapping("/api/pwl/pwl-project-library") +public class PwlProjectLibraryController extends BaseController { + @Resource + private PwlProjectLibraryService pwlProjectLibraryService; + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:list')") + @Operation(summary = "分页查询材料库资料库表") + @GetMapping("/page") + public ApiResult> page(PwlProjectLibraryParam param) { + // 使用关联查询 + return success(pwlProjectLibraryService.pageRel(param)); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:list')") + @Operation(summary = "查询全部材料库资料库表") + @GetMapping() + public ApiResult> list(PwlProjectLibraryParam param) { + // 使用关联查询 + return success(pwlProjectLibraryService.listRel(param)); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:list')") + @Operation(summary = "根据id查询材料库资料库表") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(pwlProjectLibraryService.getByIdRel(id)); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:save')") + @Operation(summary = "添加材料库资料库表") + @PostMapping() + public ApiResult save(@RequestBody PwlProjectLibrary pwlProjectLibrary) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + pwlProjectLibrary.setUserId(loginUser.getUserId()); + } + if (pwlProjectLibraryService.save(pwlProjectLibrary)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:update')") + @Operation(summary = "修改材料库资料库表") + @PutMapping() + public ApiResult update(@RequestBody PwlProjectLibrary pwlProjectLibrary) { + if (pwlProjectLibraryService.updateById(pwlProjectLibrary)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:remove')") + @Operation(summary = "删除材料库资料库表") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (pwlProjectLibraryService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:save')") + @Operation(summary = "批量添加材料库资料库表") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (pwlProjectLibraryService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:update')") + @Operation(summary = "批量修改材料库资料库表") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(pwlProjectLibraryService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:remove')") + @Operation(summary = "批量删除材料库资料库表") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (pwlProjectLibraryService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/pwl/entity/PwlProject.java b/src/main/java/com/gxwebsoft/pwl/entity/PwlProject.java index e783740..11eefa3 100644 --- a/src/main/java/com/gxwebsoft/pwl/entity/PwlProject.java +++ b/src/main/java/com/gxwebsoft/pwl/entity/PwlProject.java @@ -178,6 +178,9 @@ public class PwlProject implements Serializable { @Schema(description = "知识库ID") private String kbId; + @Schema(description = "资料库库IDs") + private String libraryIds; //英文逗号分割 + @Schema(description = "租户id") private Integer tenantId; diff --git a/src/main/java/com/gxwebsoft/pwl/entity/PwlProjectLibrary.java b/src/main/java/com/gxwebsoft/pwl/entity/PwlProjectLibrary.java new file mode 100644 index 0000000..e318723 --- /dev/null +++ b/src/main/java/com/gxwebsoft/pwl/entity/PwlProjectLibrary.java @@ -0,0 +1,74 @@ +package com.gxwebsoft.pwl.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.TableLogic; +import java.io.Serializable; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 材料库资料库表 + * + * @author 科技小王子 + * @since 2025-09-28 09:38:17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "PwlProjectLibrary对象", description = "材料库资料库表") +public class PwlProjectLibrary implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @Schema(description = "资料库名称") + private String name; + + @Schema(description = "资料库类型: biz-项目案例库, pub-公共知识库") + private String type; + + @Schema(description = "关联知识库ID") + private String kbId; + + @Schema(description = "排序(数字越小越靠前)") + private Integer sort; + + @Schema(description = "资料库图标") + private String image; + + @Schema(description = "资料库描述") + private String content; + + @Schema(description = "关联文件") + private String files; + + @Schema(description = "备注") + private String comments; + + @Schema(description = "是否推荐") + private Integer recommend; + + @Schema(description = "状态, 0正常, 1冻结") + private Integer status; + + @Schema(description = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @Schema(description = "创建用户ID") + private Integer userId; + + @Schema(description = "租户id") + private Integer tenantId; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + + @Schema(description = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/pwl/mapper/PwlProjectLibraryMapper.java b/src/main/java/com/gxwebsoft/pwl/mapper/PwlProjectLibraryMapper.java new file mode 100644 index 0000000..f0adaa4 --- /dev/null +++ b/src/main/java/com/gxwebsoft/pwl/mapper/PwlProjectLibraryMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.pwl.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.pwl.entity.PwlProjectLibrary; +import com.gxwebsoft.pwl.param.PwlProjectLibraryParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 材料库资料库表Mapper + * + * @author 科技小王子 + * @since 2025-09-28 09:38:17 + */ +public interface PwlProjectLibraryMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") PwlProjectLibraryParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") PwlProjectLibraryParam param); + +} diff --git a/src/main/java/com/gxwebsoft/pwl/mapper/xml/PwlProjectLibraryMapper.xml b/src/main/java/com/gxwebsoft/pwl/mapper/xml/PwlProjectLibraryMapper.xml new file mode 100644 index 0000000..46fefe2 --- /dev/null +++ b/src/main/java/com/gxwebsoft/pwl/mapper/xml/PwlProjectLibraryMapper.xml @@ -0,0 +1,75 @@ + + + + + + + SELECT a.* + FROM pwl_project_library a + + + AND a.id = #{param.id} + + + AND a.name LIKE CONCAT('%', #{param.name}, '%') + + + AND a.type LIKE CONCAT('%', #{param.type}, '%') + + + AND a.kb_id LIKE CONCAT('%', #{param.kbId}, '%') + + + AND a.sort = #{param.sort} + + + AND a.image LIKE CONCAT('%', #{param.image}, '%') + + + AND a.content LIKE CONCAT('%', #{param.content}, '%') + + + AND a.files LIKE CONCAT('%', #{param.files}, '%') + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.recommend = #{param.recommend} + + + AND a.status = #{param.status} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + 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/pwl/param/PwlProjectLibraryParam.java b/src/main/java/com/gxwebsoft/pwl/param/PwlProjectLibraryParam.java new file mode 100644 index 0000000..607e159 --- /dev/null +++ b/src/main/java/com/gxwebsoft/pwl/param/PwlProjectLibraryParam.java @@ -0,0 +1,68 @@ +package com.gxwebsoft.pwl.param; + +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 lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 材料库资料库表查询参数 + * + * @author 科技小王子 + * @since 2025-09-28 09:38:17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@Schema(name = "PwlProjectLibraryParam对象", description = "材料库资料库表查询参数") +public class PwlProjectLibraryParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @Schema(description = "ID") + @QueryField(type = QueryType.EQ) + private Integer id; + + @Schema(description = "资料库名称") + private String name; + + @Schema(description = "资料库类型: biz-项目案例库, pub-公共知识库") + private String type; + + @Schema(description = "关联知识库ID") + private String kbId; + + @Schema(description = "排序(数字越小越靠前)") + private String sort; + + @Schema(description = "资料库图标") + private String image; + + @Schema(description = "资料库描述") + private String content; + + @Schema(description = "关联文件") + private String files; + + @Schema(description = "备注") + private String comments; + + @Schema(description = "是否推荐") + @QueryField(type = QueryType.EQ) + private Integer recommend; + + @Schema(description = "状态, 0正常, 1冻结") + @QueryField(type = QueryType.EQ) + private Integer status; + + @Schema(description = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + + @Schema(description = "创建用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + +} diff --git a/src/main/java/com/gxwebsoft/pwl/service/PwlProjectLibraryService.java b/src/main/java/com/gxwebsoft/pwl/service/PwlProjectLibraryService.java new file mode 100644 index 0000000..139af33 --- /dev/null +++ b/src/main/java/com/gxwebsoft/pwl/service/PwlProjectLibraryService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.pwl.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.pwl.entity.PwlProjectLibrary; +import com.gxwebsoft.pwl.param.PwlProjectLibraryParam; + +import java.util.List; + +/** + * 材料库资料库表Service + * + * @author 科技小王子 + * @since 2025-09-28 09:38:17 + */ +public interface PwlProjectLibraryService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(PwlProjectLibraryParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(PwlProjectLibraryParam param); + + /** + * 根据id查询 + * + * @param id ID + * @return PwlProjectLibrary + */ + PwlProjectLibrary getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/pwl/service/impl/PwlProjectLibraryServiceImpl.java b/src/main/java/com/gxwebsoft/pwl/service/impl/PwlProjectLibraryServiceImpl.java new file mode 100644 index 0000000..0c3d174 --- /dev/null +++ b/src/main/java/com/gxwebsoft/pwl/service/impl/PwlProjectLibraryServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.pwl.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.pwl.mapper.PwlProjectLibraryMapper; +import com.gxwebsoft.pwl.service.PwlProjectLibraryService; +import com.gxwebsoft.pwl.entity.PwlProjectLibrary; +import com.gxwebsoft.pwl.param.PwlProjectLibraryParam; +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-09-28 09:38:17 + */ +@Service +public class PwlProjectLibraryServiceImpl extends ServiceImpl implements PwlProjectLibraryService { + + @Override + public PageResult pageRel(PwlProjectLibraryParam 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(PwlProjectLibraryParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public PwlProjectLibrary getByIdRel(Integer id) { + PwlProjectLibraryParam param = new PwlProjectLibraryParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +}