123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <?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.kmall.admin.dao.ProductDao">
- <resultMap type="com.kmall.admin.entity.ProductEntity" id="productMap">
- <result property="id" column="id"/>
- <result property="goodsId" column="goods_id"/>
- <result property="goodsSpecificationIds" column="goods_specification_ids"/>
- <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
- <result property="goodsSn" column="goods_sn"/>
- <result property="goodsNumber" column="goods_number"/>
- <result property="goodsDefault" column="goods_default"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.admin.entity.ProductEntity">
- select
- id,
- goods_id,
- goods_specification_ids,
- goods_specification_name_value,
- goods_sn,
- goods_number,
- goods_default
- from mall_product
- where id = #{id}
- </select>
- <select id="queryObjectByGoodsIdAndStoreId" resultType="com.kmall.admin.entity.ProductEntity">
- select
- p.id,
- p.goods_id,
- p.goods_specification_ids,
- p.goods_specification_name_value,
- p.goods_sn,
- p.goods_number,
- p.goods_default
- from mall_product p
- <if test="storeId != null and storeId != ''">
- left join mall_product_store_rela r on p.id = r.product_id and p.goods_id = r.goods_id
- </if>
- where p.goods_id = #{goodsId}
- <if test="storeId != null and storeId != ''">
- and r.store_id = #{storeId}
- </if>
- </select>
- <select id="queryList" resultType="com.kmall.admin.entity.ProductEntity">
- select
- mall_product.*,
- mall_goods.name goods_name
- from mall_product
- LEFT JOIN mall_goods ON mall_product.goods_id = mall_goods.id
- WHERE 1=1
- <if test="goodsId != null and goodsId != ''">
- AND mall_product.goods_id = #{goodsId}
- </if>
- <if test="goodsSpecificationIds != null and goodsSpecificationIds != ''">
- AND mall_product.goods_specification_ids = #{goodsSpecificationIds}
- </if>
- <if test="goodsName != null and goodsName.trim() != ''">
- AND mall_goods.name LIKE concat('%',#{goodsName},'%')
- </if>
- <if test="goodsSn != null and goodsSn.trim() != ''">
- AND mall_goods.goods_sn LIKE concat('%',#{goodsSn},'%')
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by mall_product.id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(*) from mall_product
- LEFT JOIN mall_goods ON mall_product.goods_id = mall_goods.id
- WHERE 1=1
- <if test="goodsId != null and goodsId != ''">
- AND mall_product.goods_id = #{goodsId}
- </if>
- <if test="goodsName != null and goodsName.trim() != ''">
- AND mall_goods.name LIKE concat('%',#{goodsName},'%')
- </if>
- <if test="goodsSpecificationIds != null and goodsSpecificationIds != ''">
- AND mall_product.goods_specification_ids = #{goodsSpecificationIds}
- </if>
- <if test="goodsSn != null and goodsSn.trim() != ''">
- AND mall_goods.goods_sn LIKE concat('%',#{goodsSn},'%')
- </if>
- </select>
- <insert id="save" parameterType="com.kmall.admin.entity.ProductEntity" useGeneratedKeys="true" keyProperty="id">
- insert into mall_product(
- `goods_id`,
- `goods_specification_ids`,
- `goods_specification_name_value`,
- `goods_sn`,
- `goods_number`,
- `goods_default`
- )
- values(
- #{goodsId},
- #{goodsSpecificationIds},
- #{goodsSpecificationNameValue},
- #{goodsSn},
- #{goodsNumber},
- #{goodsDefault}
- )
- </insert>
- <update id="update" parameterType="com.kmall.admin.entity.ProductEntity">
- update mall_product
- <set>
- <if test="goodsId != null">`goods_id` = #{goodsId},</if>
- <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
- <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
- #{goodsSpecificationNameValue},
- </if>
- <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
- <if test="goodsNumber != null">`goods_number` = #{goodsNumber},</if>
- <if test="goodsDefault != null">`goods_default` = #{goodsDefault},</if>
- </set>
- where id = #{id}
- </update>
- <delete id="delete">
- delete from mall_product where id = #{id}
- </delete>
- <delete id="deleteByGoodsId">
- delete from mall_product where goods_id = #{goodsId}
- </delete>
- <delete id="deleteBatch">
- delete from mall_product where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
- insert into mall_product(
- `goods_id`,
- `goods_specification_ids`,
- `goods_specification_name_value`,
- `goods_sn`,
- `goods_number`,
- `goods_default`
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- #{item.goodsId},
- #{item.goodsSpecificationIds},
- #{item.goodsSpecificationNameValue},
- #{item.goodsSn},
- #{item.goodsNumber},
- #{item.goodsDefault}
- )
- </foreach>
- </insert>
- <update id="updateBatch" parameterType="java.util.List">
- <foreach collection="list" item="item" index="index" open="" close="" separator=";">
- update mall_product
- <set>
- <if test="item.goodsId != null">`goods_id` = #{item.goodsId},</if>
- <if test="item.goodsSpecificationIds != null">`goods_specification_ids` = #{item.goodsSpecificationIds},</if>
- <if test="item.goodsSpecificationNameValue != null">`goods_specification_name_value` =
- #{item.goodsSpecificationNameValue},
- </if>
- <if test="item.goodsSn != null">`goods_sn` = #{item.goodsSn},</if>
- <if test="item.goodsNumber != null">`goods_number` = #{item.goodsNumber},</if>
- <if test="item.goodsDefault != null">`goods_default` = #{item.goodsDefault},</if>
- </set>
- where id = #{item.id}
- </foreach>
- </update>
- </mapper>
|