<?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.sun.foodie.mapper.ItemsMapper">
<resultMap id="newItems" type="com.sun.foodie.pojo.vo.NewItemsVO" autoMapping="true">
<id column="rootCatId" property="rootCatId"/>
<result column="rootCatName" property="rootCatName"/>
<collection property="simpleItemList" ofType="com.sun.foodie.pojo.vo.SimpleItemVO" autoMapping="true"/>
</resultMap>
<select id="selectSixNewItems" resultMap="newItems">
SELECT
c.id as rootCatId,
c.`name` as rootCatName,
c.slogan as slogan,
c.cat_image as catImage,
c.bg_color as bgColor,
i.id as itemId,
i.item_name as itemName,
ii.url as itemUrl,
i.created_time as createdTime
FROM
category c
LEFT JOIN
items i
ON
c.id = i.root_cat_id
LEFT JOIN
items_img ii
ON
ii.item_id = i.id
WHERE
i.on_off_status = 1
AND
c.type = 1
AND
ii.is_main = 1
AND
c.id = #{rootCatId}
ORDER BY i.created_time DESC
LIMIT 0, 6
</select>
</mapper>