Skip to content

Commit

Permalink
fix(server): rename itemGroup to group in integration API field type
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Oct 27, 2023
1 parent df04dd1 commit 40359f5
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 78 deletions.
8 changes: 4 additions & 4 deletions server/internal/adapter/gql/gqlmodel/convert_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func ToItemParam(field *ItemFieldInput) *interfaces.ItemFieldParam {
}

return &interfaces.ItemFieldParam{
ItemGroup: ToIDRef[id.ItemGroup](field.ItemGroupID),
Field: &fid,
Type: FromValueType(field.Type),
Value: field.Value,
Group: ToIDRef[id.ItemGroup](field.ItemGroupID),
Field: &fid,
Type: FromValueType(field.Type),
Value: field.Value,
}
}

Expand Down
10 changes: 5 additions & 5 deletions server/internal/adapter/integration/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func fromItemFieldParam(f integrationapi.Field) interfaces.ItemFieldParam {
}

return interfaces.ItemFieldParam{
Field: f.Id,
Key: k,
Type: integrationapi.FromValueType(f.Type),
Value: v,
ItemGroup: f.ItemGroup,
Field: f.Id,
Key: k,
Type: integrationapi.FromValueType(f.Type),
Value: v,
Group: f.Group,
}
}
78 changes: 39 additions & 39 deletions server/internal/adapter/integration/server.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/internal/usecase/interactor/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,12 +751,12 @@ func (i Item) handleGroupFields(ctx context.Context, params []interfaces.ItemFie
}

groupItemParams := lo.Filter(params, func(param interfaces.ItemFieldParam, _ int) bool {
if param.ItemGroup == nil {
if param.Group == nil {
return false
}

_, ok := lo.Find(mvg, func(item value.Group) bool {
return item == *param.ItemGroup
return item == *param.Group
})
return ok
})
Expand Down Expand Up @@ -804,7 +804,7 @@ func itemFieldsFromParams(fields []interfaces.ItemFieldParam, s *schema.Schema)
return nil, fmt.Errorf("field %s: %w", sf.Name(), err)
}

return item.NewField(sf.ID(), m, f.ItemGroup), nil
return item.NewField(sf.ID(), m, f.Group), nil
})
}

Expand Down
10 changes: 5 additions & 5 deletions server/internal/usecase/interfaces/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ var (
)

type ItemFieldParam struct {
Field *item.FieldID
Key *key.Key
Type value.Type
Value any
ItemGroup *id.ItemGroupID
Field *item.FieldID
Key *key.Key
Type value.Type
Value any
Group *id.ItemGroupID
}

type CreateItemParam struct {
Expand Down
10 changes: 5 additions & 5 deletions server/pkg/integrationapi/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ func NewItem(i *item.Item, ss schema.List, assets *AssetContext) Item {
}

return Field{
Id: f.FieldID().Ref(),
Type: lo.ToPtr(ToValueType(f.Type())),
Value: lo.ToPtr(ToValues(f.Value(), sf.Multiple(), assets)),
Key: util.ToPtrIfNotEmpty(sf.Key().String()),
ItemGroup: f.ItemGroup(),
Id: f.FieldID().Ref(),
Type: lo.ToPtr(ToValueType(f.Type())),
Value: lo.ToPtr(ToValues(f.Value(), sf.Multiple(), assets)),
Key: util.ToPtrIfNotEmpty(sf.Key().String()),
Group: f.ItemGroup(),
}, true
})
fs = append(fs, t...)
Expand Down
10 changes: 5 additions & 5 deletions server/pkg/integrationapi/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions server/pkg/item/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import (
)

type Field struct {
field FieldID
itemGroup *ItemGroupID
value *value.Multiple
field FieldID
group *ItemGroupID
value *value.Multiple
}

func NewField(field FieldID, v *value.Multiple, ig *ItemGroupID) *Field {
if v == nil {
return nil
}
return &Field{
field: field,
value: v,
itemGroup: ig,
field: field,
value: v,
group: ig,
}
}

Expand All @@ -41,5 +41,5 @@ func (f *Field) ItemGroup() *ItemGroupID {
if f == nil {
return nil
}
return f.itemGroup
return f.group
}
8 changes: 4 additions & 4 deletions server/pkg/item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func (i *Item) Field(f FieldID) *Field {

func (i *Item) FieldByItemGroupAndID(fid FieldID, igID ItemGroupID) *Field {
ff, _ := lo.Find(i.fields, func(g *Field) bool {
if g.itemGroup == nil {
if g.group == nil {
return false
}
return g.FieldID() == fid && *g.itemGroup == igID
return g.FieldID() == fid && *g.group == igID
})
return ff
}
Expand Down Expand Up @@ -126,10 +126,10 @@ func (i *Item) UpdateFields(fields []*Field) {
if g == nil || f == nil {
return false
}
if g.itemGroup == nil || f.itemGroup == nil {
if g.group == nil || f.group == nil {
return g.FieldID() == f.FieldID()
}
return g.FieldID() == f.FieldID() && *g.itemGroup == *f.itemGroup
return g.FieldID() == f.FieldID() && *g.group == *f.group
})

if !found {
Expand Down
2 changes: 1 addition & 1 deletion server/schemas/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ components:
value: {}
key:
type: string
itemGroup:
group:
x-go-type: id.ItemGroupID
type: string
refOrVersion:
Expand Down

0 comments on commit 40359f5

Please sign in to comment.