You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
829 B

  1. package model
  2. import (
  3. "gin-vue-admin/config"
  4. "gin-vue-admin/global"
  5. "gin-vue-admin/utils"
  6. )
  7. //配置文件结构体
  8. type System struct {
  9. Config config.Server
  10. }
  11. // @title GetSystemConfig
  12. // @description 读取配置文件
  13. // @auth (2020/04/05 20:22 )
  14. // @return err error
  15. // @return conf Server
  16. func (s *System) GetSystemConfig() (err error, conf config.Server) {
  17. return nil, global.GVA_CONFIG
  18. }
  19. // @title SetSystemConfig
  20. // @description set system config, 设置配置文件
  21. // @auth (2020/04/05 20:22 )
  22. // @return err error
  23. func (s *System) SetSystemConfig() (err error) {
  24. confs := utils.StructToMap(s.Config)
  25. for k, v := range confs {
  26. global.GVA_VP.Set(k, v)
  27. }
  28. err = global.GVA_VP.WriteConfig()
  29. return err
  30. }