166 lines
7.5 KiB
XML
166 lines
7.5 KiB
XML
<?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.GoodsStandardMapper">
|
|
|
|
<resultMap id="GoodsStandardResult" type="com.ghy.goods.domain.GoodsStandard">
|
|
<result property="goodsStandardId" column="goods_standard_id"/>
|
|
<result property="goodsStandardName" column="goods_standard_name"/>
|
|
<result property="goodsId" column="goods_id"/>
|
|
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
|
<result property="goodsPrice" column="goods_price"/>
|
|
<result property="extMoney" column="ext_money"/>
|
|
<result property="discountPrice" column="discount_price"/>
|
|
<result property="groupPrice" column="group_price"/>
|
|
<result property="goodsNum" column="goods_num"/>
|
|
<result property="goodsUnit" column="goods_unit"/>
|
|
<result property="saleNum" column="sale_num"/>
|
|
<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>
|
|
|
|
<sql id="selectGoodsStandard">
|
|
SELECT goods_standard_id,
|
|
goods_standard_name,
|
|
goods_id,
|
|
dept_goods_category_id,
|
|
goods_price,
|
|
ext_money,
|
|
discount_price,
|
|
group_price,
|
|
goods_num,
|
|
goods_unit,
|
|
create_by,
|
|
create_time,
|
|
sale_num,
|
|
status,
|
|
update_by,
|
|
update_time,
|
|
remark
|
|
FROM goods_standard
|
|
</sql>
|
|
|
|
<select id="selectById" resultMap="GoodsStandardResult">
|
|
<include refid="selectGoodsStandard"/>
|
|
<where>
|
|
<if test="goodsStandardId != null and goodsStandardId != 0">
|
|
AND goods_standard_id = #{goodsStandardId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectByIds" resultMap="GoodsStandardResult">
|
|
<include refid="selectGoodsStandard"/>
|
|
where goods_standard_id in
|
|
<foreach collection="collection" item="goodsStandardIds" open="(" separator="," close=")">
|
|
#{goodsStandardIds}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectByGoodsId" parameterType="long" resultMap="GoodsStandardResult">
|
|
<include refid="selectGoodsStandard"/>
|
|
<where>
|
|
<if test="goodsId != null ">
|
|
AND goods_id = #{goodsId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectByGoodsStandardId" parameterType="long" resultMap="GoodsStandardResult">
|
|
<include refid="selectGoodsStandard"/>
|
|
<where>
|
|
<if test="goodsId != null ">
|
|
AND goods_standard_id = #{goodsId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<insert id="insertGoodsStandard" parameterType="com.ghy.goods.domain.GoodsStandard" useGeneratedKeys="true" keyProperty="goodsStandardId">
|
|
insert into goods_standard (
|
|
<if test="goodsStandardName != null and goodsStandardName != ''">goods_standard_name,</if>
|
|
<if test="goodsId != null and goodsId != ''">goods_id,</if>
|
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id,</if>
|
|
<if test="goodsPrice != null and goodsPrice != ''">goods_price,</if>
|
|
<if test="extMoney != null and extMoney != ''">ext_money,</if>
|
|
<if test="discountPrice != null and discountPrice != ''">discount_price,</if>
|
|
<if test="groupPrice != null and groupPrice != ''">group_price,</if>
|
|
<if test="goodsUnit != null and goodsUnit != ''">goods_unit,</if>
|
|
<if test="goodsNum != null and goodsNum != ''">goods_num,</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="goodsStandardName != null and goodsStandardName != ''">#{goodsStandardName},</if>
|
|
<if test="goodsId != null and goodsId != ''">#{goodsId},</if>
|
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">#{deptGoodsCategoryId},</if>
|
|
<if test="goodsPrice != null and goodsPrice != ''">#{goodsPrice},</if>
|
|
<if test="extMoney != null and extMoney != ''">#{extMoney},</if>
|
|
<if test="discountPrice != null and discountPrice != ''">#{discountPrice},</if>
|
|
<if test="groupPrice != null and groupPrice != ''">#{groupPrice},</if>
|
|
<if test="goodsUnit != null and goodsUnit != ''">#{goodsUnit},</if>
|
|
<if test="goodsNum != null and goodsNum != ''">#{goodsNum},</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>
|
|
|
|
<insert id="batchInsert" parameterType="list">
|
|
INSERT INTO goods_standard (
|
|
goods_standard_name, goods_id, dept_goods_category_id, goods_price, ext_money, discount_price, group_price, goods_unit, goods_num,
|
|
sale_num, status, remark, create_by, create_time )
|
|
VALUES
|
|
<foreach collection="goodsStandards" separator="," item="goodsStandard">
|
|
(
|
|
#{goodsStandard.goodsStandardName}, #{goodsStandard.goodsId}, #{goodsStandard.deptGoodsCategoryId}, #{goodsStandard.goodsPrice}, #{goodsStandard.extMoney}, #{goodsStandard.discountPrice},
|
|
#{goodsStandard.groupPrice}, #{goodsStandard.goodsUnit}, #{goodsStandard.goodsNum}, 0, #{goodsStandard.status}, #{goodsStandard.remark}, #{goodsStandard.createBy}, sysdate()
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="checkStore" resultMap="GoodsStandardResult">
|
|
<include refid="selectGoodsStandard"/>
|
|
where goods_standard_id = #{goodsStandardId}
|
|
and goods_num >= #{num}
|
|
</select>
|
|
|
|
<delete id="deleteByGoodsId" parameterType="Long">
|
|
DELETE FROM goods_standard
|
|
WHERE goods_id = #{goodsId}
|
|
</delete>
|
|
|
|
<update id="updateSaleNum">
|
|
update
|
|
goods_standard
|
|
set
|
|
sale_num = #{saleNum}
|
|
where
|
|
goods_standard_id = #{goodsStandardId}
|
|
</update>
|
|
|
|
<update id="update">
|
|
UPDATE goods_standard
|
|
<set>
|
|
<if test="goodsStandardName != null and goodsStandardName != ''">goods_standard_name = #{goodsStandardName},</if>
|
|
<if test="goodsId != null">goods_id = #{goodsId},</if>
|
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id = #{deptGoodsCategoryId},</if>
|
|
<if test="goodsPrice != null">goods_price = #{goodsPrice},</if>
|
|
<if test="extMoney != null">ext_money = #{extMoney},</if>
|
|
<if test="discountPrice != null">discount_price = #{discountPrice},</if>
|
|
<if test="groupPrice != null">group_price = #{groupPrice},</if>
|
|
<if test="goodsUnit != null">goods_unit = #{goodsUnit},</if>
|
|
<if test="goodsNum != null">goods_num = #{goodsNum},</if>
|
|
<if test="status != null">`status` = #{status},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
update_time = sysdate()
|
|
</set>
|
|
WHERE goods_standard_id = #{goodsStandardId}
|
|
</update>
|
|
</mapper>
|