fix: add instance center Add fuzzy queries of ai
This commit is contained in:
parent
c12484bf2e
commit
6ab1fa8fd7
|
@ -37,6 +37,7 @@ type (
|
|||
InstanceCenterReq{
|
||||
InstanceType int32 `form:"instance_type"`
|
||||
InstanceClass string `form:"instance_class,optional"`
|
||||
InstanceName string `form:"instance_name,optional"`
|
||||
}
|
||||
InstanceCenterResp {
|
||||
InstanceCenterList []InstanceCenterList `json:"instanceCenterList" copier:"InstanceCenterList"`
|
||||
|
|
|
@ -32,13 +32,27 @@ func (l *InstanceCenterLogic) InstanceCenter(req *types.InstanceCenterReq) (*typ
|
|||
var InstanceCenterLists []types.InstanceCenterList
|
||||
|
||||
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 == "" {
|
||||
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 {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
if InstanceCenter == nil {
|
||||
resp.Code = 200
|
||||
resp.Msg = "No content found"
|
||||
} else {
|
||||
var instanceCenter = *InstanceCenter
|
||||
|
||||
for _, instanceCenter := range instanceCenter {
|
||||
|
@ -52,10 +66,11 @@ func (l *InstanceCenterLogic) InstanceCenter(req *types.InstanceCenterReq) (*typ
|
|||
instanceCenterlist.LogoPath = instanceCenter.LogoPath
|
||||
InstanceCenterLists = append(InstanceCenterLists, instanceCenterlist)
|
||||
}
|
||||
|
||||
resp.Code = 200
|
||||
resp.Msg = "success"
|
||||
resp.InstanceCenterList = InstanceCenterLists
|
||||
resp.TotalCount = len(InstanceCenterLists)
|
||||
}
|
||||
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -3668,6 +3668,7 @@ type InstanceCenterList struct {
|
|||
type InstanceCenterReq struct {
|
||||
InstanceType int32 `form:"instance_type"`
|
||||
InstanceClass string `form:"instance_class,optional"`
|
||||
InstanceName string `form:"instance_name,optional"`
|
||||
}
|
||||
|
||||
type InstanceCenterResp struct {
|
||||
|
|
Loading…
Reference in New Issue