...
|
...
|
@@ -9,7 +9,9 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/authlib"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
func ResponseGrid(c beego.BaseController, total int64, data interface{}, err error) {
|
...
|
...
|
@@ -94,3 +96,74 @@ func header(c beego.BaseController, key string) int { |
|
|
}
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
var BlacklistRouters = map[string]bool{
|
|
|
"/data/files": true,
|
|
|
"/data/edit-data-table": true,
|
|
|
"/data/flush-data-table": true,
|
|
|
"/data/generate-main-table": true,
|
|
|
"/data/append-data-to-table": true,
|
|
|
"/data/tables/copy-data-table": true,
|
|
|
"/data/tables/apply-on": true,
|
|
|
"/data/tables/add-sub-table": true,
|
|
|
"/data/tables/row-edit": true,
|
|
|
"/data/mapping-rules": true,
|
|
|
|
|
|
"/data/query-sets": true,
|
|
|
"/data/query-sets/copy": true,
|
|
|
"/data/query-sets/move": true,
|
|
|
"/data/query-sets/rename": true,
|
|
|
"/data/query-sets/change-status": true,
|
|
|
|
|
|
"/data/query-sets/formula": true,
|
|
|
"/data/query-sets/formula/change-status": true,
|
|
|
"/data/query-sets/formula/move": true,
|
|
|
"/data/query-sets/formula/copy": true,
|
|
|
"/data/query-sets/formula/rename": true,
|
|
|
}
|
|
|
|
|
|
func BlacklistFilter(black map[string]bool) func(ctx *context.Context) {
|
|
|
return func(ctx *context.Context) {
|
|
|
if token := ctx.Input.GetData("UserToken"); token != nil {
|
|
|
userToken, ok := token.(*domain.UserToken)
|
|
|
if !ok {
|
|
|
return
|
|
|
}
|
|
|
if userToken.UserId > 0 && userToken.UserId == constant.BlacklistUser {
|
|
|
goto CheckBlackList
|
|
|
} else if userToken.CompanyId > 0 && userToken.UserId == 0 && userToken.CompanyId == constant.BlackListCompany {
|
|
|
goto CheckBlackList
|
|
|
} else {
|
|
|
return
|
|
|
}
|
|
|
CheckBlackList:
|
|
|
var notAllow = false
|
|
|
defer func() {
|
|
|
if notAllow {
|
|
|
ctx.Output.SetStatus(http.StatusOK)
|
|
|
ctx.Output.JSON(map[string]interface{}{
|
|
|
"msg": "测试账户不允许修改数据",
|
|
|
"code": 801,
|
|
|
"data": struct{}{},
|
|
|
}, false, false)
|
|
|
}
|
|
|
}()
|
|
|
if ctx.Request.Method == http.MethodDelete || ctx.Request.Method == http.MethodPut {
|
|
|
notAllow = true
|
|
|
return
|
|
|
}
|
|
|
url := ctx.Request.URL.Path
|
|
|
if v, ok := black[url]; ok && v {
|
|
|
notAllow = true
|
|
|
return
|
|
|
}
|
|
|
if strings.HasSuffix(url, "/") {
|
|
|
url = strings.TrimSuffix(url, "/")
|
|
|
}
|
|
|
if v, ok := black[url]; ok && v {
|
|
|
notAllow = true
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|