yangfeng 1 vuosi sitten
vanhempi
commit
a5771bccd3

+ 285 - 0
web/src/main/java/com/ynfy/buss/course/category/controller/CourseCategoryController.java

@@ -0,0 +1,285 @@
+package com.ynfy.buss.course.category.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ynfy.buss.course.category.entity.CourseCategory;
+import com.ynfy.buss.course.category.service.ICourseCategoryService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+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.common.system.vo.SelectTreeModel;
+import org.jeecg.common.util.oConvertUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @Description: 课程分类
+ * @Author: jeecg-boot
+ * @Date: 2024-01-21
+ * @Version: V1.0
+ */
+@Api(tags = "课程分类")
+@RestController
+@RequestMapping("/course/courseCategory")
+@Slf4j
+public class CourseCategoryController extends JeecgController<CourseCategory, ICourseCategoryService> {
+    @Autowired
+    private ICourseCategoryService courseCategoryService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param courseCategory
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "课程分类-分页列表查询")
+    @ApiOperation(value = "课程分类-分页列表查询", notes = "课程分类-分页列表查询")
+    @GetMapping(value = "/rootList")
+    public Result<IPage<CourseCategory>> queryPageList(CourseCategory courseCategory,
+                                                       @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<CourseCategory> queryWrapper = QueryGenerator.initQueryWrapper(courseCategory, req.getParameterMap());
+            List<CourseCategory> list = courseCategoryService.queryTreeListNoPage(queryWrapper);
+            IPage<CourseCategory> pageList = new Page<>(1, 10, list.size());
+            pageList.setRecords(list);
+            return Result.OK(pageList);
+        } else {
+            String parentId = courseCategory.getPid();
+            if (oConvertUtils.isEmpty(parentId)) {
+                parentId = "0";
+            }
+            courseCategory.setPid(null);
+            QueryWrapper<CourseCategory> queryWrapper = QueryGenerator.initQueryWrapper(courseCategory, req.getParameterMap());
+            // 使用 eq 防止模糊查询
+            queryWrapper.eq("pid", parentId);
+            Page<CourseCategory> page = new Page<CourseCategory>(pageNo, pageSize);
+            IPage<CourseCategory> pageList = courseCategoryService.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 = courseCategoryService.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)
+    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 = courseCategoryService.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 = courseCategoryService.queryListByPid(tsm.getKey());
+            if (temp != null && temp.size() > 0) {
+                tsm.setChildren(temp);
+                loadAllChildren(temp);
+            }
+        }
+    }
+
+    /**
+     * 获取子数据
+     *
+     * @param courseCategory
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "课程分类-获取子数据")
+    @ApiOperation(value = "课程分类-获取子数据", notes = "课程分类-获取子数据")
+    @GetMapping(value = "/childList")
+    public Result<IPage<CourseCategory>> queryPageList(CourseCategory courseCategory, HttpServletRequest req) {
+        QueryWrapper<CourseCategory> queryWrapper = QueryGenerator.initQueryWrapper(courseCategory, req.getParameterMap());
+        List<CourseCategory> list = courseCategoryService.list(queryWrapper);
+        IPage<CourseCategory> pageList = new Page<>(1, 10, list.size());
+        pageList.setRecords(list);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 批量查询子节点
+     *
+     * @param parentIds 父ID(多个采用半角逗号分割)
+     * @param parentIds
+     * @return 返回 IPage
+     * @return
+     */
+    //@AutoLog(value = "课程分类-批量获取子数据")
+    @ApiOperation(value = "课程分类-批量获取子数据", notes = "课程分类-批量获取子数据")
+    @GetMapping("/getChildListBatch")
+    public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
+        try {
+            QueryWrapper<CourseCategory> queryWrapper = new QueryWrapper<>();
+            List<String> parentIdList = Arrays.asList(parentIds.split(","));
+            queryWrapper.in("pid", parentIdList);
+            List<CourseCategory> list = courseCategoryService.list(queryWrapper);
+            IPage<CourseCategory> pageList = new Page<>(1, 10, list.size());
+            pageList.setRecords(list);
+            return Result.OK(pageList);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("批量查询子节点失败:" + e.getMessage());
+        }
+    }
+
+    /**
+     * 添加
+     *
+     * @param courseCategory
+     * @return
+     */
+    @AutoLog(value = "课程分类-添加")
+    @ApiOperation(value = "课程分类-添加", notes = "课程分类-添加")
+    //@RequiresPermissions("course.category:course_category:add")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody CourseCategory courseCategory) {
+        courseCategoryService.addCourseCategory(courseCategory);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param courseCategory
+     * @return
+     */
+    @AutoLog(value = "课程分类-编辑")
+    @ApiOperation(value = "课程分类-编辑", notes = "课程分类-编辑")
+    //@RequiresPermissions("course.category:course_category:edit")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody CourseCategory courseCategory) {
+        courseCategoryService.updateCourseCategory(courseCategory);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "课程分类-通过id删除")
+    @ApiOperation(value = "课程分类-通过id删除", notes = "课程分类-通过id删除")
+    //@RequiresPermissions("course.category:course_category:delete")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        courseCategoryService.deleteCourseCategory(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "课程分类-批量删除")
+    @ApiOperation(value = "课程分类-批量删除", notes = "课程分类-批量删除")
+    //@RequiresPermissions("course.category:course_category:deleteBatch")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.courseCategoryService.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<CourseCategory> queryById(@RequestParam(name = "id", required = true) String id) {
+        CourseCategory courseCategory = courseCategoryService.getById(id);
+        if (courseCategory == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(courseCategory);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param courseCategory
+     */
+    //@RequiresPermissions("course.category:course_category:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, CourseCategory courseCategory) {
+        return super.exportXls(request, courseCategory, CourseCategory.class, "课程分类");
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    //@RequiresPermissions("course.category:course_category:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, CourseCategory.class);
+    }
+
+}

