zoukankan      html  css  js  c++  java
  • List<CourseRecord>转HashMap<Long, List<CourseRecord>>

    HashMap<Long, List<CourseRecord>> recordMap = Maps.newHashMap();
            for (CourseRecord courseRecord : courseRecordList) {
                List<CourseRecord> recordList = Lists.newArrayList();
                if (recordMap.containsKey(courseRecord.getStudentId())) {
                    recordList = recordMap.get(courseRecord.getStudentId());
                }
                recordList.add(courseRecord);
                recordMap.put(courseRecord.getStudentId(), recordList);
            }

    结果:

    {
        "code": 200,
        "success": true,
        "data": {
            "1310569218695020546": [
                {
                    "id": "1310781082468171778",
                    "courseId": "1310096960900935681",
                    "studentId": "1310569218695020546",
                    "age": 32,
                    "height": 175,
                    "weight": 70,
                    "deviceId": 562830,
                    "pushTime": "2020-09-29T11:18:58",
                    "heartRate": 61,
                    "isDeleted": 0
                },
                {
                    "id": "1310781087014797314",
                    "courseId": "1310096960900935681",
                    "studentId": "1310569218695020546",
                    "age": 32,
                    "height": 175,
                    "weight": 70,
                    "deviceId": 562830,
                    "pushTime": "2020-09-29T11:18:59",
                    "heartRate": 62,
                    "isDeleted": 0
                },
            ....
        }
    }    
  • 相关阅读:
    交换机技术
    第七周课后总结
    以太网原理
    test
    NetCore第一步:千里之行 始于环境构筑
    第二十课(一)
    第十九课(三)
    第十九课(二)
    第十九课(一)
    第十八课(三)
  • 原文地址:https://www.cnblogs.com/fangts/p/13749511.html
Copyright © 2011-2022 走看看