package org.ruoyi.flowable.workflow.controller; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.ruoyi.common.core.domain.R; import org.ruoyi.common.core.utils.MapstructUtils; import org.ruoyi.common.web.core.BaseController; import org.ruoyi.core.page.TableDataInfo; import org.ruoyi.flowable.workflow.domain.WfCategory; import org.ruoyi.flowable.workflow.domain.vo.WfCategoryVo; import org.ruoyi.flowable.workflow.service.IWfCategoryService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.Arrays; import java.util.List; import org.ruoyi.common.excel.utils.ExcelUtil; /** * 流程分类Controller * * @author KonBAI * @createTime 2022/3/10 00:12 */ @Validated @RequiredArgsConstructor @RestController @RequestMapping("/category") public class WfCategoryController extends BaseController { private final IWfCategoryService categoryService; /** * 查询流程分类列表 */ @GetMapping("/list") public TableDataInfo list(WfCategory category) { List list = categoryService.queryList(category); return TableDataInfo.build(list); } /** * 查询全部的流程分类列表 */ @GetMapping("/listAll") public R> listAll(WfCategory category) { return R.ok(categoryService.queryList(category)); } /** * 导出流程分类列表 */ @PostMapping("/export") public void export(@Validated WfCategory category, HttpServletResponse response) { List list = categoryService.queryList(category); List util = MapstructUtils.convert(list,WfCategoryVo.class); ExcelUtil.exportExcel(util, "流程分类", WfCategoryVo.class, response); } /** * 获取流程分类详细信息 * @param categoryId 分类主键 */ @GetMapping("/{categoryId}") public R getInfo(@NotNull(message = "主键不能为空") @PathVariable("categoryId") Long categoryId) { return R.ok(categoryService.queryById(categoryId)); } /** * 新增流程分类 */ @PostMapping public R add(@Validated @RequestBody WfCategory category) { if (!categoryService.checkCategoryCodeUnique(category)) { return R.fail("新增流程分类'" + category.getCategoryName() + "'失败,流程编码已存在"); } return R.ok(categoryService.insertCategory(category)); } /** * 修改流程分类 */ @PutMapping() public R edit(@Validated @RequestBody WfCategory category) { if (!categoryService.checkCategoryCodeUnique(category)) { return R.fail("修改流程分类'" + category.getCategoryName() + "'失败,流程编码已存在"); } return toAjax(categoryService.updateCategory(category)); } /** * 删除流程分类 * @param categoryIds 分类主键串 */ @DeleteMapping("/{categoryIds}") public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] categoryIds) { return toAjax(categoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true)); } }