mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-29 10:56:35 +08:00
feat: 新增系统全局配置&修改账号密码
This commit is contained in:
39
server/internal/sys/api/config.go
Normal file
39
server/internal/sys/api/config.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/sys/api/form"
|
||||
"mayfly-go/internal/sys/application"
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/ginx"
|
||||
"mayfly-go/pkg/utils"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ConfigApp application.Config
|
||||
}
|
||||
|
||||
func (c *Config) Configs(rc *ctx.ReqCtx) {
|
||||
g := rc.GinCtx
|
||||
condition := &entity.Config{Key: g.Query("key")}
|
||||
rc.ResData = c.ConfigApp.GetPageList(condition, ginx.GetPageParam(g), new([]entity.Config))
|
||||
}
|
||||
|
||||
func (c *Config) GetConfigValueByKey(rc *ctx.ReqCtx) {
|
||||
key := rc.GinCtx.Query("key")
|
||||
biz.NotEmpty(key, "key不能为空")
|
||||
rc.ResData = c.ConfigApp.GetConfig(key).Value
|
||||
}
|
||||
|
||||
func (c *Config) SaveConfig(rc *ctx.ReqCtx) {
|
||||
g := rc.GinCtx
|
||||
form := &form.ConfigForm{}
|
||||
ginx.BindJsonAndValid(g, form)
|
||||
rc.ReqParam = form
|
||||
|
||||
config := new(entity.Config)
|
||||
utils.Copy(config, form)
|
||||
config.SetBaseInfo(rc.LoginAccount)
|
||||
c.ConfigApp.Save(config)
|
||||
}
|
||||
Reference in New Issue
Block a user