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" />
|
|
|
|
|
<result property="goodsSort" column="goods_sort"/>
|
|
|
|
|
<result property="goodsCategoryId" column="goods_category_id"/>
|
|
|
|
|
<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-03-18 15:58:58 +08:00
|
|
|
select goods_id, goods_code, dept_id, goods_name, goods_price, goods_sort, goods_category_id,
|
2022-03-14 11:31:02 +08:00
|
|
|
goods_img_url, goods_number, status, create_by, create_time, remark
|
2022-03-14 13:06:40 +08:00
|
|
|
from goods
|
2022-03-14 11:31:02 +08:00
|
|
|
</sql>
|
|
|
|
|
|
2022-03-14 13:06:40 +08:00
|
|
|
<select id="selectGoodsList" parameterType="com.ghy.goods.domain.Goods" resultMap="GoodsResult">
|
|
|
|
|
<include refid="selectGoods" />
|
2022-03-14 11:31:02 +08:00
|
|
|
<where>
|
|
|
|
|
<if test="goodsCode != null and goodsCode != ''">
|
|
|
|
|
AND goods_code like concat('%', #{goodsCode}, '%')
|
|
|
|
|
</if>
|
2022-03-18 15:58:58 +08:00
|
|
|
<if test="deptId != null and deptId != 0">
|
|
|
|
|
AND dept_id = #{deptId}
|
|
|
|
|
</if>
|
2022-03-14 11:31:02 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
2022-03-14 13:06:40 +08:00
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
|
2022-03-14 13:55:40 +08:00
|
|
|
<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:06:40 +08:00
|
|
|
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
|
|
|
|
update goods
|
|
|
|
|
<set>
|
|
|
|
|
<if test="goodsCode != null and goodsCode != ''">goods_code = #{goodsCode},</if>
|
|
|
|
|
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
|
|
|
|
<if test="goodsSort != null and goodsSort != ''">goods_sort = #{goodsSort},</if>
|
|
|
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
|
|
|
update_time = sysdate()
|
|
|
|
|
</set>
|
|
|
|
|
where goods_id = #{goodsId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<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="goodsId != null and goodsId != 0">goods_id,</if>
|
|
|
|
|
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
|
|
|
|
<if test="goodsName != null and goodsName != ''">goods_name,</if>
|
|
|
|
|
<if test="goodsSort != null and goodsSort != ''">goods_sort,</if>
|
|
|
|
|
<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="goodsId != null and goodsId != 0">#{goodsId},</if>
|
|
|
|
|
<if test="goodsCode != null and goodsCode != ''">#{goodsCode},</if>
|
|
|
|
|
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
|
|
|
|
|
<if test="goodsSort != null and goodsSort != ''">#{goodsSort},</if>
|
|
|
|
|
<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-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"/>
|
|
|
|
|
WHERE goods_category_id = #{goodsCategoryId} LIMIT 1
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-03-14 11:31:02 +08:00
|
|
|
</mapper>
|