approveflow/app/http/module/flow_instance/api_instances_query.go

40 lines
1.1 KiB
Go

package flow_instance
import (
"approveflow/app/http/base/res"
"approveflow/app/provider/flow_instance"
"approveflow/app/utils"
"github.com/Superdanda/hade/framework/gin"
)
type InstancesQueryParam struct {
ID int64 `json:"id"`
}
// InstancesQuery handler
// @Summary 实例查询
// @Description 通过实例的ID查询流程实例详情
// @ID instances-query
// @Tags flow-instances
// @Accept json
// @Produce json
// @Param InstancesQueryParam body InstancesQueryParam true "查询参数"
// @Success 200 {object} base.Result{data=ApprovalInstanceDTO} "返回成功的流程定义数据"
// @Failure 500 {object} base.Result "返回失败的流程定义数据"
// @Router /instances/query [post]
func (api *FlowInstanceApi) InstancesQuery(c *gin.Context) {
param := utils.QuickBind[InstancesQueryParam](c)
instanceService := c.MustMake(flow_instance.FlowInstanceKey).(flow_instance.Service)
instance, err := instanceService.GetInstance(c, param.ID)
if err != nil {
res.FailWithErr(c, err)
return
}
dto, err := MapApprovalInstanceToDTO(instance)
if err != nil {
res.FailWithErr(c, err)
return
}
res.SuccessWithData(c, dto)
}