1. 配置数据库日志输出 2. 任务更新API与测试类 3. 任务删除API与测试类
This commit is contained in:
@@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
|
||||
/**
|
||||
* 任务控制层
|
||||
* @author guo
|
||||
@@ -49,9 +51,9 @@ public class TaskController {
|
||||
|
||||
@DeleteMapping("/tasks/{taskId}")
|
||||
@Operation(summary = "删除指定任务")
|
||||
public CommonResult deleteTask(@PathVariable("taskId") String taskId) {
|
||||
// return CommonResult.success(tasksService.deleteTask(taskId));
|
||||
return null;
|
||||
public CommonResult deleteTask(@PathVariable("taskId") String taskId) throws ServerException {
|
||||
tasksService.deleteTask(taskId);
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/tasks")
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TaskRequest {
|
||||
|
||||
public interface Create{}
|
||||
@Null(message = "创建时不可指定任务ID",groups = Ops.CreateG.class)
|
||||
@NotEmpty(message = "更新时必须指定任务ID",groups = Ops.UpdateG.class)
|
||||
@NotNull(message = "更新时必须指定任务ID",groups = Ops.UpdateG.class)
|
||||
private Integer id;
|
||||
/**
|
||||
* 学习任务的名称
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.guo.learningprogresstracker.dto.response.TasksListInfoResponse;
|
||||
import com.guo.learningprogresstracker.entity.TaskEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
* @description 针对表【tasks(存储学习任务的基本信息,包括优先级的多维度计算)】的数据库操作Service
|
||||
@@ -20,4 +22,6 @@ public interface TasksService extends IService<TaskEntity> {
|
||||
TaskInfoResponse getTask(String taskId);
|
||||
|
||||
void updateTask(String taskId, TaskRequest updatedTask);
|
||||
|
||||
void deleteTask(String taskId) throws ServerException;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,11 @@ import com.guo.learningprogresstracker.mapper.TasksMapper;
|
||||
import com.guo.learningprogresstracker.utils.CalculatedPriorityTool;
|
||||
import com.guo.learningprogresstracker.utils.GenerateNumTool;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
* @description 针对表【tasks(存储学习任务的基本信息,包括优先级的多维度计算)】的数据库操作Service实现
|
||||
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
implements TasksService{
|
||||
|
||||
@@ -58,6 +62,14 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
|
||||
this.updateById(taskEntity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTask(String taskId) throws ServerException {
|
||||
boolean b = this.removeById(taskId);
|
||||
if(!b){
|
||||
throw new ServerException("未能正常删除任务");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user