You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
YaYaRollCall/RollCallServer/src/main/java/cc/aspark/controller/StudentController.java

78 lines
2.3 KiB

package cc.aspark.controller;
import cc.aspark.domain.dto.PageQueryDTO;
import cc.aspark.domain.dto.StudentDTO;
import cc.aspark.domain.entity.Student;
import cc.aspark.result.PageResult;
import cc.aspark.result.Result;
import cc.aspark.service.StudentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/student")
@RequiredArgsConstructor
@Builder
@Tag(name = "学生表相关操作")
public class StudentController {
private final StudentService studentService;
@Operation(summary = "查询全部学生信息")
@GetMapping
public Result<List<Student>> list() {
List<Student> studentList = studentService.list();
return Result.success(studentList);
}
@Operation(summary = "根据 id 查询学生信息")
@GetMapping("/{id}")
public Result<Student> getStuInfoById(@PathVariable Integer id) {
Student stuInfo = studentService.getById(id);
return Result.success(stuInfo);
}
@Operation(summary = "学生信息分页查询")
@GetMapping("/page")
public Result<PageResult<Student>> pageStuInfo(PageQueryDTO pageQueryDTO) {
log.info("学生信息分页查询: {}", pageQueryDTO);
PageResult<Student> pageResult = studentService.page(pageQueryDTO);
return Result.success(pageResult);
}
@Operation(summary = "新增学生信息")
@PostMapping
public Result save(@RequestBody StudentDTO studentDTO) {
studentService.save(studentDTO);
return Result.success();
}
@Operation(summary = "更新学生信息")
@PutMapping
public Result updateStu(@RequestBody StudentDTO studentDTO) {
studentService.updateStu(studentDTO);
return Result.success();
}
@Operation(summary = "删除学生信息")
@DeleteMapping("/{ids}")
public Result deleteStus(@PathVariable List<Integer> ids) {
studentService.removeByIds(ids);
return Result.success();
}
}