存算联动修改
Former-commit-id: 9983c662e5f2c2ec2cdd3898fe2c60bd6220b583
This commit is contained in:
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) {
|
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)
|
img, err := storelink.ILinkage.DeleteImage(req.ImageId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
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)
|
task, err := storelink.ILinkage.DeleteTask(req.TaskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
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()
|
list, err := storelink.ILinkage.QueryImageList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
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)
|
task, err := storelink.ILinkage.QueryTask(req.TaskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -2,9 +2,10 @@ package storelink
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"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/svc"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"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) {
|
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) {
|
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
|
var envs []string
|
||||||
if len(req.Envs) != 0 {
|
if len(req.Envs) != 0 {
|
||||||
for _, v := range req.Envs {
|
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) {
|
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)
|
img, err := storelink.ILinkage.UploadImage(req.FilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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/api/internal/types"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus"
|
"gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Linkage interface {
|
type Linkage interface {
|
||||||
|
@ -20,6 +21,8 @@ type Linkage interface {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
COMMA = ","
|
COMMA = ","
|
||||||
|
TYPE_OCTOPUS = "octopus"
|
||||||
|
TYPE_MODELARTS = "modelarts"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -28,20 +31,34 @@ var (
|
||||||
3: "制作完成",
|
3: "制作完成",
|
||||||
4: "制作失败",
|
4: "制作失败",
|
||||||
}
|
}
|
||||||
|
AITYPE = map[string]string{
|
||||||
|
"1": TYPE_OCTOPUS,
|
||||||
|
"2": TYPE_MODELARTS,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type StoreLink struct {
|
type StoreLink struct {
|
||||||
ILinkage Linkage
|
ILinkage Linkage
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, partId int64) *StoreLink {
|
func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, participant models.ScParticipantPhyInfo) *StoreLink {
|
||||||
var participant models.ScParticipantPhyInfo
|
//todo 创建modelarts client
|
||||||
svcCtx.DbEngin.Raw("select * from sc_participant_phy_info where id = ?", partId).Scan(&participant)
|
|
||||||
|
|
||||||
linkStruct := NewOctopusLink(ctx, svcCtx, participant.Name)
|
linkStruct := NewOctopusLink(ctx, svcCtx, participant.Name)
|
||||||
return &StoreLink{ILinkage: linkStruct}
|
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) {
|
func ConvertType[T any](in *T) (interface{}, error) {
|
||||||
|
|
||||||
switch (interface{})(in).(type) {
|
switch (interface{})(in).(type) {
|
||||||
|
|
Loading…
Reference in New Issue