json.go.all.tpl 629 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // 导入所有配置
  2. package data
  3. import (
  4. mhayaDataConfig "github.com/mhaya/components/data-config"
  5. "github.com/mhaya/game/game_cluster/internal/types"
  6. mhayaMapStructure "github.com/mhaya/extend/mapstructure"
  7. )
  8. var (
  9. {{- range .AllSheets}}
  10. {{.Name}} = &{{.Name}}{}
  11. {{- end}}
  12. )
  13. func New() *mhayaDataConfig.Component {
  14. dataConfig := mhayaDataConfig.New()
  15. dataConfig.Register(
  16. {{- range .AllSheets}}
  17. {{.Name}},
  18. {{- end}}
  19. )
  20. return dataConfig
  21. }
  22. func DecodeData(input interface{}, output interface{}) error {
  23. return mhayaMapStructure.HookDecode(
  24. input,
  25. output,
  26. "json",
  27. types.GetDecodeHooks(),
  28. )
  29. }