新增材料库资料库表

This commit is contained in:
2025-09-28 10:05:33 +08:00
parent bf033b3b89
commit c9038b10ab
8 changed files with 469 additions and 0 deletions

View File

@@ -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<PageResult<PwlProjectLibrary>> page(PwlProjectLibraryParam param) {
// 使用关联查询
return success(pwlProjectLibraryService.pageRel(param));
}
@PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:list')")
@Operation(summary = "查询全部材料库资料库表")
@GetMapping()
public ApiResult<List<PwlProjectLibrary>> list(PwlProjectLibraryParam param) {
// 使用关联查询
return success(pwlProjectLibraryService.listRel(param));
}
@PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:list')")
@Operation(summary = "根据id查询材料库资料库表")
@GetMapping("/{id}")
public ApiResult<PwlProjectLibrary> 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<PwlProjectLibrary> list) {
if (pwlProjectLibraryService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:update')")
@Operation(summary = "批量修改材料库资料库表")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<PwlProjectLibrary> batchParam) {
if (batchParam.update(pwlProjectLibraryService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('pwl:pwlProjectLibrary:remove')")
@Operation(summary = "批量删除材料库资料库表")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (pwlProjectLibraryService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -178,6 +178,9 @@ public class PwlProject implements Serializable {
@Schema(description = "知识库ID") @Schema(description = "知识库ID")
private String kbId; private String kbId;
@Schema(description = "资料库库IDs")
private String libraryIds; //英文逗号分割
@Schema(description = "租户id") @Schema(description = "租户id")
private Integer tenantId; private Integer tenantId;

View File

@@ -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;
}

View File

@@ -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<PwlProjectLibrary> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<PwlProjectLibrary>
*/
List<PwlProjectLibrary> selectPageRel(@Param("page") IPage<PwlProjectLibrary> page,
@Param("param") PwlProjectLibraryParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<PwlProjectLibrary> selectListRel(@Param("param") PwlProjectLibraryParam param);
}

View File

@@ -0,0 +1,75 @@
<?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.pwl.mapper.PwlProjectLibraryMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM pwl_project_library a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.type != null">
AND a.type LIKE CONCAT('%', #{param.type}, '%')
</if>
<if test="param.kbId != null">
AND a.kb_id LIKE CONCAT('%', #{param.kbId}, '%')
</if>
<if test="param.sort != null">
AND a.sort = #{param.sort}
</if>
<if test="param.image != null">
AND a.image LIKE CONCAT('%', #{param.image}, '%')
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.files != null">
AND a.files LIKE CONCAT('%', #{param.files}, '%')
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.recommend != null">
AND a.recommend = #{param.recommend}
</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.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.pwl.entity.PwlProjectLibrary">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.pwl.entity.PwlProjectLibrary">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -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;
}

View File

@@ -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<PwlProjectLibrary> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<PwlProjectLibrary>
*/
PageResult<PwlProjectLibrary> pageRel(PwlProjectLibraryParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<PwlProjectLibrary>
*/
List<PwlProjectLibrary> listRel(PwlProjectLibraryParam param);
/**
* 根据id查询
*
* @param id ID
* @return PwlProjectLibrary
*/
PwlProjectLibrary getByIdRel(Integer id);
}

View File

@@ -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<PwlProjectLibraryMapper, PwlProjectLibrary> implements PwlProjectLibraryService {
@Override
public PageResult<PwlProjectLibrary> pageRel(PwlProjectLibraryParam param) {
PageParam<PwlProjectLibrary, PwlProjectLibraryParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<PwlProjectLibrary> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<PwlProjectLibrary> listRel(PwlProjectLibraryParam param) {
List<PwlProjectLibrary> list = baseMapper.selectListRel(param);
// 排序
PageParam<PwlProjectLibrary, PwlProjectLibraryParam> 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));
}
}