fix: add instance center Add fuzzy queries of ai
This commit is contained in:
parent
c12484bf2e
commit
6ab1fa8fd7
|
@ -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"`
|
||||||
|
|
|
@ -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
|
if InstanceCenter == nil {
|
||||||
|
resp.Code = 200
|
||||||
|
resp.Msg = "No content found"
|
||||||
|
} else {
|
||||||
|
var instanceCenter = *InstanceCenter
|
||||||
|
|
||||||
for _, instanceCenter := range instanceCenter {
|
for _, instanceCenter := range instanceCenter {
|
||||||
var instanceCenterlist types.InstanceCenterList
|
var instanceCenterlist types.InstanceCenterList
|
||||||
instanceCenterlist.InstanceName = instanceCenter.InstanceName
|
instanceCenterlist.InstanceName = instanceCenter.InstanceName
|
||||||
instanceCenterlist.InstanceType = instanceCenter.InstanceType
|
instanceCenterlist.InstanceType = instanceCenter.InstanceType
|
||||||
instanceCenterlist.InstanceClass = instanceCenter.InstanceClass
|
instanceCenterlist.InstanceClass = instanceCenter.InstanceClass
|
||||||
instanceCenterlist.Description = instanceCenter.Description
|
instanceCenterlist.Description = instanceCenter.Description
|
||||||
instanceCenterlist.InstanceClassChinese = instanceCenter.InstanceClassChinese
|
instanceCenterlist.InstanceClassChinese = instanceCenter.InstanceClassChinese
|
||||||
instanceCenterlist.Version = instanceCenter.Version
|
instanceCenterlist.Version = instanceCenter.Version
|
||||||
instanceCenterlist.LogoPath = instanceCenter.LogoPath
|
instanceCenterlist.LogoPath = instanceCenter.LogoPath
|
||||||
InstanceCenterLists = append(InstanceCenterLists, instanceCenterlist)
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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…
Reference in New Issue