package com.fs.doc.mapper;

import java.util.List;
import com.fs.doc.domain.Doc;
import com.fs.doc.param.DocQueryParam;
import com.fs.doc.vo.DocListQueryVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 档案Mapper接口
 * 
 * @author fs
 * @date 2023-01-09
 */
public interface DocMapper 
{
    /**
     * 查询档案
     * 
     * @param docId 档案ID
     * @return 档案
     */
    public Doc selectDocById(Long docId);

    /**
     * 查询档案列表
     * 
     * @param doc 档案
     * @return 档案集合
     */
    public List<Doc> selectDocList(Doc doc);

    /**
     * 新增档案
     * 
     * @param doc 档案
     * @return 结果
     */
    public int insertDoc(Doc doc);

    /**
     * 修改档案
     * 
     * @param doc 档案
     * @return 结果
     */
    public int updateDoc(Doc doc);

    /**
     * 删除档案
     * 
     * @param docId 档案ID
     * @return 结果
     */
    public int deleteDocById(Long docId);

    /**
     * 批量删除档案
     * 
     * @param docIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteDocByIds(Long[] docIds);
    @Select({"<script> " +
            "select d.* from doc d  " +
            "where 1=1 " +
            "<if test = 'maps.userId != null     '> " +
            "and d.user_id =#{maps.userId} " +
            "</if>" +
            "<if test = 'maps.userName != null and  maps.userName !=\"\"    '> " +
            "and d.user_name like CONCAT('%',#{maps.userName},'%') " +
            "</if>" +
            "<if test = 'maps.keyword != null and  maps.keyword !=\"\"    '> " +
            "and d.user_name like CONCAT('%',#{maps.keyword},'%') " +
            "</if>" +
            "<if test = 'maps.sex != null     '> " +
            "and d.sex =#{maps.sex} " +
            "</if>" +
            "<if test = 'maps.idCard != null and  maps.idCard !=\"\"   '> " +
            "and d.id_card =#{maps.idCard} " +
            "</if>" +
            " order by d.doc_id desc "+
            "</script>"})
    List<DocListQueryVO> selectDocListVOQuery(@Param("maps")DocQueryParam param);
}
