diff --git a/desc/inference/inference.api b/desc/inference/inference.api index efd59d24..3f12d5a1 100644 --- a/desc/inference/inference.api +++ b/desc/inference/inference.api @@ -34,6 +34,9 @@ type ( } /******************image inference*************************/ /******************instance center*************************/ + InstanceCenterReq{ + InstanceType int32 `form:"instance_type"` + } InstanceCenterResp { InstanceCenterList []InstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"` Code int32 `json:"code,omitempty"` @@ -46,6 +49,7 @@ type ( InstanceName string `json:"instance_name"` InstanceType int32 `json:"instance_type"` InstanceClass string `json:"instance_class"` + InstanceClassChinese string `json:"instance_class_chinese"` Description string `json:"description"` Version string `json:"version"` } diff --git a/desc/pcm.api b/desc/pcm.api index 33bd0465..f5509915 100644 --- a/desc/pcm.api +++ b/desc/pcm.api @@ -939,7 +939,7 @@ service pcm { get /inference/modelTypes returns (ModelTypesResp) @handler InstanceCenterHandler - get /inference/instanceCenter returns (InstanceCenterResp) + get /inference/instanceCenter (InstanceCenterReq) returns (InstanceCenterResp) @handler ModelNamesByTypeHandler get /inference/modelNames (ModelNamesReq) returns (ModelNamesResp) diff --git a/internal/handler/inference/instancecenterhandler.go b/internal/handler/inference/instancecenterhandler.go index 3a961fd8..d279905d 100644 --- a/internal/handler/inference/instancecenterhandler.go +++ b/internal/handler/inference/instancecenterhandler.go @@ -6,12 +6,19 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/inference" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" ) func InstanceCenterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + var req types.InstanceCenterReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + l := inference.NewInstanceCenterLogic(r.Context(), svcCtx) - resp, err := l.InstanceCenter() + resp, err := l.InstanceCenter(&req) if err != nil { httpx.ErrorCtx(r.Context(), w, err) } else { diff --git a/internal/logic/inference/instancecenterlogic.go b/internal/logic/inference/instancecenterlogic.go index a3f8aef1..dd0d90ec 100644 --- a/internal/logic/inference/instancecenterlogic.go +++ b/internal/logic/inference/instancecenterlogic.go @@ -24,14 +24,19 @@ func NewInstanceCenterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *In } } -func (l *InstanceCenterLogic) InstanceCenter() (*types.InstanceCenterResp, error) { +func (l *InstanceCenterLogic) InstanceCenter(req *types.InstanceCenterReq) (*types.InstanceCenterResp, error) { // todo: add your logic here and delete this line var resp types.InstanceCenterResp var InstanceCenter *[]models.AiInstanceCenter var InstanceCenterLists []types.InstanceCenterList - l.svcCtx.DbEngin.Raw("select * from ai_instance_center").Scan(&InstanceCenter) + if req.InstanceType == 0 { + l.svcCtx.DbEngin.Raw("select * from ai_instance_center").Scan(&InstanceCenter) + } else { + l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ?", req.InstanceType).Scan(&InstanceCenter) + + } var instanceCenter = *InstanceCenter @@ -41,6 +46,7 @@ func (l *InstanceCenterLogic) InstanceCenter() (*types.InstanceCenterResp, error instanceCenterlist.InstanceType = instanceCenter.InstanceType instanceCenterlist.InstanceClass = instanceCenter.InstanceClass instanceCenterlist.Description = instanceCenter.Description + instanceCenterlist.InstanceClassChinese = instanceCenter.InstanceClassChinese instanceCenterlist.Version = instanceCenter.Version instanceCenterlist.LogoPath = instanceCenter.LogoPath InstanceCenterLists = append(InstanceCenterLists, instanceCenterlist) diff --git a/internal/types/types.go b/internal/types/types.go index d4163adb..8183e7fa 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -3656,12 +3656,17 @@ type InputsAlRq struct { } type InstanceCenterList struct { - LogoPath string `json:"logo_path"` - InstanceName string `json:"instance_name"` - InstanceType int32 `json:"instance_type"` - InstanceClass string `json:"instance_class"` - Description string `json:"description"` - Version string `json:"version"` + LogoPath string `json:"logo_path"` + InstanceName string `json:"instance_name"` + InstanceType int32 `json:"instance_type"` + InstanceClass string `json:"instance_class"` + InstanceClassChinese string `json:"instance_class_chinese"` + Description string `json:"description"` + Version string `json:"version"` +} + +type InstanceCenterReq struct { + InstanceType int32 `form:"instance_type"` } type InstanceCenterResp struct { diff --git a/pkg/models/aiinstancecentermodel_gen.go b/pkg/models/aiinstancecentermodel_gen.go index 35c3f76f..40bbb00e 100644 --- a/pkg/models/aiinstancecentermodel_gen.go +++ b/pkg/models/aiinstancecentermodel_gen.go @@ -34,15 +34,16 @@ type ( } AiInstanceCenter struct { - Id int64 `db:"id"` // 平台唯一id - LogoPath string `db:"logo_path"` // logo图像的位置 - InstanceName string `db:"instance_name"` // 实例名称 - InstanceType int32 `db:"instance_type"` // 实例类型(1是应用实例,2是模型实例) - InstanceClass string `db:"instance_class"` // 实例类别 - Description string `db:"description"` // 描述 - Version string `db:"version"` // 版本 - CreateTime string `db:"create_time"` // 创建时间 - UpdateTime string `db:"update_time"` // 更新时间 + Id int64 `db:"id"` // 平台唯一id + LogoPath string `db:"logo_path"` // logo图像的位置 + InstanceName string `db:"instance_name"` // 实例名称 + InstanceType int32 `db:"instance_type"` // 实例类型(1是应用实例,2是模型实例) + InstanceClass string `db:"instance_class"` // 实例类别 + InstanceClassChinese string `db:"instance_class_chinese"` // 实例类别中文描述 + Description string `db:"description"` // 描述 + Version string `db:"version"` // 版本 + CreateTime string `db:"create_time"` // 创建时间 + UpdateTime string `db:"update_time"` // 更新时间 } ) @@ -74,14 +75,14 @@ func (m *defaultAiInstanceCenterModel) FindOne(ctx context.Context, id int64) (* } func (m *defaultAiInstanceCenterModel) Insert(ctx context.Context, data *AiInstanceCenter) (sql.Result, error) { - query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, aiInstanceCenterRowsExpectAutoSet) - ret, err := m.conn.ExecCtx(ctx, query, data.Id, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.Description, data.Version) + query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, aiInstanceCenterRowsExpectAutoSet) + ret, err := m.conn.ExecCtx(ctx, query, data.Id, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version) return ret, err } func (m *defaultAiInstanceCenterModel) Update(ctx context.Context, data *AiInstanceCenter) error { query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, aiInstanceCenterRowsWithPlaceHolder) - _, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.Description, data.Version, data.Id) + _, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version, data.Id) return err }