存算联动类型转换更新
Former-commit-id: 07fc2e447b89c8a45e779a24d5d7bdc3a77e9450
This commit is contained in:
parent
65b8f21dd7
commit
4a82cfa159
|
@ -41,15 +41,27 @@ func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, partId int64)
|
||||||
func ConvertType[T any](in *T) (interface{}, error) {
|
func ConvertType[T any](in *T) (interface{}, error) {
|
||||||
|
|
||||||
switch (interface{})(in).(type) {
|
switch (interface{})(in).(type) {
|
||||||
|
case *octopus.UploadImageResp:
|
||||||
|
var resp types.UploadLinkImageResp
|
||||||
|
inresp := (interface{})(in).(*octopus.UploadImageResp)
|
||||||
|
resp.Success = inresp.Success
|
||||||
|
if !resp.Success {
|
||||||
|
resp.ErrorMsg = inresp.Error.Message
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
|
||||||
case *octopus.GetUserImageListResp:
|
case *octopus.GetUserImageListResp:
|
||||||
var resp types.GetLinkImageListResp
|
var resp types.GetLinkImageListResp
|
||||||
inresp := (interface{})(in).(*octopus.GetUserImageListResp)
|
inresp := (interface{})(in).(*octopus.GetUserImageListResp)
|
||||||
resp.Success = inresp.Success
|
resp.Success = inresp.Success
|
||||||
if inresp.Error == nil {
|
if !resp.Success {
|
||||||
resp.ErrorMsg = ""
|
|
||||||
} else {
|
|
||||||
resp.ErrorMsg = inresp.Error.Message
|
resp.ErrorMsg = inresp.Error.Message
|
||||||
|
resp.Images = nil
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range inresp.Payload.Images {
|
for _, v := range inresp.Payload.Images {
|
||||||
var image types.ImageSl
|
var image types.ImageSl
|
||||||
image.ImageId = v.Image.Id
|
image.ImageId = v.Image.Id
|
||||||
|
@ -58,18 +70,59 @@ func ConvertType[T any](in *T) (interface{}, error) {
|
||||||
resp.Images = append(resp.Images, image)
|
resp.Images = append(resp.Images, image)
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|
||||||
case *octopus.DeleteImageResp:
|
case *octopus.DeleteImageResp:
|
||||||
var resp types.DeleteLinkImageResp
|
var resp types.DeleteLinkImageResp
|
||||||
|
inresp := (interface{})(in).(*octopus.DeleteImageResp)
|
||||||
|
resp.Success = inresp.Success
|
||||||
|
if !resp.Success {
|
||||||
|
resp.ErrorMsg = inresp.Error.Message
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|
||||||
case *octopus.CreateTrainJobResp:
|
case *octopus.CreateTrainJobResp:
|
||||||
var resp types.SubmitLinkTaskResp
|
var resp types.SubmitLinkTaskResp
|
||||||
|
inresp := (interface{})(in).(*octopus.CreateTrainJobResp)
|
||||||
|
resp.Success = inresp.Success
|
||||||
|
if !resp.Success {
|
||||||
|
resp.ErrorMsg = inresp.Error.Message
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.TaskId = inresp.Payload.JobId
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|
||||||
case *octopus.GetTrainJobResp:
|
case *octopus.GetTrainJobResp:
|
||||||
var resp types.GetLinkTaskResp
|
var resp types.GetLinkTaskResp
|
||||||
|
inresp := (interface{})(in).(*octopus.GetTrainJobResp)
|
||||||
|
resp.Success = inresp.Success
|
||||||
|
if !resp.Success {
|
||||||
|
resp.ErrorMsg = inresp.Error.Message
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.Task.TaskId = inresp.Payload.TrainJob.Id
|
||||||
|
resp.Task.TaskName = inresp.Payload.TrainJob.Name
|
||||||
|
resp.Task.StartedAt = inresp.Payload.TrainJob.StartedAt
|
||||||
|
resp.Task.CompletedAt = inresp.Payload.TrainJob.CompletedAt
|
||||||
|
resp.Task.TaskStatus = inresp.Payload.TrainJob.Status
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|
||||||
case *octopus.DeleteTrainJobResp:
|
case *octopus.DeleteTrainJobResp:
|
||||||
var resp types.DeleteLinkTaskResp
|
var resp types.DeleteLinkTaskResp
|
||||||
|
inresp := (interface{})(in).(*octopus.DeleteTrainJobResp)
|
||||||
|
resp.Success = inresp.Success
|
||||||
|
if !resp.Success {
|
||||||
|
resp.ErrorMsg = inresp.Error.Message
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("type convert fail")
|
return nil, errors.New("type convert fail")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue