package com.jeethink.system.mapper;

import java.util.List;
import com.jeethink.system.domain.CeshiInfo;
import org.apache.ibatis.annotations.*;

/**
 * 测试Mapper接口
 * 
 * @author sh
 * @date 2022-03-01
 */
public interface CeshiInfoMapper 
{
    /**
     * 查询测试
     * 
     * @param ceshiId 测试ID
     * @return 测试
     */
 /*   @Select("select ceshi_id as ceshiId, name, phone, age, time from ceshi_info  where ceshi_id = #{ceshiId}")*/
    /*@Select(
            "${sql}"
            )*/
    public CeshiInfo selectCeshiInfoById(@Param("sql") String sql);

    /**
     * 查询测试列表
     * 
     * @param ceshiInfo 测试
     * @return 测试集合
     */
    @Select("<script>"
            + "select ceshi_id as ceshiId, name, phone, age, time from ceshi_info"
            +"<where>"
            +"<if test=\"name != null  and name != ''\">"
            +"and name like concat('%', #{name}, '%')"
            +"</if>"
            +"<if test=\"phone != null  and phone != ''\">"
            +"and phone = #{phone}"
            +"</if>"
            +"<if test=\"age != null \">"
            +"and age = #{age}"
            +"</if>"
            +"<if test=\"time != null \">"
            +"and time = #{time}"
            +"</if>"
            +"</where>"
            + "</script>"
    )
    public List<CeshiInfo> selectCeshiInfoList(CeshiInfo ceshiInfo);

    /**
     * 新增测试
     * 
     * @param ceshiInfo 测试
     * @return 结果
     */
    /* insert into ceshi_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ceshiId != null">ceshi_id,</if>
            <if test="name != null">name,</if>
            <if test="phone != null">phone,</if>
            <if test="age != null">age,</if>
            <if test="time != null">time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ceshiId != null">#{ceshiId},</if>
            <if test="name != null">#{name},</if>
            <if test="phone != null">#{phone},</if>
            <if test="age != null">#{age},</if>
            <if test="time != null">#{time},</if>
         </trim> */
    /*@Insert("<script>"
            +"insert into ceshi_info"
            +"<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">"
            +"<if test=\"ceshiId != null\">ceshi_id,</if>\n" +
            "            <if test=\"name != null\">name,</if>\n" +
            "            <if test=\"phone != null\">phone,</if>\n" +
            "            <if test=\"age != null\">age,</if>\n" +
            "            <if test=\"time != null\">time,</if>"
            +" </trim>"
            +" <trim prefix=\"values (\" suffix=\")\" suffixOverrides=\",\">"
            +" <if test=\"ceshiId != null\">#{ceshiId},</if>\n" +
            "            <if test=\"name != null\">#{name},</if>\n" +
            "            <if test=\"phone != null\">#{phone},</if>\n" +
            "            <if test=\"age != null\">#{age},</if>\n" +
            "            <if test=\"time != null\">#{time},</if>"
            +"</trim>"
            +"</script>")*/
    @Insert("<script>"+" insert into ceshi_info set ceshi_id='5',name='a'; insert into ceshi_info set ceshi_id='23',name='a1';" +"</script>")
    public int insertCeshiInfo(CeshiInfo ceshiInfo);

    /**
     * 修改测试
     * 
     * @param ceshiInfo 测试
     * @return 结果
     */
    @Update("<script>"
            +"  update ceshi_info\n" +
            "        <trim prefix=\"SET\" suffixOverrides=\",\">\n" +
            "            <if test=\"name != null\">name = #{name},</if>\n" +
            "            <if test=\"phone != null\">phone = #{phone},</if>\n" +
            "            <if test=\"age != null\">age = #{age},</if>\n" +
            "            <if test=\"time != null\">time = #{time},</if>\n" +
            "        </trim>\n" +
            "        where ceshi_id = #{ceshiId}"
            +"</script>")
    public int updateCeshiInfo(CeshiInfo ceshiInfo);

    /**
     * 删除测试
     * 
     * @param ceshiId 测试ID
     * @return 结果
     */
    @Delete(" delete from ceshi_info where ceshi_id = #{ceshiId}")
    public int deleteCeshiInfoById(String ceshiId) ;

    /**
     * 批量删除测试
     * 
     * @param ceshiIds 需要删除的数据ID
     * @return 结果
     */
    @Delete("<script>"+
            "delete from ceshi_info where ceshi_id in \n" +
            "        <foreach item=\"ceshiId\" collection=\"array\" open=\"(\" separator=\",\" close=\")\">\n" +
            "            #{ceshiId}"+
            "</foreach>"
            +"</script>")
    public int deleteCeshiInfoByIds(String[] ceshiIds);
}
