新增添加商品和修改商品mapper层
This commit is contained in:
parent
558d25cbd0
commit
a3f2db85cd
|
|
@ -10,6 +10,18 @@ import java.util.List;
|
|||
*/
|
||||
public interface GoodsMapper {
|
||||
|
||||
/**
|
||||
* @param goods 商品属性
|
||||
* @return 成功条数
|
||||
*/
|
||||
public int insertGoods(Goods goods);
|
||||
|
||||
/**
|
||||
* @param goods 商品属性
|
||||
* @return 成功条数
|
||||
*/
|
||||
public int updateGoods(Goods goods);
|
||||
|
||||
/**
|
||||
* @param goods 商品入参
|
||||
* @return 商品集合
|
||||
|
|
@ -17,7 +29,11 @@ public interface GoodsMapper {
|
|||
public List<Goods> selectGoodsList(Goods goods);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param goodsId 商品id
|
||||
* @return 商品
|
||||
*/
|
||||
public Goods selectById(Long goodsId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
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="Goods">
|
||||
<resultMap id="GoodsResult" type="com.ghy.goods.domain.Goods">
|
||||
<id property="goodsId" column="goods_id" />
|
||||
<result property="goodsCode" column="goods_code" />
|
||||
<result property="companyId" column="company_id" />
|
||||
|
|
@ -21,14 +21,14 @@
|
|||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGoodsVo">
|
||||
<sql id="selectGoods">
|
||||
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 sys_post
|
||||
from goods
|
||||
</sql>
|
||||
|
||||
<select id="selectGoodsList" parameterType="Goods" resultMap="GoodsResult">
|
||||
<include refid="selectGoodsVo" />
|
||||
<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}, '%')
|
||||
|
|
@ -36,4 +36,49 @@
|
|||
</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>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue