|
@@ -25,146 +25,151 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
- /**
|
|
|
+/**
|
|
|
* @Description: 基础资料-知识-分类
|
|
|
* @Author: jeecg-boot
|
|
|
- * @Date: 2023-12-08
|
|
|
+ * @Date: 2023-12-08
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
-@Api(tags="基础资料-知识-分类")
|
|
|
+@Api(tags = "基础资料-知识-分类")
|
|
|
@RestController
|
|
|
@RequestMapping("/kms/category")
|
|
|
@Slf4j
|
|
|
-public class CategoryController extends JeecgController<Category, ICategoryService>{
|
|
|
- @Autowired
|
|
|
- private ICategoryService categoryService;
|
|
|
+public class CategoryController extends JeecgController<Category, ICategoryService> {
|
|
|
+ @Autowired
|
|
|
+ private ICategoryService categoryService;
|
|
|
|
|
|
- /**
|
|
|
- * 分页列表查询
|
|
|
- *
|
|
|
- * @param category
|
|
|
- * @param pageNo
|
|
|
- * @param pageSize
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@AutoLog(value = "基础资料-知识-分类-分页列表查询")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-分页列表查询", notes="基础资料-知识-分类-分页列表查询")
|
|
|
- @GetMapping(value = "/rootList")
|
|
|
- public Result<IPage<Category>> queryPageList(Category category,
|
|
|
- @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
- @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
- HttpServletRequest req) {
|
|
|
- String hasQuery = req.getParameter("hasQuery");
|
|
|
- if(hasQuery != null && "true".equals(hasQuery)){
|
|
|
- QueryWrapper<Category> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param category
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "基础资料-知识-分类-分页列表查询")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-分页列表查询", notes = "基础资料-知识-分类-分页列表查询")
|
|
|
+ @GetMapping(value = "/rootList")
|
|
|
+ public Result<IPage<Category>> queryPageList(Category category,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ String hasQuery = req.getParameter("hasQuery");
|
|
|
+// if (hasQuery != null && "true".equals(hasQuery)) {
|
|
|
+ QueryWrapper<Category> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
|
|
|
List<Category> list = categoryService.queryTreeListNoPage(queryWrapper);
|
|
|
IPage<Category> pageList = new Page<>(1, 10, list.size());
|
|
|
pageList.setRecords(list);
|
|
|
+ System.out.println("hasQuery:" + hasQuery);
|
|
|
return Result.OK(pageList);
|
|
|
- }else{
|
|
|
- String parentId = category.getPid();
|
|
|
- if (oConvertUtils.isEmpty(parentId)) {
|
|
|
- parentId = "0";
|
|
|
- }
|
|
|
- category.setPid(null);
|
|
|
- QueryWrapper<Category> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
|
|
|
- // 使用 eq 防止模糊查询
|
|
|
- queryWrapper.eq("pid", parentId);
|
|
|
- Page<Category> page = new Page<Category>(pageNo, pageSize);
|
|
|
- IPage<Category> pageList = categoryService.page(page, queryWrapper);
|
|
|
- return Result.OK(pageList);
|
|
|
- }
|
|
|
- }
|
|
|
+// } else {
|
|
|
+// System.out.println("hasQuery:" + hasQuery);
|
|
|
+// String parentId = category.getPid();
|
|
|
+// if (oConvertUtils.isEmpty(parentId)) {
|
|
|
+// parentId = "0";
|
|
|
+// }
|
|
|
+// category.setPid(null);
|
|
|
+// QueryWrapper<Category> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
|
|
|
+// // 使用 eq 防止模糊查询
|
|
|
+// queryWrapper.eq("pid", parentId);
|
|
|
+// Page<Category> page = new Page<Category>(pageNo, pageSize);
|
|
|
+// IPage<Category> pageList = categoryService.page(page, queryWrapper);
|
|
|
+// return Result.OK(pageList);
|
|
|
+// }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 【vue3专用】加载节点的子数据
|
|
|
- *
|
|
|
- * @param pid
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
|
|
- public Result<List<SelectTreeModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
|
|
|
- Result<List<SelectTreeModel>> result = new Result<>();
|
|
|
- try {
|
|
|
- List<SelectTreeModel> ls = categoryService.queryListByPid(pid);
|
|
|
- result.setResult(ls);
|
|
|
- result.setSuccess(true);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- result.setMessage(e.getMessage());
|
|
|
- result.setSuccess(false);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 【vue3专用】加载节点的子数据
|
|
|
+ *
|
|
|
+ * @param pid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
|
|
+ public Result<List<SelectTreeModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
|
|
|
+ Result<List<SelectTreeModel>> result = new Result<>();
|
|
|
+ try {
|
|
|
+ List<SelectTreeModel> ls = categoryService.queryListByPid(pid);
|
|
|
+ result.setResult(ls);
|
|
|
+ result.setSuccess(true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
+ result.setSuccess(false);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 【vue3专用】加载一级节点/如果是同步 则所有数据
|
|
|
- *
|
|
|
- * @param async
|
|
|
- * @param pcode
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
|
|
- @PermissionData(pageComponent="kms/index")
|
|
|
- public Result<List<SelectTreeModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) {
|
|
|
- Result<List<SelectTreeModel>> result = new Result<>();
|
|
|
- try {
|
|
|
- List<SelectTreeModel> ls = categoryService.queryListByCode(pcode);
|
|
|
- if (!async) {
|
|
|
- loadAllChildren(ls);
|
|
|
- }
|
|
|
- result.setResult(ls);
|
|
|
- result.setSuccess(true);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- result.setMessage(e.getMessage());
|
|
|
- result.setSuccess(false);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 【vue3专用】加载一级节点/如果是同步 则所有数据
|
|
|
+ *
|
|
|
+ * @param async
|
|
|
+ * @param pcode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
|
|
+ @PermissionData(pageComponent = "kms/index")
|
|
|
+ public Result<List<SelectTreeModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) {
|
|
|
+ Result<List<SelectTreeModel>> result = new Result<>();
|
|
|
+ try {
|
|
|
+ List<SelectTreeModel> ls = categoryService.queryListByCode(pcode);
|
|
|
+ if (!async) {
|
|
|
+ loadAllChildren(ls);
|
|
|
+ }
|
|
|
+ result.setResult(ls);
|
|
|
+ result.setSuccess(true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
+ result.setSuccess(false);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 【vue3专用】递归求子节点 同步加载用到
|
|
|
- *
|
|
|
- * @param ls
|
|
|
- */
|
|
|
- private void loadAllChildren(List<SelectTreeModel> ls) {
|
|
|
- for (SelectTreeModel tsm : ls) {
|
|
|
- List<SelectTreeModel> temp = categoryService.queryListByPid(tsm.getKey());
|
|
|
- if (temp != null && temp.size() > 0) {
|
|
|
- tsm.setChildren(temp);
|
|
|
- loadAllChildren(temp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 【vue3专用】递归求子节点 同步加载用到
|
|
|
+ *
|
|
|
+ * @param ls
|
|
|
+ */
|
|
|
+ private void loadAllChildren(List<SelectTreeModel> ls) {
|
|
|
+ for (SelectTreeModel tsm : ls) {
|
|
|
+ List<SelectTreeModel> temp = categoryService.queryListByPid(tsm.getKey());
|
|
|
+ if (temp != null && temp.size() > 0) {
|
|
|
+ tsm.setChildren(temp);
|
|
|
+ loadAllChildren(temp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 获取子数据
|
|
|
- * @param category
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@AutoLog(value = "基础资料-知识-分类-获取子数据")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-获取子数据", notes="基础资料-知识-分类-获取子数据")
|
|
|
- @GetMapping(value = "/childList")
|
|
|
- public Result<IPage<Category>> queryPageList(Category category,HttpServletRequest req) {
|
|
|
- QueryWrapper<Category> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
|
|
|
- List<Category> list = categoryService.list(queryWrapper);
|
|
|
- IPage<Category> pageList = new Page<>(1, 10, list.size());
|
|
|
+ /**
|
|
|
+ * 获取子数据
|
|
|
+ *
|
|
|
+ * @param category
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "基础资料-知识-分类-获取子数据")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-获取子数据", notes = "基础资料-知识-分类-获取子数据")
|
|
|
+ @GetMapping(value = "/childList")
|
|
|
+ public Result<IPage<Category>> queryPageList(Category category, HttpServletRequest req) {
|
|
|
+ QueryWrapper<Category> queryWrapper = QueryGenerator.initQueryWrapper(category, req.getParameterMap());
|
|
|
+ List<Category> list = categoryService.list(queryWrapper);
|
|
|
+ IPage<Category> pageList = new Page<>(1, 10, list.size());
|
|
|
pageList.setRecords(list);
|
|
|
- return Result.OK(pageList);
|
|
|
- }
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 批量查询子节点
|
|
|
- * @param parentIds 父ID(多个采用半角逗号分割)
|
|
|
- * @return 返回 IPage
|
|
|
- * @param parentIds
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@AutoLog(value = "基础资料-知识-分类-批量获取子数据")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-批量获取子数据", notes="基础资料-知识-分类-批量获取子数据")
|
|
|
+ * 批量查询子节点
|
|
|
+ *
|
|
|
+ * @param parentIds 父ID(多个采用半角逗号分割)
|
|
|
+ * @param parentIds
|
|
|
+ * @return 返回 IPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "基础资料-知识-分类-批量获取子数据")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-批量获取子数据", notes = "基础资料-知识-分类-批量获取子数据")
|
|
|
@GetMapping("/getChildListBatch")
|
|
|
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
|
|
|
try {
|
|
@@ -180,119 +185,119 @@ public class CategoryController extends JeecgController<Category, ICategoryServi
|
|
|
return Result.error("批量查询子节点失败:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加
|
|
|
- *
|
|
|
- * @param category
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "基础资料-知识-分类-添加")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-添加", notes="基础资料-知识-分类-添加")
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param category
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "基础资料-知识-分类-添加")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-添加", notes = "基础资料-知识-分类-添加")
|
|
|
@RequiresPermissions("kms:kms_bas_article_category:add")
|
|
|
- @PostMapping(value = "/add")
|
|
|
- public Result<String> add(@RequestBody Category category) {
|
|
|
- categoryService.addCategory(category);
|
|
|
- return Result.OK("添加成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑
|
|
|
- *
|
|
|
- * @param category
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "基础资料-知识-分类-编辑")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-编辑", notes="基础资料-知识-分类-编辑")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<String> add(@RequestBody Category category) {
|
|
|
+ categoryService.addCategory(category);
|
|
|
+ return Result.OK("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param category
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "基础资料-知识-分类-编辑")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-编辑", notes = "基础资料-知识-分类-编辑")
|
|
|
@RequiresPermissions("kms:kms_bas_article_category:edit")
|
|
|
- @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
- public Result<String> edit(@RequestBody Category category) {
|
|
|
- categoryService.updateCategory(category);
|
|
|
- return Result.OK("编辑成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过id删除
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "基础资料-知识-分类-通过id删除")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-通过id删除", notes="基础资料-知识-分类-通过id删除")
|
|
|
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
|
|
+ public Result<String> edit(@RequestBody Category category) {
|
|
|
+ categoryService.updateCategory(category);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "基础资料-知识-分类-通过id删除")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-通过id删除", notes = "基础资料-知识-分类-通过id删除")
|
|
|
@RequiresPermissions("kms:kms_bas_article_category:delete")
|
|
|
- @DeleteMapping(value = "/delete")
|
|
|
- public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
- categoryService.deleteCategory(id);
|
|
|
- return Result.OK("删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除
|
|
|
- *
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "基础资料-知识-分类-批量删除")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-批量删除", notes="基础资料-知识-分类-批量删除")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ categoryService.deleteCategory(id);
|
|
|
+ return Result.OK("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "基础资料-知识-分类-批量删除")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-批量删除", notes = "基础资料-知识-分类-批量删除")
|
|
|
@RequiresPermissions("kms:kms_bas_article_category:deleteBatch")
|
|
|
- @DeleteMapping(value = "/deleteBatch")
|
|
|
- public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
- this.categoryService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
- return Result.OK("批量删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@AutoLog(value = "基础资料-知识-分类-通过id查询")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-通过id查询", notes="基础资料-知识-分类-通过id查询")
|
|
|
- @GetMapping(value = "/queryById")
|
|
|
- public Result<Category> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
- Category category = categoryService.getById(id);
|
|
|
- if(category==null) {
|
|
|
- return Result.error("未找到对应数据");
|
|
|
- }
|
|
|
- return Result.OK(category);
|
|
|
- }
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
+ this.categoryService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.OK("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "基础资料-知识-分类-通过id查询")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-通过id查询", notes = "基础资料-知识-分类-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<Category> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ Category category = categoryService.getById(id);
|
|
|
+ if (category == null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ return Result.OK(category);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param category
|
|
|
- */
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param category
|
|
|
+ */
|
|
|
@RequiresPermissions("kms:kms_bas_article_category:exportXls")
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
public ModelAndView exportXls(HttpServletRequest request, Category category) {
|
|
|
- return super.exportXls(request, category, Category.class, "基础资料-知识-分类");
|
|
|
+ return super.exportXls(request, category, Category.class, "基础资料-知识-分类");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@RequiresPermissions("kms:kms_bas_article_category:importExcel")
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- return super.importExcel(request, response, Category.class);
|
|
|
+ return super.importExcel(request, response, Category.class);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- //@AutoLog(value = "基础资料-知识-分类-通过id查询")
|
|
|
- @ApiOperation(value="基础资料-知识-分类-通过id查询", notes="基础资料-知识-分类-通过id查询")
|
|
|
- @GetMapping(value = "/queryParentNodeById")
|
|
|
- public Result<List<Category>> queryParentNodeById(@RequestParam(name="id",required=true) String id) {
|
|
|
- return Result.OK(categoryService.queryParentNodeById(id));
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@AutoLog(value = "基础资料-知识-分类-通过id查询")
|
|
|
+ @ApiOperation(value = "基础资料-知识-分类-通过id查询", notes = "基础资料-知识-分类-通过id查询")
|
|
|
+ @GetMapping(value = "/queryParentNodeById")
|
|
|
+ public Result<List<Category>> queryParentNodeById(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ return Result.OK(categoryService.queryParentNodeById(id));
|
|
|
+ }
|
|
|
}
|