fengxiang
2018-07-17 04bc6b13175f4274933b42278576be9e18ab8ef7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.moral.controller;
 
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.moral.mapper.DemoMapper;
 
@RestController
@RequestMapping("demo")
public class DemoConreoller {
 
    @Resource
    private DemoMapper demoMapper;
    
    @GetMapping("list")
    public List<Map<String, Object>> getDatas(){
        List<Map<String, Object>> list = demoMapper.getDatas();
        Collections.sort(list, new Comparator<Map<String, Object>>() {
            @Override
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                return ((Date)o1.get("time")).compareTo((Date)o2.get("time"));
            }
        });
        return list;
    }
}