<?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="org.linlinjava.jz.db.dao.JzGoodsMapper">
    <resultMap id="BaseResultMap" type="org.linlinjava.jz.db.domain.JzGoods">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="goods_sn" property="goodsSn" jdbcType="VARCHAR"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
        <result column="name_en" property="nameEn" jdbcType="VARCHAR"/>
        <result column="category_id" property="categoryId" jdbcType="INTEGER"/>
        <result column="brand_id" property="brandId" jdbcType="INTEGER"/>
        <result column="gallery" property="gallery" jdbcType="VARCHAR"/>
        <result column="keywords" property="keywords" jdbcType="VARCHAR"/>
        <result column="brief" property="brief" jdbcType="VARCHAR"/>
        <result column="sort_order" property="sortOrder" jdbcType="SMALLINT"/>
        <result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
        <result column="share_url" property="shareUrl" jdbcType="VARCHAR"/>
        <result column="is_on_sale" property="isOnSale" jdbcType="BIT"/>
        <result column="is_new" property="isNew" jdbcType="BIT"/>
        <result column="is_hot" property="isHot" jdbcType="BIT"/>
        <result column="unit" property="unit" jdbcType="VARCHAR"/>
        <result column="counter_price" property="counterPrice" jdbcType="DECIMAL"/>
        <result column="retail_price" property="retailPrice" jdbcType="DECIMAL"/>
        <result column="deleted" property="deleted" jdbcType="BIT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="create_user" property="createUser" jdbcType="INTEGER"/>
        <result column="update_user" property="updateUser" jdbcType="INTEGER"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="country" property="country" jdbcType="VARCHAR"/>
    </resultMap>
    <resultMap id="ResultMapWithBLOBs" type="org.linlinjava.jz.db.domain.JzGoods" extends="BaseResultMap">
        <result column="detail" property="detail" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , goods_sn, name, name_en, category_id, brand_id, gallery, keywords, brief, sort_order,
    pic_url, share_url, is_on_sale, is_new, is_hot, unit, counter_price, retail_price, 
    deleted, create_time, create_user, update_user, update_time, country
    </sql>
    <sql id="Blob_Column_List">
        detail
    </sql>
    <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        ,
        <include refid="Blob_Column_List"/>
        from jz_goods
        where id = #{id,jdbcType=INTEGER}
    </select>
    <select id="selectByGoodsSn" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from jz_goods
        where goods_sn = #{goodsSn}
    </select>
    <select id="query" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from jz_goods
        group by name
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete
        from jz_goods
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" parameterType="org.linlinjava.jz.db.domain.JzGoods" keyProperty="id"
            useGeneratedKeys="true">
        insert into jz_goods (id, goods_sn, name,
                              name_en, category_id, brand_id,
                              gallery, keywords, brief,
                              sort_order, pic_url, share_url,
                              is_on_sale, is_new, is_hot, unit,
                              counter_price, retail_price, deleted,
                              create_time, create_user, update_user,
                              update_time, country, detail)
        values (#{id,jdbcType=INTEGER}, #{goodsSn,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
                #{nameEn,jdbcType=VARCHAR}, #{categoryId,jdbcType=INTEGER}, #{brandId,jdbcType=INTEGER},
                #{gallery,jdbcType=VARCHAR}, #{keywords,jdbcType=VARCHAR}, #{brief,jdbcType=VARCHAR},
                #{sortOrder,jdbcType=SMALLINT}, #{picUrl,jdbcType=VARCHAR}, #{shareUrl,jdbcType=VARCHAR},
                #{isOnSale,jdbcType=BIT}, #{isNew,jdbcType=BIT}, #{isHot,jdbcType=BIT}, #{unit,jdbcType=VARCHAR},
                #{counterPrice,jdbcType=DECIMAL}, #{retailPrice,jdbcType=DECIMAL}, #{deleted,jdbcType=BIT},
                #{createTime,jdbcType=TIMESTAMP}, #{createUser,jdbcType=INTEGER}, #{updateUser,jdbcType=INTEGER},
                #{updateTime,jdbcType=TIMESTAMP}, #{country,jdbcType=VARCHAR}, #{detail,jdbcType=LONGVARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="org.linlinjava.jz.db.domain.JzGoods">
        insert into jz_goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="goodsSn != null">
                goods_sn,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="nameEn != null">
                name_en,
            </if>
            <if test="categoryId != null">
                category_id,
            </if>
            <if test="brandId != null">
                brand_id,
            </if>
            <if test="gallery != null">
                gallery,
            </if>
            <if test="keywords != null">
                keywords,
            </if>
            <if test="brief != null">
                brief,
            </if>
            <if test="sortOrder != null">
                sort_order,
            </if>
            <if test="picUrl != null">
                pic_url,
            </if>
            <if test="shareUrl != null">
                share_url,
            </if>
            <if test="isOnSale != null">
                is_on_sale,
            </if>
            <if test="isNew != null">
                is_new,
            </if>
            <if test="isHot != null">
                is_hot,
            </if>
            <if test="unit != null">
                unit,
            </if>
            <if test="counterPrice != null">
                counter_price,
            </if>
            <if test="retailPrice != null">
                retail_price,
            </if>
            <if test="deleted != null">
                deleted,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createUser != null">
                create_user,
            </if>
            <if test="updateUser != null">
                update_user,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="country != null">
                country,
            </if>
            <if test="detail != null">
                detail,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="goodsSn != null">
                #{goodsSn,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="nameEn != null">
                #{nameEn,jdbcType=VARCHAR},
            </if>
            <if test="categoryId != null">
                #{categoryId,jdbcType=INTEGER},
            </if>
            <if test="brandId != null">
                #{brandId,jdbcType=INTEGER},
            </if>
            <if test="gallery != null">
                #{gallery,jdbcType=VARCHAR},
            </if>
            <if test="keywords != null">
                #{keywords,jdbcType=VARCHAR},
            </if>
            <if test="brief != null">
                #{brief,jdbcType=VARCHAR},
            </if>
            <if test="sortOrder != null">
                #{sortOrder,jdbcType=SMALLINT},
            </if>
            <if test="picUrl != null">
                #{picUrl,jdbcType=VARCHAR},
            </if>
            <if test="shareUrl != null">
                #{shareUrl,jdbcType=VARCHAR},
            </if>
            <if test="isOnSale != null">
                #{isOnSale,jdbcType=BIT},
            </if>
            <if test="isNew != null">
                #{isNew,jdbcType=BIT},
            </if>
            <if test="isHot != null">
                #{isHot,jdbcType=BIT},
            </if>
            <if test="unit != null">
                #{unit,jdbcType=VARCHAR},
            </if>
            <if test="counterPrice != null">
                #{counterPrice,jdbcType=DECIMAL},
            </if>
            <if test="retailPrice != null">
                #{retailPrice,jdbcType=DECIMAL},
            </if>
            <if test="deleted != null">
                #{deleted,jdbcType=BIT},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null">
                #{createUser,jdbcType=INTEGER},
            </if>
            <if test="updateUser != null">
                #{updateUser,jdbcType=INTEGER},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="country != null">
                #{country,jdbcType=VARCHAR},
            </if>
            <if test="detail != null">
                #{detail,jdbcType=LONGVARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="org.linlinjava.jz.db.domain.JzGoods">
        update jz_goods
        <set>
            <if test="goodsSn != null">
                goods_sn = #{goodsSn,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR},
            </if>
            <if test="nameEn != null">
                name_en = #{nameEn,jdbcType=VARCHAR},
            </if>
            <if test="categoryId != null">
                category_id = #{categoryId,jdbcType=INTEGER},
            </if>
            <if test="brandId != null">
                brand_id = #{brandId,jdbcType=INTEGER},
            </if>
            <if test="gallery != null">
                gallery = #{gallery,jdbcType=VARCHAR},
            </if>
            <if test="keywords != null">
                keywords = #{keywords,jdbcType=VARCHAR},
            </if>
            <if test="brief != null">
                brief = #{brief,jdbcType=VARCHAR},
            </if>
            <if test="sortOrder != null">
                sort_order = #{sortOrder,jdbcType=SMALLINT},
            </if>
            <if test="picUrl != null">
                pic_url = #{picUrl,jdbcType=VARCHAR},
            </if>
            <if test="shareUrl != null">
                share_url = #{shareUrl,jdbcType=VARCHAR},
            </if>
            <if test="isOnSale != null">
                is_on_sale = #{isOnSale,jdbcType=BIT},
            </if>
            <if test="isNew != null">
                is_new = #{isNew,jdbcType=BIT},
            </if>
            <if test="isHot != null">
                is_hot = #{isHot,jdbcType=BIT},
            </if>
            <if test="unit != null">
                unit = #{unit,jdbcType=VARCHAR},
            </if>
            <if test="counterPrice != null">
                counter_price = #{counterPrice,jdbcType=DECIMAL},
            </if>
            <if test="retailPrice != null">
                retail_price = #{retailPrice,jdbcType=DECIMAL},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,jdbcType=BIT},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null">
                create_user = #{createUser,jdbcType=INTEGER},
            </if>
            <if test="updateUser != null">
                update_user = #{updateUser,jdbcType=INTEGER},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="country != null">
                country = #{country,jdbcType=VARCHAR},
            </if>
            <if test="detail != null">
                detail = #{detail,jdbcType=LONGVARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKeyWithBLOBs" parameterType="org.linlinjava.jz.db.domain.JzGoods">
        update jz_goods
        set goods_sn      = #{goodsSn,jdbcType=VARCHAR},
            name          = #{name,jdbcType=VARCHAR},
            name_en       = #{nameEn,jdbcType=VARCHAR},
            category_id   = #{categoryId,jdbcType=INTEGER},
            brand_id      = #{brandId,jdbcType=INTEGER},
            gallery       = #{gallery,jdbcType=VARCHAR},
            keywords      = #{keywords,jdbcType=VARCHAR},
            brief         = #{brief,jdbcType=VARCHAR},
            sort_order    = #{sortOrder,jdbcType=SMALLINT},
            pic_url       = #{picUrl,jdbcType=VARCHAR},
            share_url     = #{shareUrl,jdbcType=VARCHAR},
            is_on_sale    = #{isOnSale,jdbcType=BIT},
            is_new        = #{isNew,jdbcType=BIT},
            is_hot        = #{isHot,jdbcType=BIT},
            unit          = #{unit,jdbcType=VARCHAR},
            counter_price = #{counterPrice,jdbcType=DECIMAL},
            retail_price  = #{retailPrice,jdbcType=DECIMAL},
            deleted       = #{deleted,jdbcType=BIT},
            create_time   = #{createTime,jdbcType=TIMESTAMP},
            create_user   = #{createUser,jdbcType=INTEGER},
            update_user   = #{updateUser,jdbcType=INTEGER},
            update_time   = #{updateTime,jdbcType=TIMESTAMP},
            country       = #{country,jdbcType=VARCHAR},
            detail        = #{detail,jdbcType=LONGVARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="org.linlinjava.jz.db.domain.JzGoods">
        update jz_goods
        set goods_sn      = #{goodsSn,jdbcType=VARCHAR},
            name          = #{name,jdbcType=VARCHAR},
            name_en       = #{nameEn,jdbcType=VARCHAR},
            category_id   = #{categoryId,jdbcType=INTEGER},
            brand_id      = #{brandId,jdbcType=INTEGER},
            gallery       = #{gallery,jdbcType=VARCHAR},
            keywords      = #{keywords,jdbcType=VARCHAR},
            brief         = #{brief,jdbcType=VARCHAR},
            sort_order    = #{sortOrder,jdbcType=SMALLINT},
            pic_url       = #{picUrl,jdbcType=VARCHAR},
            share_url     = #{shareUrl,jdbcType=VARCHAR},
            is_on_sale    = #{isOnSale,jdbcType=BIT},
            is_new        = #{isNew,jdbcType=BIT},
            is_hot        = #{isHot,jdbcType=BIT},
            unit          = #{unit,jdbcType=VARCHAR},
            counter_price = #{counterPrice,jdbcType=DECIMAL},
            retail_price  = #{retailPrice,jdbcType=DECIMAL},
            deleted       = #{deleted,jdbcType=BIT},
            create_time   = #{createTime,jdbcType=TIMESTAMP},
            create_user   = #{createUser,jdbcType=INTEGER},
            update_user   = #{updateUser,jdbcType=INTEGER},
            update_time   = #{updateTime,jdbcType=TIMESTAMP},
            country       = #{country,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>