|
@@ -0,0 +1,64 @@
|
|
|
|
+package org.dromara.dataManagement.controller;
|
|
|
|
+
|
|
|
|
+import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
|
+import org.dromara.common.excel.core.ExcelResult;
|
|
|
|
+import org.dromara.common.excel.utils.ExcelUtil;
|
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
+import org.dromara.common.web.core.BaseController;
|
|
|
|
+import org.dromara.dataManagement.domain.bo.StaffBo;
|
|
|
|
+import org.dromara.dataManagement.domain.vo.StaffExcelVo;
|
|
|
|
+import org.dromara.dataManagement.domain.vo.StaffVo;
|
|
|
|
+import org.dromara.dataManagement.service.StaffService;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+
|
|
|
|
+@SaIgnore
|
|
|
|
+@RestController
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
+@RequestMapping("/dataManagement/staff")
|
|
|
|
+public class StaffController extends BaseController {
|
|
|
|
+ private final StaffService staffService;
|
|
|
|
+ @GetMapping("/PageList")
|
|
|
|
+ public TableDataInfo<StaffVo> selectPageStaffList(StaffBo staffBo, PageQuery pageQuery) {
|
|
|
|
+ return staffService.selectPageStaffList(staffBo, pageQuery);
|
|
|
|
+ }
|
|
|
|
+ @PostMapping()
|
|
|
|
+ public R<Void> insertStaff(@Validated @RequestBody StaffBo staffBo) {
|
|
|
|
+ return toAjax(staffService.insertStaff(staffBo));
|
|
|
|
+ }
|
|
|
|
+ @PutMapping()
|
|
|
|
+ public R<Void> updateStaff(@Validated @RequestBody StaffBo staffBo) {
|
|
|
|
+ return toAjax(staffService.updateStaff(staffBo));
|
|
|
|
+ }
|
|
|
|
+ @DeleteMapping("/{staffIds}")
|
|
|
|
+ public R<Void> deleteStaffByIds(@PathVariable Long[] staffIds) {
|
|
|
|
+ return toAjax(staffService.deleteStaffByIds(staffIds));
|
|
|
|
+ }
|
|
|
|
+ @GetMapping("/downloadTemplate")
|
|
|
|
+ public void getExampleExcel(HttpServletResponse response) {
|
|
|
|
+ ExcelUtil.exportExcel(new ArrayList<>(),"职员导入模板", StaffExcelVo.class, response);
|
|
|
|
+ }
|
|
|
|
+ @PostMapping("/importExcel")
|
|
|
|
+ public R<Void> importExcel(@RequestPart("file") MultipartFile file) throws Exception {
|
|
|
|
+ ExcelResult<StaffExcelVo> result = ExcelUtil.importExcel(file.getInputStream(), StaffExcelVo.class,false);
|
|
|
|
+ staffService.insertImportExcel(result);
|
|
|
|
+ return R.ok(result.getAnalysis());
|
|
|
|
+ }
|
|
|
|
+ @GetMapping("/exportExcel")
|
|
|
|
+ public void exportStaffExcel(HttpServletResponse response) {
|
|
|
|
+ ExcelUtil.exportTemplate(CollUtil.newArrayList(new HashMap<>(),staffService.selectList()),"职员列表.xlsx","excel/职员导出模板.xlsx",response);
|
|
|
|
+ }
|
|
|
|
+ @GetMapping("/exportExcelByIds")
|
|
|
|
+ public void exportStaffExcel(@RequestParam("ids") Long[] staffIds, HttpServletResponse response) {
|
|
|
|
+ ExcelUtil.exportTemplate(CollUtil.newArrayList(new HashMap<>(),staffService.selectStaffListByIds(staffIds)),"职员列表.xlsx","excel/职员导出模板.xlsx",response);
|
|
|
|
+ }
|
|
|
|
+}
|