31 lines
887 B
Go
31 lines
887 B
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 {
|
||
|
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{}
|
||
|
|
||
|
// 使用 Convert 方法将 实体对象 转换为 DTO
|
||
|
if err := utils.Convert(approvalInstance, approvalInstanceDTO); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return approvalInstanceDTO, nil
|
||
|
}
|