<?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.zhongzheng.modules.base.mapper.ShoppingCartMapper">

    <resultMap type="com.zhongzheng.modules.base.domain.ShoppingCart" id="ShoppingCartResult">
        <result property="id" column="id"/>
        <result property="goodsId" column="goods_id"/>
        <result property="userId" column="user_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="status" column="status"/>
    </resultMap>

    <resultMap type="com.zhongzheng.modules.base.vo.ShoppingCartVo" id="ShoppingCartVoResult">
        <result property="id" column="id"/>
        <result property="goodsId" column="goods_id"/>
        <result property="status" column="status"/>

        <result property="goodsName" column="goods_name"/>
        <result property="standPrice" column="stand_price"/>
        <result property="coverUrl" column="cover_url"/>
        <result property="goodsStatus" column="goods_status"/>
        <result property="goodsType" column="goods_type"/>
        <result property="templateType" column="template_type"/>
        <result property="projectId" column="project_id"/>
    </resultMap>

    <select id="selectList" parameterType="com.zhongzheng.modules.base.bo.ShoppingCartQueryBo"  resultMap="ShoppingCartVoResult">
        SELECT
            s.id,
            s.goods_id,
            g.stand_price,
            g.cover_url,
            g.goods_type,
            g.goods_name,
            g.`status`,
            g.goods_status,
            g.project_id,
            ot.type AS template_type
        FROM
            shopping_cart s
                LEFT JOIN goods g ON s.goods_id = g.goods_id
                LEFT JOIN course_business cb ON g.business_id = cb.id
                LEFT JOIN order_input_template ot ON cb.template_status = ot.id
        WHERE
            s.user_id =  #{userId}
    </select>
</mapper>
