<?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.m2pool.lease.mapper.LeaseShoppingCartInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.m2pool.lease.entity.LeaseShoppingCartInfo">
        <id column="id" property="id" />
        <result column="product_id" property="productId" />
        <result column="product_machine_id" property="productMachineId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, cart_id, product_id, product_machine_id, create_time, update_time
    </sql>

    <select id="getProductAndMachineIds" resultType="com.m2pool.lease.dto.ShoppingCartInfoDto">
        select product_machine_id as productMachineId,
               product_id as productId,
               lease_time as leaseTime
        from lease_shopping_cart_info
        where user_id = #{userId} and version = #{version}
    </select>

    <delete id="deleteBatchData">
        DELETE FROM lease_shopping_cart_info
        WHERE id IN
        <foreach item="id" index="index" collection="ids"
                 open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>
