wms-serve-mule/src/main/resources/mapper/GoodsMapper.xml

79 lines
3.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.wms.mapper.GoodsMapper">
<resultMap type="Goods" id="GoodsMap">
<result property="goodsId" column="goods_id"/>
<result property="goodsName" column="goods_name"/>
<result property="goodsUnit" column="goods_unit"/>
<result property="lifeDays" column="life_days"/>
<result property="remark" column="remark"/>
<result property="singleWeight" column="single_weight"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectAll">
select goods_id,goods_name, goods_unit, life_days, remark, single_weight,create_time, update_time
from tbl_app_goods
</sql>
<select id="selGoods" parameterType="Goods" resultMap="GoodsMap">
<include refid="selectAll"/>
<where>
<if test="goodsId != null and goodsId != ''"> and goods_id = #{goodsId}</if>
<if test="goodsName!= null and goodsName != ''"> and goods_name like concat('%',#{goodsName},'%')</if>
<if test="goodsUnit != null and goodsUnit != ''"> and goods_unit = #{goodsUnit}</if>
<if test="lifeDays != null"> and life_days = #{lifeDays}</if>
<if test="remark != null"> and remark = #{remark}</if>
<if test="singleWeight != null"> and single_weight = #{single_weight}</if>
<if test="updateTime != null"> and update_time = #{updateTime}</if>
<if test="createTime != null"> and create_time = #{create_time}</if>
</where>
order by create_time desc
</select>
<select id="selGoodsByGoodsName" parameterType="String" resultMap="GoodsMap">
<include refid="selectAll"/>
where goods_name = #{goodsName};
</select>
<insert id="addGoods" parameterType="Goods">
insert into tbl_app_goods
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="goodsId != null">goods_id,</if>
<if test="goodsName != null">goods_name,</if>
<if test="goodsUnit != null">goods_unit,</if>
<if test="lifeDays != null">life_days,</if>
<if test="remark != null"> remark</if>
<if test="singleWeight != null">single_weight</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="goodsId != null">#{goodsId},</if>
<if test="goodsName != null">#{goodsName},</if>
<if test="goodsUnit != null">#{goodsUnit},</if>
<if test="lifeDays != null">#{lifeDays},</if>
<if test="remark != null"> #{remark}</if>
<if test="singleWeight != null">#{singleWeight}</if>
</trim>
</insert>
<update id="modifyGoods" parameterType="Goods">
update tbl_app_goods
<trim prefix="SET" suffixOverrides=",">
<if test="goodsUnit != null">goods_unit = #{goodsUnit},</if>
<if test="lifeDays != null">life_days = #{lifeDays},</if>
<if test="remark != null"> remark= #{remark},</if>
<if test="singleWeight != null">single_weight = #{singleWeight},</if>
</trim>
where goods_id = #{goodsId}
</update>
<delete id="deleteGoods" parameterType="String">
delete from tbl_app_goods where goods_id = #{goodsId}
</delete>
<update id="clearGoodsInfo" parameterType="String">
truncate table tbl_app_goods
</update>
</mapper>