+ 90 - 0
web/src/main/java/com/ynfy/buss/course/category/entity/CourseCategory.java

@@ -0,0 +1,90 @@
+package com.ynfy.buss.course.category.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description: 课程分类
+ * @Author: jeecg-boot
+ * @Date: 2024-01-21
+ * @Version: V1.0
+ */
+@Data
+@TableName("course_category")
+@ApiModel(value = "course_category对象", description = "课程分类")
+public class CourseCategory implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+    /**
+     * 名称
+     */
+    @Excel(name = "名称", width = 15)
+    @ApiModelProperty(value = "名称")
+    private String name;
+    /**
+     * 图片路径
+     */
+    @Excel(name = "图片路径", width = 15)
+    @ApiModelProperty(value = "图片路径")
+    private String imageUrl;
+    /**
+     * 父级节点
+     */
+    @Excel(name = "父级节点", width = 15)
+    @ApiModelProperty(value = "父级节点")
+    private String pid;
+    /**
+     * 排序
+     */
+    @Excel(name = "排序", width = 15)
+    @ApiModelProperty(value = "排序")
+    private Integer sort;
+    /**
+     * 是否有子节点
+     */
+    @Excel(name = "是否有子节点", width = 15, dicCode = "yn")
+    @Dict(dicCode = "yn")
+    @ApiModelProperty(value = "是否有子节点")
+    private String hasChild;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**
+     * 创建日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private Date createTime;
+    /**
+     * 更新人
+     */
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+    /**
+     * 更新日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+}

+ 36 - 0
web/src/main/java/com/ynfy/buss/course/category/mapper/CourseCategoryMapper.java

@@ -0,0 +1,36 @@
+package com.ynfy.buss.course.category.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ynfy.buss.course.category.entity.CourseCategory;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.common.system.vo.SelectTreeModel;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 课程分类
+ * @Author: jeecg-boot
+ * @Date: 2024-01-21
+ * @Version: V1.0
+ */
+public interface CourseCategoryMapper extends BaseMapper<CourseCategory> {
+
+    /**
+     * 编辑节点状态
+     *
+     * @param id
+     * @param status
+     */
+    void updateTreeNodeStatus(@Param("id") String id, @Param("status") String status);
+
+    /**
+     * 【vue3专用】根据父级ID查询树节点数据
+     *
+     * @param pid
+     * @param query
+     * @return
+     */
+    List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query);
+
+}

