¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.workflow.controller; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.validate.AddGroup; |
| | | import org.dromara.common.core.validate.EditGroup; |
| | | import org.dromara.common.excel.utils.ExcelUtil; |
| | | import org.dromara.common.idempotent.annotation.RepeatSubmit; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.workflow.common.ConditionalOnEnable; |
| | | import org.dromara.workflow.domain.bo.FlowCategoryBo; |
| | | import org.dromara.workflow.domain.vo.FlowCategoryVo; |
| | | import org.dromara.workflow.service.IFlwCategoryService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æµç¨åç±» |
| | | * |
| | | * @author may |
| | | */ |
| | | @ConditionalOnEnable |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/workflow/category") |
| | | public class FlwCategoryController extends BaseController { |
| | | |
| | | private final IFlwCategoryService flwCategoryService; |
| | | |
| | | /** |
| | | * æ¥è¯¢æµç¨åç±»å表 |
| | | */ |
| | | @SaCheckPermission("workflow:category:list") |
| | | @GetMapping("/list") |
| | | public R<List<FlowCategoryVo>> list(FlowCategoryBo bo) { |
| | | List<FlowCategoryVo> list = flwCategoryService.queryList(bo); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åºæµç¨åç±»å表 |
| | | */ |
| | | @SaCheckPermission("workflow:category:export") |
| | | @Log(title = "æµç¨åç±»", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(FlowCategoryBo bo, HttpServletResponse response) { |
| | | List<FlowCategoryVo> list = flwCategoryService.queryList(bo); |
| | | ExcelUtil.exportExcel(list, "æµç¨åç±»", FlowCategoryVo.class, response); |
| | | } |
| | | |
| | | /** |
| | | * è·åæµç¨å类详ç»ä¿¡æ¯ |
| | | * |
| | | * @param categoryId ä¸»é® |
| | | */ |
| | | @SaCheckPermission("workflow:category:query") |
| | | @GetMapping("/{categoryId}") |
| | | public R<FlowCategoryVo> getInfo(@NotNull(message = "主é®ä¸è½ä¸ºç©º") @PathVariable Long categoryId) { |
| | | flwCategoryService.checkCategoryDataScope(categoryId); |
| | | return R.ok(flwCategoryService.queryById(categoryId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢æµç¨åç±» |
| | | */ |
| | | @SaCheckPermission("workflow:category:add") |
| | | @Log(title = "æµç¨åç±»", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody FlowCategoryBo category) { |
| | | if (!flwCategoryService.checkCategoryNameUnique(category)) { |
| | | return R.fail("æ°å¢æµç¨åç±»'" + category.getCategoryName() + "'å¤±è´¥ï¼æµç¨åç±»åç§°å·²åå¨"); |
| | | } |
| | | return toAjax(flwCategoryService.insertByBo(category)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹æµç¨åç±» |
| | | */ |
| | | @SaCheckPermission("workflow:category:edit") |
| | | @Log(title = "æµç¨åç±»", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody FlowCategoryBo category) { |
| | | Long categoryId = category.getCategoryId(); |
| | | flwCategoryService.checkCategoryDataScope(categoryId); |
| | | if (!flwCategoryService.checkCategoryNameUnique(category)) { |
| | | return R.fail("ä¿®æ¹æµç¨åç±»'" + category.getCategoryName() + "'å¤±è´¥ï¼æµç¨åç±»åç§°å·²åå¨"); |
| | | } else if (category.getParentId().equals(categoryId)) { |
| | | return R.fail("ä¿®æ¹æµç¨åç±»'" + category.getCategoryName() + "'失败ï¼ä¸çº§æµç¨åç±»ä¸è½æ¯èªå·±"); |
| | | } |
| | | return toAjax(flwCategoryService.updateByBo(category)); |
| | | } |
| | | |
| | | /** |
| | | * å 餿µç¨åç±» |
| | | * |
| | | * @param categoryId ä¸»é® |
| | | */ |
| | | @SaCheckPermission("workflow:category:remove") |
| | | @Log(title = "æµç¨åç±»", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{categoryId}") |
| | | public R<Void> remove(@PathVariable Long categoryId) { |
| | | if (flwCategoryService.hasChildByCategoryId(categoryId)) { |
| | | return R.warn("åå¨ä¸çº§æµç¨åç±»,ä¸å
许å é¤"); |
| | | } |
| | | if (flwCategoryService.checkCategoryExistDefinition(categoryId)) { |
| | | return R.warn("æµç¨åç±»å卿µç¨å®ä¹,ä¸å
许å é¤"); |
| | | } |
| | | return toAjax(flwCategoryService.deleteWithValidById(categoryId)); |
| | | } |
| | | |
| | | /** |
| | | * è·åæµç¨åç±»æ å表 |
| | | * |
| | | * @param categoryBo æµç¨åç±» |
| | | */ |
| | | @GetMapping("/categoryTree") |
| | | public R<List<Tree<String>>> categoryTree(FlowCategoryBo categoryBo) { |
| | | return R.ok(flwCategoryService.selectCategoryTreeList(categoryBo)); |
| | | } |
| | | |
| | | } |