38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package flow_instance
|
|
|
|
import (
|
|
instanceModel "approveflow/app/provider/flow_instance/model"
|
|
"approveflow/app/utils"
|
|
)
|
|
|
|
func MapApprovalInstanceToDTOBatch(approvalInstances []*instanceModel.ApprovalInstance) ([]*ApprovalInstanceDTO, error) {
|
|
res := make([]*ApprovalInstanceDTO, 0, len(approvalInstances))
|
|
for _, instance := range approvalInstances {
|
|
for _, step := range instance.Steps {
|
|
step.Status = step.GetStatus()
|
|
}
|
|
dto, err := MapApprovalInstanceToDTO(instance)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res = append(res, dto)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
func MapApprovalInstanceToDTO(approvalInstance *instanceModel.ApprovalInstance) (*ApprovalInstanceDTO, error) {
|
|
// 创建目标 ApprovalInstanceDTO 对象
|
|
approvalInstanceDTO := &ApprovalInstanceDTO{}
|
|
|
|
for _, step := range approvalInstance.Steps {
|
|
step.Status = step.GetStatus()
|
|
}
|
|
|
|
// 使用 Convert 方法将 实体对象 转换为 DTO
|
|
if err := utils.Convert(approvalInstance, approvalInstanceDTO); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return approvalInstanceDTO, nil
|
|
}
|