package nju.seec.SEECdemo.web.controller; import nju.seec.SEECdemo.web.dto.BuildRecordDTO; import org.springframework.web.bind.annotation.*; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; @RestController @RequestMapping("/api/project") public class ProjectController { private static final int BUILD_SUCCESS = 1; private static final int BUILD_FAILURE = -1; private static final int UNCOMMITTED = 0; @GetMapping("/test") public String create() { return "success"; } @PostMapping("/{id:\\d+}/recentBuild") public List getBuildRecords(@PathVariable int id, @RequestParam(value = "count") int count) { List recordDTOList = new ArrayList<>(); for (int i = 1; i <= count; i++) { BuildRecordDTO recordDTO = new BuildRecordDTO(); recordDTO.setId(i); recordDTO.setBuildTime(new Timestamp(System.currentTimeMillis() - i * 10000)); recordDTOList.add(recordDTO); } return recordDTOList; } @PostMapping("/lastBuild") public int getLastBuildResult() { return BUILD_SUCCESS; } }