feat: 系统配置新增权限控制

This commit is contained in:
meilin.huang
2023-08-25 19:41:52 +08:00
parent 756e580469
commit 3634c902d0
17 changed files with 150 additions and 75 deletions

View File

@@ -16,28 +16,22 @@ type Config struct {
func (c *Config) Configs(rc *req.Ctx) {
g := rc.GinCtx
condition := &entity.Config{Key: g.Query("key")}
condition.Permission = rc.LoginAccount.Username
rc.ResData = c.ConfigApp.GetPageList(condition, ginx.GetPageParam(g), new([]entity.Config))
}
func (c *Config) GetConfigValueByKey(rc *req.Ctx) {
key := rc.GinCtx.Query("key")
biz.NotEmpty(key, "key不能为空")
rc.ResData = c.ConfigApp.GetConfig(key).Value
}
func (c *Config) GetConfigValueByKeyWithNoToken(keys []string) func(rc *req.Ctx) {
keyMap := make(map[string]struct{})
for _, key := range keys {
keyMap[key] = struct{}{}
}
return func(rc *req.Ctx) {
key := rc.GinCtx.Query("key")
biz.NotEmpty(key, "key不能为空")
if _, ok := keyMap[key]; !ok {
biz.ErrIsNil(nil, "无权限获取该配置信息")
}
rc.ResData = c.ConfigApp.GetConfig(key).Value
config := c.ConfigApp.GetConfig(key)
// 判断是否为公开配置
if config.Permission != "all" {
rc.ResData = ""
return
}
rc.ResData = config.Value
}
func (c *Config) SaveConfig(rc *req.Ctx) {