<?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="cn.ezhizao.project.business.mapper.BizCertificateMapper">

    <resultMap type="cn.ezhizao.project.business.domain.BizCertificate" id="BizCertificateResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizCertificate" resultMap="BizCertificateResult">
        SELECT * FROM biz_certificate
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0 and print_time is not null
            <if test="qrcode != null  and qrcode != ''"> AND qrcode = #{qrcode}</if>
            <if test="qrcodeUrl != null  and qrcodeUrl != ''"> AND qrcode_url = #{qrcodeUrl}</if>
            <if test="barcodeUrl != null  and barcodeUrl != ''"> AND barcode_url = #{barcodeUrl}</if>
            <if test="number != null "> AND number = #{number}</if>
            <if test="customerName != null  and customerName != ''"> AND customer_name like concat('%', #{customerName}, '%')</if>
            <if test="productCode != null  and productCode != ''"> AND product_code = #{productCode}</if>
            <if test="specification != null  and specification != ''"> AND specification = #{specification}</if>
            <if test="drawingNumber != null  and drawingNumber != ''"> AND drawing_number = #{drawingNumber}</if>
            <if test="productDescription != null  and productDescription != ''"> AND product_description = #{productDescription}</if>
            <if test="printDate != null "> AND print_date = #{printDate}</if>
            <if test="lotCode != null  and lotCode != ''"> AND lot_code = #{lotCode}</if>
            <if test="printNumber != null "> AND print_number = #{printNumber}</if>
            <if test="isDeactivate != null "> AND is_deactivate = #{isDeactivate}</if>
            <if test="type != null  and type != ''"> AND type = #{type}</if>
            <if test="year != null  and year != ''"> AND year = #{year}</if>
            <if test="labelNumber != null "> AND label_number = #{labelNumber}</if>
            <if test="dayworkId != null "> AND daywork_id = #{dayworkId}</if>
            <if test="packageNumber != null "> AND package_number = #{packageNumber}</if>
            <if test="printPages != null "> AND print_pages = #{printPages}</if>
            <if test="packageCode != null  and packageCode != ''"> AND package_code = #{packageCode}</if>
            <if test="packageNo != null  and packageNo != ''"> AND package_no = #{packageNo}</if>
            <if test="packageStandard != null  and packageStandard != ''"> AND package_standard = #{packageStandard}</if>
        </trim>
        order by print_time desc
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_certificate
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
