码迷,mamicode.com
首页 > 其他好文 > 详细

实现MyBatis批量查询

时间:2019-12-09 12:19:50      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:over   mybatis   ESS   ==   system   打印   public   pid   ice   

Service
        public List<DeviceBean> getDeviceList(Map<String, Object> parameter);
ServiceImpl
    @Override
    public Map<String, DeviceBean> getDeviceCollectStateIdByBean(Map<String, Object> parameter) {
        logger.info("DeviceServiceImpl{}==>getDeviceCollectStateIdByBean()");
        return deviceDao.getDeviceCollectStateIdByBean(parameter);
    }
Dao
        public List<DeviceBean> getDeviceList(Map<String, Object> parameter);
DaoImpl
    @Override
    public List<DeviceBean> getDeviceList(Map<String, Object> parameter) {
        logger.info("DeviceDaoImpl{}==>getDeviceList()");
        return getWriteSession().selectList(sqlId("getDeviceList"),parameter);
    }
Mapper
 
    <select id="getDeviceList"   resultType="com.yjkj.zzx.system.bean.DeviceBean" parameterType="map" >
        select
            d.id as id, d.group_id as groupId,d.farm_id as farmId, d.house_id as houseId, d.code
        from t_device d
         WHERE  d.del_flag = ‘0‘ and d.code in
            <foreach item="item" index="index" collection="codelist" open="(" separator="," close=")">  
              #{item}  
            </foreach>
    </select>
测试打印结果
    List<String> codeList =new ArrayList<String>();
    codeList.add("b827ebee9322");
    codeList.add("111");
    codeList.add("1111");
    Map<String,Object> paramap=new HashMap<String,Object>();
    paramap.put("codelist", codeList);
    List<DeviceBean> res11 = deviceService.getDeviceList(paramap);
    System.out.println(res11);





 

实现MyBatis批量查询

标签:over   mybatis   ESS   ==   system   打印   public   pid   ice   

原文地址:https://www.cnblogs.com/zhuyeshen/p/12009824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!