ghy-all/ghy-goods/src/main/resources/mapper.goods/GoodsMapper.xml

84 lines
4.1 KiB
XML
Raw Normal View History

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">
<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" />
<result property="companyId" column="company_id" />
<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"/>
<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>
<sql id="selectGoods">
2022-03-14 11:31:02 +08:00
select goods_id, goods_code, company_id, goods_name, goods_price, goods_sort, goods_category_id,
goods_img_url, goods_number, status, create_by, create_time, remark
from goods
2022-03-14 11:31:02 +08:00
</sql>
<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>
</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>
<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">
insert into sys_post(
<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
</mapper>