mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 21:22:16 +08:00
feat: config
This commit is contained in:
parent
b92ab6f574
commit
755efcb58e
@ -70,7 +70,7 @@ func (cm *ConfigManager) GetConfigList(c *gin.Context) {
|
|||||||
|
|
||||||
func (cm *ConfigManager) SetConfig(c *gin.Context) {
|
func (cm *ConfigManager) SetConfig(c *gin.Context) {
|
||||||
var req apistruct.SetConfigReq
|
var req apistruct.SetConfigReq
|
||||||
if err := c.BindJSON(&req.Data); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ func (cm *ConfigManager) SetConfig(c *gin.Context) {
|
|||||||
|
|
||||||
func compareAndSave[T any](c *gin.Context, old any, req *apistruct.SetConfigReq, client *clientv3.Client) error {
|
func compareAndSave[T any](c *gin.Context, old any, req *apistruct.SetConfigReq, client *clientv3.Client) error {
|
||||||
conf := new(T)
|
conf := new(T)
|
||||||
err := json.Unmarshal(req.Data, &conf)
|
err := json.Unmarshal([]byte(req.Data), &conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.ErrArgs.WithDetail(err.Error()).Wrap()
|
return errs.ErrArgs.WithDetail(err.Error()).Wrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,5 +12,5 @@ type GetConfigListResp struct {
|
|||||||
|
|
||||||
type SetConfigReq struct {
|
type SetConfigReq struct {
|
||||||
ConfigName string `json:"configName"`
|
ConfigName string `json:"configName"`
|
||||||
Data []byte `json:"data"`
|
Data string `json:"data"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user