update
This commit is contained in:
@@ -1,148 +1,165 @@
|
||||
package org.jeecg.modules.database.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.database.entity.DocumentLibrary;
|
||||
import org.jeecg.modules.database.service.IDocumentLibraryService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.database.entity.DocumentLibrary;
|
||||
import org.jeecg.modules.database.service.IDocumentLibraryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
*
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 知识库
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2024-08-21
|
||||
* @Date: 2024-08-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Tag(name="知识库")
|
||||
@Tag(name = "知识库")
|
||||
@RestController
|
||||
@RequestMapping("/library/documentLibrary")
|
||||
@Slf4j
|
||||
public class DocumentLibraryController extends JeecgController<DocumentLibrary, IDocumentLibraryService> {
|
||||
@Autowired
|
||||
private IDocumentLibraryService documentLibraryService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param documentLibrary
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "知识库-分页列表查询")
|
||||
@Operation(summary="知识库-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<DocumentLibrary>> queryPageList(DocumentLibrary documentLibrary,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<DocumentLibrary> queryWrapper = QueryGenerator.initQueryWrapper(documentLibrary, req.getParameterMap());
|
||||
Page<DocumentLibrary> page = new Page<DocumentLibrary>(pageNo, pageSize);
|
||||
IPage<DocumentLibrary> pageList = documentLibraryService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param documentLibrary
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-添加")
|
||||
@Operation(summary="知识库-添加")
|
||||
@RequiresPermissions("library:document_library:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody DocumentLibrary documentLibrary) {
|
||||
documentLibraryService.save(documentLibrary);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param documentLibrary
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-编辑")
|
||||
@Operation(summary="知识库-编辑")
|
||||
@RequiresPermissions("library:document_library:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody DocumentLibrary documentLibrary) {
|
||||
documentLibraryService.updateById(documentLibrary);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-通过id删除")
|
||||
@Operation(summary="知识库-通过id删除")
|
||||
@RequiresPermissions("library:document_library:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
documentLibraryService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-批量删除")
|
||||
@Operation(summary="知识库-批量删除")
|
||||
@RequiresPermissions("library:document_library:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.documentLibraryService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "知识库-通过id查询")
|
||||
@Operation(summary="知识库-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<DocumentLibrary> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
DocumentLibrary documentLibrary = documentLibraryService.getById(id);
|
||||
if(documentLibrary==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(documentLibrary);
|
||||
}
|
||||
@Autowired
|
||||
private IDocumentLibraryService documentLibraryService;
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param documentLibrary
|
||||
*/
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param documentLibrary
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "知识库-分页列表查询")
|
||||
@Operation(summary = "知识库-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<DocumentLibrary>> queryPageList(DocumentLibrary documentLibrary,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<DocumentLibrary> queryWrapper = QueryGenerator.initQueryWrapper(documentLibrary, req.getParameterMap());
|
||||
Page<DocumentLibrary> page = new Page<DocumentLibrary>(pageNo, pageSize);
|
||||
IPage<DocumentLibrary> pageList = documentLibraryService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@Operation(summary = "知识库-文档树查询")
|
||||
@GetMapping(value = "/tree")
|
||||
public Result<List<DocumentLibrary>> tree(@RequestParam(name = "parentId") String parentId, HttpServletRequest req) {
|
||||
DocumentLibrary documentLibrary = new DocumentLibrary();
|
||||
if (StringUtils.isBlank(parentId)) {
|
||||
documentLibrary.setParentId(null);
|
||||
} else {
|
||||
documentLibrary.setParentId(parentId);
|
||||
DocumentLibrary parent = documentLibraryService.getById(parentId);
|
||||
if (StringUtils.equals(parent.getType(), "DOCUMENT")) {
|
||||
return Result.OK();
|
||||
}
|
||||
}
|
||||
QueryWrapper<DocumentLibrary> queryWrapper = QueryGenerator.initQueryWrapper(documentLibrary, req.getParameterMap());
|
||||
List<DocumentLibrary> pageList = documentLibraryService.list(queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param documentLibrary
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-添加")
|
||||
@Operation(summary = "知识库-添加")
|
||||
@RequiresPermissions("library:document_library:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody DocumentLibrary documentLibrary) {
|
||||
documentLibraryService.save(documentLibrary);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param documentLibrary
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-编辑")
|
||||
@Operation(summary = "知识库-编辑")
|
||||
@RequiresPermissions("library:document_library:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody DocumentLibrary documentLibrary) {
|
||||
documentLibraryService.updateById(documentLibrary);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-通过id删除")
|
||||
@Operation(summary = "知识库-通过id删除")
|
||||
@RequiresPermissions("library:document_library:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
documentLibraryService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "知识库-批量删除")
|
||||
@Operation(summary = "知识库-批量删除")
|
||||
@RequiresPermissions("library:document_library:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.documentLibraryService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "知识库-通过id查询")
|
||||
@Operation(summary = "知识库-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<DocumentLibrary> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
DocumentLibrary documentLibrary = documentLibraryService.getById(id);
|
||||
if (documentLibrary == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(documentLibrary);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param documentLibrary
|
||||
*/
|
||||
@RequiresPermissions("library:document_library:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, DocumentLibrary documentLibrary) {
|
||||
@@ -150,12 +167,12 @@ public class DocumentLibraryController extends JeecgController<DocumentLibrary,
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("library:document_library:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
@@ -1,69 +1,96 @@
|
||||
package org.jeecg.modules.database.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 知识库
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2024-08-21
|
||||
* @Date: 2024-08-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("document_library")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description="知识库")
|
||||
@Schema(description = "知识库")
|
||||
public class DocumentLibrary implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Schema(description = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@Schema(description = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**文档标题*/
|
||||
@Excel(name = "文档标题", width = 15)
|
||||
/**
|
||||
* 文档标题
|
||||
*/
|
||||
@Excel(name = "文档标题", width = 15)
|
||||
@Schema(description = "文档标题")
|
||||
private java.lang.String title;
|
||||
/**文档标签*/
|
||||
@Excel(name = "文档标签", width = 15)
|
||||
/**
|
||||
* 文档标签
|
||||
*/
|
||||
@Excel(name = "文档标签", width = 15)
|
||||
@Schema(description = "文档标签")
|
||||
private java.lang.String tags;
|
||||
/**文档内容*/
|
||||
@Excel(name = "文档内容", width = 15)
|
||||
/**
|
||||
* 文档内容
|
||||
*/
|
||||
@Excel(name = "文档内容", width = 15)
|
||||
@Schema(description = "文档内容")
|
||||
private java.lang.String content;
|
||||
|
||||
/**
|
||||
* 父级ID
|
||||
*/
|
||||
@Excel(name = "父级ID", width = 15)
|
||||
@Schema(description = "父级ID")
|
||||
private java.lang.String parentId;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Excel(name = "类型", width = 15)
|
||||
@Schema(description = "类型(DOCUMENT/FOLDER)")
|
||||
private java.lang.String type;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.jeecg.modules.database.service;
|
||||
|
||||
import org.jeecg.modules.database.entity.DocumentLibrary;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.database.entity.DocumentLibrary;
|
||||
|
||||
/**
|
||||
* @Description: 知识库
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2024-08-21
|
||||
* @Date: 2024-08-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IDocumentLibraryService extends IService<DocumentLibrary> {
|
||||
|
||||
Reference in New Issue
Block a user