package com.fs.hospital.mapper;

import java.util.List;

import com.fs.hospital.domain.Hospital;
import com.fs.hospital.param.HospitalParam;
import com.fs.hospital.vo.HospitalHVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 诊所Mapper接口
 *
 * @author fs
 * @date 2024-02-26
 */
public interface HospitalMapper
{
    /**
     * 查询诊所
     *
     * @param hospitalId 诊所主键
     * @return 诊所
     */
    public Hospital selectHospitalByHospitalId(Long hospitalId);

    /**
     * 查询诊所列表
     *
     * @param hospital 诊所
     * @return 诊所集合
     */
    public List<Hospital> selectHospitalList(Hospital hospital);

    /**
     * 新增诊所
     *
     * @param hospital 诊所
     * @return 结果
     */
    public int insertHospital(Hospital hospital);

    /**
     * 修改诊所
     *
     * @param hospital 诊所
     * @return 结果
     */
    public int updateHospital(Hospital hospital);

    /**
     * 删除诊所
     *
     * @param hospitalId 诊所主键
     * @return 结果
     */
    public int deleteHospitalByHospitalId(Long hospitalId);

    /**
     * 批量删除诊所
     *
     * @param hospitalIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalByHospitalIds(Long[] hospitalIds);

    @Select({"<script> " +
            "select h.*,u.user_name " +
            "from hospital h left join hospital_user u on u.user_id=h.user_id " +
            "where 1=1 " +
            "<if test = 'maps.hospitalName != null and  maps.hospitalName !=\"\"     '> " +
            "and h.hospital_name like CONCAT('%',#{maps.hospitalName},'%') " +
            "</if>" +
            "<if test = 'maps.status != null   '> " +
            "and h.status = #{maps.status}" +
            "</if>" +
            "order by h.hospital_id desc " +
            "</script>"})
    List<HospitalHVO> selectHospitalVOList(@Param("maps") HospitalParam param);
}
