Mybatis返回Map<String,List>数据格式

参考:mybatis 返回Map<String,List<Entity>> 格式数据

返回Map包含List格式:Map<String,List>, 把List用对象包起来就可以了

Map<String, TScteTableCashierRelate>,一个termId对应多个cashierId,相当于group by term_id后的数据

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.MapKey;
import com.scte.model.TScteTableCashierRelate;

public interface TScteTableCashierRelateMapper {
    @MapKey("termId")
    Map<String, TScteTableCashierRelate> selectByTermList(Map<String,Object> map);
}
  <resultMap id="BaseResultMap" type="com.scte.model.TScteTableCashierRelate">
    <result column="term_id" jdbcType="VARCHAR" property="termId" />
    <result column="tm_serial_no" jdbcType="VARCHAR" property="tmSerialNo" />
    <collection property="cashierList" ofType="com.fuiou.scte.model.CashierListModel">
      <result column="cashier_id" jdbcType="VARCHAR" property="cashierId" />
    </collection>
  </resultMap>

  <select id="selectByTermList" parameterType="java.util.Map" resultMap="BaseResultMap">
    select mchnt_cd, shop_id, term_id, tm_serial_no, cashier_id
    from t_scte_table_cashier_relate
    where mchnt_cd = #{mchntCd} and shop_id = #{shopId}
    	and term_id in (<foreach collection="termList" item="item" index="index" separator=",">#{item}</foreach> )
  </select>
public class TScteTableCashierRelate {
    private String termId;     // 终端号
    private String tmSerialNo; // 终端序列号
    private List<CashierListModel> cashierList; // 收银员列表

    public String getTermId() {
        return termId;
    }

    public void setTermId(String termId) {
        this.termId = termId;
    }

    public List<CashierListModel> getCashierList() {
        return cashierList;
    }

    public void setCashierList(List<CashierListModel> cashierList) {
        this.cashierList = cashierList;
    }
}
public class CashierListModel{

    /** 收银员账号*/
    private String cashierId;

    /** 收银员名称 */
    private String cashierName;


    public String getCashierId() {
        return cashierId;
    }

    public void setCashierId(String cashierId) {
        this.cashierId = cashierId;
    }

    public String getCashierName() {
        return cashierName;
    }

    public void setCashierName(String cashierName) {
        this.cashierName = cashierName;
    }
}
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值