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