StudentController.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package com.schoolinout.web.controller.system;
  2. import com.schoolinout.common.annotation.Log;
  3. import com.schoolinout.common.core.controller.BaseController;
  4. import com.schoolinout.common.core.domain.AjaxResult;
  5. import com.schoolinout.common.core.page.TableDataInfo;
  6. import com.schoolinout.common.enums.BusinessType;
  7. import com.schoolinout.common.utils.poi.ExcelUtil;
  8. import com.schoolinout.system.domain.Student;
  9. import com.schoolinout.system.service.IStudentService;
  10. import io.swagger.v3.oas.annotations.tags.Tag;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.security.access.prepost.PreAuthorize;
  13. import org.springframework.web.bind.annotation.*;
  14. import javax.servlet.http.HttpServletResponse;
  15. import java.util.List;
  16. /**
  17. * 学生管理Controller
  18. *
  19. * @author sakura
  20. * @date 2024-01-03
  21. */
  22. @Tag(name = "学生管理接口")
  23. @RestController
  24. @RequestMapping("/system/student")
  25. public class StudentController extends BaseController {
  26. @Autowired
  27. private IStudentService studentService;
  28. @GetMapping("/list/all")
  29. public AjaxResult getAll(Student student) {
  30. return success(studentService.listAll(student));
  31. }
  32. /**
  33. * 查询学生管理列表
  34. */
  35. @PreAuthorize("@ss.hasPermi('system:student:list')")
  36. @GetMapping("/list")
  37. public TableDataInfo list(Student student) {
  38. startPage();
  39. List<Student> list = studentService.selectStudentList(student);
  40. return getDataTable(list);
  41. }
  42. /**
  43. * 导出学生管理列表
  44. */
  45. @PreAuthorize("@ss.hasPermi('system:student:export')")
  46. @Log(title = "学生管理", businessType = BusinessType.EXPORT)
  47. @PostMapping("/export")
  48. public void export(HttpServletResponse response, Student student) {
  49. List<Student> list = studentService.selectStudentList(student);
  50. ExcelUtil<Student> util = new ExcelUtil<Student>(Student.class);
  51. util.exportExcel(response, list, "学生管理数据");
  52. }
  53. /**
  54. * 获取学生管理详细信息
  55. */
  56. @PreAuthorize("@ss.hasPermi('system:student:query')")
  57. @GetMapping(value = "/{id}")
  58. public AjaxResult getInfo(@PathVariable("id") Long id) {
  59. return success(studentService.selectStudentById(id));
  60. }
  61. /**
  62. * 新增学生管理
  63. */
  64. @PreAuthorize("@ss.hasPermi('system:student:add')")
  65. @Log(title = "学生管理", businessType = BusinessType.INSERT)
  66. @PostMapping
  67. public AjaxResult add(@RequestBody Student student) {
  68. return toAjax(studentService.insertStudent(student));
  69. }
  70. /**
  71. * 修改学生管理
  72. */
  73. @PreAuthorize("@ss.hasPermi('system:student:edit')")
  74. @Log(title = "学生管理", businessType = BusinessType.UPDATE)
  75. @PutMapping
  76. public AjaxResult edit(@RequestBody Student student) {
  77. return toAjax(studentService.updateStudent(student));
  78. }
  79. /**
  80. * 删除学生管理
  81. */
  82. @PreAuthorize("@ss.hasPermi('system:student:remove')")
  83. @Log(title = "学生管理", businessType = BusinessType.DELETE)
  84. @DeleteMapping("/{ids}")
  85. public AjaxResult remove(@PathVariable Long[] ids) {
  86. return toAjax(studentService.deleteStudentByIds(ids));
  87. }
  88. }