package org.dromara.main.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.main.domain.MainPostCandidateReview;
import org.dromara.main.domain.vo.StudentJobRecordVo;

import java.util.List;

@Mapper
public interface MainPostCandidateReviewMapper extends BaseMapperPlus<MainPostCandidateReview, MainPostCandidateReview> {

    /**
     * 查询学员任职记录列表（关联岗位表和租户表）
     */
    @Select("""
        SELECT r.id,
               r.candidate_id,
               r.tenant_id,
               r.post_id,
               r.student_id,
               r.employment_status,
               r.entry_time,
               r.leave_time,
               r.leave_reason,
               t.company_name AS companyName,
               p.post_name AS postName,
               p.post_type AS postType
          FROM main_post_candidate_review r
          LEFT JOIN sys_tenant t ON t.tenant_id = r.tenant_id
          LEFT JOIN main_position p ON p.id = r.post_id AND p.del_flag = '0'
         WHERE r.student_id = #{studentId}
           AND r.del_flag = '0'
         ORDER BY r.create_time DESC
        """)
    List<StudentJobRecordVo> selectJobListByStudentId(@Param("studentId") Long studentId);
}
