<?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"><mappernamespace="com.chudong.xy.dao.item.IItemDao"><resultMaptype="Item"id="itemResultMap" ><idproperty="id"column="id" /><resultproperty="numIid"column="num_iid" /><resultproperty="title"column="title" /><resultproperty="subTitle"column="sub_title" /><resultproperty="cat"column="cat" /><resultproperty="picUrl"column="pic_url" /><resultproperty="picThumUrl"column="pic_thum_url" /><resultproperty="outerId"column="outer_id" /><resultproperty="props"column="props" /><resultproperty="marketPrice"column="market_price" /><resultproperty="price"column="price" /><resultproperty="num"column="num" /><resultproperty="listTime"column="list_time" /><resultproperty="delistTime"column="delist_time" /><resultproperty="sales"column="sales" /><resultproperty="created"column="created" /><resultproperty="modified"column="modified" /><resultproperty="enableStatus"column="enable_status" /></resultMap><!-- 与活动和搭配套餐进行关联 --><resultMaptype="Item"id="itemDetailResultMap"extends="itemResultMap"><associationproperty="active"column="id"javaType="com.chudong.xy.domain.active.Active"select="selectActive"/><collectionproperty="withPackages"column="id"javaType="java.util.ArrayList"ofType="com.chudong.xy.domain.item.Item"select="selectWithPackages"/></resultMap><resultMaptype="Active"id="activeResultMap"><idproperty="id"column="id" /><resultproperty="title"column="title" /><resultproperty="picUrl"column="pic_url" /></resultMap><!-- 查询单个商品,并装载活动和搭配套餐 --><selectid="queryDetailById"parameterType="long"resultMap="itemDetailResultMap">
SELECT * from item where id = #{id} and enable_status = 1
</select><!-- 根据商品id得到一个活动 --><selectid="selectActive"parameterType="long"resultMap="activeResultMap">
select id,title,pic_url from active where id = (select active_id from active_item where item_id = #{id} and enable_status=1 limit 0,1)
</select><!-- 根据商品id得到搭配套餐中的商品 --><selectid="selectWithPackages"parameterType="long"resultMap="itemResultMap">
select * from item where id in(select mapping_id from item_relation where item_id = #{id} and type=1 and enable_status=1)
</select></mapper>