<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qianhe.zqbf.mapper.ZqczXmzBfjlMapper">
    <!--  返回实体  -->
    <resultMap id="ZqczXmzBfjlResult" type="ZqczXmzBfjl">
        <result property="jlid" column="jlid"/>
        <result property="xqid" column="xqid"/>
        <result property="dqzt" column="dqzt"/>
        <result property="gxr" column="gxr"/>
        <result property="gxsj" column="gxsj"/>
        <result property="bz" column="bz"/>
    </resultMap>
    <!--  通用查询  -->
    <sql id="selectCommon">
        SELECT jlid, xqid, dqzt, gxr, gxsj, bz from zqcz_xmz_bfjl
    </sql>
    <!--  条件查询  -->
    <select id="list" parameterType="ZqczXmzBfjlQuery" resultMap="ZqczXmzBfjlResult">
        <include refid="selectCommon"></include>
        <where>
            <if test="xqid != null ">AND xqid = #{xqid}</if>
            <if test="dqzt != null  and dqzt !='' ">AND dqzt = #{dqzt}</if>
        </where>
        ORDER BY gxsj
    </select>
    <!--  新增  -->
    <insert id="add" parameterType="ZqczXmzBfjl">
        INSERT INTO zqcz_xmz_bfjl
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="xqid != null ">xqid,</if>
            <if test="dqzt != null  and dqzt != ''">dqzt,</if>
            <if test="gxr != null  and gxr != ''">gxr,</if>
            <if test="bz != null  and bz != ''">bz,</if>
            gxsj
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="xqid != null ">#{xqid},</if>
            <if test="dqzt != null  and dqzt != ''">#{dqzt},</if>
            <if test="gxr != null  and gxr != ''">#{gxr},</if>
            <if test="bz != null  and bz != ''">#{bz},</if>
            now()
        </trim>
    </insert>
    <!--  删除  -->
    <delete id="delete" parameterType="long">
        DELETE FROM zqcz_xmz_bfjl WHERE xmid = #{id}
    </delete>
</mapper>