package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalTreatOrderLogs;
import com.fs.hospital.vo.HospitalTreatOrderLogsHVO;
import org.apache.ibatis.annotations.Select;

/**
 * 治疗记录Mapper接口
 *
 * @author fs
 * @date 2024-03-26
 */
public interface HospitalTreatOrderLogsMapper
{
    /**
     * 查询治疗记录
     *
     * @param logsId 治疗记录主键
     * @return 治疗记录
     */
    public HospitalTreatOrderLogs selectHospitalTreatOrderLogsByLogsId(Long logsId);

    /**
     * 查询治疗记录列表
     *
     * @param hospitalTreatOrderLogs 治疗记录
     * @return 治疗记录集合
     */
    public List<HospitalTreatOrderLogs> selectHospitalTreatOrderLogsList(HospitalTreatOrderLogs hospitalTreatOrderLogs);

    /**
     * 新增治疗记录
     *
     * @param hospitalTreatOrderLogs 治疗记录
     * @return 结果
     */
    public int insertHospitalTreatOrderLogs(HospitalTreatOrderLogs hospitalTreatOrderLogs);

    /**
     * 修改治疗记录
     *
     * @param hospitalTreatOrderLogs 治疗记录
     * @return 结果
     */
    public int updateHospitalTreatOrderLogs(HospitalTreatOrderLogs hospitalTreatOrderLogs);

    /**
     * 删除治疗记录
     *
     * @param logsId 治疗记录主键
     * @return 结果
     */
    public int deleteHospitalTreatOrderLogsByLogsId(Long logsId);

    /**
     * 批量删除治疗记录
     *
     * @param logsIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalTreatOrderLogsByLogsIds(Long[] logsIds);



    @Select({"<script> " +
            "select l.*,u.user_name from hospital_treat_order_logs l LEFT JOIN hospital_user u ON  u.user_id=l.user_id"+
            "<where>   " +
            "            <if test=\"orderId != null \"> and l.order_id = #{orderId}</if>\n" +
            "            <if test=\"userId != null \"> and l.user_id = #{userId}</if>\n" +
            "            <if test=\"content != null  and content != ''\"> and l.content = #{content}</if>\n" +
            "            <if test=\"logsJson != null  and logsJson != ''\"> and l.logs_json = #{logsJson}</if>\n" +
            "            <if test=\"hospitalId != null \"> and l.hospital_id = #{hospitalId}</if>\n" +
            "            <if test=\"count != null \"> and l.count = #{count}</if>\n" +
            "        </where>"+
            "order by l.logs_id desc"+
            "</script>"})
    List<HospitalTreatOrderLogsHVO> selectHospitalTreatOrderLogsListVO(HospitalTreatOrderLogs hospitalTreatOrderLogs);
}
