diff --git a/server/info/internal/logic/infologic.go b/server/info/internal/logic/infologic.go index 8b020b62..8f11e6b9 100644 --- a/server/info/internal/logic/infologic.go +++ b/server/info/internal/logic/infologic.go @@ -85,7 +85,7 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r } mlist := strings.Split(module, ".") - if len(mlist) == 0 { + if len(mlist) < 2 { return resp.SetStatusWithMessage(basic.CodeApiErr, fmt.Sprintf("%s format error", module)) } @@ -95,8 +95,11 @@ 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)) } + moduleName := mlist[1] + cond = moduleName + " and " + cond + if mquery, ok := mquerys[mtable]; ok { - mquery.ModuleQuery[strings.Join(mlist[1:], ",")] = struct{}{} + mquery.ModuleQuery[strings.Join(mlist[2:], ",")] = struct{}{} } else { mquery := &ModuleQuery{ TableName: tname, @@ -108,7 +111,7 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r for _, mquery := range mquerys { - sqlstr := fmt.Sprintf("select id, module, %s as querydata from %s where %s order by ctime asc", mquery.EncodeQuery("metadata"), mquery.TableName, cond) + sqlstr := fmt.Sprintf("select id, module, %s as querydata from %s where %s order by ctime asc limit 1", mquery.EncodeQuery("metadata"), mquery.TableName, cond) raw := l.svcCtx.MysqlConn.Raw(sqlstr) @@ -135,7 +138,7 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r var querydata map[string]any = make(map[string]any) err = json.Unmarshal([]byte(info["querydata"].(string)), &querydata) if err != nil { - logx.Error(err, info) + logx.Error(err) return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error()) }