feat:1.优化commonResult 2. 重新初始化数据库结构
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package com.guo.learningprogresstracker.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.guo.learningprogresstracker.common.Ops;
|
||||
import com.guo.learningprogresstracker.dto.TaskInfo;
|
||||
import com.guo.learningprogresstracker.dto.response.StudySessionResponce;
|
||||
import com.guo.learningprogresstracker.dto.response.TaskInfoResponse;
|
||||
import com.guo.learningprogresstracker.entity.CommonResult;
|
||||
import com.guo.learningprogresstracker.dto.request.TaskRequest;
|
||||
import com.guo.learningprogresstracker.exception.ErrorParameterException;
|
||||
@@ -27,6 +30,7 @@ import java.rmi.ServerException;
|
||||
|
||||
/**
|
||||
* 任务控制层
|
||||
*
|
||||
* @author guo
|
||||
*/
|
||||
@RequestMapping("/tasks")
|
||||
@@ -41,44 +45,43 @@ public class TaskController {
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "添加新任务")
|
||||
public CommonResult addTask(@RequestBody @Validated({Ops.CreateG.class}) TaskRequest taskRequest) throws ErrorParameterException {
|
||||
public CommonResult<String> addTask(@RequestBody @Validated({Ops.CreateG.class}) TaskRequest taskRequest) throws ErrorParameterException {
|
||||
return CommonResult.success(tasksService.addTask(taskRequest));
|
||||
}
|
||||
|
||||
@Operation(summary = "任务详情API")
|
||||
@GetMapping("/{taskId}")
|
||||
public CommonResult getTask(@PathVariable("taskId") String taskId) {
|
||||
public CommonResult<TaskInfoResponse> getTask(@PathVariable("taskId") String taskId) {
|
||||
return CommonResult.success(tasksService.getTask(taskId));
|
||||
}
|
||||
|
||||
@PutMapping("/{taskId}")
|
||||
@Operation(summary = "更新任务详情")
|
||||
public CommonResult updateTask(@PathVariable("taskId") String taskId,@Validated(Ops.UpdateG.class) @RequestBody TaskRequest updatedTask) {
|
||||
public CommonResult<Void> updateTask(@PathVariable("taskId") String taskId, @Validated(Ops.UpdateG.class) @RequestBody TaskRequest updatedTask) {
|
||||
tasksService.updateTask(taskId, updatedTask);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{taskId}")
|
||||
@Operation(summary = "删除指定任务")
|
||||
public CommonResult deleteTask(@PathVariable("taskId") String taskId) throws ServerException {
|
||||
public CommonResult<Void> deleteTask(@PathVariable("taskId") String taskId) throws ServerException {
|
||||
tasksService.deleteTask(taskId);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "获取所有任务列表")
|
||||
public CommonResult tasksList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
public CommonResult<Page<TaskInfo>> tasksList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
return CommonResult.success(tasksService.taskList(pageNum, pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始或继续一个【学习会话】
|
||||
*
|
||||
*/
|
||||
@GetMapping("/{taskNum}/study-sessions/start-or-continue")
|
||||
public CommonResult startOrContinueStudySession(@NotEmpty(message = "taskNum不可为空")
|
||||
@PathVariable String taskNum) throws NotFindEntitiesException {
|
||||
public CommonResult<StudySessionResponce> startOrContinueStudySession(@NotEmpty(message = "taskNum不可为空")
|
||||
@PathVariable String taskNum) throws NotFindEntitiesException {
|
||||
StudySessionResponce response = studySessionsServiceImpl.startOrContinueStudySession(taskNum);
|
||||
return CommonResult.success(response);
|
||||
|
||||
@@ -88,8 +91,8 @@ public class TaskController {
|
||||
* 通过学习任务num获取该任务的未结束会话
|
||||
*/
|
||||
@GetMapping("/{taskNum}/not-ended-study-session")
|
||||
public CommonResult getNotEndedStudySessionByTaskNum(@NotEmpty(message = "taskNum不可为空")
|
||||
@PathVariable String taskNum) throws ErrorParameterException {
|
||||
public CommonResult<StudySessionResponce> getNotEndedStudySessionByTaskNum(@NotEmpty(message = "taskNum不可为空")
|
||||
@PathVariable String taskNum) throws ErrorParameterException {
|
||||
StudySessionResponce response = studySessionsServiceImpl.getNotEndedStudySessionByTaskNum(taskNum);
|
||||
return CommonResult.success(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user