SysDepartmentMapper.java 910 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * 爱组搭 http://aizuda.com 低代码组件化开发平台
  3. * ------------------------------------------
  4. * 受知识产权保护,请勿删除版权申明
  5. */
  6. package com.aizuda.boot.system.mapper;
  7. import com.aizuda.service.mapper.CrudMapper;
  8. import com.aizuda.boot.system.entity.SysDepartment;
  9. import org.apache.ibatis.annotations.Mapper;
  10. import org.apache.ibatis.annotations.Param;
  11. import org.apache.ibatis.annotations.Select;
  12. import java.util.List;
  13. /**
  14. * <p>
  15. * 部门 Mapper 接口
  16. * </p>
  17. *
  18. * @author 青苗
  19. * @since 2021-11-07
  20. */
  21. @Mapper
  22. public interface SysDepartmentMapper extends CrudMapper<SysDepartment> {
  23. /**
  24. * 根据 id 递归子类集合
  25. */
  26. @Select("WITH RECURSIVE r AS (SELECT id FROM sys_department WHERE id=#{id} UNION ALL SELECT c.id FROM sys_department c JOIN r ON c.pid=r.id) SELECT id FROM r")
  27. List<Long> selectIdsRecursive(@Param("id") Long id);
  28. }