<?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="cn.jnu.core.dao.GoodDao" >
<!-- 创建商品
<insert id="createGood" parameterType="Good" >
insert into m_good (
user_id, good_name, description, depreciation, good_price, good_status, good_photo
)
values (
#{user_id},
#{name, jdbcType=VARCHAR},
#{description, jdbcType=VARCHAR},
#{depreciation, jdbcType=NUMERIC},
#{price, jdbcType=NUMERIC},
#{status, jdbcType=NUMERIC},
#{photo, jdbcType=VARCHAR}
)
</insert>
-->
<!-- 调用存储过程,插入商品并返回数据库中生成的id -->
<update id="createGood" parameterType="Good" statementType="CALLABLE">
call proc_add_good(
#{user_id, jdbcType=NUMERIC},
#{name, jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{depreciation, jdbcType=NUMERIC},
#{price, jdbcType=NUMERIC},
#{status, jdbcType=NUMERIC},
#{photo, jdbcType=NUMERIC},
#{goods_id, mode=OUT, jdbcType=NUMERIC, javaType=Integer}
)
</update>
<!-- 根据id查询某件商品的信息 -->
<select id="findById" parameterType="Integer" resultType="GoodQueryVo">
select good_name name, description, depreciation, good_price, a.user_id seller_id, username seller
from m_good a, m_user b
where a.user_id = b.user_id and goods_id = #{gid}
</select>
<!-- 根据gid删除指定商品 -->
<delete id="deleteGood" parameterType="Integer" >
delete from m_good
where goods_id = #{gid}
</delete>
<!-- 修改商品信息 -->
<update id="updateGood" parameterType="Good" >
update m_good
<set>
<if test="name != null and name != ''" >
good_name = #{name},
</if>
<if test="description != null and description != ''" >
description = #{description},
</if>
<if test="depreciation != null">
depreciation = #{depreciation},
</if>
<if test="price != null">
good_price = #{price},
</if>
</set>
where goods_id = #{gid}
</update>
<!-- 商品进行搜索 -->
<select id="findGoodList" parameterType="Map" resultType="Good" >
select goods_id, a.user_id, good_name name, description, depreciation, good_price price,
good_status status, create_time createTime, good_photo photo
from m_good a, m_user b
<where>
a.user_id = b.user_id
<if test="good_name != null and good_name != ''" >
and good_name like concat('%', concat(#{good_name}, '%'))
</if>
<if test="user_name != null and user_name != ''" >
and username like concat('%', concat(#{user_name}, '%'))
</if>
<if test="depreciation != null" >
and depreciation >= #{depreciation}
</if>
<if test="price_max != null" >
and price <= #{price_max}
</if>
<if test="price_min != null" >
and price >= #{price_min}
</if>
</where>
</select>
</mapper>
GoodDao
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...