pet/com.datang.pet.mapper/target/classes/mapperExtend/GoodsListMapperExtend.xml

95 lines
4.5 KiB
XML

<?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.datang.pet.mapperExtend.GoodsMapperExtend">
<resultMap id="getGoodsListResultMap" type="com.datang.pet.vo.GoodsList">
<result column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="visit_give_location" jdbcType="VARCHAR" property="visitGiveLocation" />
<result column="image" jdbcType="VARCHAR" property="image" />
<result column="presentation" jdbcType="VARCHAR" property="presentation" />
<result column="src" jdbcType="VARCHAR" property="src" />
<collection property="specList" ofType="com.datang.pet.pojo.Spec">
<result column="spec_id" jdbcType="VARCHAR" property="specId"/>
<result column="goods_id" jdbcType="VARCHAR" property="goodsId"/>
<result column="spec_name" jdbcType="VARCHAR" property="specName"/>
<result column="price" jdbcType="DOUBLE" property="price"/>
</collection>
</resultMap>
<resultMap id="getShoppingCarListResultMap" type="com.datang.pet.vo.GetShoppingCarList">
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="goods_id" jdbcType="VARCHAR" property="goodsId" />
<result column="quantity" jdbcType="INTEGER" property="quantity" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="spec" jdbcType="VARCHAR" property="spec" />
<result column="name" jdbcType="DOUBLE" property="name" />
<result column="visit_give_location" jdbcType="VARCHAR" property="visitGiveLocation" />
<result column="image" jdbcType="VARCHAR" property="image" />
<result column="presentation" jdbcType="VARCHAR" property="presentation" />
<result column="spec_id" jdbcType="VARCHAR" property="specId" />
<result column="spec_name" jdbcType="VARCHAR" property="specName" />
<result column="price" jdbcType="DOUBLE" property="price" />
<result column="src" jdbcType="VARCHAR" property="src" />
</resultMap>
<resultMap id="getGoodsInfoResultMap" type="com.datang.pet.vo.GetGoodsInfo">
<result column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="visit_give_location" jdbcType="VARCHAR" property="visitGiveLocation" />
<result column="image" jdbcType="VARCHAR" property="image" />
<result column="presentation" jdbcType="VARCHAR" property="presentation" />
<result column="presentation_url" jdbcType="VARCHAR" property="presentationUrl" />
<collection property="srcList" ofType="com.datang.pet.pojo.Resource">
<result column="src" jdbcType="VARCHAR" property="src"></result>
</collection>
<collection property="specList" ofType="com.datang.pet.pojo.Spec">
<result column="spec_id" jdbcType="VARCHAR" property="specId"></result>
<result column="goods_id" jdbcType="VARCHAR" property="goodsId"></result>
<result column="spec_name" jdbcType="VARCHAR" property="specName"></result>
<result column="price" jdbcType="VARCHAR" property="price"></result>
</collection>
</resultMap>
<select id="getGoodsList" resultMap="getGoodsListResultMap">
SELECT * FROM
(
SELECT goods.*,resource.src FROM goods LEFT JOIN resource ON image = resource.id AND resource.sequence = 1
)AS g
LEFT JOIN spec AS s ON g.id=s.goods_id
</select>
<select id="getShoppingCarList" resultMap="getShoppingCarListResultMap">
SELECT s.*,r.src FROM
(
SELECT g.*,s.spec_id,s.spec_name,s.price FROM
(
SELECT s.*,g.name,g.visit_give_location,g.image,g.presentation FROM
(
SELECT * FROM shopping_car WHERE user_id=#{userId}
)AS s
LEFT JOIN goods AS g ON s.goods_id = g.id
)AS g LEFT JOIN spec AS s ON g.spec = s.spec_id
)AS s LEFT JOIN resource AS r ON s.image = r.id AND r.sequence=1
ORDER BY s.create_date DESC
</select>
<select id="getGoodsInfo" resultMap="getGoodsInfoResultMap">
SELECT g.*,r.src AS presentation_url FROM
(
SELECT g.*,r.src FROM
(
SELECT * FROM
(
SELECT * FROM goods WHERE id =#{goodsId}
)AS g
LEFT JOIN spec AS s ON g.id=s.goods_id
)AS g
LEFT JOIN resource AS r ON g.image = r.id
)AS g
LEFT JOIN resource AS r ON g.presentation = r.id
</select>
</mapper>