package com.lz.modules.app.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lz.modules.app.dto.ReportProgressListDto;
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.job.model.responseBo.DepartmentStaffBo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 部门与员工关联表
 *
 * @author fumeiai
 * @email fumeiai@linzikg.com
 * @date 2020-04-29 20:59:20
 */
@Mapper
public interface DepartmentsStaffRelateDao extends BaseMapper<DepartmentsStaffRelateEntity> {

    /**
     * 批量插入部门员工关系数据
     *
     * @param relates
     * @return
     */
    int addDepartmentStaffRelateBatch(@Param("relates") List<DepartmentsStaffRelateEntity> relates);

    /**
     * 根据用户id获取部门id信息
     */
    String getRelateInfoByStaffId(@Param("staffId") Long staffId);

    /**
     * 根据staffId修改departmentId
     *
     * @param departmentId
     * @param staffId
     * @return
     */
    int updateByStaffId(@Param("departmentId") String departmentId, @Param("staffId") DepartmentStaffBo staffId);

    void deleteAllRelates();

    String getRelateByStaffIdAndDepartmentId(@Param("staffId") Long staffId, @Param("departmentId") String departmentId);

    List<DepartmentsStaffRelateEntity> selectByDepartmentIds(@Param("departmentIds") List<String> departmentIds);

    List<DepartmentsStaffRelateEntity> selectByStaffIds(@Param("staffIds") List<Long> staffIds);

    List<DepartmentsStaffRelateEntity> selectAll();

    DepartmentsStaffRelateEntity selectLastDepartmentByStaffId(@Param("staffId") Long staffId);

    DepartmentsStaffRelateEntity selectLeaderByDepartmentId(@Param("departmentId") String departmentId);

    DepartmentsStaffRelateEntity selectDepartmentByDepartmentId(@Param("departmentId") String departmentId);

    DepartmentsStaffRelateEntity selectByStaffId(@Param("staffId") Long staffId);

    List<ReportProgressListDto> getDepartmentNameByStaffIds(@Param("staffIds") List<String>  staffIds);

    List<String> selectStaffIdsByDepartments(@Param("deparmentIds")List<String> deparmentIds);

    List<StaffEntity> selectLeadersByDepartmentId(@Param("depId") String depId);

    List<Long> selectLongStaffIdsByDepartments(@Param("departmentIds") List<String> departmentIds);

    List<Long> selectAllStaffIds();
}
