1 /** 2 * 查询产品的医保名称、省标名称 3 * @param productIds 4 * @return 5 */ 6 @MapKey("productId") 7 public Map<Long,ProvinceProduct> selectCheckProductNameOpenProductDirectoryNameInMap(@Param("productIds") List<Long> productIds);
<resultMap type="ProvinceProduct" id="ProvinceProductResult"> <result property="productId" column="product_id" /> <result property="openProductDirectoryName" column="open_product_directory_name"/> <result property="medicalName" column="medical_name"/> </resultMap> <!-- 查询医保名称、省标名称 --> <select id="selectCheckProductNameOpenProductDirectoryNameInMap" parameterType="list" resultMap="ProvinceProductResult"> /* select a.product_id, opp.open_product_directory_name, spc.medical_name,spc.product_name check_product_name from sys_product a left join sys_product_province_relation ppr on a.product_id = ppr.product_id left join sys_open_product_price opp on ppr.open_product_price_id = opp.open_product_price_id LEFT JOIN sys_price_set sps on a.product_id=sps.product_id LEFT JOIN sys_price_way spw on spw.price_set_id=sps.price_set_id left join sys_product_check spc on a.yb_id = spc.yb_id WHERE spw.price_way_code=101 and a.product_status !=2 and a. product_id in <foreach item="productId" collection="productIds" open="(" separator="," close=")"> #{productId} </foreach> */ select 1 product_id, '省标名称11' open_product_directory_name, '医保名称11' check_product_name union select 1 product_id, '省标名称12' open_product_directory_name, '医保名称12' check_product_name union select 1 product_id, '省标名称13' open_product_directory_name, '医保名称13' check_product_name union select 2 product_id, '省标名称21' open_product_directory_name, '医保名称22' check_product_name union select 2 product_id, '省标名称22' open_product_directory_name, '医保名称22' check_product_name union select 3 product_id, '省标名称31' open_product_directory_name, '医保名称31' check_product_name union select 3 product_id, '省标名称32' open_product_directory_name, '医保名称32' check_product_name union select 3 product_id, '省标名称33' open_product_directory_name, '医保名称33' check_product_name </select>
返回结果: 1==>医保名称13--省标名称13--1 2==>医保名称22--省标名称22--2 3==>医保名称33--省标名称33--3 结论:key相同时,会返回最后一条数据
标签:Map,product,name,省标,查询,名称,Mybatis,open,id From: https://www.cnblogs.com/thaipine/p/16910855.html