package com.fs.his.mapper;

import java.util.List;
import com.fs.his.domain.FsHealthData;
import com.fs.his.param.FsHealthDataParam;
import com.fs.his.param.FsHealthDataUParam;
import com.fs.his.vo.FsHealthDataListUVO;
import com.fs.his.vo.FsHealthDataListVO;
import org.apache.ibatis.annotations.Select;

/**
 * 健康数据Mapper接口
 *
 * @author fs
 * @date 2024-09-02
 */
public interface FsHealthDataMapper
{
    /**
     * 查询健康数据
     *
     * @param id 健康数据主键
     * @return 健康数据
     */
    public FsHealthData selectFsHealthDataById(Long id);

    /**
     * 查询健康数据列表
     *
     * @param fsHealthData 健康数据
     * @return 健康数据集合
     */
    public List<FsHealthData> selectFsHealthDataList(FsHealthData fsHealthData);

    /**
     * 新增健康数据
     *
     * @param fsHealthData 健康数据
     * @return 结果
     */
    public int insertFsHealthData(FsHealthData fsHealthData);

    /**
     * 修改健康数据
     *
     * @param fsHealthData 健康数据
     * @return 结果
     */
    public int updateFsHealthData(FsHealthData fsHealthData);

    /**
     * 删除健康数据
     *
     * @param id 健康数据主键
     * @return 结果
     */
    public int deleteFsHealthDataById(Long id);

    /**
     * 批量删除健康数据
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsHealthDataByIds(Long[] ids);

    @Select("select * from fs_health_data where user_id=#{userId} order by id desc")
    List<FsHealthDataListUVO> selectFsHealthDataListUVO(FsHealthDataUParam param);
    @Select({"<script> " +
            "select h.*,u.nick_name, CONCAT(LEFT(u.phone, 3), '****', RIGHT(u.phone, 4)) AS phone from fs_health_data h left join fs_user u on h.user_id=u.user_id "+
            "<where> " +
            "  <if test=\"userId != null \"> and h.user_id = #{userId}</if>" +
            "  <if test=\"phone != null \"> and u.phone = #{phone}</if>" +
            "</where> order by h.id desc "+
            "</script>"})
    List<FsHealthDataListVO> selectFsHealthDataListVO(FsHealthDataParam fsHealthData);
}
