mybatis 入参为list<Object> 出参map<String,Object> 出参总结

传入list  返回map

//通过MapKey 指定返回map的 key值
@MapKey("keyId")
Map<String, XXXDto> getInvoiceByItems(@Param("XXXDto") List<XXXDto> XXXDtos);

 mapper.xml

<resultMap id="BaseResultMap" type="com.xxx.dto.xxxxDto">
    <result column="keyId" property="keyId"/>
    <result column="xxx" property="xxx"/>
</resultMap>

<select id="getInvoiceByItems" resultMap="BaseResultMap">
    select
    CONCAT(d.xxx,'_',d.xxx)as keyId,  -- 根据需求确定key
    xxx

    from a 
    left join b on a.id = b.id
    where
    <foreach item="xxxDto" index="index" collection="xxxDtos" separator="or">
        (a.xxx= #{xxxDto.xxx})
    </foreach>
</select>

 

posted @ 2021-03-09 14:44  纷纷暮雪春风来  阅读(766)  评论(0编辑  收藏  举报