|
@@ -21,42 +21,93 @@ import org.springframework.web.multipart.MultipartFile;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 职员管理接口
|
|
|
|
+ */
|
|
@SaIgnore
|
|
@SaIgnore
|
|
@RestController
|
|
@RestController
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@RequestMapping("/dataManagement/staff")
|
|
@RequestMapping("/dataManagement/staff")
|
|
public class StaffController extends BaseController {
|
|
public class StaffController extends BaseController {
|
|
private final StaffService staffService;
|
|
private final StaffService staffService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询职员管理列表
|
|
|
|
+ * @param staffBo 职员Bo对象
|
|
|
|
+ * @param pageQuery 分页信息
|
|
|
|
+ * @return 查询结果
|
|
|
|
+ */
|
|
@GetMapping("/PageList")
|
|
@GetMapping("/PageList")
|
|
public TableDataInfo<StaffVo> selectPageStaffList(StaffBo staffBo, PageQuery pageQuery) {
|
|
public TableDataInfo<StaffVo> selectPageStaffList(StaffBo staffBo, PageQuery pageQuery) {
|
|
return staffService.selectPageStaffList(staffBo, pageQuery);
|
|
return staffService.selectPageStaffList(staffBo, pageQuery);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增职员
|
|
|
|
+ * @param staffBo 职员Bo对象
|
|
|
|
+ * @return 新增结果
|
|
|
|
+ */
|
|
@PostMapping()
|
|
@PostMapping()
|
|
public R<Void> insertStaff(@Validated @RequestBody StaffBo staffBo) {
|
|
public R<Void> insertStaff(@Validated @RequestBody StaffBo staffBo) {
|
|
return toAjax(staffService.insertStaff(staffBo));
|
|
return toAjax(staffService.insertStaff(staffBo));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改职员
|
|
|
|
+ * @param staffBo 职员Bo对象
|
|
|
|
+ * @return 修改结果
|
|
|
|
+ */
|
|
@PutMapping()
|
|
@PutMapping()
|
|
public R<Void> updateStaff(@Validated @RequestBody StaffBo staffBo) {
|
|
public R<Void> updateStaff(@Validated @RequestBody StaffBo staffBo) {
|
|
return toAjax(staffService.updateStaff(staffBo));
|
|
return toAjax(staffService.updateStaff(staffBo));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除职员
|
|
|
|
+ * @param staffIds 职员ids
|
|
|
|
+ * @return 删除结果
|
|
|
|
+ */
|
|
@DeleteMapping("/{staffIds}")
|
|
@DeleteMapping("/{staffIds}")
|
|
public R<Void> deleteStaffByIds(@PathVariable Long[] staffIds) {
|
|
public R<Void> deleteStaffByIds(@PathVariable Long[] staffIds) {
|
|
return toAjax(staffService.deleteStaffByIds(staffIds));
|
|
return toAjax(staffService.deleteStaffByIds(staffIds));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 下载职员导入模板
|
|
|
|
+ * @param response 响应对象
|
|
|
|
+ */
|
|
@GetMapping("/downloadTemplate")
|
|
@GetMapping("/downloadTemplate")
|
|
public void getExampleExcel(HttpServletResponse response) {
|
|
public void getExampleExcel(HttpServletResponse response) {
|
|
ExcelUtil.exportExcel(new ArrayList<>(),"职员导入模板", StaffExcelVo.class, response);
|
|
ExcelUtil.exportExcel(new ArrayList<>(),"职员导入模板", StaffExcelVo.class, response);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导入职员Excel
|
|
|
|
+ * @param file 文件对象
|
|
|
|
+ * @return 是否解析成功
|
|
|
|
+ * @throws Exception 运行错误
|
|
|
|
+ */
|
|
@PostMapping("/importExcel")
|
|
@PostMapping("/importExcel")
|
|
public R<Void> importExcel(@RequestPart("file") MultipartFile file) throws Exception {
|
|
public R<Void> importExcel(@RequestPart("file") MultipartFile file) throws Exception {
|
|
ExcelResult<StaffExcelVo> result = ExcelUtil.importExcel(file.getInputStream(), StaffExcelVo.class,false);
|
|
ExcelResult<StaffExcelVo> result = ExcelUtil.importExcel(file.getInputStream(), StaffExcelVo.class,false);
|
|
staffService.insertImportExcel(result);
|
|
staffService.insertImportExcel(result);
|
|
return R.ok(result.getAnalysis());
|
|
return R.ok(result.getAnalysis());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过Excel导出所有职员数据
|
|
|
|
+ * @param response 响应对象
|
|
|
|
+ */
|
|
@GetMapping("/exportExcel")
|
|
@GetMapping("/exportExcel")
|
|
public void exportStaffExcel(HttpServletResponse response) {
|
|
public void exportStaffExcel(HttpServletResponse response) {
|
|
ExcelUtil.exportTemplate(CollUtil.newArrayList(new HashMap<>(),staffService.selectList()),"职员列表.xlsx","excel/职员导出模板.xlsx",response);
|
|
ExcelUtil.exportTemplate(CollUtil.newArrayList(new HashMap<>(),staffService.selectList()),"职员列表.xlsx","excel/职员导出模板.xlsx",response);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据职员Ids导出Excel
|
|
|
|
+ * @param staffIds 职员Ids
|
|
|
|
+ * @param response 响应对象
|
|
|
|
+ */
|
|
@GetMapping("/exportExcelByIds")
|
|
@GetMapping("/exportExcelByIds")
|
|
public void exportStaffExcel(@RequestParam("ids") Long[] staffIds, HttpServletResponse response) {
|
|
public void exportStaffExcel(@RequestParam("ids") Long[] staffIds, HttpServletResponse response) {
|
|
ExcelUtil.exportTemplate(CollUtil.newArrayList(new HashMap<>(),staffService.selectStaffListByIds(staffIds)),"职员列表.xlsx","excel/职员导出模板.xlsx",response);
|
|
ExcelUtil.exportTemplate(CollUtil.newArrayList(new HashMap<>(),staffService.selectStaffListByIds(staffIds)),"职员列表.xlsx","excel/职员导出模板.xlsx",response);
|