fix
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/check"
|
||||
"strings"
|
||||
|
||||
"context"
|
||||
@@ -47,6 +48,11 @@ type InfoType struct {
|
||||
// CreateAt time.Time `json:"ctime"`
|
||||
}
|
||||
|
||||
type ModuleQuery struct {
|
||||
ModuleName string
|
||||
ModuleQuery string
|
||||
}
|
||||
|
||||
func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
@@ -61,9 +67,14 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r
|
||||
cond = "user_id = 0 and guest_id = 0"
|
||||
}
|
||||
|
||||
var mquerys []*ModuleQuery
|
||||
var metadict map[string]any = make(map[string]any)
|
||||
|
||||
for _, module := range req.Module {
|
||||
if !check.CheckModuleQuery(module) {
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, fmt.Sprintf("%s format is error", module))
|
||||
}
|
||||
|
||||
mlist := strings.Split(module, ".")
|
||||
if len(mlist) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, fmt.Sprintf("%s format error", module))
|
||||
@@ -75,7 +86,13 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, fmt.Sprintf("%s format error, table %s not found", module, tname))
|
||||
}
|
||||
|
||||
sqlstr := fmt.Sprintf("select id, module, metadata from %s where %s ", tname, cond)
|
||||
mquerys = append(mquerys, &ModuleQuery{ModuleName: mtable, ModuleQuery: strings.Join(mlist[1:], ",")})
|
||||
|
||||
}
|
||||
|
||||
for _, mquery := range mquerys {
|
||||
|
||||
sqlstr := fmt.Sprintf("select id, module, metadata from %s where %s ", mquery.ModuleName, cond)
|
||||
var info InfoType
|
||||
err := l.svcCtx.MysqlConn.Raw(sqlstr).Scan(&info).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
|
||||
Reference in New Issue
Block a user