package com.mosquito.project.permission;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * 部门Repository
 */
@Repository
public interface DepartmentRepository extends JpaRepository<SysDepartment, Long> {

    /**
     * 根据父部门ID查询
     */
    List<SysDepartment> findByParentId(Long parentId);

    /**
     * 根据部门代码查询
     */
    Optional<SysDepartment> findByDeptCode(String deptCode);

    /**
     * 检查部门代码是否存在
     */
    boolean existsByDeptCode(String deptCode);
}