+ 25 - 0
web/src/main/java/com/ynfy/buss/course/category/mapper/xml/CourseCategoryMapper.xml

@@ -0,0 +1,25 @@
+<?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.ynfy.buss.course.category.mapper.CourseCategoryMapper">
+
+	<update id="updateTreeNodeStatus" parameterType="java.lang.String">
+		update course_category set has_child = #{status} where id = #{id}
+	</update>
+
+  	<!-- 【vue3专用】 -->
+	<select id="queryListByPid" parameterType="java.lang.Object" resultType="org.jeecg.common.system.vo.SelectTreeModel">
+		select
+		  id as "key",
+		  name as "title",
+		  (case when has_child = '1' then 0 else 1 end) as isLeaf,
+		  pid as parentId
+		from course_category
+		where pid = #{pid}
+		<if test="query != null">
+			<foreach collection="query.entrySet()" item="value" index="key">
+				and ${key} = #{value}
+			</foreach>
+		</if>
+	</select>
+
+</mapper>

+ 81 - 0
web/src/main/java/com/ynfy/buss/course/category/service/ICourseCategoryService.java

@@ -0,0 +1,81 @@
+package com.ynfy.buss.course.category.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ynfy.buss.course.category.entity.CourseCategory;
+import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.system.vo.SelectTreeModel;
+
+import java.util.List;
+
+/**
+ * @Description: 课程分类
+ * @Author: jeecg-boot
+ * @Date: 2024-01-21
+ * @Version: V1.0
+ */
+public interface ICourseCategoryService extends IService<CourseCategory> {
+
+    /**
+     * 根节点父ID的值
+     */
+    public static final String ROOT_PID_VALUE = "0";
+
+    /**
+     * 树节点有子节点状态值
+     */
+    public static final String HASCHILD = "1";
+
+    /**
+     * 树节点无子节点状态值
+     */
+    public static final String NOCHILD = "0";
+
+    /**
+     * 新增节点
+     *
+     * @param courseCategory
+     */
+    void addCourseCategory(CourseCategory courseCategory);
+
+    /**
+     * 修改节点
+     *
+     * @param courseCategory
+     * @throws JeecgBootException
+     */
+    void updateCourseCategory(CourseCategory courseCategory) throws JeecgBootException;
+
+    /**
+     * 删除节点
+     *
+     * @param id
+     * @throws JeecgBootException
+     */
+    void deleteCourseCategory(String id) throws JeecgBootException;
+
+    /**
+     * 查询所有数据,无分页
+     *
+     * @param queryWrapper
+     * @return List<CourseCategory>
+     */
+    List<CourseCategory> queryTreeListNoPage(QueryWrapper<CourseCategory> queryWrapper);
+
+    /**
+     * 【vue3专用】根据父级编码加载分类字典的数据
+     *
+     * @param parentCode
+     * @return
+     */
+    List<SelectTreeModel> queryListByCode(String parentCode);
+
+    /**
+     * 【vue3专用】根据pid查询子节点集合
+     *
+     * @param pid
+     * @return
+     */
+    List<SelectTreeModel> queryListByPid(String pid);
+
+}

+ 223 - 0
web/src/main/java/com/ynfy/buss/course/category/service/impl/CourseCategoryServiceImpl.java

