add: 目标crud
This commit is contained in:
64
src/main/java/com/dota/nexus/controller/GoalController.java
Normal file
64
src/main/java/com/dota/nexus/controller/GoalController.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.dota.nexus.controller;
|
||||
|
||||
import com.dota.nexus.entity.Goal;
|
||||
import com.dota.nexus.entity.R;
|
||||
import com.dota.nexus.service.GoalService;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController("goal")
|
||||
public class GoalController {
|
||||
GoalService goalService;
|
||||
|
||||
public GoalController(GoalService goalService) {
|
||||
this.goalService = goalService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增目标
|
||||
*/
|
||||
@GetMapping
|
||||
public R addGoal(Goal goal) {
|
||||
goalService.save(goal);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除目标
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R deleteGoal(Integer id) {
|
||||
goalService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成目标
|
||||
*/
|
||||
@PostMapping("done")
|
||||
public R doneGoal(Integer id) {
|
||||
goalService.doneGoal(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 目标进行中
|
||||
*/
|
||||
@PostMapping("doing")
|
||||
public R doingGoal(Integer id) {
|
||||
goalService.doingGoal(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消目标
|
||||
*/
|
||||
@PostMapping("cancel")
|
||||
public R cancelGoal(Integer id) {
|
||||
goalService.cancelGoal(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user