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> getDeptListByCompId(@Param("parentComp") Integer parentComp);

    List<DepartmentPO> getDeptListByPId(@Param("PId") Long PId);

    int countChildByPID(@Param("pid") Long pid);


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

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

    /**
     * 根据搜索条件查询数据
     *
     * @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") Long id);

    /**
     * 根据UUID查询数据
     *
     * @param uuid
     * @return
     */
    DepartmentPO getDepartmentByUUID(@Param("uuid") String uuid);

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

    /**
     * 添加数据
     *
     * @param departmentPO
     * @return
     */
    int insertIgnoreNull(DepartmentPO departmentPO);

    /**
     * 更新主表内容
     *
     * @param departmentPO
     * @return
     */
    int updateBaseDept(DepartmentPO departmentPO);

    /**
     * 更新禁用标记
     *
     * @param departmentPO
     * @return
     */
    int updateForbiddenTagById(DepartmentPO departmentPO);

    /**
     * 批量删除
     *
     * @param ids
     */
    int deleteByIds(@Param("ids") Collection<Long> ids);

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

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

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

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