forked from mirrors/homebox
feat: Notifiers CRUD (#337)
* introduce scaffold for new models * wip: shoutrrr wrapper (may remove) * update schema files * gen: ent code * gen: migrations * go mod tidy * add group_id to notifier * db migration * new mapper helpers * notifier repo * introduce experimental adapter pattern for hdlrs * refactor adapters to fit more common use cases * new routes for notifiers * update errors to fix validation panic * go tidy * reverse checkbox label display * wip: notifiers UI * use badges instead of text * improve documentation * add scaffold schema reference * remove notifier service * refactor schema folder * support group edges via scaffold * delete test file * include link to API docs * audit and update documentation + improve format * refactor schema edges * refactor * add custom validator * set validate + order fields by name * fix failing tests
This commit is contained in:
parent
2665b666f1
commit
23b5892aef
100 changed files with 11437 additions and 2075 deletions
|
@ -433,6 +433,17 @@ func (iu *ItemUpdate) ClearSoldNotes() *ItemUpdate {
|
|||
return iu
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (iu *ItemUpdate) SetGroupID(id uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.SetGroupID(id)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (iu *ItemUpdate) SetGroup(g *Group) *ItemUpdate {
|
||||
return iu.SetGroupID(g.ID)
|
||||
}
|
||||
|
||||
// SetParentID sets the "parent" edge to the Item entity by ID.
|
||||
func (iu *ItemUpdate) SetParentID(id uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.SetParentID(id)
|
||||
|
@ -467,17 +478,6 @@ func (iu *ItemUpdate) AddChildren(i ...*Item) *ItemUpdate {
|
|||
return iu.AddChildIDs(ids...)
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (iu *ItemUpdate) SetGroupID(id uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.SetGroupID(id)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (iu *ItemUpdate) SetGroup(g *Group) *ItemUpdate {
|
||||
return iu.SetGroupID(g.ID)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (iu *ItemUpdate) AddLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.AddLabelIDs(ids...)
|
||||
|
@ -562,6 +562,12 @@ func (iu *ItemUpdate) Mutation() *ItemMutation {
|
|||
return iu.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (iu *ItemUpdate) ClearGroup() *ItemUpdate {
|
||||
iu.mutation.ClearGroup()
|
||||
return iu
|
||||
}
|
||||
|
||||
// ClearParent clears the "parent" edge to the Item entity.
|
||||
func (iu *ItemUpdate) ClearParent() *ItemUpdate {
|
||||
iu.mutation.ClearParent()
|
||||
|
@ -589,12 +595,6 @@ func (iu *ItemUpdate) RemoveChildren(i ...*Item) *ItemUpdate {
|
|||
return iu.RemoveChildIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (iu *ItemUpdate) ClearGroup() *ItemUpdate {
|
||||
iu.mutation.ClearGroup()
|
||||
return iu
|
||||
}
|
||||
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (iu *ItemUpdate) ClearLabel() *ItemUpdate {
|
||||
iu.mutation.ClearLabel()
|
||||
|
@ -903,6 +903,41 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
if iu.mutation.SoldNotesCleared() {
|
||||
_spec.ClearField(item.FieldSoldNotes, field.TypeString)
|
||||
}
|
||||
if iu.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iu.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iu.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@ -992,41 +1027,6 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iu.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iu.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iu.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
|
@ -1696,6 +1696,17 @@ func (iuo *ItemUpdateOne) ClearSoldNotes() *ItemUpdateOne {
|
|||
return iuo
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (iuo *ItemUpdateOne) SetGroupID(id uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.SetGroupID(id)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (iuo *ItemUpdateOne) SetGroup(g *Group) *ItemUpdateOne {
|
||||
return iuo.SetGroupID(g.ID)
|
||||
}
|
||||
|
||||
// SetParentID sets the "parent" edge to the Item entity by ID.
|
||||
func (iuo *ItemUpdateOne) SetParentID(id uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.SetParentID(id)
|
||||
|
@ -1730,17 +1741,6 @@ func (iuo *ItemUpdateOne) AddChildren(i ...*Item) *ItemUpdateOne {
|
|||
return iuo.AddChildIDs(ids...)
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (iuo *ItemUpdateOne) SetGroupID(id uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.SetGroupID(id)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (iuo *ItemUpdateOne) SetGroup(g *Group) *ItemUpdateOne {
|
||||
return iuo.SetGroupID(g.ID)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (iuo *ItemUpdateOne) AddLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.AddLabelIDs(ids...)
|
||||
|
@ -1825,6 +1825,12 @@ func (iuo *ItemUpdateOne) Mutation() *ItemMutation {
|
|||
return iuo.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (iuo *ItemUpdateOne) ClearGroup() *ItemUpdateOne {
|
||||
iuo.mutation.ClearGroup()
|
||||
return iuo
|
||||
}
|
||||
|
||||
// ClearParent clears the "parent" edge to the Item entity.
|
||||
func (iuo *ItemUpdateOne) ClearParent() *ItemUpdateOne {
|
||||
iuo.mutation.ClearParent()
|
||||
|
@ -1852,12 +1858,6 @@ func (iuo *ItemUpdateOne) RemoveChildren(i ...*Item) *ItemUpdateOne {
|
|||
return iuo.RemoveChildIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (iuo *ItemUpdateOne) ClearGroup() *ItemUpdateOne {
|
||||
iuo.mutation.ClearGroup()
|
||||
return iuo
|
||||
}
|
||||
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (iuo *ItemUpdateOne) ClearLabel() *ItemUpdateOne {
|
||||
iuo.mutation.ClearLabel()
|
||||
|
@ -2196,6 +2196,41 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
|
|||
if iuo.mutation.SoldNotesCleared() {
|
||||
_spec.ClearField(item.FieldSoldNotes, field.TypeString)
|
||||
}
|
||||
if iuo.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iuo.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iuo.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@ -2285,41 +2320,6 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
|
|||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iuo.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iuo.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: item.GroupTable,
|
||||
Columns: []string{item.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: group.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iuo.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue