Contents
  1. 1. Write Statistical SQLs
  2. 2. Define Parameter and Response VOs
  3. 3. Write the APIs

Write Statistical SQLs

Before write the code, you can write statistical SQLs first. Because the core of statistical APIs are SQLs. As the saying goes, “first, solve the problem, then, write the code”.

Define Parameter and Response VOs

VO (value object) is typically used for data transfer between business layers and only contains data.

Parameter VOs

1
2
3
4
5
6
7
8
@Data
public class SomeStatParam {
private Date beginTime;
private Date endTime;
private Integer type;
private Integer userId;
...
}

Response VOs

1
2
3
4
@Data
public class someStatResult {
...
}

Write the APIs

1
2
3
4
5
6
7
8
9
@RestController
@RequestMapping(value = "/moduleName")
public class SomeStatController {
@GetMapping(value = "/getSomeStat")
public ResponseEntity<SomeStatResult> getSomeStat(SomeStatParam someStatParam) {
SomeStatResult data = someStatService.getSomeStat(someStatParam);
return ResponseEntity.ok(data);
}
}
Contents
  1. 1. Write Statistical SQLs
  2. 2. Define Parameter and Response VOs
  3. 3. Write the APIs