2024-11-14 17:02:41 +08:00
|
|
|
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
|
2024-11-15 16:53:35 +08:00
|
|
|
// @Tags flow-instances
|
2024-11-14 17:02:41 +08:00
|
|
|
// @Accept json
|
|
|
|
// @Produce json
|
|
|
|
// @Param InstancesQueryParam body InstancesQueryParam true "查询参数"
|
2024-11-15 16:53:35 +08:00
|
|
|
// @Success 200 {object} base.Result{data=ApprovalInstanceDTO} "返回成功的流程定义数据"
|
|
|
|
// @Failure 500 {object} base.Result "返回失败的流程定义数据"
|
2024-11-14 17:02:41 +08:00
|
|
|
// @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)
|
|
|
|
}
|