package cn.hnthyy.thmz.mapper.his;

import cn.hnthyy.thmz.entity.his.Employee;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface EmployeeMapper {
    /**
     * 根据医生工号查询医生
     *
     * @param codeRs
     * @return
     */
    @Select(" select top 1 rtrim(code) employeeCode,rtrim(name) employeeName,del_flag from a_employee_mi  where  code_rs =#{codeRs}")
    Employee selectByCodeRs(@Param("rsCode") String codeRs);


    /**
     * 根据部门id列表查询医生列表
     *
     * @param depts 部门id列表
     * @return
     */
    @Select({"<script>",
            "select rtrim(code) employee_code,rtrim(name) employee_name,del_flag from a_employee_mi ",
            "<when test='depts!=null'>",
            " where dept_code in",
            "<foreach item='item' index='index' collection='depts' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</when>",
            "</script>"})
    List<Employee> selectEmployeeByDepts(@Param("depts") List<String> depts);


    /**
     * 根据部门id查询医生列表
     *
     * @param dept 部门id
     * @return
     */
    @Select({"<script>",
            "select rtrim(code) employee_code,rtrim(name) employee_name,del_flag from a_employee_mi",
            "<when test='dept!=null'>",
            " where dept_code =#{dept}",
            "</when>",
            "</script>"})
    List<Employee> selectEmployeeByDept(@Param("dept") String dept);


    /**
     * 根据医生姓名查询医生
     *
     * @param name
     * @return
     */
    @Select(" select top 1 rtrim(code) employeeCode,rtrim(name) employeeName,del_flag from a_employee_mi  where  name =#{name}")
    Employee selectByUserName(@Param("name") String name);


    /**
     * 根据医生编号查询医生
     *
     * @param code
     * @return
     */
    @Select(" select top 1 rtrim(code) employeeCode,rtrim(name) employeeName,del_flag from a_employee_mi  where  code =#{code}")
    Employee selectByUserCode(@Param("code") String code);
}
