|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package inference
-
- import (
- "context"
- "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
-
- "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
- "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type InstanceCenterLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewInstanceCenterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceCenterLogic {
- return &InstanceCenterLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- 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
-
- 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
-
- for _, instanceCenter := range instanceCenter {
- var instanceCenterlist types.InstanceCenterList
- instanceCenterlist.InstanceName = instanceCenter.InstanceName
- 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)
- }
-
- resp.Code = 200
- resp.Msg = "success"
- resp.InstanceCenterList = InstanceCenterLists
- resp.TotalCount = len(InstanceCenterLists)
- return &resp, nil
- }
|