问题描述
@Result注解column参数传递多个参数。
官方文档
property | description |
---|---|
column | 数据库的列名或者列标签别名。与传递给resultSet.getString(columnName)的参数名称相同。注意: 在处理组合键时,您可以使用column=“{prop1=col1,prop2=col2}”这样的语法,设置多个列名传入到嵌套查询语句。这就会把prop1和prop2设置到目标嵌套选择语句的参数对象中。 |
解决方案
@Mapper
public interface OrdersMapper {
@SelectProvider(type=BillProvider.class , method="queryBillDetail")
@Results({
@Result(id=true,column="id",property="id"),
@Result(column="order_num",property="orderNum"),
@Result(column="{orderId=id,sourceId=source_id}",javaType=BigDecimal.class,property="cbpFee",many=@Many(select="com.ecloud.hobay.orders.service.infrastructure.mapper.wallet.WalletDetailMapper.getchangeFee"))
})
Bill queryBillDetail(QureryBillParams qureryBillParams) throws Exception;
}
@Mapper
public interface WalletDetailMapper {
@Select({"SELECT ABS(changes) changes from wallet_detail WHERE biz_type=1 AND category=1 AND (source_id = #{orderId} or source_id = #{sourceId}) ORDER BY create_time LIMIT 1"})
BigDecimal getchangeFee(Map<String,Object> param);
}
参考文章
https://blog.csdn.net/BL_Endian/article/details/76013843
https://blog.csdn.net/weixin_34055787/article/details/91890168
https://blog.csdn.net/weixin_43297055/article/details/93635950