package com.fs.his.mapper;

import java.util.List;

import com.fs.common.core.domain.R;
import com.fs.his.domain.FsHealthTongue;
import com.fs.his.param.FsHealthTongueListUParam;
import com.fs.his.param.FsHealthTongueParam;
import com.fs.his.param.FsHealthTongueUParam;
import com.fs.his.vo.FsHealthTongueListUVO;
import com.fs.his.vo.FsHealthTongueListVO;
import com.fs.his.vo.FsHealthTongueUVO;
import org.apache.ibatis.annotations.Select;

/**
 * 舌苔Mapper接口
 *
 * @author fs
 * @date 2024-09-19
 */
public interface FsHealthTongueMapper
{
    /**
     * 查询舌苔
     *
     * @param id 舌苔主键
     * @return 舌苔
     */
    public FsHealthTongue selectFsHealthTongueById(Long id);

    /**
     * 查询舌苔列表
     *
     * @param fsHealthTongue 舌苔
     * @return 舌苔集合
     */
    public List<FsHealthTongue> selectFsHealthTongueList(FsHealthTongue fsHealthTongue);

    /**
     * 新增舌苔
     *
     * @param fsHealthTongue 舌苔
     * @return 结果
     */
    public int insertFsHealthTongue(FsHealthTongue fsHealthTongue);

    /**
     * 修改舌苔
     *
     * @param fsHealthTongue 舌苔
     * @return 结果
     */
    public int updateFsHealthTongue(FsHealthTongue fsHealthTongue);

    /**
     * 删除舌苔
     *
     * @param id 舌苔主键
     * @return 结果
     */
    public int deleteFsHealthTongueById(Long id);

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

    @Select("select  * from fs_health_tongue where user_id=#{userId}")
    List<FsHealthTongueListUVO> selectFsHealthTongueUListVO(FsHealthTongueListUParam param);
    @Select("select  count(1) from fs_health_tongue where user_id=#{userId} and DATE(create_time) = CURDATE()")
    Long selectFsHealthTongueCountByUserId(Long userId);

    @Select("select  count(1) from fs_health_tongue where user_id=#{userId}")
    Long selectFsHealthTongueAllCountByUserId(Long userId);

    @Select("select item_type_json FROM fs_test_temp WHERE temp_code ='C1694077002122'")
    String selectTypeJSON();
    @Select("select  t.*,u.avatar from fs_health_tongue t LEFT JOIN fs_user u on u.user_id=t.user_id  where t.user_id=#{userId} order by t.id desc limit 1")
    FsHealthTongueUVO selectFsHealthTongueByUserId(long userId);

    @Select({"<script> " +
            " select t.*,u.phone from fs_health_tongue t left join fs_user u on u.user_id =t.user_id where 1=1 " +
            " <if test=\"userId != null \"> and t.user_id = #{userId}</if>     " +
            " <if test=\"name != null  and name != ''\"> and t.name like concat('%', #{name}, '%')</if> " +
            " <if test=\"phone != null  and phone != ''\"> and u.phone = #{phone}</if>" +
            " <if test=\"sex != null \"> and t.sex = #{sex}</if> " +
            "order by id desc" +
            "</script>"})
    List<FsHealthTongueListVO> selectFsHealthTongueListVO(FsHealthTongueParam param);
    @Select("select  t.*,u.avatar from fs_health_tongue t LEFT JOIN fs_user u on u.user_id=t.user_id where t.id=#{id} ")
    FsHealthTongueUVO selectFsHealthTongueUVOById(Long id);

}
