@@ -396,15 +396,36 @@ func (i *imlServiceModule) Create(ctx context.Context, teamID string, input *ser
396396 }
397397 }
398398 }
399-
400- err := i .serviceModelMappingService .Save (ctx , & service_model_mapping.Save {
401- Sid : input .Id ,
402- Content : input .ModelMapping ,
403- })
399+ err := i .serviceService .Create (ctx , mo )
404400 if err != nil {
405401 return err
406402 }
407- return i .serviceService .Create (ctx , mo )
403+ if input .ModelMapping != "" {
404+ m := make (map [string ]string )
405+ err = json .Unmarshal ([]byte (input .ModelMapping ), & m )
406+ if err != nil {
407+ return err
408+ }
409+ err = i .serviceModelMappingService .Save (ctx , & service_model_mapping.Save {
410+ Sid : input .Id ,
411+ Content : input .ModelMapping ,
412+ })
413+ if err != nil {
414+ return err
415+ }
416+ client , err := i .clusterService .GatewayClient (ctx , cluster .DefaultClusterID )
417+ if err != nil {
418+ return err
419+ }
420+ err = client .Hash ().Online (ctx , & gateway.HashRelease {
421+ HashKey : fmt .Sprintf ("%s:%s" , gateway .KeyServiceMapping , input .Id ),
422+ HashMap : m ,
423+ })
424+ if err != nil {
425+ return err
426+ }
427+ }
428+ return nil
408429 })
409430 if err != nil {
410431 return nil , err
@@ -473,7 +494,7 @@ func (i *imlServiceModule) Edit(ctx context.Context, id string, input *service_d
473494
474495 }
475496 }
476- if input .ModelMapping != nil {
497+ if input .ModelMapping != nil && * input . ModelMapping != "" {
477498 m := make (map [string ]string )
478499 err = json .Unmarshal ([]byte (* input .ModelMapping ), & m )
479500 if err != nil {
0 commit comments