Browse Source

fix: add instance center Add fuzzy queries of ai

pull/318/head
qiwang 1 year ago
parent
commit
6ab1fa8fd7
3 changed files with 36 additions and 19 deletions
  1. +1
    -0
      desc/inference/inference.api
  2. +34
    -19
      internal/logic/inference/instancecenterlogic.go
  3. +1
    -0
      internal/types/types.go

+ 1
- 0
desc/inference/inference.api View File

@@ -37,6 +37,7 @@ type (
InstanceCenterReq{ InstanceCenterReq{
InstanceType int32 `form:"instance_type"` InstanceType int32 `form:"instance_type"`
InstanceClass string `form:"instance_class,optional"` InstanceClass string `form:"instance_class,optional"`
InstanceName string `form:"instance_name,optional"`
} }
InstanceCenterResp { InstanceCenterResp {
InstanceCenterList []InstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"` InstanceCenterList []InstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"`


+ 34
- 19
internal/logic/inference/instancecenterlogic.go View File

@@ -32,30 +32,45 @@ func (l *InstanceCenterLogic) InstanceCenter(req *types.InstanceCenterReq) (*typ
var InstanceCenterLists []types.InstanceCenterList var InstanceCenterLists []types.InstanceCenterList


if req.InstanceType == 0 { if req.InstanceType == 0 {
l.svcCtx.DbEngin.Raw("select * from ai_instance_center").Scan(&InstanceCenter)
tx := l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_name like CONCAT(?, '%')", req.InstanceName).Scan(&InstanceCenter)
if tx.Error == nil {
logx.Error("find nil")
}
} else if req.InstanceType != 0 && req.InstanceClass == "" { } else if req.InstanceType != 0 && req.InstanceClass == "" {
l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? ", req.InstanceType).Scan(&InstanceCenter)
tx := l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? and instance_name like CONCAT(?, '%')", req.InstanceType, req.InstanceName).Scan(&InstanceCenter)
if tx.Error == nil {
logx.Error("find nil")

}
} else { } else {
l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? and instance_class = ?", req.InstanceType, req.InstanceClass).Scan(&InstanceCenter)
tx := l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? and instance_class = ? and instance_name like CONCAT(?, '%')", req.InstanceType, req.InstanceClass, req.InstanceName).Scan(&InstanceCenter)
if tx.Error == nil {
logx.Error("find nil")
}
} }


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)
if InstanceCenter == nil {
resp.Code = 200
resp.Msg = "No content found"
} else {
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)
} }


resp.Code = 200
resp.Msg = "success"
resp.InstanceCenterList = InstanceCenterLists
resp.TotalCount = len(InstanceCenterLists)
return &resp, nil return &resp, nil
} }

+ 1
- 0
internal/types/types.go View File

@@ -3668,6 +3668,7 @@ type InstanceCenterList struct {
type InstanceCenterReq struct { type InstanceCenterReq struct {
InstanceType int32 `form:"instance_type"` InstanceType int32 `form:"instance_type"`
InstanceClass string `form:"instance_class,optional"` InstanceClass string `form:"instance_class,optional"`
InstanceName string `form:"instance_name,optional"`
} }


type InstanceCenterResp struct { type InstanceCenterResp struct {


Loading…
Cancel
Save