add: 习惯curd
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.dota.nexus.controller;
|
||||
|
||||
import com.dota.nexus.entity.HabitRecord;
|
||||
import com.dota.nexus.entity.R;
|
||||
import com.dota.nexus.service.HabitRecordService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@RestController("habit_record")
|
||||
public class HabitRecordController {
|
||||
HabitRecordService habitRecordService;
|
||||
|
||||
public HabitRecordController(HabitRecordService habitRecordService) {
|
||||
this.habitRecordService = habitRecordService;
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
public R addHabitRecord(Integer id) {
|
||||
var habit = new HabitRecord();
|
||||
habit.setCreateTime(LocalDateTime.now());
|
||||
habit.setUpdateTime(LocalDateTime.now());
|
||||
habit.setGoalId(id);
|
||||
habitRecordService.save(habit);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user