2022-03-14 11:31:02 +08:00
|
|
|
<?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.ghy.goods.mapper.GoodsMapper">
|
2022-03-14 13:06:40 +08:00
|
|
|
<resultMap id="GoodsResult" type="com.ghy.goods.domain.Goods">
|
2022-03-14 11:31:02 +08:00
|
|
|
<id property="goodsId" column="goods_id" />
|
|
|
|
|
<result property="goodsCode" column="goods_code" />
|
2022-03-18 15:58:58 +08:00
|
|
|
<result property="deptId" column="dept_id" />
|
2022-03-14 11:31:02 +08:00
|
|
|
<result property="goodsName" column="goods_name" />
|
|
|
|
|
<result property="goodsPrice" column="goods_price" />
|
2022-05-10 19:22:45 +08:00
|
|
|
<result property="discountsPrice" column="discounts_price" />
|
2022-05-05 14:35:48 +08:00
|
|
|
<result property="groupPrice" column="group_price" />
|
2022-03-14 11:31:02 +08:00
|
|
|
<result property="goodsSort" column="goods_sort"/>
|
2022-05-10 19:22:45 +08:00
|
|
|
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
2022-03-14 11:31:02 +08:00
|
|
|
<result property="goodsImgUrl" column="goods_img_url"/>
|
2022-03-14 16:56:11 +08:00
|
|
|
<result property="goodsVideoUrl" column="goods_video_url"/>
|
2022-03-14 11:31:02 +08:00
|
|
|
<result property="goodsNumber" column="goods_number"/>
|
|
|
|
|
<result property="status" column="status"/>
|
|
|
|
|
<result property="createBy" column="create_by" />
|
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
|
<result property="updateBy" column="update_by" />
|
|
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
2022-03-14 13:06:40 +08:00
|
|
|
<sql id="selectGoods">
|
2022-05-10 19:22:45 +08:00
|
|
|
SELECT goods_id, goods_code, dept_id, goods_name, goods_price, discounts_price, group_price, goods_sort,
|
|
|
|
|
dept_goods_category_id, goods_img_url, goods_video_url, goods_number, status, create_by, create_time, remark
|
|
|
|
|
FROM goods
|
2022-03-14 11:31:02 +08:00
|
|
|
</sql>
|
|
|
|
|
|
2022-05-11 17:35:13 +08:00
|
|
|
<select id="checkAGoodsStore" parameterType="com.ghy.goods.request.AppGoodsRequest" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods" />
|
|
|
|
|
where goods_id = #{goodsId} and goods_number >= #{num}
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-03-14 13:06:40 +08:00
|
|
|
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
2022-05-10 19:22:45 +08:00
|
|
|
UPDATE goods
|
2022-03-14 13:06:40 +08:00
|
|
|
<set>
|
|
|
|
|
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="goodsPrice != null and goodsPrice != ''">goods_price = #{goodsPrice},</if>
|
|
|
|
|
<if test="discountsPrice != null and discountsPrice != ''">discounts_price = #{discountsPrice},</if>
|
|
|
|
|
<if test="groupPrice != null and groupPrice != ''">group_price = #{groupPrice},</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="goodsSort != null and goodsSort != ''">goods_sort = #{goodsSort},</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id = #{deptGoodsCategoryId},</if>
|
|
|
|
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url = #{goodsImgUrl},</if>
|
|
|
|
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url = #{goodsVideoUrl},</if>
|
|
|
|
|
<if test="goodsNumber != null and goodsNumber != ''">goods_number = #{goodsNumber},</if>
|
|
|
|
|
<if test="status != null and status != ''">`status` = #{status},</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
|
|
|
update_time = sysdate()
|
|
|
|
|
</set>
|
2022-05-10 19:22:45 +08:00
|
|
|
WHERE goods_id = #{goodsId}
|
2022-03-14 13:06:40 +08:00
|
|
|
</update>
|
|
|
|
|
|
2022-05-10 20:54:51 +08:00
|
|
|
<update id="setCode">
|
|
|
|
|
UPDATE goods
|
|
|
|
|
SET goods_code = #{goodsCode}, update_time = sysdate()
|
|
|
|
|
WHERE goods_id = #{goodsId}
|
|
|
|
|
</update>
|
|
|
|
|
|
2022-03-14 13:06:40 +08:00
|
|
|
<insert id="insertGoods" parameterType="com.ghy.goods.domain.Goods" useGeneratedKeys="true" keyProperty="goodsId">
|
2022-03-17 14:54:11 +08:00
|
|
|
insert into goods(
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="deptId != null and deptId != ''">dept_id,</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="goodsName != null and goodsName != ''">goods_name,</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="goodsPrice != null and goodsPrice != ''">goods_price,</if>
|
|
|
|
|
<if test="discountsPrice != null and discountsPrice != ''">discounts_price,</if>
|
|
|
|
|
<if test="groupPrice != null and groupPrice != ''">group_price,</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="goodsSort != null and goodsSort != ''">goods_sort,</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">dept_goods_category_id,</if>
|
|
|
|
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url,</if>
|
|
|
|
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url,</if>
|
|
|
|
|
<if test="goodsNumber != null and goodsNumber != ''">goods_number,</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="status != null and status != ''">status,</if>
|
|
|
|
|
<if test="remark != null and remark != ''">remark,</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
|
|
|
create_time
|
|
|
|
|
)values(
|
|
|
|
|
<if test="goodsCode != null and goodsCode != ''">#{goodsCode},</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="goodsPrice != null and goodsPrice != ''">#{goodsPrice},</if>
|
|
|
|
|
<if test="discountsPrice != null and discountsPrice != ''">#{discountsPrice},</if>
|
|
|
|
|
<if test="groupPrice != null and groupPrice != ''">#{groupPrice},</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="goodsSort != null and goodsSort != ''">#{goodsSort},</if>
|
2022-05-10 19:22:45 +08:00
|
|
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">#{deptGoodsCategoryId},</if>
|
|
|
|
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">#{goodsImgUrl},</if>
|
|
|
|
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">#{goodsVideoUrl},</if>
|
|
|
|
|
<if test="goodsNumber != null and goodsNumber != ''">#{goodsNumber},</if>
|
2022-03-14 13:06:40 +08:00
|
|
|
<if test="status != null and status != ''">#{status},</if>
|
|
|
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
|
|
sysdate()
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
2022-03-14 11:31:02 +08:00
|
|
|
|
2022-05-10 19:22:45 +08:00
|
|
|
<select id="selectGoodsList" parameterType="com.ghy.goods.domain.Goods" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods" />
|
|
|
|
|
<where>
|
|
|
|
|
<if test="goodsCode != null and goodsCode != ''">
|
|
|
|
|
AND goods_code like concat('%', #{goodsCode}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectById" parameterType="long" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="goodsId != null and goodsId != 0">
|
|
|
|
|
AND goods_id = #{goodsId}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteGoodsByIds" parameterType="Long">
|
|
|
|
|
delete from goods where goods_id in
|
|
|
|
|
<foreach collection="array" item="goodsId" open="(" separator="," close=")">
|
|
|
|
|
#{goodsId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
2022-03-14 13:55:40 +08:00
|
|
|
<select id="checkGoodsNameUnique" parameterType="String" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods"/>
|
|
|
|
|
where goods_name=#{goodsName} limit 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="checkGoodsCodeUnique" parameterType="String" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods"/>
|
|
|
|
|
where goods_code=#{goodsCode} limit 1
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-03-18 18:25:14 +08:00
|
|
|
<select id="selectOneByGoodsCategoryId" parameterType="String" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods"/>
|
2022-05-10 19:22:45 +08:00
|
|
|
WHERE dept_goods_category_id = #{deptGoodsCategoryId} LIMIT 1
|
2022-03-18 18:25:14 +08:00
|
|
|
</select>
|
|
|
|
|
|
2022-05-17 21:19:41 +08:00
|
|
|
<select id="selectByIds" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods"/>
|
|
|
|
|
goods_id IN
|
|
|
|
|
<foreach collection="ids" item="goodsId" open="(" separator="," close=")">
|
|
|
|
|
#{goodsId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
2022-03-14 11:31:02 +08:00
|
|
|
</mapper>
|