forked from JointCloud/pcm-coordinator
parent
8a99562dae
commit
a712151707
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue