返回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;
}
}