123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- package v1
- import (
- "fmt"
- "gin-vue-admin/global"
- "gin-vue-admin/model"
- "gin-vue-admin/model/request"
- "gin-vue-admin/model/response"
- "gin-vue-admin/service"
- "github.com/gin-gonic/gin"
- )
- // @Tags WorkflowProcess
- // @Summary 创建WorkflowProcess
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body model.WorkflowProcess true "创建WorkflowProcess"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /workflowProcess/createWorkflowProcess [post]
- func CreateWorkflowProcess(c *gin.Context) {
- var workflowProcess model.WorkflowProcess
- _ = c.ShouldBindJSON(&workflowProcess)
- err := service.CreateWorkflowProcess(workflowProcess)
- if err != nil {
- response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
- } else {
- response.OkWithMessage("创建成功", c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 删除WorkflowProcess
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body model.WorkflowProcess true "删除WorkflowProcess"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
- // @Router /workflowProcess/deleteWorkflowProcess [delete]
- func DeleteWorkflowProcess(c *gin.Context) {
- var workflowProcess model.WorkflowProcess
- _ = c.ShouldBindJSON(&workflowProcess)
- err := service.DeleteWorkflowProcess(workflowProcess)
- if err != nil {
- response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
- } else {
- response.OkWithMessage("删除成功", c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 批量删除WorkflowProcess
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.IdsReq true "批量删除WorkflowProcess"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
- // @Router /workflowProcess/deleteWorkflowProcessByIds [delete]
- func DeleteWorkflowProcessByIds(c *gin.Context) {
- var IDS request.IdsReq
- _ = c.ShouldBindJSON(&IDS)
- err := service.DeleteWorkflowProcessByIds(IDS)
- if err != nil {
- response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
- } else {
- response.OkWithMessage("删除成功", c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 更新WorkflowProcess
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body model.WorkflowProcess true "更新WorkflowProcess"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
- // @Router /workflowProcess/updateWorkflowProcess [put]
- func UpdateWorkflowProcess(c *gin.Context) {
- var workflowProcess model.WorkflowProcess
- _ = c.ShouldBindJSON(&workflowProcess)
- err := service.UpdateWorkflowProcess(&workflowProcess)
- if err != nil {
- response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
- } else {
- response.OkWithMessage("更新成功", c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 用id查询WorkflowProcess
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body model.WorkflowProcess true "用id查询WorkflowProcess"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
- // @Router /workflowProcess/findWorkflowProcess [get]
- func FindWorkflowProcess(c *gin.Context) {
- var workflowProcess model.WorkflowProcess
- _ = c.ShouldBindQuery(&workflowProcess)
- err, reworkflowProcess := service.GetWorkflowProcess(workflowProcess.ID)
- if err != nil {
- response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
- } else {
- response.OkWithData(gin.H{"reworkflowProcess": reworkflowProcess}, c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 用id查询工作流步骤
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body model.WorkflowProcess true "用id查询WorkflowProcess"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
- // @Router /workflowProcess/findWorkflowStep [get]
- func FindWorkflowStep(c *gin.Context) {
- var workflowProcess model.WorkflowProcess
- _ = c.ShouldBindQuery(&workflowProcess)
- err, workflow := service.FindWorkflowStep(workflowProcess.ID)
- if err != nil {
- response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
- } else {
- response.OkWithData(gin.H{"workflow": workflow}, c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 分页获取WorkflowProcess列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.WorkflowProcessSearch true "分页获取WorkflowProcess列表"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /workflowProcess/getWorkflowProcessList [get]
- func GetWorkflowProcessList(c *gin.Context) {
- var pageInfo request.WorkflowProcessSearch
- _ = c.ShouldBindQuery(&pageInfo)
- err, list, total := service.GetWorkflowProcessInfoList(pageInfo)
- if err != nil {
- response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
- } else {
- response.OkWithData(response.PageResult{
- List: list,
- Total: total,
- Page: pageInfo.Page,
- PageSize: pageInfo.PageSize,
- }, c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 开启工作流
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /workflowProcess/startWorkflow [post]
- func StartWorkflow(c *gin.Context) {
- business := c.Query("businessType")
- wfInfo := model.WorkflowBusinessStruct[business]()
- c.ShouldBindJSON(wfInfo)
- err := service.StartWorkflow(wfInfo)
- if err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- response.OkWithMessage("启动成功", c)
- }
- // @Tags WorkflowProcess
- // @Summary 提交工作流
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /workflowProcess/completeWorkflowMove [post]
- func CompleteWorkflowMove(c *gin.Context) {
- business := c.Query("businessType")
- wfInfo := model.WorkflowBusinessStruct[business]()
- c.ShouldBindJSON(wfInfo)
- err := service.CompleteWorkflowMove(wfInfo)
- if err != nil {
- response.FailWithMessage(err.Error(), c)
- return
- }
- response.OkWithMessage("启动成功", c)
- }
- // @Tags WorkflowProcess
- // @Summary 我发起的工作流
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /workflowProcess/getMyStated [get]
- func GetMyStated(c *gin.Context) {
- if claims, exists := c.Get("claims"); !exists {
- errStr := "从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件"
- global.GVA_LOG.Error(errStr)
- response.FailWithMessage(errStr, c)
- } else {
- waitUse := claims.(*request.CustomClaims)
- err, wfms := service.GetMyStated(waitUse.ID)
- if err != nil {
- errStr := err.Error()
- global.GVA_LOG.Error(errStr)
- response.FailWithMessage(errStr, c)
- return
- }
- response.OkWithData(gin.H{"wfms": wfms}, c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 我的待办
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /workflowProcess/getMyNeed [get]
- func GetMyNeed(c *gin.Context) {
- if claims, exists := c.Get("claims"); !exists {
- errStr := "从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件"
- global.GVA_LOG.Error(errStr)
- response.FailWithMessage(errStr, c)
- } else {
- waitUse := claims.(*request.CustomClaims)
- err, wfms := service.GetMyNeed(waitUse.ID, waitUse.AuthorityId)
- if err != nil {
- errStr := err.Error()
- global.GVA_LOG.Error(errStr)
- response.FailWithMessage(errStr, c)
- return
- }
- response.OkWithData(gin.H{"wfms": wfms}, c)
- }
- }
- // @Tags WorkflowProcess
- // @Summary 根据id获取当前节点详情和历史
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.GetById true "根据id获取当前节点详情和过往"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /workflowProcess/getWorkflowMoveByID [get]
- func GetWorkflowMoveByID(c *gin.Context) {
- var req request.GetById
- _ = c.ShouldBindQuery(&req)
- err, move, moves, business := service.GetWorkflowMoveByID(req.Id)
- if err != nil {
- errStr := err.Error()
- global.GVA_LOG.Error(errStr)
- response.FailWithMessage(errStr, c)
- return
- }
- response.OkWithData(gin.H{"move": move, "moves": moves, "business": business}, c)
- }
|