fix
This commit is contained in:
parent
2d62681600
commit
aa4a48b68a
@ -27,6 +27,8 @@ type queueItem struct {
|
|||||||
var mapMq = make(map[constants.RABBIT_MQ]queueItem)
|
var mapMq = make(map[constants.RABBIT_MQ]queueItem)
|
||||||
|
|
||||||
func InitRabbitMq(url string, config *tls.Config) *RabbitMqHandle {
|
func InitRabbitMq(url string, config *tls.Config) *RabbitMqHandle {
|
||||||
|
return nil
|
||||||
|
|
||||||
url = strings.Trim(url, " ")
|
url = strings.Trim(url, " ")
|
||||||
if url == "" {
|
if url == "" {
|
||||||
return nil
|
return nil
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
"fusenapi/utils/check"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
@ -47,6 +48,11 @@ type InfoType struct {
|
|||||||
// CreateAt time.Time `json:"ctime"`
|
// 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) {
|
func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// 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"
|
cond = "user_id = 0 and guest_id = 0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mquerys []*ModuleQuery
|
||||||
var metadict map[string]any = make(map[string]any)
|
var metadict map[string]any = make(map[string]any)
|
||||||
|
|
||||||
for _, module := range req.Module {
|
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, ".")
|
mlist := strings.Split(module, ".")
|
||||||
if len(mlist) == 0 {
|
if len(mlist) == 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeApiErr, fmt.Sprintf("%s format error", module))
|
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))
|
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
|
var info InfoType
|
||||||
err := l.svcCtx.MysqlConn.Raw(sqlstr).Scan(&info).Error
|
err := l.svcCtx.MysqlConn.Raw(sqlstr).Scan(&info).Error
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
|
@ -56,3 +56,10 @@ func hasInvalidPatterns(key string) bool {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var checkModuleRe = regexp.MustCompile("[^\\.a-zA-Z_-]")
|
||||||
|
|
||||||
|
// CheckModuleQuery 检查模块的json查询的格式
|
||||||
|
func CheckModuleQuery(moduleQuery string) bool {
|
||||||
|
return !checkModuleRe.MatchString(moduleQuery)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user