MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / importServices

Method importServices

controller/system/import.go:151–196  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

149}
150
151func (i *imlImportConfigController) importServices(ctx context.Context) error {
152 data, err := unmarshal[service_dto.ExportService]("service")
153 if err != nil {
154 return err
155 }
156 for _, d := range data {
157 // 判断是否存在,如果存在,则更新
158 _, err = i.serviceModule.Get(ctx, d.Id)
159 if err != nil {
160 if !errors.Is(err, gorm.ErrRecordNotFound) {
161 return err
162 }
163 _, err = i.serviceModule.Create(ctx, d.Team, &service_dto.CreateService{
164 Id: d.Id,
165 Name: d.Name,
166 Prefix: d.Prefix,
167 Description: d.Description,
168 ServiceType: d.ServiceType,
169 Logo: d.Logo,
170 Tags: d.Tags,
171 Catalogue: d.Catalogue,
172 })
173 if err != nil {
174 return fmt.Errorf("create service(%s) error: %v", d.Id, err)
175 }
176 } else {
177 _, err = i.serviceModule.Edit(ctx, d.Id, &service_dto.EditService{
178 Name: &d.Name,
179 Description: &d.Description,
180 ServiceType: &d.ServiceType,
181 Catalogue: &d.Catalogue,
182 Logo: &d.Logo,
183 Tags: &d.Tags,
184 })
185 if err != nil {
186 return fmt.Errorf("update service(%s) error: %v", d.Id, err)
187 }
188 }
189
190 //err = i.serviceModule.SaveServiceDoc(ctx, d.Id, &service_dto.SaveServiceDoc{Doc: d.Doc})
191 //if err != nil {
192 // return fmt.Errorf("save service(%s) doc error: %v", d.Id, err)
193 //}
194 }
195 return nil
196}
197
198func (i *imlImportConfigController) importApplications(ctx context.Context) error {
199 data, err := unmarshal[service_dto.ExportApp]("app")

Callers 1

ImportAllMethod · 0.95

Calls 3

GetMethod · 0.65
CreateMethod · 0.65
EditMethod · 0.65

Tested by

no test coverage detected