<?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.dcsoft.system.mapper.SysProductMapper">
    
    <resultMap type="SysProduct" id="SysProductResult">
        <result property="id"    column="id"    />
        <result property="avatar"    column="avatar"    />
        <result property="name"    column="name"    />
        <result property="version"    column="version"    />
        <result property="bigtype"    column="bigtype"    />
        <result property="subtype"    column="subtype"    />
        <result property="genre"    column="genre"    />
        <result property="describes"    column="describes"    />
        <result property="network"    column="network"    />
        <result property="dataFormat"    column="data_format"    />
        <result property="scale"    column="scale"    />
        <result property="attestation"    column="attestation"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSysProductVo">
        select id, avatar, name, version, bigtype, subtype, genre, describes, network, data_format, scale, attestation, create_by, create_time, update_by, update_time from sys_product
    </sql>

    <select id="selectSysProductList" parameterType="SysProduct" resultMap="SysProductResult">
        <include refid="selectSysProductVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="bigtype != null  and bigtype != ''"> and bigtype = #{bigtype}</if>
            <if test="subtype != null  and subtype != ''"> and subtype = #{subtype}</if>
            <if test="genre != null  and genre != ''"> and genre = #{genre}</if>
            <if test="describes != null  and describes != ''"> and describes = #{describes}</if>
            <if test="network != null  and network != ''"> and network = #{network}</if>
            <if test="dataFormat != null  and dataFormat != ''"> and data_format = #{dataFormat}</if>
            <if test="scale != null  and scale != ''"> and scale = #{scale}</if>
            <if test="attestation != null  and attestation != ''"> and attestation = #{attestation}</if>
        </where>
    </select>
    
    <select id="selectSysProductById" parameterType="Long" resultMap="SysProductResult">
        <include refid="selectSysProductVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysProduct" parameterType="SysProduct">
        insert into sys_product
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="avatar != null">avatar,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="version != null">version,</if>
            <if test="bigtype != null">bigtype,</if>
            <if test="subtype != null">subtype,</if>
            <if test="genre != null">genre,</if>
            <if test="describes != null">describes,</if>
            <if test="network != null">network,</if>
            <if test="dataFormat != null">data_format,</if>
            <if test="scale != null">scale,</if>
            <if test="attestation != null">attestation,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="avatar != null">#{avatar},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="version != null">#{version},</if>
            <if test="bigtype != null">#{bigtype},</if>
            <if test="subtype != null">#{subtype},</if>
            <if test="genre != null">#{genre},</if>
            <if test="describes != null">#{describes},</if>
            <if test="network != null">#{network},</if>
            <if test="dataFormat != null">#{dataFormat},</if>
            <if test="scale != null">#{scale},</if>
            <if test="attestation != null">#{attestation},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateSysProduct" parameterType="SysProduct">
        update sys_product
        <trim prefix="SET" suffixOverrides=",">
            <if test="avatar != null">avatar = #{avatar},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="version != null">version = #{version},</if>
            <if test="bigtype != null">bigtype = #{bigtype},</if>
            <if test="subtype != null">subtype = #{subtype},</if>
            <if test="genre != null">genre = #{genre},</if>
            <if test="describes != null">describes = #{describes},</if>
            <if test="network != null">network = #{network},</if>
            <if test="dataFormat != null">data_format = #{dataFormat},</if>
            <if test="scale != null">scale = #{scale},</if>
            <if test="attestation != null">attestation = #{attestation},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysProductById" parameterType="Long">
        delete from sys_product where id = #{id}
    </delete>

    <delete id="deleteSysProductByIds" parameterType="String">
        delete from sys_product where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>