package com.fs.company.mapper;

import com.fs.company.domain.CompanyDept;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 部门Mapper接口
 * 
 * @author fs
 * @date 2021-05-25
 */
public interface CompanyDeptMapper 
{
    /**
     * 查询部门
     * 
     * @param deptId 部门ID
     * @return 部门
     */
    public CompanyDept selectCompanyDeptById(Long deptId);

    /**
     * 查询部门列表
     * 
     * @param companyDept 部门
     * @return 部门集合
     */
    public List<CompanyDept> selectCompanyDeptList(CompanyDept companyDept);

    /**
     * 新增部门
     * 
     * @param companyDept 部门
     * @return 结果
     */
    public int insertCompanyDept(CompanyDept companyDept);

    /**
     * 修改部门
     * 
     * @param companyDept 部门
     * @return 结果
     */
    public int updateCompanyDept(CompanyDept companyDept);

    /**
     * 删除部门
     * 
     * @param deptId 部门ID
     * @return 结果
     */
    public int deleteCompanyDeptById(Long deptId);

    /**
     * 批量删除部门
     * 
     * @param deptIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanyDeptByIds(Long[] deptIds);

    List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);

    @Select("select count(1) from company_dept where company_id=#{companyId} and dept_name =#{deptName} ")
    int checkDeptNameUnique(@Param("companyId")Long companyId, @Param("deptName")String deptName);

    int checkDeptExistUser(Long deptId);

    int hasChildByDeptId(Long deptId);

    int selectNormalChildrenDeptById(Long deptId);

    List<CompanyDept> selectChildrenDeptById(Long deptId);

    int updateDeptChildren(@Param("depts")List<CompanyDept> children);

    int updateDeptStatus(CompanyDept dept);
    @Select("select dept_name from company_dept where FIND_IN_SET(dept_id,#{ids}) ")
    List<String> selectCompanyDeptNamesByIds(String ids);

    @Select("select company_id from company_dept where dept_id =#{deptId} ")
    Long selectCompanyDeptByIdCompany(Long deptId);
}
