StaffController.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package com.zhongzheng.controller.staff;
  2. import java.util.List;
  3. import java.util.Arrays;
  4. import lombok.RequiredArgsConstructor;
  5. import org.springframework.security.access.prepost.PreAuthorize;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PostMapping;
  9. import org.springframework.web.bind.annotation.PutMapping;
  10. import org.springframework.web.bind.annotation.DeleteMapping;
  11. import org.springframework.web.bind.annotation.PathVariable;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import com.zhongzheng.common.annotation.Log;
  16. import com.zhongzheng.common.core.controller.BaseController;
  17. import com.zhongzheng.common.core.domain.AjaxResult;
  18. import com.zhongzheng.common.enums.BusinessType;
  19. import com.zhongzheng.modules.staff.vo.StaffVo;
  20. import com.zhongzheng.modules.staff.bo.StaffQueryBo;
  21. import com.zhongzheng.modules.staff.bo.StaffAddBo;
  22. import com.zhongzheng.modules.staff.bo.StaffEditBo;
  23. import com.zhongzheng.modules.staff.service.IStaffService;
  24. import com.zhongzheng.common.utils.poi.ExcelUtil;
  25. import com.zhongzheng.common.core.page.TableDataInfo;
  26. import io.swagger.annotations.Api;
  27. import io.swagger.annotations.ApiOperation;
  28. import org.springframework.web.multipart.MultipartFile;
  29. /**
  30. * 企业部门员工Controller
  31. *
  32. * @author ruoyi
  33. * @date 2024-03-21
  34. */
  35. @Api(value = "企业部门员工控制器", tags = {"企业部门员工管理"})
  36. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  37. @RestController
  38. @RequestMapping("/system/staff")
  39. public class StaffController extends BaseController {
  40. private final IStaffService iStaffService;
  41. /**
  42. * 查询企业部门员工列表
  43. */
  44. @ApiOperation("查询企业部门员工列表")
  45. @PreAuthorize("@ss.hasPermi('system:staff:list')")
  46. @GetMapping("/staffList")
  47. public TableDataInfo<StaffVo> list(StaffQueryBo bo) {
  48. startPage();
  49. List<StaffVo> list = iStaffService.selectStaffList(bo);
  50. return getDataTable(list);
  51. }
  52. /**
  53. * 导出企业部门员工列表
  54. */
  55. @ApiOperation("导出企业部门员工列表")
  56. @PreAuthorize("@ss.hasPermi('system:staff:export')")
  57. @Log(title = "企业部门员工", businessType = BusinessType.EXPORT)
  58. @GetMapping("/export")
  59. public AjaxResult<StaffVo> export(StaffQueryBo bo) {
  60. List<StaffVo> list = iStaffService.queryList(bo);
  61. ExcelUtil<StaffVo> util = new ExcelUtil<StaffVo>(StaffVo.class);
  62. return util.exportExcel(list, "企业部门员工");
  63. }
  64. /**
  65. * 获取企业部门员工详细信息
  66. */
  67. @ApiOperation("获取企业部门员工详细信息")
  68. @PreAuthorize("@ss.hasPermi('system:staff:query')")
  69. @GetMapping("/{staffId}")
  70. public AjaxResult<StaffVo> getInfo(@PathVariable("staffId" ) Long staffId) {
  71. return AjaxResult.success(iStaffService.queryById(staffId));
  72. }
  73. /**
  74. * 新增企业部门员工
  75. */
  76. @ApiOperation("新增企业部门员工")
  77. @PreAuthorize("@ss.hasPermi('system:staff:add')")
  78. @Log(title = "企业部门员工", businessType = BusinessType.INSERT)
  79. @PostMapping("/insertOrUpdateStaff")
  80. public AjaxResult<Void> add(@RequestBody StaffAddBo bo) {
  81. return toAjax(iStaffService.insertByAddBo(bo) ? 1 : 0);
  82. }
  83. /**
  84. * 修改企业部门员工
  85. */
  86. @ApiOperation("修改企业部门员工")
  87. @PreAuthorize("@ss.hasPermi('system:staff:edit')")
  88. @Log(title = "企业部门员工", businessType = BusinessType.UPDATE)
  89. @PostMapping("/updateStaffRemarks")
  90. public AjaxResult<Void> edit(@RequestBody StaffEditBo bo) {
  91. return toAjax(iStaffService.updateByEditBo(bo) ? 1 : 0);
  92. }
  93. /**
  94. * 删除企业部门员工
  95. */
  96. @ApiOperation("删除企业部门员工")
  97. @PreAuthorize("@ss.hasPermi('system:staff:remove')")
  98. @Log(title = "企业部门员工" , businessType = BusinessType.DELETE)
  99. @PostMapping("/deleteStaff")
  100. public AjaxResult<Void> remove(@RequestBody StaffEditBo bo ) {
  101. return toAjax(iStaffService.deleteWithValidByIds(bo)?1:0);
  102. }
  103. /**
  104. * 导入部门员工excel
  105. */
  106. @ApiOperation("导入员工文档列表")
  107. @PreAuthorize("@ss.hasPermi('system:staff:importStaffList')")
  108. @Log(title = "部门员工" , businessType = BusinessType.DELETE)
  109. @PostMapping("/importStaffList")
  110. public AjaxResult<Void> importStaffList( MultipartFile file ) {
  111. return toAjax(iStaffService.importExcelList(file)?1:0);
  112. }
  113. }