51 lines
1.2 KiB
Java
51 lines
1.2 KiB
Java
package com.dota.nexus.controller;
|
|
|
|
import com.dota.nexus.entity.Anniversary;
|
|
import com.dota.nexus.entity.R;
|
|
import com.dota.nexus.service.AnniversaryService;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@RestController
|
|
@RequestMapping("anniversary")
|
|
public class AnniversaryController {
|
|
AnniversaryService anniversaryService;
|
|
|
|
public AnniversaryController(AnniversaryService anniversaryService) {
|
|
this.anniversaryService = anniversaryService;
|
|
}
|
|
|
|
/**
|
|
* 获取未来所有周年日和纪念日
|
|
*/
|
|
@GetMapping("future")
|
|
public R getFuture() {
|
|
return R.ok(anniversaryService.getFuture());
|
|
}
|
|
|
|
/**
|
|
* 获取过去的纪念日
|
|
*/
|
|
@GetMapping("past")
|
|
public R getPast() {
|
|
return R.ok(anniversaryService.getPast());
|
|
}
|
|
|
|
@PostMapping
|
|
public R add(Anniversary anniversary) {
|
|
anniversaryService.saveOrUpdate(anniversary);
|
|
return R.ok();
|
|
}
|
|
|
|
@DeleteMapping
|
|
public R del(Integer id) {
|
|
anniversaryService.removeById(id);
|
|
return R.ok();
|
|
}
|
|
|
|
@PutMapping
|
|
public R update(Anniversary anniversary) {
|
|
anniversaryService.saveOrUpdate(anniversary);
|
|
return R.ok();
|
|
}
|
|
}
|