<?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.soss.system.mapper.GoodsSkuMapper"> <resultMap type="GoodsSku" id="GoodsSkuResult"> <result property="id" column="id" /> <result property="goodsId" column="goods_id" /> <result property="ruleList" column="rule_list" /> <result property="isDeleted" column="is_deleted"/> <result property="createdAt" column="created_at"/> <result property="updatedAt" column="updated_at"/> <result property="price" column="price"/> <result property="discount" column="discount"/> </resultMap> <sql id="selectGoodsSkuVo"> select id, goods_id, rule_list, is_deleted, created_at, updated_at, price,discount from goods_sku </sql> <select id="selectSkuListForOrder" resultMap="GoodsSkuResult"> select id, goods_id, price, discount, is_deleted from goods_sku where id in <foreach collection="ids" item="id" separator="," open="(" close=")">#{id}</foreach> </select> <select id="selectGoodsSkuList" parameterType="GoodsSku" resultMap="GoodsSkuResult"> <include refid="selectGoodsSkuVo"/> <where> and is_deleted in (0, 2) <if test="goodsId != null and goodsId != ''">and goods_id = #{goodsId}</if> <if test="ruleList != null and ruleList != ''">and rule_list = #{ruleList}</if> <if test="isDeleted != null and isDeleted != ''">and is_deleted = #{isDeleted}</if> <if test="createdAt != null ">and created_at = #{createdAt}</if> <if test="updatedAt != null ">and updated_at = #{updatedAt}</if> <if test="price != null "> and price = #{price}</if> <if test="discount != null "> and discount = #{discount}</if> </where> </select> <select id="selectGoodsSkuById" parameterType="Long" resultMap="GoodsSkuResult"> <include refid="selectGoodsSkuVo"/> where id = #{id} </select> <insert id="insertGoodsSku" parameterType="GoodsSku" useGeneratedKeys="true" keyProperty="id"> insert into goods_sku <trim prefix="(" suffix=")" suffixOverrides=","> <if test="goodsId != null and goodsId != ''">goods_id,</if> <if test="ruleList != null and ruleList != ''">rule_list,</if> <if test="isDeleted != null and isDeleted != ''">is_deleted,</if> <if test="createdAt != null">created_at,</if> <if test="updatedAt != null">updated_at,</if> <if test="price != null">price,</if> <if test="discount != null">discount,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="goodsId != null and goodsId != ''">#{goodsId},</if> <if test="ruleList != null and ruleList != ''">#{ruleList},</if> <if test="isDeleted != null and isDeleted != ''">#{isDeleted},</if> <if test="createdAt != null">#{createdAt},</if> <if test="updatedAt != null">#{updatedAt},</if> <if test="price != null">#{price},</if> <if test="discount != null">#{discount},</if> </trim> </insert> <update id="updateGoodsSku" parameterType="GoodsSku"> update goods_sku <trim prefix="SET" suffixOverrides=","> <if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if> <if test="ruleList != null and ruleList != ''">rule_list = #{ruleList},</if> <if test="isDeleted != null">is_deleted = #{isDeleted},</if> <if test="updatedAt != null">updated_at = #{updatedAt},</if> <if test="price != null">price = #{price},</if> <if test="discount != null">price = #{discount},</if> </trim> where id = #{id} </update> <delete id="deleteGoodsSkuById" parameterType="String"> delete from goods_sku where id = #{id} </delete> <delete id="deleteGoodsSkuByIds" parameterType="String"> delete from goods_sku where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> <update id="deleteGoodsSkuByGoodsId"> update goods_sku set is_deleted = 1 where goods_id=#{goodsId} </update> <select id="selectSpec" resultMap="GoodsSkuResult"> <include refid="selectGoodsSkuVo"/> where is_deleted in (0, 2) and rule_list like concat('%',#{query},'%') </select> </mapper>