package com.nursinghome.mapper;

import com.nursinghome.entity.HealthRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HealthRecordMapper {
    @Insert("INSERT INTO health_record(elder_id, nurse_id, temperature, bp_systolic, bp_diastolic, heart_rate, note, record_time, created_at) VALUES(#{elderId}, #{nurseId}, #{temperature}, #{bpSystolic}, #{bpDiastolic}, #{heartRate}, #{note}, #{recordTime}, NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(HealthRecord record);

    @Select("SELECT * FROM health_record WHERE elder_id = #{elderId} ORDER BY record_time DESC")
    List<HealthRecord> listByElderId(Long elderId);

    @Select("<script>SELECT * FROM health_record WHERE elder_id IN <foreach collection='elderIds' item='id' open='(' separator=',' close=')'>#{id}</foreach> ORDER BY record_time DESC</script>")
    List<HealthRecord> listByElderIds(@Param("elderIds") List<Long> elderIds);
}
