购物车系列_映射文件

<mapper namespace="com.bw.dao.ShoppingCarMapper">
     <insert id="insertShoppingCar" useGeneratedKeys="true" keyProperty="id" parameterType="shoppingCar">
        insert into t_shoppingCar(p_id,u_id,count,priceCount)
        values(#{product.id},#{user.id},#{count},#{priceCount})
         <selectKey  resultType="int"  order="AFTER"  keyProperty="id">
            SELECT LAST_INSERT_ID()  AS  id
        </selectKey>
    </insert>
    
    <resultMap type="shoppingCar" id="rm">
        <id column="id"  property="id"/>
        <result column="count" property="count"/>
        <result column="priceCount" property="priceCount"/>
    
        <association property="product" javaType="product">
            <id column="p_id" property="id"/>
            <result column="name" property="name"/>
            <result column="price" property="price"/>
            <result column="describe" property="describe"/>
        </association>
        <association property="user" javaType="user">
            <id column="u_id" property="id"/>
            <result column="uname" property="name"/>
            <result column="email" property="email"/>
        </association>
    </resultMap>
    <select id="selectById" parameterType="integer" resultMap ="rm">
        select distinct * from t_shoppingCar s,t_order o  where s.id !=o.shoppingCar_id and s.p_id=#{id}
    </select>
    <update id="updateShoppingCar" parameterType="shoppingCar">
    update t_shoppingCar set count=#{count}  where id=#{id}
    </update>
    <insert id="insertOeder" parameterType="integer">
        insert into t_order(shoppingCar_id) values(#{id})
    </insert>
    <select id="selectShop" parameterType="user" resultMap="rm">
        select distinct s.*,p.* from t_shoppingCar s,t_order o , t_product p  where s.id !=o.shoppingCar_id and s.p_id=p.id and s.u_id=#{id}
    </select>    
    <delete id="deleteShop" parameterType="ids">
        delete from t_shoppingCar where u_id=#{uid}
        <if test="sid!=0">
        and id=#{sid}
        </if>
    </delete>
    <update id="updateShop" parameterType="shoppingCar">
    update t_shoppingCar set count=#{count},priceCount=#{priceCount}  where id=#{id}
    </update>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值