package dto import "MeterService/database/appApi" type App struct { AppId int `json:"appId"` AppSecret string `json:"appSecret"` AppName string `json:"appName"` Host string `json:"host"` Apis []*AppApi `json:"apis"` } type AppApi struct { Url string `json:"url"` Type string `json:"type"` } type RespApp struct { AppId int `json:"appId"` AppSecret string `json:"appSecret"` } func (m *App) ToDbApp() *appApi.App { dbApp := appApi.NewApp() dbApp.AppName = m.AppName dbApp.AppSecret = m.AppSecret dbApp.AppId = m.AppId dbApp.Host = m.Host dbApp.Apis = make([]*appApi.AppApi, 0) for _, v := range m.Apis { dbApp.Apis = append(dbApp.Apis, &appApi.AppApi{ AppId: m.AppId, Type: v.Type, Host: m.Host, Url: v.Url, }) } return dbApp }