diff --git a/api/internal/logic/storelink/deletelinkimagelogic.go b/api/internal/logic/storelink/deletelinkimagelogic.go index a866554f..519b48fe 100644 --- a/api/internal/logic/storelink/deletelinkimagelogic.go +++ b/api/internal/logic/storelink/deletelinkimagelogic.go @@ -24,7 +24,8 @@ func NewDeleteLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *D } func (l *DeleteLinkImageLogic) DeleteLinkImage(req *types.DeleteLinkImageReq) (resp *types.DeleteLinkImageResp, err error) { - storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, req.PartId) + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) img, err := storelink.ILinkage.DeleteImage(req.ImageId) if err != nil { return nil, err diff --git a/api/internal/logic/storelink/deletelinktasklogic.go b/api/internal/logic/storelink/deletelinktasklogic.go index 4085b5d5..bcc11933 100644 --- a/api/internal/logic/storelink/deletelinktasklogic.go +++ b/api/internal/logic/storelink/deletelinktasklogic.go @@ -24,7 +24,8 @@ func NewDeleteLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *De } func (l *DeleteLinkTaskLogic) DeleteLinkTask(req *types.DeleteLinkTaskReq) (resp *types.DeleteLinkTaskResp, err error) { - storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, req.PartId) + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) task, err := storelink.ILinkage.DeleteTask(req.TaskId) if err != nil { return nil, err diff --git a/api/internal/logic/storelink/getlinkimagelistlogic.go b/api/internal/logic/storelink/getlinkimagelistlogic.go index 3c9e0346..1f84cd61 100644 --- a/api/internal/logic/storelink/getlinkimagelistlogic.go +++ b/api/internal/logic/storelink/getlinkimagelistlogic.go @@ -23,7 +23,8 @@ func NewGetLinkImageListLogic(ctx context.Context, svcCtx *svc.ServiceContext) * } func (l *GetLinkImageListLogic) GetLinkImageList(req *types.GetLinkImageListReq) (resp *types.GetLinkImageListResp, err error) { - storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, req.PartId) + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) list, err := storelink.ILinkage.QueryImageList() if err != nil { return nil, err diff --git a/api/internal/logic/storelink/getlinktasklogic.go b/api/internal/logic/storelink/getlinktasklogic.go index c4fae475..f9f15ae0 100644 --- a/api/internal/logic/storelink/getlinktasklogic.go +++ b/api/internal/logic/storelink/getlinktasklogic.go @@ -24,7 +24,8 @@ func NewGetLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLi } func (l *GetLinkTaskLogic) GetLinkTask(req *types.GetLinkTaskReq) (resp *types.GetLinkTaskResp, err error) { - storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, req.PartId) + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) task, err := storelink.ILinkage.QueryTask(req.TaskId) if err != nil { return nil, err diff --git a/api/internal/logic/storelink/getparticipantslogic.go b/api/internal/logic/storelink/getparticipantslogic.go index da141fd0..58df1487 100644 --- a/api/internal/logic/storelink/getparticipantslogic.go +++ b/api/internal/logic/storelink/getparticipantslogic.go @@ -2,9 +2,10 @@ package storelink import ( "context" - + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + "strconv" "github.com/zeromicro/go-zero/core/logx" ) @@ -24,7 +25,23 @@ func NewGetParticipantsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G } func (l *GetParticipantsLogic) GetParticipants(req *types.GetParticipantsReq) (resp *types.GetParticipantsResp, err error) { - // todo: add your logic here and delete this line + participants := storeLink.GetParticipants(l.svcCtx.DbEngin) + var res types.GetParticipantsResp + + if len(participants) == 0 { + res.Success = false + return &res, nil + } + + for _, participant := range participants { + var p types.ParticipantSl + p.ParticipantId = strconv.FormatInt(participant.Id, 10) + p.ParticipantType = storeLink.AITYPE[participant.Type] + p.ParticipantName = participant.Name + res.Participants = append(res.Participants, p) + } + + res.Success = true + return &res, nil - return } diff --git a/api/internal/logic/storelink/submitlinktasklogic.go b/api/internal/logic/storelink/submitlinktasklogic.go index e47b2344..ca89c416 100644 --- a/api/internal/logic/storelink/submitlinktasklogic.go +++ b/api/internal/logic/storelink/submitlinktasklogic.go @@ -24,7 +24,8 @@ func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Su } func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) { - storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, req.PartId) + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) var envs []string if len(req.Envs) != 0 { for _, v := range req.Envs { diff --git a/api/internal/logic/storelink/uploadlinkimagelogic.go b/api/internal/logic/storelink/uploadlinkimagelogic.go index 52000e6e..8ca88f42 100644 --- a/api/internal/logic/storelink/uploadlinkimagelogic.go +++ b/api/internal/logic/storelink/uploadlinkimagelogic.go @@ -24,7 +24,8 @@ func NewUploadLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *U } func (l *UploadLinkImageLogic) UploadLinkImage(req *types.UploadLinkImageReq) (resp *types.UploadLinkImageResp, err error) { - storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, req.PartId) + participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin) + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant) img, err := storelink.ILinkage.UploadImage(req.FilePath) if err != nil { return nil, err diff --git a/api/internal/storeLink/storeLink.go b/api/internal/storeLink/storeLink.go index 3ab543f1..b54d6346 100644 --- a/api/internal/storeLink/storeLink.go +++ b/api/internal/storeLink/storeLink.go @@ -7,6 +7,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models" "gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus" + "gorm.io/gorm" ) type Linkage interface { @@ -19,7 +20,9 @@ type Linkage interface { } const ( - COMMA = "," + COMMA = "," + TYPE_OCTOPUS = "octopus" + TYPE_MODELARTS = "modelarts" ) var ( @@ -28,20 +31,34 @@ var ( 3: "制作完成", 4: "制作失败", } + AITYPE = map[string]string{ + "1": TYPE_OCTOPUS, + "2": TYPE_MODELARTS, + } ) type StoreLink struct { ILinkage Linkage } -func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, partId int64) *StoreLink { - var participant models.ScParticipantPhyInfo - svcCtx.DbEngin.Raw("select * from sc_participant_phy_info where id = ?", partId).Scan(&participant) - +func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, participant models.ScParticipantPhyInfo) *StoreLink { + //todo 创建modelarts client linkStruct := NewOctopusLink(ctx, svcCtx, participant.Name) return &StoreLink{ILinkage: linkStruct} } +func GetParticipants(dbEngin *gorm.DB) []models.ScParticipantPhyInfo { + var participants []models.ScParticipantPhyInfo + dbEngin.Raw("select * from sc_participant_phy_info where type = 1").Scan(&participants) + return participants +} + +func GetParticipantById(partId int64, dbEngin *gorm.DB) models.ScParticipantPhyInfo { + var participant models.ScParticipantPhyInfo + dbEngin.Raw("select * from sc_participant_phy_info where id = ?", partId).Scan(&participant) + return participant +} + func ConvertType[T any](in *T) (interface{}, error) { switch (interface{})(in).(type) {