| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryImportExcelVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryImportReqVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryImportRespVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryRespVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; |
| | |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得流程分类") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('bpm:category:query')") |
| | | public CommonResult<BpmCategoryRespVO> getCategory(@RequestParam("id") Long id) { |
| | | BpmCategoryDO category = categoryService.getCategory(id); |
| | | return success(BeanUtils.toBean(category, BpmCategoryRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得流程分类分页") |
| | | @PreAuthorize("@ss.hasPermission('bpm:category:query')") |
| | | public CommonResult<PageResult<BpmCategoryRespVO>> getCategoryPage(@Valid BpmCategoryPageReqVO pageReqVO) { |
| | | PageResult<BpmCategoryDO> pageResult = categoryService.getCategoryPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, BpmCategoryRespVO.class)); |
| | |
| | | .setName(category.getName()).setCode(category.getCode()))); |
| | | } |
| | | |
| | | } |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入流程分类模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<BpmCategoryImportExcelVO> list = Arrays.asList( |
| | | BpmCategoryImportExcelVO.builder().name("示例分类").code("example") |
| | | .description("示例流程分类").status(CommonStatusEnum.ENABLE.getStatus()).sort(1).build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "流程分类导入模板.xls", "流程分类列表", BpmCategoryImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入流程分类") |
| | | @PreAuthorize("@ss.hasPermission('bpm:category:import')") |
| | | public CommonResult<BpmCategoryImportRespVO> importExcel(@Valid BpmCategoryImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<BpmCategoryImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), BpmCategoryImportExcelVO.class); |
| | | return success(categoryService.importCategoryList(list, importReqVO)); |
| | | } |
| | | |
| | | } |