DzTeacherController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package com.ruoyi.web.controller.dz;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.ruoyi.common.utils.SecurityUtils;
  5. import com.ruoyi.dz.service.IDzTeacherClassService;
  6. import com.ruoyi.enums.UserTypeEnum;
  7. import org.springframework.security.access.prepost.PreAuthorize;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.PutMapping;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.ruoyi.common.annotation.Log;
  18. import com.ruoyi.common.core.controller.BaseController;
  19. import com.ruoyi.common.core.domain.AjaxResult;
  20. import com.ruoyi.common.enums.BusinessType;
  21. import com.ruoyi.dz.domain.DzTeacher;
  22. import com.ruoyi.dz.service.IDzTeacherService;
  23. import com.ruoyi.common.utils.poi.ExcelUtil;
  24. import com.ruoyi.common.core.page.TableDataInfo;
  25. /**
  26. * 老师Controller
  27. *
  28. * @author ruoyi
  29. * @date 2025-09-12
  30. */
  31. @RestController
  32. @RequestMapping("/dz/teacher")
  33. public class DzTeacherController extends BaseController
  34. {
  35. @Autowired
  36. private IDzTeacherService dzTeacherService;
  37. @Autowired
  38. private IDzTeacherClassService teacherClassService;
  39. /**
  40. * 查询老师列表
  41. */
  42. @PreAuthorize("@ss.hasPermi('dz:teacher:list')")
  43. @GetMapping("/list")
  44. public TableDataInfo list(DzTeacher dzTeacher)
  45. {
  46. if(!UserTypeEnum.isSys(SecurityUtils.getLoginUser().getUser().getUserType())){
  47. dzTeacher.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
  48. }
  49. startPage();
  50. List<DzTeacher> list = dzTeacherService.selectDzTeacherList(dzTeacher);
  51. return getDataTable(list);
  52. }
  53. /**
  54. * 导出老师列表
  55. */
  56. @PreAuthorize("@ss.hasPermi('dz:teacher:export')")
  57. @Log(title = "老师", businessType = BusinessType.EXPORT)
  58. @PostMapping("/export")
  59. public void export(HttpServletResponse response, DzTeacher dzTeacher)
  60. {
  61. List<DzTeacher> list = dzTeacherService.selectDzTeacherList(dzTeacher);
  62. ExcelUtil<DzTeacher> util = new ExcelUtil<DzTeacher>(DzTeacher.class);
  63. util.exportExcel(response, list, "老师数据");
  64. }
  65. /**
  66. * 获取老师详细信息
  67. */
  68. @PreAuthorize("@ss.hasPermi('dz:teacher:query')")
  69. @GetMapping(value = "/{teacherId}")
  70. public AjaxResult getInfo(@PathVariable("teacherId") Long teacherId)
  71. {
  72. return success(dzTeacherService.selectDzTeacherByTeacherId(teacherId));
  73. }
  74. /**
  75. * 新增老师
  76. */
  77. @PreAuthorize("@ss.hasPermi('dz:teacher:add')")
  78. @Log(title = "老师", businessType = BusinessType.INSERT)
  79. @PostMapping
  80. public AjaxResult add(@RequestBody DzTeacher dzTeacher)
  81. {
  82. return AjaxResult.success(dzTeacherService.insertDzTeacher(dzTeacher));
  83. }
  84. /**
  85. * 修改老师
  86. */
  87. @PreAuthorize("@ss.hasPermi('dz:teacher:edit')")
  88. @Log(title = "老师", businessType = BusinessType.UPDATE)
  89. @PutMapping
  90. public AjaxResult edit(@RequestBody DzTeacher dzTeacher)
  91. {
  92. return toAjax(dzTeacherService.updateDzTeacher(dzTeacher));
  93. }
  94. /**
  95. * 删除老师
  96. */
  97. @PreAuthorize("@ss.hasPermi('dz:teacher:remove')")
  98. @Log(title = "老师", businessType = BusinessType.DELETE)
  99. @DeleteMapping("/{teacherIds}")
  100. public AjaxResult remove(@PathVariable Long[] teacherIds)
  101. {
  102. return toAjax(dzTeacherService.deleteDzTeacherByTeacherIds(teacherIds));
  103. }
  104. }