| | |
| | | import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostRespVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSaveReqVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSimpleRespVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostImportExcelVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostImportRespVO; |
| | | import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; |
| | | import cn.iocoder.yudao.module.system.service.dept.PostService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | @GetMapping("/export-excel") |
| | | @Operation(summary = "岗位管理") |
| | | @Operation(summary = "导出岗位 Excel") |
| | | @PreAuthorize("@ss.hasPermission('system:post:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void export(HttpServletResponse response, @Validated PostPageReqVO reqVO) throws IOException { |
| | |
| | | BeanUtils.toBean(list, PostRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入岗位模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<PostImportExcelVO> list = Arrays.asList( |
| | | PostImportExcelVO.builder().name("全栈开发").code("fullstack").sort(1) |
| | | .status(CommonStatusEnum.ENABLE.getStatus()).remark("全栈开发工程师").build(), |
| | | PostImportExcelVO.builder().name("前端开发").code("frontend").sort(2) |
| | | .status(CommonStatusEnum.ENABLE.getStatus()).remark("前端开发工程师").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "岗位导入模板.xls", "岗位列表", PostImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入岗位") |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "Excel 文件", required = true), |
| | | @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('system:post:import')") |
| | | public CommonResult<PostImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<PostImportExcelVO> list = ExcelUtils.read(file, PostImportExcelVO.class); |
| | | return success(postService.importPostList(list, updateSupport)); |
| | | } |
| | | |
| | | } |