add: 目标crud

This commit is contained in:
kkunkka
2025-10-10 11:40:34 +08:00
parent 9e20d0f5f8
commit f86462bb24
8 changed files with 139 additions and 5 deletions

View 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();
}
}