mybatis返回一个map集合

mybatis中resulttype如下定义即可:

 
    

mapper接口:

 List> selOrdersState();

下面是将接收到的map进行处理:

 @Override
    public Map selOrdersState() {
        Map stateMap = new HashMap<>();
        List> mapList = orderMapper.selOrdersState();
        for (Map map: mapList) {
            String state =null;
            Integer state_id = null;
            for (Map.Entry maps:map.entrySet()) {
                System.out.println("key"+maps.getKey());
                //System.out.println("key"+maps.getValue());
                if("state_id".equals(maps.getKey())){
                    state_id = new Integer(String.valueOf(maps.getValue()));
                }
                if("state".equals(maps.getKey())){
                    state = String.valueOf(maps.getValue());
                }
                stateMap.put(state_id,state);
            }
        }
        return stateMap ;
    }

你可能感兴趣的:(mybatis返回一个map集合)