mirror of
https://github.com/hay-kot/homebox.git
synced 2025-06-03 02:52:28 +00:00
feat: maintenance log (#170)
* remove repo for document tokens * remove schema for doc tokens * fix id template and generate cmd * schema updates * code gen * bump dependencies * fix broken migrations + add maintenance entry type * spelling * remove debug logger * implement repository layer * routes * API client * wip: maintenance log * remove depreciated call
This commit is contained in:
parent
d6da63187b
commit
5bbb969763
79 changed files with 6320 additions and 4957 deletions
|
@ -15,13 +15,13 @@ import (
|
|||
"github.com/hay-kot/homebox/backend/internal/data/ent/authroles"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/document"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/documenttoken"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/item"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
|
@ -42,8 +42,6 @@ type Client struct {
|
|||
AuthTokens *AuthTokensClient
|
||||
// Document is the client for interacting with the Document builders.
|
||||
Document *DocumentClient
|
||||
// DocumentToken is the client for interacting with the DocumentToken builders.
|
||||
DocumentToken *DocumentTokenClient
|
||||
// Group is the client for interacting with the Group builders.
|
||||
Group *GroupClient
|
||||
// GroupInvitationToken is the client for interacting with the GroupInvitationToken builders.
|
||||
|
@ -56,6 +54,8 @@ type Client struct {
|
|||
Label *LabelClient
|
||||
// Location is the client for interacting with the Location builders.
|
||||
Location *LocationClient
|
||||
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
||||
MaintenanceEntry *MaintenanceEntryClient
|
||||
// User is the client for interacting with the User builders.
|
||||
User *UserClient
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ func (c *Client) init() {
|
|||
c.AuthRoles = NewAuthRolesClient(c.config)
|
||||
c.AuthTokens = NewAuthTokensClient(c.config)
|
||||
c.Document = NewDocumentClient(c.config)
|
||||
c.DocumentToken = NewDocumentTokenClient(c.config)
|
||||
c.Group = NewGroupClient(c.config)
|
||||
c.GroupInvitationToken = NewGroupInvitationTokenClient(c.config)
|
||||
c.Item = NewItemClient(c.config)
|
||||
c.ItemField = NewItemFieldClient(c.config)
|
||||
c.Label = NewLabelClient(c.config)
|
||||
c.Location = NewLocationClient(c.config)
|
||||
c.MaintenanceEntry = NewMaintenanceEntryClient(c.config)
|
||||
c.User = NewUserClient(c.config)
|
||||
}
|
||||
|
||||
|
@ -120,13 +120,13 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
|||
AuthRoles: NewAuthRolesClient(cfg),
|
||||
AuthTokens: NewAuthTokensClient(cfg),
|
||||
Document: NewDocumentClient(cfg),
|
||||
DocumentToken: NewDocumentTokenClient(cfg),
|
||||
Group: NewGroupClient(cfg),
|
||||
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
||||
Item: NewItemClient(cfg),
|
||||
ItemField: NewItemFieldClient(cfg),
|
||||
Label: NewLabelClient(cfg),
|
||||
Location: NewLocationClient(cfg),
|
||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
@ -151,13 +151,13 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
|||
AuthRoles: NewAuthRolesClient(cfg),
|
||||
AuthTokens: NewAuthTokensClient(cfg),
|
||||
Document: NewDocumentClient(cfg),
|
||||
DocumentToken: NewDocumentTokenClient(cfg),
|
||||
Group: NewGroupClient(cfg),
|
||||
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
||||
Item: NewItemClient(cfg),
|
||||
ItemField: NewItemFieldClient(cfg),
|
||||
Label: NewLabelClient(cfg),
|
||||
Location: NewLocationClient(cfg),
|
||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
@ -191,13 +191,13 @@ func (c *Client) Use(hooks ...Hook) {
|
|||
c.AuthRoles.Use(hooks...)
|
||||
c.AuthTokens.Use(hooks...)
|
||||
c.Document.Use(hooks...)
|
||||
c.DocumentToken.Use(hooks...)
|
||||
c.Group.Use(hooks...)
|
||||
c.GroupInvitationToken.Use(hooks...)
|
||||
c.Item.Use(hooks...)
|
||||
c.ItemField.Use(hooks...)
|
||||
c.Label.Use(hooks...)
|
||||
c.Location.Use(hooks...)
|
||||
c.MaintenanceEntry.Use(hooks...)
|
||||
c.User.Use(hooks...)
|
||||
}
|
||||
|
||||
|
@ -652,22 +652,6 @@ func (c *DocumentClient) QueryGroup(d *Document) *GroupQuery {
|
|||
return query
|
||||
}
|
||||
|
||||
// QueryDocumentTokens queries the document_tokens edge of a Document.
|
||||
func (c *DocumentClient) QueryDocumentTokens(d *Document) *DocumentTokenQuery {
|
||||
query := &DocumentTokenQuery{config: c.config}
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := d.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(document.Table, document.FieldID, id),
|
||||
sqlgraph.To(documenttoken.Table, documenttoken.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, document.DocumentTokensTable, document.DocumentTokensColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(d.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryAttachments queries the attachments edge of a Document.
|
||||
func (c *DocumentClient) QueryAttachments(d *Document) *AttachmentQuery {
|
||||
query := &AttachmentQuery{config: c.config}
|
||||
|
@ -689,112 +673,6 @@ func (c *DocumentClient) Hooks() []Hook {
|
|||
return c.hooks.Document
|
||||
}
|
||||
|
||||
// DocumentTokenClient is a client for the DocumentToken schema.
|
||||
type DocumentTokenClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewDocumentTokenClient returns a client for the DocumentToken from the given config.
|
||||
func NewDocumentTokenClient(c config) *DocumentTokenClient {
|
||||
return &DocumentTokenClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `documenttoken.Hooks(f(g(h())))`.
|
||||
func (c *DocumentTokenClient) Use(hooks ...Hook) {
|
||||
c.hooks.DocumentToken = append(c.hooks.DocumentToken, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a DocumentToken entity.
|
||||
func (c *DocumentTokenClient) Create() *DocumentTokenCreate {
|
||||
mutation := newDocumentTokenMutation(c.config, OpCreate)
|
||||
return &DocumentTokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of DocumentToken entities.
|
||||
func (c *DocumentTokenClient) CreateBulk(builders ...*DocumentTokenCreate) *DocumentTokenCreateBulk {
|
||||
return &DocumentTokenCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for DocumentToken.
|
||||
func (c *DocumentTokenClient) Update() *DocumentTokenUpdate {
|
||||
mutation := newDocumentTokenMutation(c.config, OpUpdate)
|
||||
return &DocumentTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *DocumentTokenClient) UpdateOne(dt *DocumentToken) *DocumentTokenUpdateOne {
|
||||
mutation := newDocumentTokenMutation(c.config, OpUpdateOne, withDocumentToken(dt))
|
||||
return &DocumentTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *DocumentTokenClient) UpdateOneID(id uuid.UUID) *DocumentTokenUpdateOne {
|
||||
mutation := newDocumentTokenMutation(c.config, OpUpdateOne, withDocumentTokenID(id))
|
||||
return &DocumentTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for DocumentToken.
|
||||
func (c *DocumentTokenClient) Delete() *DocumentTokenDelete {
|
||||
mutation := newDocumentTokenMutation(c.config, OpDelete)
|
||||
return &DocumentTokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *DocumentTokenClient) DeleteOne(dt *DocumentToken) *DocumentTokenDeleteOne {
|
||||
return c.DeleteOneID(dt.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *DocumentTokenClient) DeleteOneID(id uuid.UUID) *DocumentTokenDeleteOne {
|
||||
builder := c.Delete().Where(documenttoken.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &DocumentTokenDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for DocumentToken.
|
||||
func (c *DocumentTokenClient) Query() *DocumentTokenQuery {
|
||||
return &DocumentTokenQuery{
|
||||
config: c.config,
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a DocumentToken entity by its id.
|
||||
func (c *DocumentTokenClient) Get(ctx context.Context, id uuid.UUID) (*DocumentToken, error) {
|
||||
return c.Query().Where(documenttoken.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *DocumentTokenClient) GetX(ctx context.Context, id uuid.UUID) *DocumentToken {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryDocument queries the document edge of a DocumentToken.
|
||||
func (c *DocumentTokenClient) QueryDocument(dt *DocumentToken) *DocumentQuery {
|
||||
query := &DocumentQuery{config: c.config}
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := dt.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(documenttoken.Table, documenttoken.FieldID, id),
|
||||
sqlgraph.To(document.Table, document.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, documenttoken.DocumentTable, documenttoken.DocumentColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(dt.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *DocumentTokenClient) Hooks() []Hook {
|
||||
return c.hooks.DocumentToken
|
||||
}
|
||||
|
||||
// GroupClient is a client for the Group schema.
|
||||
type GroupClient struct {
|
||||
config
|
||||
|
@ -1268,6 +1146,22 @@ func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery {
|
|||
return query
|
||||
}
|
||||
|
||||
// QueryMaintenanceEntries queries the maintenance_entries edge of a Item.
|
||||
func (c *ItemClient) QueryMaintenanceEntries(i *Item) *MaintenanceEntryQuery {
|
||||
query := &MaintenanceEntryQuery{config: c.config}
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
sqlgraph.To(maintenanceentry.Table, maintenanceentry.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, item.MaintenanceEntriesTable, item.MaintenanceEntriesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(i.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryAttachments queries the attachments edge of a Item.
|
||||
func (c *ItemClient) QueryAttachments(i *Item) *AttachmentQuery {
|
||||
query := &AttachmentQuery{config: c.config}
|
||||
|
@ -1671,6 +1565,112 @@ func (c *LocationClient) Hooks() []Hook {
|
|||
return c.hooks.Location
|
||||
}
|
||||
|
||||
// MaintenanceEntryClient is a client for the MaintenanceEntry schema.
|
||||
type MaintenanceEntryClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewMaintenanceEntryClient returns a client for the MaintenanceEntry from the given config.
|
||||
func NewMaintenanceEntryClient(c config) *MaintenanceEntryClient {
|
||||
return &MaintenanceEntryClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `maintenanceentry.Hooks(f(g(h())))`.
|
||||
func (c *MaintenanceEntryClient) Use(hooks ...Hook) {
|
||||
c.hooks.MaintenanceEntry = append(c.hooks.MaintenanceEntry, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a MaintenanceEntry entity.
|
||||
func (c *MaintenanceEntryClient) Create() *MaintenanceEntryCreate {
|
||||
mutation := newMaintenanceEntryMutation(c.config, OpCreate)
|
||||
return &MaintenanceEntryCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of MaintenanceEntry entities.
|
||||
func (c *MaintenanceEntryClient) CreateBulk(builders ...*MaintenanceEntryCreate) *MaintenanceEntryCreateBulk {
|
||||
return &MaintenanceEntryCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for MaintenanceEntry.
|
||||
func (c *MaintenanceEntryClient) Update() *MaintenanceEntryUpdate {
|
||||
mutation := newMaintenanceEntryMutation(c.config, OpUpdate)
|
||||
return &MaintenanceEntryUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MaintenanceEntryClient) UpdateOne(me *MaintenanceEntry) *MaintenanceEntryUpdateOne {
|
||||
mutation := newMaintenanceEntryMutation(c.config, OpUpdateOne, withMaintenanceEntry(me))
|
||||
return &MaintenanceEntryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *MaintenanceEntryClient) UpdateOneID(id uuid.UUID) *MaintenanceEntryUpdateOne {
|
||||
mutation := newMaintenanceEntryMutation(c.config, OpUpdateOne, withMaintenanceEntryID(id))
|
||||
return &MaintenanceEntryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for MaintenanceEntry.
|
||||
func (c *MaintenanceEntryClient) Delete() *MaintenanceEntryDelete {
|
||||
mutation := newMaintenanceEntryMutation(c.config, OpDelete)
|
||||
return &MaintenanceEntryDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MaintenanceEntryClient) DeleteOne(me *MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
||||
return c.DeleteOneID(me.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *MaintenanceEntryClient) DeleteOneID(id uuid.UUID) *MaintenanceEntryDeleteOne {
|
||||
builder := c.Delete().Where(maintenanceentry.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &MaintenanceEntryDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for MaintenanceEntry.
|
||||
func (c *MaintenanceEntryClient) Query() *MaintenanceEntryQuery {
|
||||
return &MaintenanceEntryQuery{
|
||||
config: c.config,
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a MaintenanceEntry entity by its id.
|
||||
func (c *MaintenanceEntryClient) Get(ctx context.Context, id uuid.UUID) (*MaintenanceEntry, error) {
|
||||
return c.Query().Where(maintenanceentry.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *MaintenanceEntryClient) GetX(ctx context.Context, id uuid.UUID) *MaintenanceEntry {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryItem queries the item edge of a MaintenanceEntry.
|
||||
func (c *MaintenanceEntryClient) QueryItem(me *MaintenanceEntry) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := me.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, id),
|
||||
sqlgraph.To(item.Table, item.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(me.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *MaintenanceEntryClient) Hooks() []Hook {
|
||||
return c.hooks.MaintenanceEntry
|
||||
}
|
||||
|
||||
// UserClient is a client for the User schema.
|
||||
type UserClient struct {
|
||||
config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue