You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

  1. package v1
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global/response"
  5. "gin-vue-admin/model"
  6. "gin-vue-admin/service"
  7. "gin-vue-admin/utils"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // @Tags workflow
  11. // @Summary 注册工作流
  12. // @Produce application/json
  13. // @Param data body model.SysWorkflow true "注册工作流接口"
  14. // @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
  15. // @Router /workflow/createWorkFlow [post]
  16. func CreateWorkFlow(c *gin.Context) {
  17. var wk model.SysWorkflow
  18. _ = c.ShouldBindJSON(&wk)
  19. WKVerify := utils.Rules{
  20. "WorkflowNickName": {utils.NotEmpty()},
  21. "WorkflowName": {utils.NotEmpty()},
  22. "WorkflowDescription": {utils.NotEmpty()},
  23. "WorkflowStepInfo": {utils.NotEmpty()},
  24. }
  25. WKVerifyErr := utils.Verify(wk, WKVerify)
  26. if WKVerifyErr != nil {
  27. response.FailWithMessage(WKVerifyErr.Error(), c)
  28. return
  29. }
  30. err := service.Create(wk)
  31. if err != nil {
  32. response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
  33. } else {
  34. response.OkWithMessage("获取成功", c)
  35. }
  36. }