@@ -0,0 +1,223 @@
+package com.ynfy.buss.course.category.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ynfy.buss.course.category.entity.CourseCategory;
+import com.ynfy.buss.course.category.mapper.CourseCategoryMapper;
+import com.ynfy.buss.course.category.service.ICourseCategoryService;
+import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.system.vo.SelectTreeModel;
+import org.jeecg.common.util.oConvertUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @Description: 课程分类
+ * @Author: jeecg-boot
+ * @Date: 2024-01-21
+ * @Version: V1.0
+ */
+@Service
+public class CourseCategoryServiceImpl extends ServiceImpl<CourseCategoryMapper, CourseCategory> implements ICourseCategoryService {
+
+    @Override
+    public void addCourseCategory(CourseCategory courseCategory) {
+        //新增时设置hasChild为0
+        courseCategory.setHasChild(ICourseCategoryService.NOCHILD);
+        if (oConvertUtils.isEmpty(courseCategory.getPid())) {
+            courseCategory.setPid(ICourseCategoryService.ROOT_PID_VALUE);
+        } else {
+            //如果当前节点父ID不为空 则设置父节点的hasChildren 为1
+            CourseCategory parent = baseMapper.selectById(courseCategory.getPid());
+            if (parent != null && !"1".equals(parent.getHasChild())) {
+                parent.setHasChild("1");
+                baseMapper.updateById(parent);
+            }
+        }
+        baseMapper.insert(courseCategory);
+    }
+
+    @Override
+    public void updateCourseCategory(CourseCategory courseCategory) {
+        CourseCategory entity = this.getById(courseCategory.getId());
+        if (entity == null) {
+            throw new JeecgBootException("未找到对应实体");
+        }
+        String old_pid = entity.getPid();
+        String new_pid = courseCategory.getPid();
+        if (!old_pid.equals(new_pid)) {
+            updateOldParentNode(old_pid);
+            if (oConvertUtils.isEmpty(new_pid)) {
+                courseCategory.setPid(ICourseCategoryService.ROOT_PID_VALUE);
+            }
+            if (!ICourseCategoryService.ROOT_PID_VALUE.equals(courseCategory.getPid())) {
+                baseMapper.updateTreeNodeStatus(courseCategory.getPid(), ICourseCategoryService.HASCHILD);
+            }
+        }
+        baseMapper.updateById(courseCategory);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteCourseCategory(String id) throws JeecgBootException {
+        //查询选中节点下所有子节点一并删除
+        id = this.queryTreeChildIds(id);
+        if (id.indexOf(",") > 0) {
+            StringBuffer sb = new StringBuffer();
+            String[] idArr = id.split(",");
+            for (String idVal : idArr) {
+                if (idVal != null) {
+                    CourseCategory courseCategory = this.getById(idVal);
+                    String pidVal = courseCategory.getPid();
+                    //查询此节点上一级是否还有其他子节点
+                    List<CourseCategory> dataList = baseMapper.selectList(new QueryWrapper<CourseCategory>().eq("pid", pidVal).notIn("id", Arrays.asList(idArr)));
+                    boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(pidVal) && !sb.toString().contains(pidVal);
+                    if (flag) {
+                        //如果当前节点原本有子节点 现在木有了,更新状态
+                        sb.append(pidVal).append(",");
+                    }
+                }
+            }
+            //批量删除节点
+            baseMapper.deleteBatchIds(Arrays.asList(idArr));
+            //修改已无子节点的标识
+            String[] pidArr = sb.toString().split(",");
+            for (String pid : pidArr) {
+                this.updateOldParentNode(pid);
+            }
+        } else {
+            CourseCategory courseCategory = this.getById(id);
+            if (courseCategory == null) {
+                throw new JeecgBootException("未找到对应实体");
+            }
+            updateOldParentNode(courseCategory.getPid());
+            baseMapper.deleteById(id);
+        }
+    }
+
+    @Override
+    public List<CourseCategory> queryTreeListNoPage(QueryWrapper<CourseCategory> queryWrapper) {
+        List<CourseCategory> dataList = baseMapper.selectList(queryWrapper);
+        List<CourseCategory> mapList = new ArrayList<>();
+        for (CourseCategory data : dataList) {
+            String pidVal = data.getPid();
+            //递归查询子节点的根节点
+            if (pidVal != null && !ICourseCategoryService.NOCHILD.equals(pidVal)) {
+                CourseCategory rootVal = this.getTreeRoot(pidVal);
+                if (rootVal != null && !mapList.contains(rootVal)) {
+                    mapList.add(rootVal);
+                }
+            } else {
+                if (!mapList.contains(data)) {
+                    mapList.add(data);
+                }
+            }
+        }
+        return mapList;
+    }
+
+    @Override
+    public List<SelectTreeModel> queryListByCode(String parentCode) {
+        String pid = ROOT_PID_VALUE;
+        if (oConvertUtils.isNotEmpty(parentCode)) {
+            LambdaQueryWrapper<CourseCategory> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(CourseCategory::getPid, parentCode);
+            List<CourseCategory> list = baseMapper.selectList(queryWrapper);
+            if (list == null || list.size() == 0) {
+                throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!");
+            }
+            if (list.size() > 1) {
+                throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!");
+            }
+            pid = list.get(0).getId();
+        }
+        return baseMapper.queryListByPid(pid, null);
+    }
+
+    @Override
+    public List<SelectTreeModel> queryListByPid(String pid) {
+        if (oConvertUtils.isEmpty(pid)) {
+            pid = ROOT_PID_VALUE;
+        }
+        return baseMapper.queryListByPid(pid, null);
+    }
+
+    /**
+     * 根据所传pid查询旧的父级节点的子节点并修改相应状态值
+     *
+     * @param pid
+     */
+    private void updateOldParentNode(String pid) {
+        if (!ICourseCategoryService.ROOT_PID_VALUE.equals(pid)) {
+            Long count = baseMapper.selectCount(new QueryWrapper<CourseCategory>().eq("pid", pid));
+            if (count == null || count <= 1) {
+                baseMapper.updateTreeNodeStatus(pid, ICourseCategoryService.NOCHILD);
+            }
+        }
+    }
+
+    /**
+     * 递归查询节点的根节点
+     *
+     * @param pidVal
+     * @return
+     */
+    private CourseCategory getTreeRoot(String pidVal) {
+        CourseCategory data = baseMapper.selectById(pidVal);
+        if (data != null && !ICourseCategoryService.ROOT_PID_VALUE.equals(data.getPid())) {
+            return this.getTreeRoot(data.getPid());
+        } else {
+            return data;
+        }
+    }
+
+    /**
+     * 根据id查询所有子节点id
+     *
+     * @param ids
+     * @return
+     */
+    private String queryTreeChildIds(String ids) {
+        //获取id数组
+        String[] idArr = ids.split(",");
+        StringBuffer sb = new StringBuffer();
+        for (String pidVal : idArr) {
+            if (pidVal != null) {
+                if (!sb.toString().contains(pidVal)) {
+                    if (sb.toString().length() > 0) {
+                        sb.append(",");
+                    }
+                    sb.append(pidVal);
+                    this.getTreeChildIds(pidVal, sb);
+                }
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 递归查询所有子节点
+     *
+     * @param pidVal
+     * @param sb
+     * @return
+     */
+    private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) {
+        List<CourseCategory> dataList = baseMapper.selectList(new QueryWrapper<CourseCategory>().eq("pid", pidVal));
+        if (dataList != null && dataList.size() > 0) {
+            for (CourseCategory tree : dataList) {
+                if (!sb.toString().contains(tree.getId())) {
+                    sb.append(",").append(tree.getId());
+                }
+                this.getTreeChildIds(tree.getId(), sb);
+            }
+        }
+        return sb;
+    }
+
+}