Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
5df734c546
|
@ -5,6 +5,8 @@ Timeout: 15000 #服务超时时间(毫秒)
|
||||||
ReplicaId: 200
|
ReplicaId: 200
|
||||||
SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen
|
SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen
|
||||||
SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672
|
SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672
|
||||||
|
Log:
|
||||||
|
Stat: false
|
||||||
Auth:
|
Auth:
|
||||||
AccessSecret: fusen2023
|
AccessSecret: fusen2023
|
||||||
AccessExpire: 2592000
|
AccessExpire: 2592000
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
@ -107,7 +108,7 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r
|
||||||
|
|
||||||
for _, mquery := range mquerys {
|
for _, mquery := range mquerys {
|
||||||
|
|
||||||
sqlstr := fmt.Sprintf("select id, module, %s as querydata from %s where %s ", mquery.EncodeQuery("metadata"), mquery.TableName, cond)
|
sqlstr := fmt.Sprintf("select id, module, %s as querydata from %s where %s order by ctime asc", mquery.EncodeQuery("metadata"), mquery.TableName, cond)
|
||||||
|
|
||||||
raw := l.svcCtx.MysqlConn.Raw(sqlstr)
|
raw := l.svcCtx.MysqlConn.Raw(sqlstr)
|
||||||
|
|
||||||
|
@ -131,15 +132,14 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r
|
||||||
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
logx.Error(info)
|
var querydata map[string]any = make(map[string]any)
|
||||||
// var querydata map[string]any = make(map[string]any)
|
err = json.Unmarshal([]byte(info["querydata"].(string)), &querydata)
|
||||||
// err = json.Unmarshal([]byte(info["querydata"].(string)), &querydata)
|
if err != nil {
|
||||||
// if err != nil {
|
logx.Error(err, info)
|
||||||
// logx.Error(err, info)
|
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
||||||
// return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
for k, v := range info {
|
for k, v := range querydata {
|
||||||
metadict[k] = v
|
metadict[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
93
server/info/internal/logic/infologic_test.go
Normal file
93
server/info/internal/logic/infologic_test.go
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"fusenapi/initalize"
|
||||||
|
"fusenapi/utils/check"
|
||||||
|
"log"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(t *testing.T) {
|
||||||
|
|
||||||
|
conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen")
|
||||||
|
cond := "user_id = 105 and guest_id = 0"
|
||||||
|
|
||||||
|
var mquerys map[string]*ModuleQuery = make(map[string]*ModuleQuery)
|
||||||
|
var metadict map[string]any = make(map[string]any)
|
||||||
|
|
||||||
|
for _, module := range []string{"material.logo_url"} {
|
||||||
|
if !check.CheckModuleQuery(module) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mlist := strings.Split(module, ".")
|
||||||
|
if len(mlist) == 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mtable := mlist[0]
|
||||||
|
tname, ok := ModuleTable[mtable]
|
||||||
|
if !ok {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if mquery, ok := mquerys[mtable]; ok {
|
||||||
|
mquery.ModuleQuery[strings.Join(mlist[1:], ",")] = struct{}{}
|
||||||
|
} else {
|
||||||
|
mquery := &ModuleQuery{
|
||||||
|
TableName: tname,
|
||||||
|
ModuleName: mtable,
|
||||||
|
ModuleQuery: map[string]struct{}{strings.Join(mlist[1:], ","): {}}}
|
||||||
|
mquerys[mtable] = mquery
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
raw := conn.Raw(sqlstr)
|
||||||
|
|
||||||
|
if raw.Error != nil {
|
||||||
|
if raw.Error == gorm.ErrRecordNotFound {
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
logx.Error(raw.Error)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var info map[string]any = make(map[string]any)
|
||||||
|
err := raw.Scan(&info).Error
|
||||||
|
if err == gorm.ErrRecordNotFound {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err, mquery.EncodeQuery("metadata"))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
logx.Error(info["querydata"].(string))
|
||||||
|
var querydata map[string]any = make(map[string]any)
|
||||||
|
err = json.Unmarshal([]byte(info["querydata"].(string)), &querydata)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err, info)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println(querydata)
|
||||||
|
|
||||||
|
for k, v := range querydata {
|
||||||
|
metadict[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user