package com.engine.organization.mapper.department;

import com.engine.organization.entity.department.po.DepartmentPO;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @Author weaver_cl
 * @description:
 * @Date 2022/5/20
 * @Version V1.0
 **/
public interface DepartmentMapper {
    List<DepartmentPO> getDeptListByPId(@Param("PId") Integer PId);

    /**
     * 查询所有数据
     *
     * @return
     */
    List<DepartmentPO> listAll(@Param("orderSql") String orderSql);

    /**
     * 根据No查询数据
     *
     * @param departmentCode
     * @return
     */
    List<DepartmentPO> listByNo(@Param("departmentCode") String departmentCode);

    /**
     * 根据搜索条件查询数据
     *
     * @return
     */
    List<DepartmentPO> listByFilter(@Param("departmentPO") DepartmentPO departmentPO, @Param("orderSql") String orderSql);

    /**
     * 浏览按钮展示数据用
     *
     * @param ids
     * @return
     */
    List<Map<String, Object>> listDeptsByIds(@Param("ids") Collection<Long> ids);

    List<DepartmentPO> getDeptsByIds(@Param("ids") Collection<Long> ids);

    /**
     * 根据ID查询数据
     *
     * @param id
     * @return
     */
    DepartmentPO getDeptById(@Param("id") Integer id);

    /**
     * 根据ID查询名称
     *
     * @param id
     * @return
     */
    String getDeptNameById(@Param("id") Integer id);

    /**
     * 查询所有被引用的ID
     *
     * @return
     */
    List<String> listUsedId();

    /**
     * 获取最大排序
     *
     * @return
     */
    Double getMaxShowOrder();

    /**
     * 根据名称、上级 查询部门元素
     *
     * @param departmentName
     * @param subCompanyId1
     * @param supDepId
     * @return
     */
    Integer getIdByNameAndPid(@Param("departmentName") String departmentName, @Param("subCompanyId1") Integer subCompanyId1, @Param("supDepId") Integer supDepId);

    int checkRepeatNo(@Param("departmentCode") String departmentCode, @Param("id") Long id);

    List<String> hasSubs();

    int countUsedInJob(@Param("supDepId") Long supDepId);

    String getIdByDepartmentCode(@Param("departmentCode") String departmentCode);

    String getDepartmentPrincipal(@Param("deptId") Integer deptId);

}
