<?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.BizProductMapper">

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

    <select id="getList" parameterType="BizProduct" resultMap="BizProductResult">
        SELECT * FROM biz_product
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="id!=null and id!=''"> AND id = #{id}</if>
            <if test="productCode != null  and productCode != ''"> AND product_code like CONCAT('%', #{productCode}, '%')</if>
            <if test="preStock != null  and preStock != ''"> AND pre_stock = #{preStock}</if>
            <if test="type != null  and type != ''"> AND type = #{type}</if>
            <if test="shaftBroadCategoryCode != null  and shaftBroadCategoryCode != ''"> AND shaft_broad_category_code = #{shaftBroadCategoryCode}</if>
            <if test="shaftCategoryCode != null  and shaftCategoryCode != ''"> AND shaft_category_code = #{shaftCategoryCode}</if>
            <if test="specification != null  and specification != ''"> AND specification LIKE CONCAT('%', #{specification}, '%')</if>
            <if test="drawingNumber != null  and drawingNumber != ''"> AND drawing_number LIKE CONCAT('%',#{drawingNumber},'%')</if>
            <if test="companyAlias != null  and companyAlias != ''">  AND company_alias LIKE CONCAT('%', #{companyAlias}, '%')</if>
            <if test="description != null  and description != ''"> AND description like concat('%',#{description},'%')</if>
            <if test="diameter != null "> AND diameter = #{diameter}</if>
            <if test="lenght != null "> AND lenght = #{lenght}</if>
            <if test="thickness != null "> AND thickness = #{thickness}</if>
            <if test="companyCode != null  and companyCode != ''"> AND company_code = #{companyCode}</if>
            <if test="salesmanCode != null  and salesmanCode != ''"> AND salesman_code = #{salesmanCode}</if>
            <if test="stockKeeperCode != null  and stockKeeperCode != ''"> AND stock_keeper_code = #{stockKeeperCode}</if>
            <if test="dispatcherCode != null  and dispatcherCode != ''"> AND dispatcher_code = #{dispatcherCode}</if>
            <if test="productStatusCode != null  and productStatusCode != ''"> AND product_status_code = #{productStatusCode}</if>
            <if test="productionTypeCode != null  and productionTypeCode != ''"> AND production_type_code = #{productionTypeCode}</if>
            <if test="technicianCode != null  and technicianCode != ''"> AND technician_code = #{technicianCode}</if>
            <if test="creatorCode != null  and creatorCode != ''"> AND creator_code = #{creatorCode}</if>
            <if test="tenantId != null  and tenantId != 0"> AND tenant_id = #{tenantId}</if>
        </trim>
    </select>

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