¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.dromara.workflow.controller; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | 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.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.web.core.BaseController; |
| | | import org.dromara.warm.flow.core.entity.Definition; |
| | | import org.dromara.warm.flow.core.service.DefService; |
| | | import org.dromara.warm.flow.orm.entity.FlowDefinition; |
| | | import org.dromara.workflow.common.ConditionalOnEnable; |
| | | import org.dromara.workflow.domain.vo.FlowDefinitionVo; |
| | | import org.dromara.workflow.service.IFlwDefinitionService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æµç¨å®ä¹ç®¡ç æ§å¶å± |
| | | * |
| | | * @author may |
| | | */ |
| | | @ConditionalOnEnable |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/workflow/definition") |
| | | public class FlwDefinitionController extends BaseController { |
| | | |
| | | private final DefService defService; |
| | | private final IFlwDefinitionService flwDefinitionService; |
| | | |
| | | /** |
| | | * æ¥è¯¢æµç¨å®ä¹å表 |
| | | * |
| | | * @param flowDefinition åæ° |
| | | * @param pageQuery å页 |
| | | */ |
| | | @GetMapping("/list") |
| | | public TableDataInfo<FlowDefinitionVo> list(FlowDefinition flowDefinition, PageQuery pageQuery) { |
| | | return flwDefinitionService.queryList(flowDefinition, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æªåå¸çæµç¨å®ä¹å表 |
| | | * |
| | | * @param flowDefinition åæ° |
| | | * @param pageQuery å页 |
| | | */ |
| | | @GetMapping("/unPublishList") |
| | | public TableDataInfo<FlowDefinitionVo> unPublishList(FlowDefinition flowDefinition, PageQuery pageQuery) { |
| | | return flwDefinitionService.unPublishList(flowDefinition, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * è·åæµç¨å®ä¹è¯¦ç»ä¿¡æ¯ |
| | | * |
| | | * @param id æµç¨å®ä¹id |
| | | */ |
| | | @GetMapping(value = "/{id}") |
| | | public R<Definition> getInfo(@PathVariable Long id) { |
| | | return R.ok(defService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢æµç¨å®ä¹ |
| | | * |
| | | * @param flowDefinition åæ° |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | @RepeatSubmit() |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> add(@RequestBody FlowDefinition flowDefinition) { |
| | | return R.ok(defService.checkAndSave(flowDefinition)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹æµç¨å®ä¹ |
| | | * |
| | | * @param flowDefinition åæ° |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | @RepeatSubmit() |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> edit(@RequestBody FlowDefinition flowDefinition) { |
| | | return R.ok(defService.updateById(flowDefinition)); |
| | | } |
| | | |
| | | /** |
| | | * å叿µç¨å®ä¹ |
| | | * |
| | | * @param id æµç¨å®ä¹id |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.INSERT) |
| | | @PutMapping("/publish/{id}") |
| | | @RepeatSubmit() |
| | | public R<Boolean> publish(@PathVariable Long id) { |
| | | return R.ok(flwDefinitionService.publish(id)); |
| | | } |
| | | |
| | | /** |
| | | * åæ¶å叿µç¨å®ä¹ |
| | | * |
| | | * @param id æµç¨å®ä¹id |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.INSERT) |
| | | @PutMapping("/unPublish/{id}") |
| | | @RepeatSubmit() |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> unPublish(@PathVariable Long id) { |
| | | return R.ok(defService.unPublish(id)); |
| | | } |
| | | |
| | | /** |
| | | * å 餿µç¨å®ä¹ |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@PathVariable List<Long> ids) { |
| | | return toAjax(flwDefinitionService.removeDef(ids)); |
| | | } |
| | | |
| | | /** |
| | | * å¤å¶æµç¨å®ä¹ |
| | | * |
| | | * @param id æµç¨å®ä¹id |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.INSERT) |
| | | @PostMapping("/copy/{id}") |
| | | @RepeatSubmit() |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> copy(@PathVariable Long id) { |
| | | return R.ok(defService.copyDef(id)); |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥æµç¨å®ä¹ |
| | | * |
| | | * @param file æä»¶ |
| | | * @param category åç±» |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importDef") |
| | | public R<Boolean> importDef(MultipartFile file, String category) { |
| | | return R.ok(flwDefinitionService.importJson(file, category)); |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åºæµç¨å®ä¹ |
| | | * |
| | | * @param id æµç¨å®ä¹id |
| | | * @param response ååº |
| | | * @throws IOException å¼å¸¸ |
| | | */ |
| | | @Log(title = "æµç¨å®ä¹", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportDef/{id}") |
| | | public void exportDef(@PathVariable Long id, HttpServletResponse response) throws IOException { |
| | | flwDefinitionService.exportDef(id, response); |
| | | } |
| | | |
| | | /** |
| | | * è·åæµç¨å®ä¹JSONå符串 |
| | | * |
| | | * @param id æµç¨å®ä¹id |
| | | */ |
| | | @GetMapping("/xmlString/{id}") |
| | | public R<String> xmlString(@PathVariable Long id) { |
| | | return R.ok("æä½æå", defService.exportJson(id)); |
| | | } |
| | | |
| | | /** |
| | | * æ¿æ´»/æèµ·æµç¨å®ä¹ |
| | | * |
| | | * @param id æµç¨å®ä¹id |
| | | * @param active æ¿æ´»/æèµ· |
| | | */ |
| | | @RepeatSubmit() |
| | | @PutMapping("/active/{id}") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> active(@PathVariable Long id, @RequestParam boolean active) { |
| | | return R.ok(active ? defService.active(id) : defService.unActive(id)); |
| | | } |
| | | |
| | | } |