package thyyxxk.webserver.dao.his.redislike;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.login.UserInfo;

import java.util.List;

@Mapper
public interface RedisLikeDao {

    @Select("select rtrim(name) from a_employee_mi with(nolock) where code=#{code}")
    String selectEmployeeName(@Param("code") String code);

    @Select("select rtrim(name) from zd_unit_code with(nolock) where code=#{code}")
    String selectDeptName(@Param("code") String code);

    @Select("select (select rtrim(t.name) from zd_unit_code t where t.code=dept_code ) + '-' + " +
            "rtrim(name) from a_employee_mi with(nolock) where code=#{code}")
    String selectDeptAndUser(@Param("code") String code);

    @Select("select code=(select b.name from t_region b where b.code=a.parent_code),a.name from t_region a where code=#{code}")
    CodeName selectAdmdvsNameAndParentName(@Param("code") String code);

    @Select("select name,code='' from t_si_admdvs where code=#{code}")
    CodeName selectAdmdvsName(@Param("code") String code);

    @Select("select wjw_code from zd_anaesthesia where code=#{code}")
    String selectWjwAnaesthesia(@Param("code") String code);

    @Select("select wjw_code from zd_unit_code where code=#{code}")
    String selectWjwDepartment(@Param("code") String code);

    @Select("select wjw_code from zd_nation_code where code=#{code}")
    String selectWjwNation(@Param("code") String code);

    @Select("select rtrim(name) from zd_country_code where code=#{code}")
    String selectCountryName(@Param("code") String code);

    @Select("select a.code," +
            " a.name," +
            " password," +
            " a.code_rs,rtrim(b.yb_code) as ybCode," +
            " rtrim(b.dept_code) as deptCode," +
            " cast(isnull(NULLIF(doctor_xz_yp, ''), 0) as int) doctor_xz_yp " +
            "from dj_user_base a, a_employee_mi b where a.code=#{code} and isnull(b.del_flag,0)!=1 and a.code=b.code")
    UserInfo selectUserInfo(@Param("code") String code);

    @Select("select role_id from dj_user_role where user_code=#{code}")
    List<Integer> selectUserRoles(@Param("code") String code);
}
