add: 习惯curd

This commit is contained in:
kkunkka
2025-10-10 14:49:34 +08:00
parent 79c0e37b87
commit affb754ae4
8 changed files with 100 additions and 2 deletions

View File

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