app.go 809 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dto
  2. import "MeterService/database/appApi"
  3. type App struct {
  4. AppId int `json:"appId"`
  5. AppSecret string `json:"appSecret"`
  6. AppName string `json:"appName"`
  7. Host string `json:"host"`
  8. Apis []*AppApi `json:"apis"`
  9. }
  10. type AppApi struct {
  11. Url string `json:"url"`
  12. Type string `json:"type"`
  13. }
  14. type RespApp struct {
  15. AppId int `json:"appId"`
  16. AppSecret string `json:"appSecret"`
  17. }
  18. func (m *App) ToDbApp() *appApi.App {
  19. dbApp := appApi.NewApp()
  20. dbApp.AppName = m.AppName
  21. dbApp.AppSecret = m.AppSecret
  22. dbApp.AppId = m.AppId
  23. dbApp.Host = m.Host
  24. dbApp.Apis = make([]*appApi.AppApi, 0)
  25. for _, v := range m.Apis {
  26. dbApp.Apis = append(dbApp.Apis, &appApi.AppApi{
  27. AppId: m.AppId,
  28. Type: v.Type,
  29. Host: m.Host,
  30. Url: v.Url,
  31. })
  32. }
  33. return dbApp
  34. }