一对一 一对多
<resultMap id="orderMessageMap" type="com.hywa.orderclient.vo.RiderOrderMessageVo">
<id column="id" property="orderId"/>
<result column="complete" property="status"/>
<result column="create_time" property="createTime"/>
<result column="delivery_time" property="deliveryTime"/>
<result column="purchase_order_number" property="purchaseOrderNumber"/>
<result column="tally_time" property="tallyTime"/>
<result column="rider" property="rider"/>
<association property="logisticsMessageWxVo"
javaType="com.hywa.orderclient.vo.LogisticsMessageWxVo">
<result column="recipient" property="recipient"/>
<result column="recipient_phone" property="recipientPhone"/>
<result column="recipient_address" property="recipientAddress"/>
</association>
<collection property="list" javaType="java.util.List"
ofType="com.hywa.orderclient.vo.TransferOrderOfRiderVo">
<id column="transfer_order_id" property="id"/>
<result column="water_number" property="waterNumber"/>
<result column="seller_name" property="sellerName"/>
<result column="stall_name" property="stallName"/>
<result column="product_name" property="productName"/>
<result column="specification" property="specification"/>
<result column="amount" property="amount"/>
<result column="update_time" property="pickUpTime"/>
<result column="transfer_order_status" property="status"/>
</collection>
</resultMap>
一对多
public class DbAssetsStockAllot extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long aId;
/** 领用部门id */
private Long depId;
/** 领用物资表 */
private List<Long> stockValue;
}
<resultMap type="com.xtd.project.assets.domain.DbAssetsStockAllot" id="DbAssetsStockAllotResultEx">
<result property="aId" column="a_id" />
<result property="depId" column="dep_id" />
<collection property="stockValue" javaType="java.util.List" ofType="java.lang.Long">
<result column="db_as_st_id"/>
</collection>
</resultMap>
SELECT
a.a_id,
a.dep_id,
b.db_as_st_id
FROM
db_assets_stock_allot a
LEFT JOIN db_assets_stock_allot_ex b ON a.a_id = b.allot_id
WHERE
a.a_id = #{aId}
一对多
/**
* 卖家商品展示列表
* @author vic
* */
@Data
@ApiModel(value = "卖家商品展示列表",description = "卖家商品展示列表")
public class SellerProductInfoWxVO implements Serializable {
private static final long serialVersionUID = -1315457250100612951L;
/** 主键*/
@ApiModelProperty(value = "主键",example = "主键")
private String id;
@ApiModelProperty(value = "卖家id",example = "卖家id")
private String sellerId;
@ApiModelProperty(value = "卖家名称",example = "卖家名称")
private String sellerName;
/** 名称*/
@ApiModelProperty(value = "商品名称",example = "商品名称")
private String name;
/** 别名*/
@ApiModelProperty(value = "商品别名",example = "商品别名")
private String goodsName;
/** 商品类型*/
@ApiModelProperty(value = "商品大类型",example = "商品大类型")
private String productBigTypeId;
/** 商品类型*/
@ApiModelProperty(value = "商品类型",example = "商品类型")
private String productTypeId;
/** 商品主键*/
@ApiModelProperty(value = "商品主键",example = "商品主键")
private String productId;
/**商品图标*/
@ApiModelProperty(value = "商品图标",example = "商品图标")
private String imgUrl;
/**状态*/
@ApiModelProperty(value = "状态",example = "状态 0启用,1禁用")
private String enable;
/** 规格信息*/
@ApiModelProperty(value = "规格信息",example = "规格信息")
private List<SellerProductSpec> sellerProductSpecs;
}
<resultMap id="findProductByIdOfBuyerMap" type="com.hywa.supplychain.baseclient.vo.SellerProductInfoWxVO">
<id column="id" property="id" jdbcType="CHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="seller_id" property="sellerId" jdbcType="VARCHAR"/>
<result column="seller_name" property="sellerName" jdbcType="VARCHAR"/>
<result column="goods_name" property="goodsName" jdbcType="VARCHAR"/>
<result column="img_url" property="imgUrl" jdbcType="VARCHAR"/>
<result column="enable" property="enable" jdbcType="VARCHAR"/>
<result column="product_big_type_id" property="productBigTypeId" jdbcType="VARCHAR"/>
<result column="product_type_id" property="productTypeId" jdbcType="VARCHAR"/>
<result column="product_id" property="productId" jdbcType="VARCHAR"/>
<collection property="sellerProductSpecs" javaType="java.util.List"
ofType="com.hywa.supplychain.baseclient.entity.SellerProductSpec">
<id column="specId" property="id" jdbcType="CHAR"/>
<result column="specification" property="specification" jdbcType="VARCHAR"/>
<result column="price" property="price" jdbcType="DOUBLE"/>
<result column="inventory" property="inventory" jdbcType="DOUBLE"/>
<result column="avg_price" property="avgPrice" jdbcType="DOUBLE"/>
</collection>
</resultMap>
<select id="findProductByIdOfBuyer" resultMap="findProductByIdOfBuyerMap">
SELECT
product.id,
info.`name` AS name,
sel.id as seller_id,
sel.`name` AS seller_name,
product.goods_name,
info.img_url,
product.product_big_type_id,
product.product_type_id,
product.product_id,
product. ENABLE,
spec.id AS specId,
spec.specification,
spec.price,
spec.avg_price,
spec.inventory
FROM
t_bp_seller_product_info product
LEFT JOIN t_bp_seller_info sel ON sel.id = product.seller_id
LEFT JOIN t_bs_product_info info ON product.product_id = info.id
LEFT JOIN t_bp_seller_product_spec spec ON product.id = spec.product_id
WHERE
spec.is_del = 0
AND product.id = #{id}
</select>