package com.fs.doc.mapper;

import java.util.List;
import com.fs.doc.domain.DocRecord;
import com.fs.doc.param.DocRecordParam;
import com.fs.doc.param.DocRecordQueryParam;
import com.fs.doc.vo.DocRecordListQueryVO;
import com.fs.doc.vo.DocRecordVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 记录Mapper接口
 * 
 * @author fs
 * @date 2023-01-09
 */
public interface DocRecordMapper 
{
    /**
     * 查询记录
     * 
     * @param recordId 记录ID
     * @return 记录
     */
    public DocRecord selectDocRecordById(Long recordId);

    /**
     * 查询记录列表
     * 
     * @param docRecord 记录
     * @return 记录集合
     */
    public List<DocRecord> selectDocRecordList(DocRecord docRecord);

    /**
     * 新增记录
     * 
     * @param docRecord 记录
     * @return 结果
     */
    public int insertDocRecord(DocRecord docRecord);

    /**
     * 修改记录
     * 
     * @param docRecord 记录
     * @return 结果
     */
    public int updateDocRecord(DocRecord docRecord);

    /**
     * 删除记录
     * 
     * @param recordId 记录ID
     * @return 结果
     */
    public int deleteDocRecordById(Long recordId);

    /**
     * 批量删除记录
     * 
     * @param recordIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteDocRecordByIds(Long[] recordIds);
    @Select({"<script> " +
            "select r.*,c.user_name,c.id_card,c.sex,c.birthday from doc_record r left join doc c on c.doc_id=r.doc_id  " +
            "where 1=1 " +
            "<if test = 'maps.docId != null  '> " +
            "and r.doc_id =#{maps.docId} " +
            "</if>" +
            "<if test = 'maps.userId != null  '> " +
            "and r.user_id =#{maps.userId} " +
            "</if>" +
            "<if test = 'maps.userName != null and  maps.userName !=\"\"    '> " +
            "and c.user_name like CONCAT('%',#{maps.userName},'%') " +
            "</if>" +
            "<if test = 'maps.idCard != null and  maps.idCard !=\"\"   '> " +
            "and c.id_card =#{maps.idCard} " +
            "</if>" +
            " order by r.record_id desc "+
            "</script>"})
    List<DocRecordListQueryVO> selectDocRecordListVOQuery(@Param("maps")DocRecordQueryParam param);
    @Select({"<script> " +
            "select r.*,c.user_name,c.id_card,c.sex,c.birthday from doc_record r left join doc c on c.doc_id=r.doc_id  " +
            "where 1=1 " +
            "<if test = 'maps.docId != null  '> " +
            "and r.doc_id =#{maps.docId} " +
            "</if>" +
            "<if test = 'maps.userId != null  '> " +
            "and r.user_id =#{maps.userId} " +
            "</if>" +
            "<if test = 'maps.userName != null and  maps.userName !=\"\"    '> " +
            "and c.user_name like CONCAT('%',#{maps.userName},'%') " +
            "</if>" +
            "<if test = 'maps.idCard != null and  maps.idCard !=\"\"   '> " +
            "and c.id_card =#{maps.idCard} " +
            "</if>" +
            " order by r.record_id desc "+
            "</script>"})
    List<DocRecordVO> selectDocRecordListVO(@Param("maps")DocRecordParam docRecord);
}
