mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-26 23:21:39 +01:00
* feat: Add item templates feature (#435) Add ability to create and manage item templates for quick item creation. Templates store default values and custom fields that can be applied when creating new items. Backend changes: - New ItemTemplate and TemplateField Ent schemas - Template CRUD API endpoints - Create item from template endpoint Frontend changes: - Templates management page with create/edit/delete - Template selector in item creation modal - 'Use as Template' action on item detail page - Templates link in navigation menu * refactor: Improve template item creation with a single query - Add `CreateFromTemplate` method to ItemsRepository that creates items with all template data (including custom fields) in a single atomic transaction, replacing the previous two-phase create-then-update pattern - Fix `GetOne` to require group ID parameter so templates can only be accessed by users in the owning group (security fix) - Simplify `HandleItemTemplatesCreateItem` handler using the new transactional method * Refactor item template types and formatting Updated type annotations in CreateModal.vue to use specific ItemTemplate types instead of 'any'. Improved code formatting for template fields and manufacturer display. Also refactored warranty field logic in item details page for better readability. This resolves the linter issues as well that the bot in github keeps nagging at. * Add 'id' property to template fields Introduces an 'id' property to each field object in CreateModal.vue and item details page to support unique identification of fields. This change prepares the codebase for future enhancements that may require field-level identification. * Removed redundant SQL migrations. Removed redundant SQL migrations per @tankerkiller125's findings. * Updates to PR #1099. Regarding pull #1099. Fixed an issue causing some conflict with GUIDs and old rows in the migration files. * Add new fields and location edge to ItemTemplate Addresses recommendations from @tonyaellie. * Relocated add template button * Added more default fields to the template * Added translation of all strings (think so?) * Make oval buttons round * Added duplicate button to the template (this required a rewrite of the migration files, I made sure only 1 exists per DB type) * Added a Save as template button to a item detail view (this creates a template with all the current data of that item) * Changed all occurrences of space to gap and flex where applicable. * Made template selection persistent after item created. * Collapsible template info on creation view. * Updates to translation and fix for labels/locations I also added a test in here because I keep missing small function tests. That should prevent that from happening again. * Linted * Bring up to date with main, fix some lint/type check issues * In theory fix playwright tests * Fix defaults being unable to be nullable/empty (and thus limiting flexibility) * Last few fixes I think * Forgot to fix the golang tests --------- Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
This commit is contained in:
164
backend/app/api/handlers/v1/v1_ctrl_item_templates.go
Normal file
164
backend/app/api/handlers/v1/v1_ctrl_item_templates.go
Normal file
@@ -0,0 +1,164 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hay-kot/httpkit/errchain"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/core/services"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/web/adapters"
|
||||
)
|
||||
|
||||
// HandleItemTemplatesGetAll godoc
|
||||
//
|
||||
// @Summary Get All Item Templates
|
||||
// @Tags Item Templates
|
||||
// @Produce json
|
||||
// @Success 200 {object} []repo.ItemTemplateSummary
|
||||
// @Router /v1/templates [GET]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleItemTemplatesGetAll() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request) ([]repo.ItemTemplateSummary, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.ItemTemplates.GetAll(r.Context(), auth.GID)
|
||||
}
|
||||
|
||||
return adapters.Command(fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleItemTemplatesGet godoc
|
||||
//
|
||||
// @Summary Get Item Template
|
||||
// @Tags Item Templates
|
||||
// @Produce json
|
||||
// @Param id path string true "Template ID"
|
||||
// @Success 200 {object} repo.ItemTemplateOut
|
||||
// @Router /v1/templates/{id} [GET]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleItemTemplatesGet() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID) (repo.ItemTemplateOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.ItemTemplates.GetOne(r.Context(), auth.GID, ID)
|
||||
}
|
||||
|
||||
return adapters.CommandID("id", fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleItemTemplatesCreate godoc
|
||||
//
|
||||
// @Summary Create Item Template
|
||||
// @Tags Item Templates
|
||||
// @Produce json
|
||||
// @Param payload body repo.ItemTemplateCreate true "Template Data"
|
||||
// @Success 201 {object} repo.ItemTemplateOut
|
||||
// @Router /v1/templates [POST]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleItemTemplatesCreate() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, body repo.ItemTemplateCreate) (repo.ItemTemplateOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.ItemTemplates.Create(r.Context(), auth.GID, body)
|
||||
}
|
||||
|
||||
return adapters.Action(fn, http.StatusCreated)
|
||||
}
|
||||
|
||||
// HandleItemTemplatesUpdate godoc
|
||||
//
|
||||
// @Summary Update Item Template
|
||||
// @Tags Item Templates
|
||||
// @Produce json
|
||||
// @Param id path string true "Template ID"
|
||||
// @Param payload body repo.ItemTemplateUpdate true "Template Data"
|
||||
// @Success 200 {object} repo.ItemTemplateOut
|
||||
// @Router /v1/templates/{id} [PUT]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleItemTemplatesUpdate() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID, body repo.ItemTemplateUpdate) (repo.ItemTemplateOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
body.ID = ID
|
||||
return ctrl.repo.ItemTemplates.Update(r.Context(), auth.GID, body)
|
||||
}
|
||||
|
||||
return adapters.ActionID("id", fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleItemTemplatesDelete godoc
|
||||
//
|
||||
// @Summary Delete Item Template
|
||||
// @Tags Item Templates
|
||||
// @Produce json
|
||||
// @Param id path string true "Template ID"
|
||||
// @Success 204
|
||||
// @Router /v1/templates/{id} [DELETE]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleItemTemplatesDelete() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID) (any, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
err := ctrl.repo.ItemTemplates.Delete(r.Context(), auth.GID, ID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return adapters.CommandID("id", fn, http.StatusNoContent)
|
||||
}
|
||||
|
||||
type ItemTemplateCreateItemRequest struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
Description string `json:"description" validate:"max=1000"`
|
||||
LocationID uuid.UUID `json:"locationId" validate:"required"`
|
||||
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||
Quantity *int `json:"quantity"`
|
||||
}
|
||||
|
||||
// HandleItemTemplatesCreateItem godoc
|
||||
//
|
||||
// @Summary Create Item from Template
|
||||
// @Tags Item Templates
|
||||
// @Produce json
|
||||
// @Param id path string true "Template ID"
|
||||
// @Param payload body ItemTemplateCreateItemRequest true "Item Data"
|
||||
// @Success 201 {object} repo.ItemOut
|
||||
// @Router /v1/templates/{id}/create-item [POST]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleItemTemplatesCreateItem() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, templateID uuid.UUID, body ItemTemplateCreateItemRequest) (repo.ItemOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
|
||||
template, err := ctrl.repo.ItemTemplates.GetOne(r.Context(), auth.GID, templateID)
|
||||
if err != nil {
|
||||
return repo.ItemOut{}, err
|
||||
}
|
||||
|
||||
quantity := template.DefaultQuantity
|
||||
if body.Quantity != nil {
|
||||
quantity = *body.Quantity
|
||||
}
|
||||
|
||||
// Build custom fields from template
|
||||
fields := make([]repo.ItemField, len(template.Fields))
|
||||
for i, f := range template.Fields {
|
||||
fields[i] = repo.ItemField{
|
||||
Type: f.Type,
|
||||
Name: f.Name,
|
||||
TextValue: f.TextValue,
|
||||
}
|
||||
}
|
||||
|
||||
// Create item with all template data in a single transaction
|
||||
return ctrl.repo.Items.CreateFromTemplate(r.Context(), auth.GID, repo.ItemCreateFromTemplate{
|
||||
Name: body.Name,
|
||||
Description: body.Description,
|
||||
Quantity: quantity,
|
||||
LocationID: body.LocationID,
|
||||
LabelIDs: body.LabelIDs,
|
||||
Insured: template.DefaultInsured,
|
||||
Manufacturer: template.DefaultManufacturer,
|
||||
ModelNumber: template.DefaultModelNumber,
|
||||
LifetimeWarranty: template.DefaultLifetimeWarranty,
|
||||
WarrantyDetails: template.DefaultWarrantyDetails,
|
||||
Fields: fields,
|
||||
})
|
||||
}
|
||||
|
||||
return adapters.ActionID("id", fn, http.StatusCreated)
|
||||
}
|
||||
@@ -145,6 +145,14 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
|
||||
|
||||
r.Get("/assets/{id}", chain.ToHandlerFunc(v1Ctrl.HandleAssetGet(), userMW...))
|
||||
|
||||
// Item Templates
|
||||
r.Get("/templates", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesGetAll(), userMW...))
|
||||
r.Post("/templates", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesCreate(), userMW...))
|
||||
r.Get("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesGet(), userMW...))
|
||||
r.Put("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesUpdate(), userMW...))
|
||||
r.Delete("/templates/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesDelete(), userMW...))
|
||||
r.Post("/templates/{id}/create-item", chain.ToHandlerFunc(v1Ctrl.HandleItemTemplatesCreateItem(), userMW...))
|
||||
|
||||
// Maintenance
|
||||
r.Get("/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceGetAll(), userMW...))
|
||||
r.Put("/maintenance/{id}", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceEntryUpdate(), userMW...))
|
||||
|
||||
@@ -1963,6 +1963,209 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Get All Item Templates",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateSummary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Create Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Template Data",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Get Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Update Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Template Data",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Delete Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates/{id}/create-item": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Create Item from Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Item Data",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ItemTemplateCreateItemRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/change-password": {
|
||||
"put": {
|
||||
"security": [
|
||||
@@ -2032,6 +2235,51 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/login/oidc": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Authentication"
|
||||
],
|
||||
"summary": "OIDC Login Initiation",
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/login/oidc/callback": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Authentication"
|
||||
],
|
||||
"summary": "OIDC Callback Handler",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization code",
|
||||
"name": "code",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "State parameter",
|
||||
"name": "state",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/logout": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -2092,6 +2340,12 @@ const docTemplate = `{
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"403": {
|
||||
"description": "Local login is not enabled",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2462,6 +2716,13 @@ const docTemplate = `{
|
||||
"$ref": "#/definitions/ent.GroupInvitationToken"
|
||||
}
|
||||
},
|
||||
"item_templates": {
|
||||
"description": "ItemTemplates holds the value of the item_templates edge.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ent.ItemTemplate"
|
||||
}
|
||||
},
|
||||
"items": {
|
||||
"description": "Items holds the value of the items edge.",
|
||||
"type": "array",
|
||||
@@ -2799,6 +3060,122 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.ItemTemplate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "CreatedAt holds the value of the \"created_at\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"default_description": {
|
||||
"description": "Default description for items created from this template",
|
||||
"type": "string"
|
||||
},
|
||||
"default_insured": {
|
||||
"description": "DefaultInsured holds the value of the \"default_insured\" field.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_label_ids": {
|
||||
"description": "Default label IDs for items created from this template",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default_lifetime_warranty": {
|
||||
"description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_manufacturer": {
|
||||
"description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"default_model_number": {
|
||||
"description": "Default model number for items created from this template",
|
||||
"type": "string"
|
||||
},
|
||||
"default_name": {
|
||||
"description": "Default name template for items (can use placeholders)",
|
||||
"type": "string"
|
||||
},
|
||||
"default_quantity": {
|
||||
"description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
|
||||
"type": "integer"
|
||||
},
|
||||
"default_warranty_details": {
|
||||
"description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description holds the value of the \"description\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"edges": {
|
||||
"description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.ItemTemplateEdges"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"description": "ID of the ent.",
|
||||
"type": "string"
|
||||
},
|
||||
"include_purchase_fields": {
|
||||
"description": "Whether to include purchase fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"include_sold_fields": {
|
||||
"description": "Whether to include sold fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"include_warranty_fields": {
|
||||
"description": "Whether to include warranty fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"description": "Notes holds the value of the \"notes\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.ItemTemplateEdges": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fields": {
|
||||
"description": "Fields holds the value of the fields edge.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ent.TemplateField"
|
||||
}
|
||||
},
|
||||
"group": {
|
||||
"description": "Group holds the value of the group edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.Group"
|
||||
}
|
||||
]
|
||||
},
|
||||
"location": {
|
||||
"description": "Location holds the value of the location edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.Location"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.Label": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3048,6 +3425,64 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.TemplateField": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "CreatedAt holds the value of the \"created_at\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description holds the value of the \"description\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"edges": {
|
||||
"description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.TemplateFieldEdges"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"description": "ID of the ent.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"text_value": {
|
||||
"description": "TextValue holds the value of the \"text_value\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"description": "Type holds the value of the \"type\" field.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/templatefield.Type"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.TemplateFieldEdges": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"item_template": {
|
||||
"description": "ItemTemplate holds the value of the item_template edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.ItemTemplate"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3083,6 +3518,14 @@ const docTemplate = `{
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"oidc_issuer": {
|
||||
"description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"oidc_subject": {
|
||||
"description": "OidcSubject holds the value of the \"oidc_subject\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
"description": "Role holds the value of the \"role\" field.",
|
||||
"allOf": [
|
||||
@@ -3583,6 +4026,280 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"defaultDescription": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocationId": {
|
||||
"description": "Default location and labels",
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateOut": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultDescription": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabels": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateLabelSummary"
|
||||
}
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocation": {
|
||||
"description": "Default location and labels",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/repo.TemplateLocationSummary"
|
||||
}
|
||||
]
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer"
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"defaultDescription": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocationId": {
|
||||
"description": "Default location and labels",
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemType": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -4078,6 +4795,45 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateField": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"textValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateLabelSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateLocationSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TotalsByOrganizer": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4135,6 +4891,12 @@ const docTemplate = `{
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidcIssuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidcSubject": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -4214,6 +4976,15 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"templatefield.Type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"text"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"TypeText"
|
||||
]
|
||||
},
|
||||
"user.Role": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -4251,6 +5022,9 @@ const docTemplate = `{
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidc": {
|
||||
"$ref": "#/definitions/v1.OIDCStatus"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -4333,6 +5107,36 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ItemTemplateCreateItemRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"locationId",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"labelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"locationId": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.LoginForm": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4349,6 +5153,23 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.OIDCStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allowLocal": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"autoRedirect": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"buttonText": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.TokenResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -2122,6 +2122,223 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Get All Item Templates",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/repo.ItemTemplateSummary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Create Item Template",
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/repo.ItemTemplateCreate"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Template Data",
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Get Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Update Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/repo.ItemTemplateUpdate"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Template Data",
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Delete Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates/{id}/create-item": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Create Item from Template",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/v1.ItemTemplateCreateItemRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Item Data",
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/repo.ItemOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/change-password": {
|
||||
"put": {
|
||||
"security": [
|
||||
@@ -2197,6 +2414,52 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/login/oidc": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Authentication"
|
||||
],
|
||||
"summary": "OIDC Login Initiation",
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/login/oidc/callback": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Authentication"
|
||||
],
|
||||
"summary": "OIDC Callback Handler",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Authorization code",
|
||||
"name": "code",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "State parameter",
|
||||
"name": "state",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/logout": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -2254,6 +2517,16 @@
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"403": {
|
||||
"description": "Local login is not enabled",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2640,6 +2913,13 @@
|
||||
"$ref": "#/components/schemas/ent.GroupInvitationToken"
|
||||
}
|
||||
},
|
||||
"item_templates": {
|
||||
"description": "ItemTemplates holds the value of the item_templates edge.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ent.ItemTemplate"
|
||||
}
|
||||
},
|
||||
"items": {
|
||||
"description": "Items holds the value of the items edge.",
|
||||
"type": "array",
|
||||
@@ -2977,6 +3257,122 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.ItemTemplate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "CreatedAt holds the value of the \"created_at\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"default_description": {
|
||||
"description": "Default description for items created from this template",
|
||||
"type": "string"
|
||||
},
|
||||
"default_insured": {
|
||||
"description": "DefaultInsured holds the value of the \"default_insured\" field.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_label_ids": {
|
||||
"description": "Default label IDs for items created from this template",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default_lifetime_warranty": {
|
||||
"description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_manufacturer": {
|
||||
"description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"default_model_number": {
|
||||
"description": "Default model number for items created from this template",
|
||||
"type": "string"
|
||||
},
|
||||
"default_name": {
|
||||
"description": "Default name template for items (can use placeholders)",
|
||||
"type": "string"
|
||||
},
|
||||
"default_quantity": {
|
||||
"description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
|
||||
"type": "integer"
|
||||
},
|
||||
"default_warranty_details": {
|
||||
"description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description holds the value of the \"description\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"edges": {
|
||||
"description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ent.ItemTemplateEdges"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"description": "ID of the ent.",
|
||||
"type": "string"
|
||||
},
|
||||
"include_purchase_fields": {
|
||||
"description": "Whether to include purchase fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"include_sold_fields": {
|
||||
"description": "Whether to include sold fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"include_warranty_fields": {
|
||||
"description": "Whether to include warranty fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"description": "Notes holds the value of the \"notes\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.ItemTemplateEdges": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fields": {
|
||||
"description": "Fields holds the value of the fields edge.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ent.TemplateField"
|
||||
}
|
||||
},
|
||||
"group": {
|
||||
"description": "Group holds the value of the group edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ent.Group"
|
||||
}
|
||||
]
|
||||
},
|
||||
"location": {
|
||||
"description": "Location holds the value of the location edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ent.Location"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.Label": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3226,6 +3622,64 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.TemplateField": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "CreatedAt holds the value of the \"created_at\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description holds the value of the \"description\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"edges": {
|
||||
"description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ent.TemplateFieldEdges"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"description": "ID of the ent.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"text_value": {
|
||||
"description": "TextValue holds the value of the \"text_value\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"description": "Type holds the value of the \"type\" field.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/templatefield.Type"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.TemplateFieldEdges": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"item_template": {
|
||||
"description": "ItemTemplate holds the value of the item_template edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ent.ItemTemplate"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3261,6 +3715,14 @@
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"oidc_issuer": {
|
||||
"description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"oidc_subject": {
|
||||
"description": "OidcSubject holds the value of the \"oidc_subject\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
"description": "Role holds the value of the \"role\" field.",
|
||||
"allOf": [
|
||||
@@ -3761,6 +4223,280 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"defaultDescription": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"nullable": true
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocationId": {
|
||||
"description": "Default location and labels",
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer",
|
||||
"nullable": true
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateOut": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultDescription": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabels": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/repo.TemplateLabelSummary"
|
||||
}
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocation": {
|
||||
"description": "Default location and labels",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/repo.TemplateLocationSummary"
|
||||
}
|
||||
]
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer"
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"defaultDescription": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"nullable": true
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocationId": {
|
||||
"description": "Default location and labels",
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"nullable": true
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer",
|
||||
"nullable": true
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemType": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -4256,6 +4992,45 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateField": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"textValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateLabelSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateLocationSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TotalsByOrganizer": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4313,6 +5088,12 @@
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidcIssuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidcSubject": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -4392,6 +5173,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"templatefield.Type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"text"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"TypeText"
|
||||
]
|
||||
},
|
||||
"user.Role": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -4429,6 +5219,9 @@
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidc": {
|
||||
"$ref": "#/components/schemas/v1.OIDCStatus"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -4511,6 +5304,36 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ItemTemplateCreateItemRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"locationId",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"labelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"locationId": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.LoginForm": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4527,6 +5350,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.OIDCStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allowLocal": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"autoRedirect": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"buttonText": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.TokenResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1257,6 +1257,134 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/v1.APISummary"
|
||||
/v1/templates:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Item Templates
|
||||
summary: Get All Item Templates
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.ItemTemplateSummary"
|
||||
post:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Item Templates
|
||||
summary: Create Item Template
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ItemTemplateCreate"
|
||||
description: Template Data
|
||||
required: true
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ItemTemplateOut"
|
||||
"/v1/templates/{id}":
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Item Templates
|
||||
summary: Get Item Template
|
||||
parameters:
|
||||
- description: Template ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ItemTemplateOut"
|
||||
put:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Item Templates
|
||||
summary: Update Item Template
|
||||
parameters:
|
||||
- description: Template ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ItemTemplateUpdate"
|
||||
description: Template Data
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ItemTemplateOut"
|
||||
delete:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Item Templates
|
||||
summary: Delete Item Template
|
||||
parameters:
|
||||
- description: Template ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"/v1/templates/{id}/create-item":
|
||||
post:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Item Templates
|
||||
summary: Create Item from Template
|
||||
parameters:
|
||||
- description: Template ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/v1.ItemTemplateCreateItemRequest"
|
||||
description: Item Data
|
||||
required: true
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ItemOut"
|
||||
/v1/users/change-password:
|
||||
put:
|
||||
security:
|
||||
@@ -1302,6 +1430,35 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/v1.TokenResponse"
|
||||
/v1/users/login/oidc:
|
||||
get:
|
||||
tags:
|
||||
- Authentication
|
||||
summary: OIDC Login Initiation
|
||||
responses:
|
||||
"302":
|
||||
description: Found
|
||||
/v1/users/login/oidc/callback:
|
||||
get:
|
||||
tags:
|
||||
- Authentication
|
||||
summary: OIDC Callback Handler
|
||||
parameters:
|
||||
- description: Authorization code
|
||||
name: code
|
||||
in: query
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- description: State parameter
|
||||
name: state
|
||||
in: query
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"302":
|
||||
description: Found
|
||||
/v1/users/logout:
|
||||
post:
|
||||
security:
|
||||
@@ -1342,6 +1499,12 @@ paths:
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"403":
|
||||
description: Local login is not enabled
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
/v1/users/self:
|
||||
get:
|
||||
security:
|
||||
@@ -1590,6 +1753,11 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.GroupInvitationToken"
|
||||
item_templates:
|
||||
description: ItemTemplates holds the value of the item_templates edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.ItemTemplate"
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
type: array
|
||||
@@ -1826,6 +1994,93 @@ components:
|
||||
description: Item holds the value of the item edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Item"
|
||||
ent.ItemTemplate:
|
||||
type: object
|
||||
properties:
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
default_description:
|
||||
description: Default description for items created from this template
|
||||
type: string
|
||||
default_insured:
|
||||
description: DefaultInsured holds the value of the "default_insured" field.
|
||||
type: boolean
|
||||
default_label_ids:
|
||||
description: Default label IDs for items created from this template
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default_lifetime_warranty:
|
||||
description: DefaultLifetimeWarranty holds the value of the
|
||||
"default_lifetime_warranty" field.
|
||||
type: boolean
|
||||
default_manufacturer:
|
||||
description: DefaultManufacturer holds the value of the "default_manufacturer"
|
||||
field.
|
||||
type: string
|
||||
default_model_number:
|
||||
description: Default model number for items created from this template
|
||||
type: string
|
||||
default_name:
|
||||
description: Default name template for items (can use placeholders)
|
||||
type: string
|
||||
default_quantity:
|
||||
description: DefaultQuantity holds the value of the "default_quantity" field.
|
||||
type: integer
|
||||
default_warranty_details:
|
||||
description: DefaultWarrantyDetails holds the value of the
|
||||
"default_warranty_details" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
description: >-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
|
||||
The values are being populated by the ItemTemplateQuery when eager-loading is set.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.ItemTemplateEdges"
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
include_purchase_fields:
|
||||
description: Whether to include purchase fields in items created from this
|
||||
template
|
||||
type: boolean
|
||||
include_sold_fields:
|
||||
description: Whether to include sold fields in items created from this template
|
||||
type: boolean
|
||||
include_warranty_fields:
|
||||
description: Whether to include warranty fields in items created from this
|
||||
template
|
||||
type: boolean
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
notes:
|
||||
description: Notes holds the value of the "notes" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
ent.ItemTemplateEdges:
|
||||
type: object
|
||||
properties:
|
||||
fields:
|
||||
description: Fields holds the value of the fields edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.TemplateField"
|
||||
group:
|
||||
description: Group holds the value of the group edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Group"
|
||||
location:
|
||||
description: Location holds the value of the location edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Location"
|
||||
ent.Label:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1998,6 +2253,45 @@ components:
|
||||
description: User holds the value of the user edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.User"
|
||||
ent.TemplateField:
|
||||
type: object
|
||||
properties:
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
description: >-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
|
||||
The values are being populated by the TemplateFieldQuery when eager-loading is set.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.TemplateFieldEdges"
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
text_value:
|
||||
description: TextValue holds the value of the "text_value" field.
|
||||
type: string
|
||||
type:
|
||||
description: Type holds the value of the "type" field.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/templatefield.Type"
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
ent.TemplateFieldEdges:
|
||||
type: object
|
||||
properties:
|
||||
item_template:
|
||||
description: ItemTemplate holds the value of the item_template edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.ItemTemplate"
|
||||
ent.User:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2026,6 +2320,12 @@ components:
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
oidc_issuer:
|
||||
description: OidcIssuer holds the value of the "oidc_issuer" field.
|
||||
type: string
|
||||
oidc_subject:
|
||||
description: OidcSubject holds the value of the "oidc_subject" field.
|
||||
type: string
|
||||
role:
|
||||
description: Role holds the value of the "role" field.
|
||||
allOf:
|
||||
@@ -2361,6 +2661,201 @@ components:
|
||||
nullable: true
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.ItemTemplateCreate:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
defaultDescription:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and labels
|
||||
type: string
|
||||
nullable: true
|
||||
defaultManufacturer:
|
||||
type: string
|
||||
maxLength: 255
|
||||
nullable: true
|
||||
defaultModelNumber:
|
||||
type: string
|
||||
maxLength: 255
|
||||
nullable: true
|
||||
defaultName:
|
||||
type: string
|
||||
maxLength: 255
|
||||
nullable: true
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
nullable: true
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
nullable: true
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
fields:
|
||||
description: Custom fields
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateField"
|
||||
includePurchaseFields:
|
||||
type: boolean
|
||||
includeSoldFields:
|
||||
type: boolean
|
||||
includeWarrantyFields:
|
||||
description: Metadata flags
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
notes:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
repo.ItemTemplateOut:
|
||||
type: object
|
||||
properties:
|
||||
createdAt:
|
||||
type: string
|
||||
defaultDescription:
|
||||
type: string
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateLabelSummary"
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocation:
|
||||
description: Default location and labels
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/repo.TemplateLocationSummary"
|
||||
defaultManufacturer:
|
||||
type: string
|
||||
defaultModelNumber:
|
||||
type: string
|
||||
defaultName:
|
||||
type: string
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
fields:
|
||||
description: Custom fields
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateField"
|
||||
id:
|
||||
type: string
|
||||
includePurchaseFields:
|
||||
type: boolean
|
||||
includeSoldFields:
|
||||
type: boolean
|
||||
includeWarrantyFields:
|
||||
description: Metadata flags
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
notes:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.ItemTemplateSummary:
|
||||
type: object
|
||||
properties:
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.ItemTemplateUpdate:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
defaultDescription:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and labels
|
||||
type: string
|
||||
nullable: true
|
||||
defaultManufacturer:
|
||||
type: string
|
||||
maxLength: 255
|
||||
nullable: true
|
||||
defaultModelNumber:
|
||||
type: string
|
||||
maxLength: 255
|
||||
nullable: true
|
||||
defaultName:
|
||||
type: string
|
||||
maxLength: 255
|
||||
nullable: true
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
nullable: true
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
nullable: true
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
fields:
|
||||
description: Custom fields
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateField"
|
||||
id:
|
||||
type: string
|
||||
includePurchaseFields:
|
||||
type: boolean
|
||||
includeSoldFields:
|
||||
type: boolean
|
||||
includeWarrantyFields:
|
||||
description: Metadata flags
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
notes:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
repo.ItemType:
|
||||
type: string
|
||||
enum:
|
||||
@@ -2698,6 +3193,31 @@ components:
|
||||
type: integer
|
||||
total:
|
||||
type: integer
|
||||
repo.TemplateField:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
textValue:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
repo.TemplateLabelSummary:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
repo.TemplateLocationSummary:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
repo.TotalsByOrganizer:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2737,6 +3257,10 @@ components:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
oidcIssuer:
|
||||
type: string
|
||||
oidcSubject:
|
||||
type: string
|
||||
repo.UserUpdate:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2786,6 +3310,12 @@ components:
|
||||
type: string
|
||||
token:
|
||||
type: string
|
||||
templatefield.Type:
|
||||
type: string
|
||||
enum:
|
||||
- text
|
||||
x-enum-varnames:
|
||||
- TypeText
|
||||
user.Role:
|
||||
type: string
|
||||
enum:
|
||||
@@ -2813,6 +3343,8 @@ components:
|
||||
$ref: "#/components/schemas/services.Latest"
|
||||
message:
|
||||
type: string
|
||||
oidc:
|
||||
$ref: "#/components/schemas/v1.OIDCStatus"
|
||||
title:
|
||||
type: string
|
||||
versions:
|
||||
@@ -2865,6 +3397,27 @@ components:
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
v1.ItemTemplateCreateItemRequest:
|
||||
type: object
|
||||
required:
|
||||
- locationId
|
||||
- name
|
||||
properties:
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
locationId:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
quantity:
|
||||
type: integer
|
||||
v1.LoginForm:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2876,6 +3429,17 @@ components:
|
||||
username:
|
||||
type: string
|
||||
example: admin@admin.com
|
||||
v1.OIDCStatus:
|
||||
type: object
|
||||
properties:
|
||||
allowLocal:
|
||||
type: boolean
|
||||
autoRedirect:
|
||||
type: boolean
|
||||
buttonText:
|
||||
type: string
|
||||
enabled:
|
||||
type: boolean
|
||||
v1.TokenResponse:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -1961,6 +1961,209 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Get All Item Templates",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateSummary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Create Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Template Data",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Get Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Update Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Template Data",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemTemplateOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Delete Item Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates/{id}/create-item": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Item Templates"
|
||||
],
|
||||
"summary": "Create Item from Template",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Template ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Item Data",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.ItemTemplateCreateItemRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Created",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/repo.ItemOut"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/change-password": {
|
||||
"put": {
|
||||
"security": [
|
||||
@@ -2030,6 +2233,51 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/login/oidc": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Authentication"
|
||||
],
|
||||
"summary": "OIDC Login Initiation",
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/login/oidc/callback": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Authentication"
|
||||
],
|
||||
"summary": "OIDC Callback Handler",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Authorization code",
|
||||
"name": "code",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "State parameter",
|
||||
"name": "state",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"302": {
|
||||
"description": "Found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/users/logout": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -2090,6 +2338,12 @@
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No Content"
|
||||
},
|
||||
"403": {
|
||||
"description": "Local login is not enabled",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2460,6 +2714,13 @@
|
||||
"$ref": "#/definitions/ent.GroupInvitationToken"
|
||||
}
|
||||
},
|
||||
"item_templates": {
|
||||
"description": "ItemTemplates holds the value of the item_templates edge.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ent.ItemTemplate"
|
||||
}
|
||||
},
|
||||
"items": {
|
||||
"description": "Items holds the value of the items edge.",
|
||||
"type": "array",
|
||||
@@ -2797,6 +3058,122 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.ItemTemplate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "CreatedAt holds the value of the \"created_at\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"default_description": {
|
||||
"description": "Default description for items created from this template",
|
||||
"type": "string"
|
||||
},
|
||||
"default_insured": {
|
||||
"description": "DefaultInsured holds the value of the \"default_insured\" field.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_label_ids": {
|
||||
"description": "Default label IDs for items created from this template",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default_lifetime_warranty": {
|
||||
"description": "DefaultLifetimeWarranty holds the value of the \"default_lifetime_warranty\" field.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"default_manufacturer": {
|
||||
"description": "DefaultManufacturer holds the value of the \"default_manufacturer\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"default_model_number": {
|
||||
"description": "Default model number for items created from this template",
|
||||
"type": "string"
|
||||
},
|
||||
"default_name": {
|
||||
"description": "Default name template for items (can use placeholders)",
|
||||
"type": "string"
|
||||
},
|
||||
"default_quantity": {
|
||||
"description": "DefaultQuantity holds the value of the \"default_quantity\" field.",
|
||||
"type": "integer"
|
||||
},
|
||||
"default_warranty_details": {
|
||||
"description": "DefaultWarrantyDetails holds the value of the \"default_warranty_details\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description holds the value of the \"description\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"edges": {
|
||||
"description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the ItemTemplateQuery when eager-loading is set.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.ItemTemplateEdges"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"description": "ID of the ent.",
|
||||
"type": "string"
|
||||
},
|
||||
"include_purchase_fields": {
|
||||
"description": "Whether to include purchase fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"include_sold_fields": {
|
||||
"description": "Whether to include sold fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"include_warranty_fields": {
|
||||
"description": "Whether to include warranty fields in items created from this template",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"description": "Notes holds the value of the \"notes\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.ItemTemplateEdges": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fields": {
|
||||
"description": "Fields holds the value of the fields edge.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ent.TemplateField"
|
||||
}
|
||||
},
|
||||
"group": {
|
||||
"description": "Group holds the value of the group edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.Group"
|
||||
}
|
||||
]
|
||||
},
|
||||
"location": {
|
||||
"description": "Location holds the value of the location edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.Location"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.Label": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3046,6 +3423,64 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.TemplateField": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"created_at": {
|
||||
"description": "CreatedAt holds the value of the \"created_at\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"description": "Description holds the value of the \"description\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"edges": {
|
||||
"description": "Edges holds the relations/edges for other nodes in the graph.\nThe values are being populated by the TemplateFieldQuery when eager-loading is set.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.TemplateFieldEdges"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"description": "ID of the ent.",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"text_value": {
|
||||
"description": "TextValue holds the value of the \"text_value\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"description": "Type holds the value of the \"type\" field.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/templatefield.Type"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updated_at": {
|
||||
"description": "UpdatedAt holds the value of the \"updated_at\" field.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.TemplateFieldEdges": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"item_template": {
|
||||
"description": "ItemTemplate holds the value of the item_template edge.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ent.ItemTemplate"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ent.User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3081,6 +3516,14 @@
|
||||
"description": "Name holds the value of the \"name\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"oidc_issuer": {
|
||||
"description": "OidcIssuer holds the value of the \"oidc_issuer\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"oidc_subject": {
|
||||
"description": "OidcSubject holds the value of the \"oidc_subject\" field.",
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
"description": "Role holds the value of the \"role\" field.",
|
||||
"allOf": [
|
||||
@@ -3581,6 +4024,280 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"defaultDescription": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocationId": {
|
||||
"description": "Default location and labels",
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateOut": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultDescription": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabels": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateLabelSummary"
|
||||
}
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocation": {
|
||||
"description": "Default location and labels",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/repo.TemplateLocationSummary"
|
||||
}
|
||||
]
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string"
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer"
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemTemplateUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"defaultDescription": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultInsured": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLabelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultLifetimeWarranty": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultLocationId": {
|
||||
"description": "Default location and labels",
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultManufacturer": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultModelNumber": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultName": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultQuantity": {
|
||||
"description": "Default values for items",
|
||||
"type": "integer",
|
||||
"x-nullable": true
|
||||
},
|
||||
"defaultWarrantyDetails": {
|
||||
"type": "string",
|
||||
"maxLength": 1000,
|
||||
"x-nullable": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"fields": {
|
||||
"description": "Custom fields",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.TemplateField"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"includePurchaseFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeSoldFields": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"includeWarrantyFields": {
|
||||
"description": "Metadata flags",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.ItemType": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -4076,6 +4793,45 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateField": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"textValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateLabelSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TemplateLocationSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repo.TotalsByOrganizer": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4133,6 +4889,12 @@
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidcIssuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidcSubject": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -4212,6 +4974,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"templatefield.Type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"text"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"TypeText"
|
||||
]
|
||||
},
|
||||
"user.Role": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -4249,6 +5020,9 @@
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"oidc": {
|
||||
"$ref": "#/definitions/v1.OIDCStatus"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -4331,6 +5105,36 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.ItemTemplateCreateItemRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"locationId",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 1000
|
||||
},
|
||||
"labelIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"locationId": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 255,
|
||||
"minLength": 1
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.LoginForm": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4347,6 +5151,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.OIDCStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allowLocal": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"autoRedirect": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"buttonText": {
|
||||
"type": "string"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.TokenResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -179,6 +179,11 @@ definitions:
|
||||
items:
|
||||
$ref: '#/definitions/ent.GroupInvitationToken'
|
||||
type: array
|
||||
item_templates:
|
||||
description: ItemTemplates holds the value of the item_templates edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.ItemTemplate'
|
||||
type: array
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
items:
|
||||
@@ -414,6 +419,92 @@ definitions:
|
||||
- $ref: '#/definitions/ent.Item'
|
||||
description: Item holds the value of the item edge.
|
||||
type: object
|
||||
ent.ItemTemplate:
|
||||
properties:
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
default_description:
|
||||
description: Default description for items created from this template
|
||||
type: string
|
||||
default_insured:
|
||||
description: DefaultInsured holds the value of the "default_insured" field.
|
||||
type: boolean
|
||||
default_label_ids:
|
||||
description: Default label IDs for items created from this template
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
default_lifetime_warranty:
|
||||
description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty"
|
||||
field.
|
||||
type: boolean
|
||||
default_manufacturer:
|
||||
description: DefaultManufacturer holds the value of the "default_manufacturer"
|
||||
field.
|
||||
type: string
|
||||
default_model_number:
|
||||
description: Default model number for items created from this template
|
||||
type: string
|
||||
default_name:
|
||||
description: Default name template for items (can use placeholders)
|
||||
type: string
|
||||
default_quantity:
|
||||
description: DefaultQuantity holds the value of the "default_quantity" field.
|
||||
type: integer
|
||||
default_warranty_details:
|
||||
description: DefaultWarrantyDetails holds the value of the "default_warranty_details"
|
||||
field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.ItemTemplateEdges'
|
||||
description: |-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
The values are being populated by the ItemTemplateQuery when eager-loading is set.
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
include_purchase_fields:
|
||||
description: Whether to include purchase fields in items created from this
|
||||
template
|
||||
type: boolean
|
||||
include_sold_fields:
|
||||
description: Whether to include sold fields in items created from this template
|
||||
type: boolean
|
||||
include_warranty_fields:
|
||||
description: Whether to include warranty fields in items created from this
|
||||
template
|
||||
type: boolean
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
notes:
|
||||
description: Notes holds the value of the "notes" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
type: object
|
||||
ent.ItemTemplateEdges:
|
||||
properties:
|
||||
fields:
|
||||
description: Fields holds the value of the fields edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.TemplateField'
|
||||
type: array
|
||||
group:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Group'
|
||||
description: Group holds the value of the group edge.
|
||||
location:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Location'
|
||||
description: Location holds the value of the location edge.
|
||||
type: object
|
||||
ent.Label:
|
||||
properties:
|
||||
color:
|
||||
@@ -582,6 +673,44 @@ definitions:
|
||||
- $ref: '#/definitions/ent.User'
|
||||
description: User holds the value of the user edge.
|
||||
type: object
|
||||
ent.TemplateField:
|
||||
properties:
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.TemplateFieldEdges'
|
||||
description: |-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
The values are being populated by the TemplateFieldQuery when eager-loading is set.
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
text_value:
|
||||
description: TextValue holds the value of the "text_value" field.
|
||||
type: string
|
||||
type:
|
||||
allOf:
|
||||
- $ref: '#/definitions/templatefield.Type'
|
||||
description: Type holds the value of the "type" field.
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
type: object
|
||||
ent.TemplateFieldEdges:
|
||||
properties:
|
||||
item_template:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.ItemTemplate'
|
||||
description: ItemTemplate holds the value of the item_template edge.
|
||||
type: object
|
||||
ent.User:
|
||||
properties:
|
||||
activated_on:
|
||||
@@ -608,6 +737,12 @@ definitions:
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
oidc_issuer:
|
||||
description: OidcIssuer holds the value of the "oidc_issuer" field.
|
||||
type: string
|
||||
oidc_subject:
|
||||
description: OidcSubject holds the value of the "oidc_subject" field.
|
||||
type: string
|
||||
role:
|
||||
allOf:
|
||||
- $ref: '#/definitions/user.Role'
|
||||
@@ -944,6 +1079,201 @@ definitions:
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.ItemTemplateCreate:
|
||||
properties:
|
||||
defaultDescription:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and labels
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultManufacturer:
|
||||
maxLength: 255
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultModelNumber:
|
||||
maxLength: 255
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultName:
|
||||
maxLength: 255
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
x-nullable: true
|
||||
defaultWarrantyDetails:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
x-nullable: true
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
fields:
|
||||
description: Custom fields
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateField'
|
||||
type: array
|
||||
includePurchaseFields:
|
||||
type: boolean
|
||||
includeSoldFields:
|
||||
type: boolean
|
||||
includeWarrantyFields:
|
||||
description: Metadata flags
|
||||
type: boolean
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
notes:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.ItemTemplateOut:
|
||||
properties:
|
||||
createdAt:
|
||||
type: string
|
||||
defaultDescription:
|
||||
type: string
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabels:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateLabelSummary'
|
||||
type: array
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocation:
|
||||
allOf:
|
||||
- $ref: '#/definitions/repo.TemplateLocationSummary'
|
||||
description: Default location and labels
|
||||
defaultManufacturer:
|
||||
type: string
|
||||
defaultModelNumber:
|
||||
type: string
|
||||
defaultName:
|
||||
type: string
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
fields:
|
||||
description: Custom fields
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateField'
|
||||
type: array
|
||||
id:
|
||||
type: string
|
||||
includePurchaseFields:
|
||||
type: boolean
|
||||
includeSoldFields:
|
||||
type: boolean
|
||||
includeWarrantyFields:
|
||||
description: Metadata flags
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
notes:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.ItemTemplateSummary:
|
||||
properties:
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.ItemTemplateUpdate:
|
||||
properties:
|
||||
defaultDescription:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and labels
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultManufacturer:
|
||||
maxLength: 255
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultModelNumber:
|
||||
maxLength: 255
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultName:
|
||||
maxLength: 255
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
x-nullable: true
|
||||
defaultWarrantyDetails:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
x-nullable: true
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
fields:
|
||||
description: Custom fields
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateField'
|
||||
type: array
|
||||
id:
|
||||
type: string
|
||||
includePurchaseFields:
|
||||
type: boolean
|
||||
includeSoldFields:
|
||||
type: boolean
|
||||
includeWarrantyFields:
|
||||
description: Metadata flags
|
||||
type: boolean
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
notes:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.ItemType:
|
||||
enum:
|
||||
- location
|
||||
@@ -1281,6 +1611,31 @@ definitions:
|
||||
total:
|
||||
type: integer
|
||||
type: object
|
||||
repo.TemplateField:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
textValue:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateLabelSummary:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateLocationSummary:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
repo.TotalsByOrganizer:
|
||||
properties:
|
||||
id:
|
||||
@@ -1319,6 +1674,10 @@ definitions:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
oidcIssuer:
|
||||
type: string
|
||||
oidcSubject:
|
||||
type: string
|
||||
type: object
|
||||
repo.UserUpdate:
|
||||
properties:
|
||||
@@ -1369,6 +1728,12 @@ definitions:
|
||||
token:
|
||||
type: string
|
||||
type: object
|
||||
templatefield.Type:
|
||||
enum:
|
||||
- text
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- TypeText
|
||||
user.Role:
|
||||
enum:
|
||||
- user
|
||||
@@ -1395,6 +1760,8 @@ definitions:
|
||||
$ref: '#/definitions/services.Latest'
|
||||
message:
|
||||
type: string
|
||||
oidc:
|
||||
$ref: '#/definitions/v1.OIDCStatus'
|
||||
title:
|
||||
type: string
|
||||
versions:
|
||||
@@ -1448,6 +1815,27 @@ definitions:
|
||||
token:
|
||||
type: string
|
||||
type: object
|
||||
v1.ItemTemplateCreateItemRequest:
|
||||
properties:
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
locationId:
|
||||
type: string
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
quantity:
|
||||
type: integer
|
||||
required:
|
||||
- locationId
|
||||
- name
|
||||
type: object
|
||||
v1.LoginForm:
|
||||
properties:
|
||||
password:
|
||||
@@ -1459,6 +1847,17 @@ definitions:
|
||||
example: admin@admin.com
|
||||
type: string
|
||||
type: object
|
||||
v1.OIDCStatus:
|
||||
properties:
|
||||
allowLocal:
|
||||
type: boolean
|
||||
autoRedirect:
|
||||
type: boolean
|
||||
buttonText:
|
||||
type: string
|
||||
enabled:
|
||||
type: boolean
|
||||
type: object
|
||||
v1.TokenResponse:
|
||||
properties:
|
||||
attachmentToken:
|
||||
@@ -2679,6 +3078,130 @@ paths:
|
||||
summary: Application Info
|
||||
tags:
|
||||
- Base
|
||||
/v1/templates:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.ItemTemplateSummary'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get All Item Templates
|
||||
tags:
|
||||
- Item Templates
|
||||
post:
|
||||
parameters:
|
||||
- description: Template Data
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/repo.ItemTemplateCreate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/repo.ItemTemplateOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create Item Template
|
||||
tags:
|
||||
- Item Templates
|
||||
/v1/templates/{id}:
|
||||
delete:
|
||||
parameters:
|
||||
- description: Template ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Delete Item Template
|
||||
tags:
|
||||
- Item Templates
|
||||
get:
|
||||
parameters:
|
||||
- description: Template ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.ItemTemplateOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Item Template
|
||||
tags:
|
||||
- Item Templates
|
||||
put:
|
||||
parameters:
|
||||
- description: Template ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Template Data
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/repo.ItemTemplateUpdate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.ItemTemplateOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Update Item Template
|
||||
tags:
|
||||
- Item Templates
|
||||
/v1/templates/{id}/create-item:
|
||||
post:
|
||||
parameters:
|
||||
- description: Template ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Item Data
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/v1.ItemTemplateCreateItemRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/repo.ItemOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create Item from Template
|
||||
tags:
|
||||
- Item Templates
|
||||
/v1/users/change-password:
|
||||
put:
|
||||
parameters:
|
||||
@@ -2722,6 +3245,35 @@ paths:
|
||||
summary: User Login
|
||||
tags:
|
||||
- Authentication
|
||||
/v1/users/login/oidc:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"302":
|
||||
description: Found
|
||||
summary: OIDC Login Initiation
|
||||
tags:
|
||||
- Authentication
|
||||
/v1/users/login/oidc/callback:
|
||||
get:
|
||||
parameters:
|
||||
- description: Authorization code
|
||||
in: query
|
||||
name: code
|
||||
required: true
|
||||
type: string
|
||||
- description: State parameter
|
||||
in: query
|
||||
name: state
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"302":
|
||||
description: Found
|
||||
summary: OIDC Callback Handler
|
||||
tags:
|
||||
- Authentication
|
||||
/v1/users/logout:
|
||||
post:
|
||||
responses:
|
||||
@@ -2759,6 +3311,10 @@ paths:
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
"403":
|
||||
description: Local login is not enabled
|
||||
schema:
|
||||
type: string
|
||||
summary: Register New User
|
||||
tags:
|
||||
- User
|
||||
|
||||
376
backend/internal/data/ent/client.go
generated
376
backend/internal/data/ent/client.go
generated
@@ -23,10 +23,12 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
|
||||
@@ -49,6 +51,8 @@ type Client struct {
|
||||
Item *ItemClient
|
||||
// ItemField is the client for interacting with the ItemField builders.
|
||||
ItemField *ItemFieldClient
|
||||
// ItemTemplate is the client for interacting with the ItemTemplate builders.
|
||||
ItemTemplate *ItemTemplateClient
|
||||
// Label is the client for interacting with the Label builders.
|
||||
Label *LabelClient
|
||||
// Location is the client for interacting with the Location builders.
|
||||
@@ -57,6 +61,8 @@ type Client struct {
|
||||
MaintenanceEntry *MaintenanceEntryClient
|
||||
// Notifier is the client for interacting with the Notifier builders.
|
||||
Notifier *NotifierClient
|
||||
// TemplateField is the client for interacting with the TemplateField builders.
|
||||
TemplateField *TemplateFieldClient
|
||||
// User is the client for interacting with the User builders.
|
||||
User *UserClient
|
||||
}
|
||||
@@ -77,10 +83,12 @@ func (c *Client) init() {
|
||||
c.GroupInvitationToken = NewGroupInvitationTokenClient(c.config)
|
||||
c.Item = NewItemClient(c.config)
|
||||
c.ItemField = NewItemFieldClient(c.config)
|
||||
c.ItemTemplate = NewItemTemplateClient(c.config)
|
||||
c.Label = NewLabelClient(c.config)
|
||||
c.Location = NewLocationClient(c.config)
|
||||
c.MaintenanceEntry = NewMaintenanceEntryClient(c.config)
|
||||
c.Notifier = NewNotifierClient(c.config)
|
||||
c.TemplateField = NewTemplateFieldClient(c.config)
|
||||
c.User = NewUserClient(c.config)
|
||||
}
|
||||
|
||||
@@ -181,10 +189,12 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
||||
Item: NewItemClient(cfg),
|
||||
ItemField: NewItemFieldClient(cfg),
|
||||
ItemTemplate: NewItemTemplateClient(cfg),
|
||||
Label: NewLabelClient(cfg),
|
||||
Location: NewLocationClient(cfg),
|
||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||
Notifier: NewNotifierClient(cfg),
|
||||
TemplateField: NewTemplateFieldClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
@@ -212,10 +222,12 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
GroupInvitationToken: NewGroupInvitationTokenClient(cfg),
|
||||
Item: NewItemClient(cfg),
|
||||
ItemField: NewItemFieldClient(cfg),
|
||||
ItemTemplate: NewItemTemplateClient(cfg),
|
||||
Label: NewLabelClient(cfg),
|
||||
Location: NewLocationClient(cfg),
|
||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||
Notifier: NewNotifierClient(cfg),
|
||||
TemplateField: NewTemplateFieldClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
@@ -247,8 +259,8 @@ func (c *Client) Close() error {
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
for _, n := range []interface{ Use(...Hook) }{
|
||||
c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken,
|
||||
c.Item, c.ItemField, c.Label, c.Location, c.MaintenanceEntry, c.Notifier,
|
||||
c.User,
|
||||
c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry,
|
||||
c.Notifier, c.TemplateField, c.User,
|
||||
} {
|
||||
n.Use(hooks...)
|
||||
}
|
||||
@@ -259,8 +271,8 @@ func (c *Client) Use(hooks ...Hook) {
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||
c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken,
|
||||
c.Item, c.ItemField, c.Label, c.Location, c.MaintenanceEntry, c.Notifier,
|
||||
c.User,
|
||||
c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry,
|
||||
c.Notifier, c.TemplateField, c.User,
|
||||
} {
|
||||
n.Intercept(interceptors...)
|
||||
}
|
||||
@@ -283,6 +295,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.Item.mutate(ctx, m)
|
||||
case *ItemFieldMutation:
|
||||
return c.ItemField.mutate(ctx, m)
|
||||
case *ItemTemplateMutation:
|
||||
return c.ItemTemplate.mutate(ctx, m)
|
||||
case *LabelMutation:
|
||||
return c.Label.mutate(ctx, m)
|
||||
case *LocationMutation:
|
||||
@@ -291,6 +305,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.MaintenanceEntry.mutate(ctx, m)
|
||||
case *NotifierMutation:
|
||||
return c.Notifier.mutate(ctx, m)
|
||||
case *TemplateFieldMutation:
|
||||
return c.TemplateField.mutate(ctx, m)
|
||||
case *UserMutation:
|
||||
return c.User.mutate(ctx, m)
|
||||
default:
|
||||
@@ -981,6 +997,22 @@ func (c *GroupClient) QueryNotifiers(_m *Group) *NotifierQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryItemTemplates queries the item_templates edge of a Group.
|
||||
func (c *GroupClient) QueryItemTemplates(_m *Group) *ItemTemplateQuery {
|
||||
query := (&ItemTemplateClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.ItemTemplatesTable, group.ItemTemplatesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *GroupClient) Hooks() []Hook {
|
||||
return c.hooks.Group
|
||||
@@ -1565,6 +1597,187 @@ func (c *ItemFieldClient) mutate(ctx context.Context, m *ItemFieldMutation) (Val
|
||||
}
|
||||
}
|
||||
|
||||
// ItemTemplateClient is a client for the ItemTemplate schema.
|
||||
type ItemTemplateClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewItemTemplateClient returns a client for the ItemTemplate from the given config.
|
||||
func NewItemTemplateClient(c config) *ItemTemplateClient {
|
||||
return &ItemTemplateClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `itemtemplate.Hooks(f(g(h())))`.
|
||||
func (c *ItemTemplateClient) Use(hooks ...Hook) {
|
||||
c.hooks.ItemTemplate = append(c.hooks.ItemTemplate, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `itemtemplate.Intercept(f(g(h())))`.
|
||||
func (c *ItemTemplateClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.ItemTemplate = append(c.inters.ItemTemplate, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a ItemTemplate entity.
|
||||
func (c *ItemTemplateClient) Create() *ItemTemplateCreate {
|
||||
mutation := newItemTemplateMutation(c.config, OpCreate)
|
||||
return &ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of ItemTemplate entities.
|
||||
func (c *ItemTemplateClient) CreateBulk(builders ...*ItemTemplateCreate) *ItemTemplateCreateBulk {
|
||||
return &ItemTemplateCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *ItemTemplateClient) MapCreateBulk(slice any, setFunc func(*ItemTemplateCreate, int)) *ItemTemplateCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &ItemTemplateCreateBulk{err: fmt.Errorf("calling to ItemTemplateClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*ItemTemplateCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &ItemTemplateCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for ItemTemplate.
|
||||
func (c *ItemTemplateClient) Update() *ItemTemplateUpdate {
|
||||
mutation := newItemTemplateMutation(c.config, OpUpdate)
|
||||
return &ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *ItemTemplateClient) UpdateOne(_m *ItemTemplate) *ItemTemplateUpdateOne {
|
||||
mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplate(_m))
|
||||
return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *ItemTemplateClient) UpdateOneID(id uuid.UUID) *ItemTemplateUpdateOne {
|
||||
mutation := newItemTemplateMutation(c.config, OpUpdateOne, withItemTemplateID(id))
|
||||
return &ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for ItemTemplate.
|
||||
func (c *ItemTemplateClient) Delete() *ItemTemplateDelete {
|
||||
mutation := newItemTemplateMutation(c.config, OpDelete)
|
||||
return &ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *ItemTemplateClient) DeleteOne(_m *ItemTemplate) *ItemTemplateDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *ItemTemplateClient) DeleteOneID(id uuid.UUID) *ItemTemplateDeleteOne {
|
||||
builder := c.Delete().Where(itemtemplate.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &ItemTemplateDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for ItemTemplate.
|
||||
func (c *ItemTemplateClient) Query() *ItemTemplateQuery {
|
||||
return &ItemTemplateQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeItemTemplate},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a ItemTemplate entity by its id.
|
||||
func (c *ItemTemplateClient) Get(ctx context.Context, id uuid.UUID) (*ItemTemplate, error) {
|
||||
return c.Query().Where(itemtemplate.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *ItemTemplateClient) GetX(ctx context.Context, id uuid.UUID) *ItemTemplate {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a ItemTemplate.
|
||||
func (c *ItemTemplateClient) QueryGroup(_m *ItemTemplate) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, itemtemplate.GroupTable, itemtemplate.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryFields queries the fields edge of a ItemTemplate.
|
||||
func (c *ItemTemplateClient) QueryFields(_m *ItemTemplate) *TemplateFieldQuery {
|
||||
query := (&TemplateFieldClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
|
||||
sqlgraph.To(templatefield.Table, templatefield.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, itemtemplate.FieldsTable, itemtemplate.FieldsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLocation queries the location edge of a ItemTemplate.
|
||||
func (c *ItemTemplateClient) QueryLocation(_m *ItemTemplate) *LocationQuery {
|
||||
query := (&LocationClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, id),
|
||||
sqlgraph.To(location.Table, location.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ItemTemplateClient) Hooks() []Hook {
|
||||
return c.hooks.ItemTemplate
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *ItemTemplateClient) Interceptors() []Interceptor {
|
||||
return c.inters.ItemTemplate
|
||||
}
|
||||
|
||||
func (c *ItemTemplateClient) mutate(ctx context.Context, m *ItemTemplateMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&ItemTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&ItemTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&ItemTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&ItemTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown ItemTemplate mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// LabelClient is a client for the Label schema.
|
||||
type LabelClient struct {
|
||||
config
|
||||
@@ -2241,6 +2454,155 @@ func (c *NotifierClient) mutate(ctx context.Context, m *NotifierMutation) (Value
|
||||
}
|
||||
}
|
||||
|
||||
// TemplateFieldClient is a client for the TemplateField schema.
|
||||
type TemplateFieldClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewTemplateFieldClient returns a client for the TemplateField from the given config.
|
||||
func NewTemplateFieldClient(c config) *TemplateFieldClient {
|
||||
return &TemplateFieldClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `templatefield.Hooks(f(g(h())))`.
|
||||
func (c *TemplateFieldClient) Use(hooks ...Hook) {
|
||||
c.hooks.TemplateField = append(c.hooks.TemplateField, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `templatefield.Intercept(f(g(h())))`.
|
||||
func (c *TemplateFieldClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.TemplateField = append(c.inters.TemplateField, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a TemplateField entity.
|
||||
func (c *TemplateFieldClient) Create() *TemplateFieldCreate {
|
||||
mutation := newTemplateFieldMutation(c.config, OpCreate)
|
||||
return &TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of TemplateField entities.
|
||||
func (c *TemplateFieldClient) CreateBulk(builders ...*TemplateFieldCreate) *TemplateFieldCreateBulk {
|
||||
return &TemplateFieldCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *TemplateFieldClient) MapCreateBulk(slice any, setFunc func(*TemplateFieldCreate, int)) *TemplateFieldCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &TemplateFieldCreateBulk{err: fmt.Errorf("calling to TemplateFieldClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*TemplateFieldCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &TemplateFieldCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for TemplateField.
|
||||
func (c *TemplateFieldClient) Update() *TemplateFieldUpdate {
|
||||
mutation := newTemplateFieldMutation(c.config, OpUpdate)
|
||||
return &TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *TemplateFieldClient) UpdateOne(_m *TemplateField) *TemplateFieldUpdateOne {
|
||||
mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateField(_m))
|
||||
return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *TemplateFieldClient) UpdateOneID(id uuid.UUID) *TemplateFieldUpdateOne {
|
||||
mutation := newTemplateFieldMutation(c.config, OpUpdateOne, withTemplateFieldID(id))
|
||||
return &TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for TemplateField.
|
||||
func (c *TemplateFieldClient) Delete() *TemplateFieldDelete {
|
||||
mutation := newTemplateFieldMutation(c.config, OpDelete)
|
||||
return &TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *TemplateFieldClient) DeleteOne(_m *TemplateField) *TemplateFieldDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *TemplateFieldClient) DeleteOneID(id uuid.UUID) *TemplateFieldDeleteOne {
|
||||
builder := c.Delete().Where(templatefield.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &TemplateFieldDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for TemplateField.
|
||||
func (c *TemplateFieldClient) Query() *TemplateFieldQuery {
|
||||
return &TemplateFieldQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeTemplateField},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a TemplateField entity by its id.
|
||||
func (c *TemplateFieldClient) Get(ctx context.Context, id uuid.UUID) (*TemplateField, error) {
|
||||
return c.Query().Where(templatefield.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *TemplateFieldClient) GetX(ctx context.Context, id uuid.UUID) *TemplateField {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryItemTemplate queries the item_template edge of a TemplateField.
|
||||
func (c *TemplateFieldClient) QueryItemTemplate(_m *TemplateField) *ItemTemplateQuery {
|
||||
query := (&ItemTemplateClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(templatefield.Table, templatefield.FieldID, id),
|
||||
sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, templatefield.ItemTemplateTable, templatefield.ItemTemplateColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *TemplateFieldClient) Hooks() []Hook {
|
||||
return c.hooks.TemplateField
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *TemplateFieldClient) Interceptors() []Interceptor {
|
||||
return c.inters.TemplateField
|
||||
}
|
||||
|
||||
func (c *TemplateFieldClient) mutate(ctx context.Context, m *TemplateFieldMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&TemplateFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&TemplateFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&TemplateFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&TemplateFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown TemplateField mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// UserClient is a client for the User schema.
|
||||
type UserClient struct {
|
||||
config
|
||||
@@ -2426,10 +2788,12 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error)
|
||||
type (
|
||||
hooks struct {
|
||||
Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField,
|
||||
Label, Location, MaintenanceEntry, Notifier, User []ent.Hook
|
||||
ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
|
||||
User []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField,
|
||||
Label, Location, MaintenanceEntry, Notifier, User []ent.Interceptor
|
||||
ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
|
||||
User []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
||||
4
backend/internal/data/ent/ent.go
generated
4
backend/internal/data/ent/ent.go
generated
@@ -19,10 +19,12 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
|
||||
@@ -91,10 +93,12 @@ func checkColumn(t, c string) error {
|
||||
groupinvitationtoken.Table: groupinvitationtoken.ValidColumn,
|
||||
item.Table: item.ValidColumn,
|
||||
itemfield.Table: itemfield.ValidColumn,
|
||||
itemtemplate.Table: itemtemplate.ValidColumn,
|
||||
label.Table: label.ValidColumn,
|
||||
location.Table: location.ValidColumn,
|
||||
maintenanceentry.Table: maintenanceentry.ValidColumn,
|
||||
notifier.Table: notifier.ValidColumn,
|
||||
templatefield.Table: templatefield.ValidColumn,
|
||||
user.Table: user.ValidColumn,
|
||||
})
|
||||
})
|
||||
|
||||
18
backend/internal/data/ent/group.go
generated
18
backend/internal/data/ent/group.go
generated
@@ -46,9 +46,11 @@ type GroupEdges struct {
|
||||
InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"`
|
||||
// Notifiers holds the value of the notifiers edge.
|
||||
Notifiers []*Notifier `json:"notifiers,omitempty"`
|
||||
// ItemTemplates holds the value of the item_templates edge.
|
||||
ItemTemplates []*ItemTemplate `json:"item_templates,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [6]bool
|
||||
loadedTypes [7]bool
|
||||
}
|
||||
|
||||
// UsersOrErr returns the Users value or an error if the edge
|
||||
@@ -105,6 +107,15 @@ func (e GroupEdges) NotifiersOrErr() ([]*Notifier, error) {
|
||||
return nil, &NotLoadedError{edge: "notifiers"}
|
||||
}
|
||||
|
||||
// ItemTemplatesOrErr returns the ItemTemplates value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e GroupEdges) ItemTemplatesOrErr() ([]*ItemTemplate, error) {
|
||||
if e.loadedTypes[6] {
|
||||
return e.ItemTemplates, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "item_templates"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Group) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
@@ -204,6 +215,11 @@ func (_m *Group) QueryNotifiers() *NotifierQuery {
|
||||
return NewGroupClient(_m.config).QueryNotifiers(_m)
|
||||
}
|
||||
|
||||
// QueryItemTemplates queries the "item_templates" edge of the Group entity.
|
||||
func (_m *Group) QueryItemTemplates() *ItemTemplateQuery {
|
||||
return NewGroupClient(_m.config).QueryItemTemplates(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Group.
|
||||
// Note that you need to call Group.Unwrap() before calling this method if this Group
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
|
||||
30
backend/internal/data/ent/group/group.go
generated
30
backend/internal/data/ent/group/group.go
generated
@@ -35,6 +35,8 @@ const (
|
||||
EdgeInvitationTokens = "invitation_tokens"
|
||||
// EdgeNotifiers holds the string denoting the notifiers edge name in mutations.
|
||||
EdgeNotifiers = "notifiers"
|
||||
// EdgeItemTemplates holds the string denoting the item_templates edge name in mutations.
|
||||
EdgeItemTemplates = "item_templates"
|
||||
// Table holds the table name of the group in the database.
|
||||
Table = "groups"
|
||||
// UsersTable is the table that holds the users relation/edge.
|
||||
@@ -79,6 +81,13 @@ const (
|
||||
NotifiersInverseTable = "notifiers"
|
||||
// NotifiersColumn is the table column denoting the notifiers relation/edge.
|
||||
NotifiersColumn = "group_id"
|
||||
// ItemTemplatesTable is the table that holds the item_templates relation/edge.
|
||||
ItemTemplatesTable = "item_templates"
|
||||
// ItemTemplatesInverseTable is the table name for the ItemTemplate entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "itemtemplate" package.
|
||||
ItemTemplatesInverseTable = "item_templates"
|
||||
// ItemTemplatesColumn is the table column denoting the item_templates relation/edge.
|
||||
ItemTemplatesColumn = "group_item_templates"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for group fields.
|
||||
@@ -226,6 +235,20 @@ func ByNotifiers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
sqlgraph.OrderByNeighborTerms(s, newNotifiersStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByItemTemplatesCount orders the results by item_templates count.
|
||||
func ByItemTemplatesCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newItemTemplatesStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByItemTemplates orders the results by item_templates terms.
|
||||
func ByItemTemplates(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newItemTemplatesStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newUsersStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
@@ -268,3 +291,10 @@ func newNotifiersStep() *sqlgraph.Step {
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn),
|
||||
)
|
||||
}
|
||||
func newItemTemplatesStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ItemTemplatesInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ItemTemplatesTable, ItemTemplatesColumn),
|
||||
)
|
||||
}
|
||||
|
||||
23
backend/internal/data/ent/group/where.go
generated
23
backend/internal/data/ent/group/where.go
generated
@@ -424,6 +424,29 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.Group {
|
||||
})
|
||||
}
|
||||
|
||||
// HasItemTemplates applies the HasEdge predicate on the "item_templates" edge.
|
||||
func HasItemTemplates() predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ItemTemplatesTable, ItemTemplatesColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasItemTemplatesWith applies the HasEdge predicate on the "item_templates" edge with a given conditions (other predicates).
|
||||
func HasItemTemplatesWith(preds ...predicate.ItemTemplate) predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
step := newItemTemplatesStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Group) predicate.Group {
|
||||
return predicate.Group(sql.AndPredicates(predicates...))
|
||||
|
||||
32
backend/internal/data/ent/group_create.go
generated
32
backend/internal/data/ent/group_create.go
generated
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
@@ -179,6 +180,21 @@ func (_c *GroupCreate) AddNotifiers(v ...*Notifier) *GroupCreate {
|
||||
return _c.AddNotifierIDs(ids...)
|
||||
}
|
||||
|
||||
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
|
||||
func (_c *GroupCreate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddItemTemplateIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity.
|
||||
func (_c *GroupCreate) AddItemTemplates(v ...*ItemTemplate) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddItemTemplateIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (_c *GroupCreate) Mutation() *GroupMutation {
|
||||
return _c.mutation
|
||||
@@ -398,6 +414,22 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.ItemTemplatesTable,
|
||||
Columns: []string{group.ItemTemplatesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
||||
77
backend/internal/data/ent/group_query.go
generated
77
backend/internal/data/ent/group_query.go
generated
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
@@ -36,6 +37,7 @@ type GroupQuery struct {
|
||||
withLabels *LabelQuery
|
||||
withInvitationTokens *GroupInvitationTokenQuery
|
||||
withNotifiers *NotifierQuery
|
||||
withItemTemplates *ItemTemplateQuery
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -204,6 +206,28 @@ func (_q *GroupQuery) QueryNotifiers() *NotifierQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryItemTemplates chains the current query on the "item_templates" edge.
|
||||
func (_q *GroupQuery) QueryItemTemplates() *ItemTemplateQuery {
|
||||
query := (&ItemTemplateClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, selector),
|
||||
sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.ItemTemplatesTable, group.ItemTemplatesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Group entity from the query.
|
||||
// Returns a *NotFoundError when no Group was found.
|
||||
func (_q *GroupQuery) First(ctx context.Context) (*Group, error) {
|
||||
@@ -402,6 +426,7 @@ func (_q *GroupQuery) Clone() *GroupQuery {
|
||||
withLabels: _q.withLabels.Clone(),
|
||||
withInvitationTokens: _q.withInvitationTokens.Clone(),
|
||||
withNotifiers: _q.withNotifiers.Clone(),
|
||||
withItemTemplates: _q.withItemTemplates.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
@@ -474,6 +499,17 @@ func (_q *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery {
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithItemTemplates tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "item_templates" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *GroupQuery) WithItemTemplates(opts ...func(*ItemTemplateQuery)) *GroupQuery {
|
||||
query := (&ItemTemplateClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withItemTemplates = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@@ -552,13 +588,14 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
|
||||
var (
|
||||
nodes = []*Group{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [6]bool{
|
||||
loadedTypes = [7]bool{
|
||||
_q.withUsers != nil,
|
||||
_q.withLocations != nil,
|
||||
_q.withItems != nil,
|
||||
_q.withLabels != nil,
|
||||
_q.withInvitationTokens != nil,
|
||||
_q.withNotifiers != nil,
|
||||
_q.withItemTemplates != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
@@ -623,6 +660,13 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withItemTemplates; query != nil {
|
||||
if err := _q.loadItemTemplates(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.ItemTemplates = []*ItemTemplate{} },
|
||||
func(n *Group, e *ItemTemplate) { n.Edges.ItemTemplates = append(n.Edges.ItemTemplates, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
@@ -811,6 +855,37 @@ func (_q *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *GroupQuery) loadItemTemplates(ctx context.Context, query *ItemTemplateQuery, nodes []*Group, init func(*Group), assign func(*Group, *ItemTemplate)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.ItemTemplate(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(group.ItemTemplatesColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.group_item_templates
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "group_item_templates" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "group_item_templates" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *GroupQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
|
||||
163
backend/internal/data/ent/group_update.go
generated
163
backend/internal/data/ent/group_update.go
generated
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
@@ -159,6 +160,21 @@ func (_u *GroupUpdate) AddNotifiers(v ...*Notifier) *GroupUpdate {
|
||||
return _u.AddNotifierIDs(ids...)
|
||||
}
|
||||
|
||||
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
|
||||
func (_u *GroupUpdate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate {
|
||||
_u.mutation.AddItemTemplateIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity.
|
||||
func (_u *GroupUpdate) AddItemTemplates(v ...*ItemTemplate) *GroupUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddItemTemplateIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (_u *GroupUpdate) Mutation() *GroupMutation {
|
||||
return _u.mutation
|
||||
@@ -290,6 +306,27 @@ func (_u *GroupUpdate) RemoveNotifiers(v ...*Notifier) *GroupUpdate {
|
||||
return _u.RemoveNotifierIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
|
||||
func (_u *GroupUpdate) ClearItemTemplates() *GroupUpdate {
|
||||
_u.mutation.ClearItemTemplates()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItemTemplateIDs removes the "item_templates" edge to ItemTemplate entities by IDs.
|
||||
func (_u *GroupUpdate) RemoveItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate {
|
||||
_u.mutation.RemoveItemTemplateIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItemTemplates removes "item_templates" edges to ItemTemplate entities.
|
||||
func (_u *GroupUpdate) RemoveItemTemplates(v ...*ItemTemplate) *GroupUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveItemTemplateIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *GroupUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
@@ -627,6 +664,51 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.ItemTemplatesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.ItemTemplatesTable,
|
||||
Columns: []string{group.ItemTemplatesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedItemTemplatesIDs(); len(nodes) > 0 && !_u.mutation.ItemTemplatesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.ItemTemplatesTable,
|
||||
Columns: []string{group.ItemTemplatesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.ItemTemplatesTable,
|
||||
Columns: []string{group.ItemTemplatesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{group.Label}
|
||||
@@ -771,6 +853,21 @@ func (_u *GroupUpdateOne) AddNotifiers(v ...*Notifier) *GroupUpdateOne {
|
||||
return _u.AddNotifierIDs(ids...)
|
||||
}
|
||||
|
||||
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
|
||||
func (_u *GroupUpdateOne) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne {
|
||||
_u.mutation.AddItemTemplateIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddItemTemplates adds the "item_templates" edges to the ItemTemplate entity.
|
||||
func (_u *GroupUpdateOne) AddItemTemplates(v ...*ItemTemplate) *GroupUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddItemTemplateIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (_u *GroupUpdateOne) Mutation() *GroupMutation {
|
||||
return _u.mutation
|
||||
@@ -902,6 +999,27 @@ func (_u *GroupUpdateOne) RemoveNotifiers(v ...*Notifier) *GroupUpdateOne {
|
||||
return _u.RemoveNotifierIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
|
||||
func (_u *GroupUpdateOne) ClearItemTemplates() *GroupUpdateOne {
|
||||
_u.mutation.ClearItemTemplates()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItemTemplateIDs removes the "item_templates" edge to ItemTemplate entities by IDs.
|
||||
func (_u *GroupUpdateOne) RemoveItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne {
|
||||
_u.mutation.RemoveItemTemplateIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItemTemplates removes "item_templates" edges to ItemTemplate entities.
|
||||
func (_u *GroupUpdateOne) RemoveItemTemplates(v ...*ItemTemplate) *GroupUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveItemTemplateIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the GroupUpdate builder.
|
||||
func (_u *GroupUpdateOne) Where(ps ...predicate.Group) *GroupUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
@@ -1269,6 +1387,51 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.ItemTemplatesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.ItemTemplatesTable,
|
||||
Columns: []string{group.ItemTemplatesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedItemTemplatesIDs(); len(nodes) > 0 && !_u.mutation.ItemTemplatesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.ItemTemplatesTable,
|
||||
Columns: []string{group.ItemTemplatesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.ItemTemplatesTable,
|
||||
Columns: []string{group.ItemTemplatesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &Group{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
||||
8
backend/internal/data/ent/has_id.go
generated
8
backend/internal/data/ent/has_id.go
generated
@@ -32,6 +32,10 @@ func (_m *ItemField) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *ItemTemplate) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *Label) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
@@ -48,6 +52,10 @@ func (_m *Notifier) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *TemplateField) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *User) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
24
backend/internal/data/ent/hook/hook.go
generated
24
backend/internal/data/ent/hook/hook.go
generated
@@ -93,6 +93,18 @@ func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, e
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemFieldMutation", m)
|
||||
}
|
||||
|
||||
// The ItemTemplateFunc type is an adapter to allow the use of ordinary
|
||||
// function as ItemTemplate mutator.
|
||||
type ItemTemplateFunc func(context.Context, *ent.ItemTemplateMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ItemTemplateFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.ItemTemplateMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemTemplateMutation", m)
|
||||
}
|
||||
|
||||
// The LabelFunc type is an adapter to allow the use of ordinary
|
||||
// function as Label mutator.
|
||||
type LabelFunc func(context.Context, *ent.LabelMutation) (ent.Value, error)
|
||||
@@ -141,6 +153,18 @@ func (f NotifierFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, er
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotifierMutation", m)
|
||||
}
|
||||
|
||||
// The TemplateFieldFunc type is an adapter to allow the use of ordinary
|
||||
// function as TemplateField mutator.
|
||||
type TemplateFieldFunc func(context.Context, *ent.TemplateFieldMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f TemplateFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.TemplateFieldMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.TemplateFieldMutation", m)
|
||||
}
|
||||
|
||||
// The UserFunc type is an adapter to allow the use of ordinary
|
||||
// function as User mutator.
|
||||
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
|
||||
|
||||
376
backend/internal/data/ent/itemtemplate.go
generated
Normal file
376
backend/internal/data/ent/itemtemplate.go
generated
Normal file
@@ -0,0 +1,376 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
)
|
||||
|
||||
// ItemTemplate is the model entity for the ItemTemplate schema.
|
||||
type ItemTemplate struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Description holds the value of the "description" field.
|
||||
Description string `json:"description,omitempty"`
|
||||
// Notes holds the value of the "notes" field.
|
||||
Notes string `json:"notes,omitempty"`
|
||||
// DefaultQuantity holds the value of the "default_quantity" field.
|
||||
DefaultQuantity int `json:"default_quantity,omitempty"`
|
||||
// DefaultInsured holds the value of the "default_insured" field.
|
||||
DefaultInsured bool `json:"default_insured,omitempty"`
|
||||
// Default name template for items (can use placeholders)
|
||||
DefaultName string `json:"default_name,omitempty"`
|
||||
// Default description for items created from this template
|
||||
DefaultDescription string `json:"default_description,omitempty"`
|
||||
// DefaultManufacturer holds the value of the "default_manufacturer" field.
|
||||
DefaultManufacturer string `json:"default_manufacturer,omitempty"`
|
||||
// Default model number for items created from this template
|
||||
DefaultModelNumber string `json:"default_model_number,omitempty"`
|
||||
// DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty" field.
|
||||
DefaultLifetimeWarranty bool `json:"default_lifetime_warranty,omitempty"`
|
||||
// DefaultWarrantyDetails holds the value of the "default_warranty_details" field.
|
||||
DefaultWarrantyDetails string `json:"default_warranty_details,omitempty"`
|
||||
// Whether to include warranty fields in items created from this template
|
||||
IncludeWarrantyFields bool `json:"include_warranty_fields,omitempty"`
|
||||
// Whether to include purchase fields in items created from this template
|
||||
IncludePurchaseFields bool `json:"include_purchase_fields,omitempty"`
|
||||
// Whether to include sold fields in items created from this template
|
||||
IncludeSoldFields bool `json:"include_sold_fields,omitempty"`
|
||||
// Default label IDs for items created from this template
|
||||
DefaultLabelIds []uuid.UUID `json:"default_label_ids,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ItemTemplateQuery when eager-loading is set.
|
||||
Edges ItemTemplateEdges `json:"edges"`
|
||||
group_item_templates *uuid.UUID
|
||||
item_template_location *uuid.UUID
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ItemTemplateEdges holds the relations/edges for other nodes in the graph.
|
||||
type ItemTemplateEdges struct {
|
||||
// Group holds the value of the group edge.
|
||||
Group *Group `json:"group,omitempty"`
|
||||
// Fields holds the value of the fields edge.
|
||||
Fields []*TemplateField `json:"fields,omitempty"`
|
||||
// Location holds the value of the location edge.
|
||||
Location *Location `json:"location,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [3]bool
|
||||
}
|
||||
|
||||
// GroupOrErr returns the Group value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e ItemTemplateEdges) GroupOrErr() (*Group, error) {
|
||||
if e.Group != nil {
|
||||
return e.Group, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: group.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "group"}
|
||||
}
|
||||
|
||||
// FieldsOrErr returns the Fields value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ItemTemplateEdges) FieldsOrErr() ([]*TemplateField, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.Fields, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "fields"}
|
||||
}
|
||||
|
||||
// LocationOrErr returns the Location value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e ItemTemplateEdges) LocationOrErr() (*Location, error) {
|
||||
if e.Location != nil {
|
||||
return e.Location, nil
|
||||
} else if e.loadedTypes[2] {
|
||||
return nil, &NotFoundError{label: location.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "location"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*ItemTemplate) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case itemtemplate.FieldDefaultLabelIds:
|
||||
values[i] = new([]byte)
|
||||
case itemtemplate.FieldDefaultInsured, itemtemplate.FieldDefaultLifetimeWarranty, itemtemplate.FieldIncludeWarrantyFields, itemtemplate.FieldIncludePurchaseFields, itemtemplate.FieldIncludeSoldFields:
|
||||
values[i] = new(sql.NullBool)
|
||||
case itemtemplate.FieldDefaultQuantity:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case itemtemplate.FieldName, itemtemplate.FieldDescription, itemtemplate.FieldNotes, itemtemplate.FieldDefaultName, itemtemplate.FieldDefaultDescription, itemtemplate.FieldDefaultManufacturer, itemtemplate.FieldDefaultModelNumber, itemtemplate.FieldDefaultWarrantyDetails:
|
||||
values[i] = new(sql.NullString)
|
||||
case itemtemplate.FieldCreatedAt, itemtemplate.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case itemtemplate.FieldID:
|
||||
values[i] = new(uuid.UUID)
|
||||
case itemtemplate.ForeignKeys[0]: // group_item_templates
|
||||
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
||||
case itemtemplate.ForeignKeys[1]: // item_template_location
|
||||
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the ItemTemplate fields.
|
||||
func (_m *ItemTemplate) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case itemtemplate.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case itemtemplate.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case itemtemplate.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case itemtemplate.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Name = value.String
|
||||
}
|
||||
case itemtemplate.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Description = value.String
|
||||
}
|
||||
case itemtemplate.FieldNotes:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field notes", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Notes = value.String
|
||||
}
|
||||
case itemtemplate.FieldDefaultQuantity:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_quantity", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultQuantity = int(value.Int64)
|
||||
}
|
||||
case itemtemplate.FieldDefaultInsured:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_insured", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultInsured = value.Bool
|
||||
}
|
||||
case itemtemplate.FieldDefaultName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_name", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultName = value.String
|
||||
}
|
||||
case itemtemplate.FieldDefaultDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_description", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultDescription = value.String
|
||||
}
|
||||
case itemtemplate.FieldDefaultManufacturer:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_manufacturer", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultManufacturer = value.String
|
||||
}
|
||||
case itemtemplate.FieldDefaultModelNumber:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_model_number", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultModelNumber = value.String
|
||||
}
|
||||
case itemtemplate.FieldDefaultLifetimeWarranty:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_lifetime_warranty", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultLifetimeWarranty = value.Bool
|
||||
}
|
||||
case itemtemplate.FieldDefaultWarrantyDetails:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_warranty_details", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DefaultWarrantyDetails = value.String
|
||||
}
|
||||
case itemtemplate.FieldIncludeWarrantyFields:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field include_warranty_fields", values[i])
|
||||
} else if value.Valid {
|
||||
_m.IncludeWarrantyFields = value.Bool
|
||||
}
|
||||
case itemtemplate.FieldIncludePurchaseFields:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field include_purchase_fields", values[i])
|
||||
} else if value.Valid {
|
||||
_m.IncludePurchaseFields = value.Bool
|
||||
}
|
||||
case itemtemplate.FieldIncludeSoldFields:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field include_sold_fields", values[i])
|
||||
} else if value.Valid {
|
||||
_m.IncludeSoldFields = value.Bool
|
||||
}
|
||||
case itemtemplate.FieldDefaultLabelIds:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_label_ids", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.DefaultLabelIds); err != nil {
|
||||
return fmt.Errorf("unmarshal field default_label_ids: %w", err)
|
||||
}
|
||||
}
|
||||
case itemtemplate.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_item_templates", values[i])
|
||||
} else if value.Valid {
|
||||
_m.group_item_templates = new(uuid.UUID)
|
||||
*_m.group_item_templates = *value.S.(*uuid.UUID)
|
||||
}
|
||||
case itemtemplate.ForeignKeys[1]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field item_template_location", values[i])
|
||||
} else if value.Valid {
|
||||
_m.item_template_location = new(uuid.UUID)
|
||||
*_m.item_template_location = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the ItemTemplate.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *ItemTemplate) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the ItemTemplate entity.
|
||||
func (_m *ItemTemplate) QueryGroup() *GroupQuery {
|
||||
return NewItemTemplateClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// QueryFields queries the "fields" edge of the ItemTemplate entity.
|
||||
func (_m *ItemTemplate) QueryFields() *TemplateFieldQuery {
|
||||
return NewItemTemplateClient(_m.config).QueryFields(_m)
|
||||
}
|
||||
|
||||
// QueryLocation queries the "location" edge of the ItemTemplate entity.
|
||||
func (_m *ItemTemplate) QueryLocation() *LocationQuery {
|
||||
return NewItemTemplateClient(_m.config).QueryLocation(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ItemTemplate.
|
||||
// Note that you need to call ItemTemplate.Unwrap() before calling this method if this ItemTemplate
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *ItemTemplate) Update() *ItemTemplateUpdateOne {
|
||||
return NewItemTemplateClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the ItemTemplate entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *ItemTemplate) Unwrap() *ItemTemplate {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: ItemTemplate is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *ItemTemplate) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("ItemTemplate(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(_m.Description)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("notes=")
|
||||
builder.WriteString(_m.Notes)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_quantity=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DefaultQuantity))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_insured=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DefaultInsured))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_name=")
|
||||
builder.WriteString(_m.DefaultName)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_description=")
|
||||
builder.WriteString(_m.DefaultDescription)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_manufacturer=")
|
||||
builder.WriteString(_m.DefaultManufacturer)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_model_number=")
|
||||
builder.WriteString(_m.DefaultModelNumber)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_lifetime_warranty=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DefaultLifetimeWarranty))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_warranty_details=")
|
||||
builder.WriteString(_m.DefaultWarrantyDetails)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("include_warranty_fields=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.IncludeWarrantyFields))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("include_purchase_fields=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.IncludePurchaseFields))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("include_sold_fields=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.IncludeSoldFields))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_label_ids=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DefaultLabelIds))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// ItemTemplates is a parsable slice of ItemTemplate.
|
||||
type ItemTemplates []*ItemTemplate
|
||||
301
backend/internal/data/ent/itemtemplate/itemtemplate.go
generated
Normal file
301
backend/internal/data/ent/itemtemplate/itemtemplate.go
generated
Normal file
@@ -0,0 +1,301 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package itemtemplate
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the itemtemplate type in the database.
|
||||
Label = "item_template"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldDescription holds the string denoting the description field in the database.
|
||||
FieldDescription = "description"
|
||||
// FieldNotes holds the string denoting the notes field in the database.
|
||||
FieldNotes = "notes"
|
||||
// FieldDefaultQuantity holds the string denoting the default_quantity field in the database.
|
||||
FieldDefaultQuantity = "default_quantity"
|
||||
// FieldDefaultInsured holds the string denoting the default_insured field in the database.
|
||||
FieldDefaultInsured = "default_insured"
|
||||
// FieldDefaultName holds the string denoting the default_name field in the database.
|
||||
FieldDefaultName = "default_name"
|
||||
// FieldDefaultDescription holds the string denoting the default_description field in the database.
|
||||
FieldDefaultDescription = "default_description"
|
||||
// FieldDefaultManufacturer holds the string denoting the default_manufacturer field in the database.
|
||||
FieldDefaultManufacturer = "default_manufacturer"
|
||||
// FieldDefaultModelNumber holds the string denoting the default_model_number field in the database.
|
||||
FieldDefaultModelNumber = "default_model_number"
|
||||
// FieldDefaultLifetimeWarranty holds the string denoting the default_lifetime_warranty field in the database.
|
||||
FieldDefaultLifetimeWarranty = "default_lifetime_warranty"
|
||||
// FieldDefaultWarrantyDetails holds the string denoting the default_warranty_details field in the database.
|
||||
FieldDefaultWarrantyDetails = "default_warranty_details"
|
||||
// FieldIncludeWarrantyFields holds the string denoting the include_warranty_fields field in the database.
|
||||
FieldIncludeWarrantyFields = "include_warranty_fields"
|
||||
// FieldIncludePurchaseFields holds the string denoting the include_purchase_fields field in the database.
|
||||
FieldIncludePurchaseFields = "include_purchase_fields"
|
||||
// FieldIncludeSoldFields holds the string denoting the include_sold_fields field in the database.
|
||||
FieldIncludeSoldFields = "include_sold_fields"
|
||||
// FieldDefaultLabelIds holds the string denoting the default_label_ids field in the database.
|
||||
FieldDefaultLabelIds = "default_label_ids"
|
||||
// EdgeGroup holds the string denoting the group edge name in mutations.
|
||||
EdgeGroup = "group"
|
||||
// EdgeFields holds the string denoting the fields edge name in mutations.
|
||||
EdgeFields = "fields"
|
||||
// EdgeLocation holds the string denoting the location edge name in mutations.
|
||||
EdgeLocation = "location"
|
||||
// Table holds the table name of the itemtemplate in the database.
|
||||
Table = "item_templates"
|
||||
// GroupTable is the table that holds the group relation/edge.
|
||||
GroupTable = "item_templates"
|
||||
// GroupInverseTable is the table name for the Group entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "group" package.
|
||||
GroupInverseTable = "groups"
|
||||
// GroupColumn is the table column denoting the group relation/edge.
|
||||
GroupColumn = "group_item_templates"
|
||||
// FieldsTable is the table that holds the fields relation/edge.
|
||||
FieldsTable = "template_fields"
|
||||
// FieldsInverseTable is the table name for the TemplateField entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "templatefield" package.
|
||||
FieldsInverseTable = "template_fields"
|
||||
// FieldsColumn is the table column denoting the fields relation/edge.
|
||||
FieldsColumn = "item_template_fields"
|
||||
// LocationTable is the table that holds the location relation/edge.
|
||||
LocationTable = "item_templates"
|
||||
// LocationInverseTable is the table name for the Location entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "location" package.
|
||||
LocationInverseTable = "locations"
|
||||
// LocationColumn is the table column denoting the location relation/edge.
|
||||
LocationColumn = "item_template_location"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for itemtemplate fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldName,
|
||||
FieldDescription,
|
||||
FieldNotes,
|
||||
FieldDefaultQuantity,
|
||||
FieldDefaultInsured,
|
||||
FieldDefaultName,
|
||||
FieldDefaultDescription,
|
||||
FieldDefaultManufacturer,
|
||||
FieldDefaultModelNumber,
|
||||
FieldDefaultLifetimeWarranty,
|
||||
FieldDefaultWarrantyDetails,
|
||||
FieldIncludeWarrantyFields,
|
||||
FieldIncludePurchaseFields,
|
||||
FieldIncludeSoldFields,
|
||||
FieldDefaultLabelIds,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "item_templates"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"group_item_templates",
|
||||
"item_template_location",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
NameValidator func(string) error
|
||||
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||
DescriptionValidator func(string) error
|
||||
// NotesValidator is a validator for the "notes" field. It is called by the builders before save.
|
||||
NotesValidator func(string) error
|
||||
// DefaultDefaultQuantity holds the default value on creation for the "default_quantity" field.
|
||||
DefaultDefaultQuantity int
|
||||
// DefaultDefaultInsured holds the default value on creation for the "default_insured" field.
|
||||
DefaultDefaultInsured bool
|
||||
// DefaultNameValidator is a validator for the "default_name" field. It is called by the builders before save.
|
||||
DefaultNameValidator func(string) error
|
||||
// DefaultDescriptionValidator is a validator for the "default_description" field. It is called by the builders before save.
|
||||
DefaultDescriptionValidator func(string) error
|
||||
// DefaultManufacturerValidator is a validator for the "default_manufacturer" field. It is called by the builders before save.
|
||||
DefaultManufacturerValidator func(string) error
|
||||
// DefaultModelNumberValidator is a validator for the "default_model_number" field. It is called by the builders before save.
|
||||
DefaultModelNumberValidator func(string) error
|
||||
// DefaultDefaultLifetimeWarranty holds the default value on creation for the "default_lifetime_warranty" field.
|
||||
DefaultDefaultLifetimeWarranty bool
|
||||
// DefaultWarrantyDetailsValidator is a validator for the "default_warranty_details" field. It is called by the builders before save.
|
||||
DefaultWarrantyDetailsValidator func(string) error
|
||||
// DefaultIncludeWarrantyFields holds the default value on creation for the "include_warranty_fields" field.
|
||||
DefaultIncludeWarrantyFields bool
|
||||
// DefaultIncludePurchaseFields holds the default value on creation for the "include_purchase_fields" field.
|
||||
DefaultIncludePurchaseFields bool
|
||||
// DefaultIncludeSoldFields holds the default value on creation for the "include_sold_fields" field.
|
||||
DefaultIncludeSoldFields bool
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the ItemTemplate queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDescription orders the results by the description field.
|
||||
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDescription, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNotes orders the results by the notes field.
|
||||
func ByNotes(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNotes, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultQuantity orders the results by the default_quantity field.
|
||||
func ByDefaultQuantity(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultQuantity, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultInsured orders the results by the default_insured field.
|
||||
func ByDefaultInsured(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultInsured, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultName orders the results by the default_name field.
|
||||
func ByDefaultName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultDescription orders the results by the default_description field.
|
||||
func ByDefaultDescription(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultDescription, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultManufacturer orders the results by the default_manufacturer field.
|
||||
func ByDefaultManufacturer(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultManufacturer, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultModelNumber orders the results by the default_model_number field.
|
||||
func ByDefaultModelNumber(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultModelNumber, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultLifetimeWarranty orders the results by the default_lifetime_warranty field.
|
||||
func ByDefaultLifetimeWarranty(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultLifetimeWarranty, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDefaultWarrantyDetails orders the results by the default_warranty_details field.
|
||||
func ByDefaultWarrantyDetails(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDefaultWarrantyDetails, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIncludeWarrantyFields orders the results by the include_warranty_fields field.
|
||||
func ByIncludeWarrantyFields(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIncludeWarrantyFields, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIncludePurchaseFields orders the results by the include_purchase_fields field.
|
||||
func ByIncludePurchaseFields(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIncludePurchaseFields, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIncludeSoldFields orders the results by the include_sold_fields field.
|
||||
func ByIncludeSoldFields(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIncludeSoldFields, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByGroupField orders the results by group field.
|
||||
func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
|
||||
// ByFieldsCount orders the results by fields count.
|
||||
func ByFieldsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newFieldsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByFields orders the results by fields terms.
|
||||
func ByFields(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newFieldsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByLocationField orders the results by location field.
|
||||
func ByLocationField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newLocationStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newGroupStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(GroupInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
|
||||
)
|
||||
}
|
||||
func newFieldsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(FieldsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, FieldsTable, FieldsColumn),
|
||||
)
|
||||
}
|
||||
func newLocationStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(LocationInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, false, LocationTable, LocationColumn),
|
||||
)
|
||||
}
|
||||
991
backend/internal/data/ent/itemtemplate/where.go
generated
Normal file
991
backend/internal/data/ent/itemtemplate/where.go
generated
Normal file
@@ -0,0 +1,991 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package itemtemplate
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
|
||||
func Description(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// Notes applies equality check predicate on the "notes" field. It's identical to NotesEQ.
|
||||
func Notes(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldNotes, v))
|
||||
}
|
||||
|
||||
// DefaultQuantity applies equality check predicate on the "default_quantity" field. It's identical to DefaultQuantityEQ.
|
||||
func DefaultQuantity(v int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultQuantity, v))
|
||||
}
|
||||
|
||||
// DefaultInsured applies equality check predicate on the "default_insured" field. It's identical to DefaultInsuredEQ.
|
||||
func DefaultInsured(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultInsured, v))
|
||||
}
|
||||
|
||||
// DefaultName applies equality check predicate on the "default_name" field. It's identical to DefaultNameEQ.
|
||||
func DefaultName(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultDescription applies equality check predicate on the "default_description" field. It's identical to DefaultDescriptionEQ.
|
||||
func DefaultDescription(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturer applies equality check predicate on the "default_manufacturer" field. It's identical to DefaultManufacturerEQ.
|
||||
func DefaultManufacturer(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumber applies equality check predicate on the "default_model_number" field. It's identical to DefaultModelNumberEQ.
|
||||
func DefaultModelNumber(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultLifetimeWarranty applies equality check predicate on the "default_lifetime_warranty" field. It's identical to DefaultLifetimeWarrantyEQ.
|
||||
func DefaultLifetimeWarranty(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultLifetimeWarranty, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetails applies equality check predicate on the "default_warranty_details" field. It's identical to DefaultWarrantyDetailsEQ.
|
||||
func DefaultWarrantyDetails(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// IncludeWarrantyFields applies equality check predicate on the "include_warranty_fields" field. It's identical to IncludeWarrantyFieldsEQ.
|
||||
func IncludeWarrantyFields(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeWarrantyFields, v))
|
||||
}
|
||||
|
||||
// IncludePurchaseFields applies equality check predicate on the "include_purchase_fields" field. It's identical to IncludePurchaseFieldsEQ.
|
||||
func IncludePurchaseFields(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldIncludePurchaseFields, v))
|
||||
}
|
||||
|
||||
// IncludeSoldFields applies equality check predicate on the "include_sold_fields" field. It's identical to IncludeSoldFieldsEQ.
|
||||
func IncludeSoldFields(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeSoldFields, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// DescriptionEQ applies the EQ predicate on the "description" field.
|
||||
func DescriptionEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionNEQ applies the NEQ predicate on the "description" field.
|
||||
func DescriptionNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIn applies the In predicate on the "description" field.
|
||||
func DescriptionIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionNotIn applies the NotIn predicate on the "description" field.
|
||||
func DescriptionNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionGT applies the GT predicate on the "description" field.
|
||||
func DescriptionGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionGTE applies the GTE predicate on the "description" field.
|
||||
func DescriptionGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLT applies the LT predicate on the "description" field.
|
||||
func DescriptionLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLTE applies the LTE predicate on the "description" field.
|
||||
func DescriptionLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContains applies the Contains predicate on the "description" field.
|
||||
func DescriptionContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
|
||||
func DescriptionHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
|
||||
func DescriptionHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIsNil applies the IsNil predicate on the "description" field.
|
||||
func DescriptionIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionNotNil applies the NotNil predicate on the "description" field.
|
||||
func DescriptionNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
|
||||
func DescriptionEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
|
||||
func DescriptionContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// NotesEQ applies the EQ predicate on the "notes" field.
|
||||
func NotesEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesNEQ applies the NEQ predicate on the "notes" field.
|
||||
func NotesNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesIn applies the In predicate on the "notes" field.
|
||||
func NotesIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldNotes, vs...))
|
||||
}
|
||||
|
||||
// NotesNotIn applies the NotIn predicate on the "notes" field.
|
||||
func NotesNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldNotes, vs...))
|
||||
}
|
||||
|
||||
// NotesGT applies the GT predicate on the "notes" field.
|
||||
func NotesGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesGTE applies the GTE predicate on the "notes" field.
|
||||
func NotesGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesLT applies the LT predicate on the "notes" field.
|
||||
func NotesLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesLTE applies the LTE predicate on the "notes" field.
|
||||
func NotesLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesContains applies the Contains predicate on the "notes" field.
|
||||
func NotesContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesHasPrefix applies the HasPrefix predicate on the "notes" field.
|
||||
func NotesHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesHasSuffix applies the HasSuffix predicate on the "notes" field.
|
||||
func NotesHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesIsNil applies the IsNil predicate on the "notes" field.
|
||||
func NotesIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldNotes))
|
||||
}
|
||||
|
||||
// NotesNotNil applies the NotNil predicate on the "notes" field.
|
||||
func NotesNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldNotes))
|
||||
}
|
||||
|
||||
// NotesEqualFold applies the EqualFold predicate on the "notes" field.
|
||||
func NotesEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldNotes, v))
|
||||
}
|
||||
|
||||
// NotesContainsFold applies the ContainsFold predicate on the "notes" field.
|
||||
func NotesContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldNotes, v))
|
||||
}
|
||||
|
||||
// DefaultQuantityEQ applies the EQ predicate on the "default_quantity" field.
|
||||
func DefaultQuantityEQ(v int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultQuantity, v))
|
||||
}
|
||||
|
||||
// DefaultQuantityNEQ applies the NEQ predicate on the "default_quantity" field.
|
||||
func DefaultQuantityNEQ(v int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultQuantity, v))
|
||||
}
|
||||
|
||||
// DefaultQuantityIn applies the In predicate on the "default_quantity" field.
|
||||
func DefaultQuantityIn(vs ...int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldDefaultQuantity, vs...))
|
||||
}
|
||||
|
||||
// DefaultQuantityNotIn applies the NotIn predicate on the "default_quantity" field.
|
||||
func DefaultQuantityNotIn(vs ...int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultQuantity, vs...))
|
||||
}
|
||||
|
||||
// DefaultQuantityGT applies the GT predicate on the "default_quantity" field.
|
||||
func DefaultQuantityGT(v int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldDefaultQuantity, v))
|
||||
}
|
||||
|
||||
// DefaultQuantityGTE applies the GTE predicate on the "default_quantity" field.
|
||||
func DefaultQuantityGTE(v int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultQuantity, v))
|
||||
}
|
||||
|
||||
// DefaultQuantityLT applies the LT predicate on the "default_quantity" field.
|
||||
func DefaultQuantityLT(v int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldDefaultQuantity, v))
|
||||
}
|
||||
|
||||
// DefaultQuantityLTE applies the LTE predicate on the "default_quantity" field.
|
||||
func DefaultQuantityLTE(v int) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultQuantity, v))
|
||||
}
|
||||
|
||||
// DefaultInsuredEQ applies the EQ predicate on the "default_insured" field.
|
||||
func DefaultInsuredEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultInsured, v))
|
||||
}
|
||||
|
||||
// DefaultInsuredNEQ applies the NEQ predicate on the "default_insured" field.
|
||||
func DefaultInsuredNEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultInsured, v))
|
||||
}
|
||||
|
||||
// DefaultNameEQ applies the EQ predicate on the "default_name" field.
|
||||
func DefaultNameEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameNEQ applies the NEQ predicate on the "default_name" field.
|
||||
func DefaultNameNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameIn applies the In predicate on the "default_name" field.
|
||||
func DefaultNameIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldDefaultName, vs...))
|
||||
}
|
||||
|
||||
// DefaultNameNotIn applies the NotIn predicate on the "default_name" field.
|
||||
func DefaultNameNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultName, vs...))
|
||||
}
|
||||
|
||||
// DefaultNameGT applies the GT predicate on the "default_name" field.
|
||||
func DefaultNameGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameGTE applies the GTE predicate on the "default_name" field.
|
||||
func DefaultNameGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameLT applies the LT predicate on the "default_name" field.
|
||||
func DefaultNameLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameLTE applies the LTE predicate on the "default_name" field.
|
||||
func DefaultNameLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameContains applies the Contains predicate on the "default_name" field.
|
||||
func DefaultNameContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameHasPrefix applies the HasPrefix predicate on the "default_name" field.
|
||||
func DefaultNameHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameHasSuffix applies the HasSuffix predicate on the "default_name" field.
|
||||
func DefaultNameHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameIsNil applies the IsNil predicate on the "default_name" field.
|
||||
func DefaultNameIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultName))
|
||||
}
|
||||
|
||||
// DefaultNameNotNil applies the NotNil predicate on the "default_name" field.
|
||||
func DefaultNameNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultName))
|
||||
}
|
||||
|
||||
// DefaultNameEqualFold applies the EqualFold predicate on the "default_name" field.
|
||||
func DefaultNameEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultNameContainsFold applies the ContainsFold predicate on the "default_name" field.
|
||||
func DefaultNameContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultName, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionEQ applies the EQ predicate on the "default_description" field.
|
||||
func DefaultDescriptionEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionNEQ applies the NEQ predicate on the "default_description" field.
|
||||
func DefaultDescriptionNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionIn applies the In predicate on the "default_description" field.
|
||||
func DefaultDescriptionIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldDefaultDescription, vs...))
|
||||
}
|
||||
|
||||
// DefaultDescriptionNotIn applies the NotIn predicate on the "default_description" field.
|
||||
func DefaultDescriptionNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultDescription, vs...))
|
||||
}
|
||||
|
||||
// DefaultDescriptionGT applies the GT predicate on the "default_description" field.
|
||||
func DefaultDescriptionGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionGTE applies the GTE predicate on the "default_description" field.
|
||||
func DefaultDescriptionGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionLT applies the LT predicate on the "default_description" field.
|
||||
func DefaultDescriptionLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionLTE applies the LTE predicate on the "default_description" field.
|
||||
func DefaultDescriptionLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionContains applies the Contains predicate on the "default_description" field.
|
||||
func DefaultDescriptionContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionHasPrefix applies the HasPrefix predicate on the "default_description" field.
|
||||
func DefaultDescriptionHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionHasSuffix applies the HasSuffix predicate on the "default_description" field.
|
||||
func DefaultDescriptionHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionIsNil applies the IsNil predicate on the "default_description" field.
|
||||
func DefaultDescriptionIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultDescription))
|
||||
}
|
||||
|
||||
// DefaultDescriptionNotNil applies the NotNil predicate on the "default_description" field.
|
||||
func DefaultDescriptionNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultDescription))
|
||||
}
|
||||
|
||||
// DefaultDescriptionEqualFold applies the EqualFold predicate on the "default_description" field.
|
||||
func DefaultDescriptionEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultDescriptionContainsFold applies the ContainsFold predicate on the "default_description" field.
|
||||
func DefaultDescriptionContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultDescription, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerEQ applies the EQ predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerNEQ applies the NEQ predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerIn applies the In predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldDefaultManufacturer, vs...))
|
||||
}
|
||||
|
||||
// DefaultManufacturerNotIn applies the NotIn predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultManufacturer, vs...))
|
||||
}
|
||||
|
||||
// DefaultManufacturerGT applies the GT predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerGTE applies the GTE predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerLT applies the LT predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerLTE applies the LTE predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerContains applies the Contains predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerHasPrefix applies the HasPrefix predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerHasSuffix applies the HasSuffix predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerIsNil applies the IsNil predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultManufacturer))
|
||||
}
|
||||
|
||||
// DefaultManufacturerNotNil applies the NotNil predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultManufacturer))
|
||||
}
|
||||
|
||||
// DefaultManufacturerEqualFold applies the EqualFold predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultManufacturerContainsFold applies the ContainsFold predicate on the "default_manufacturer" field.
|
||||
func DefaultManufacturerContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultManufacturer, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberEQ applies the EQ predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberNEQ applies the NEQ predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberIn applies the In predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldDefaultModelNumber, vs...))
|
||||
}
|
||||
|
||||
// DefaultModelNumberNotIn applies the NotIn predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultModelNumber, vs...))
|
||||
}
|
||||
|
||||
// DefaultModelNumberGT applies the GT predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberGTE applies the GTE predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberLT applies the LT predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberLTE applies the LTE predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberContains applies the Contains predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberHasPrefix applies the HasPrefix predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberHasSuffix applies the HasSuffix predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberIsNil applies the IsNil predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultModelNumber))
|
||||
}
|
||||
|
||||
// DefaultModelNumberNotNil applies the NotNil predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultModelNumber))
|
||||
}
|
||||
|
||||
// DefaultModelNumberEqualFold applies the EqualFold predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultModelNumberContainsFold applies the ContainsFold predicate on the "default_model_number" field.
|
||||
func DefaultModelNumberContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultModelNumber, v))
|
||||
}
|
||||
|
||||
// DefaultLifetimeWarrantyEQ applies the EQ predicate on the "default_lifetime_warranty" field.
|
||||
func DefaultLifetimeWarrantyEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultLifetimeWarranty, v))
|
||||
}
|
||||
|
||||
// DefaultLifetimeWarrantyNEQ applies the NEQ predicate on the "default_lifetime_warranty" field.
|
||||
func DefaultLifetimeWarrantyNEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultLifetimeWarranty, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsEQ applies the EQ predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsNEQ applies the NEQ predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsNEQ(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsIn applies the In predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIn(FieldDefaultWarrantyDetails, vs...))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsNotIn applies the NotIn predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsNotIn(vs ...string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotIn(FieldDefaultWarrantyDetails, vs...))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsGT applies the GT predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsGT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGT(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsGTE applies the GTE predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsGTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldGTE(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsLT applies the LT predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsLT(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLT(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsLTE applies the LTE predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsLTE(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldLTE(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsContains applies the Contains predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsContains(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContains(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsHasPrefix applies the HasPrefix predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsHasPrefix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasPrefix(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsHasSuffix applies the HasSuffix predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsHasSuffix(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldHasSuffix(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsIsNil applies the IsNil predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultWarrantyDetails))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsNotNil applies the NotNil predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultWarrantyDetails))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsEqualFold applies the EqualFold predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsEqualFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEqualFold(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// DefaultWarrantyDetailsContainsFold applies the ContainsFold predicate on the "default_warranty_details" field.
|
||||
func DefaultWarrantyDetailsContainsFold(v string) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldContainsFold(FieldDefaultWarrantyDetails, v))
|
||||
}
|
||||
|
||||
// IncludeWarrantyFieldsEQ applies the EQ predicate on the "include_warranty_fields" field.
|
||||
func IncludeWarrantyFieldsEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeWarrantyFields, v))
|
||||
}
|
||||
|
||||
// IncludeWarrantyFieldsNEQ applies the NEQ predicate on the "include_warranty_fields" field.
|
||||
func IncludeWarrantyFieldsNEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludeWarrantyFields, v))
|
||||
}
|
||||
|
||||
// IncludePurchaseFieldsEQ applies the EQ predicate on the "include_purchase_fields" field.
|
||||
func IncludePurchaseFieldsEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldIncludePurchaseFields, v))
|
||||
}
|
||||
|
||||
// IncludePurchaseFieldsNEQ applies the NEQ predicate on the "include_purchase_fields" field.
|
||||
func IncludePurchaseFieldsNEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludePurchaseFields, v))
|
||||
}
|
||||
|
||||
// IncludeSoldFieldsEQ applies the EQ predicate on the "include_sold_fields" field.
|
||||
func IncludeSoldFieldsEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldEQ(FieldIncludeSoldFields, v))
|
||||
}
|
||||
|
||||
// IncludeSoldFieldsNEQ applies the NEQ predicate on the "include_sold_fields" field.
|
||||
func IncludeSoldFieldsNEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludeSoldFields, v))
|
||||
}
|
||||
|
||||
// DefaultLabelIdsIsNil applies the IsNil predicate on the "default_label_ids" field.
|
||||
func DefaultLabelIdsIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultLabelIds))
|
||||
}
|
||||
|
||||
// DefaultLabelIdsNotNil applies the NotNil predicate on the "default_label_ids" field.
|
||||
func DefaultLabelIdsNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultLabelIds))
|
||||
}
|
||||
|
||||
// HasGroup applies the HasEdge predicate on the "group" edge.
|
||||
func HasGroup() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
|
||||
func HasGroupWith(preds ...predicate.Group) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(func(s *sql.Selector) {
|
||||
step := newGroupStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasFields applies the HasEdge predicate on the "fields" edge.
|
||||
func HasFields() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, FieldsTable, FieldsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasFieldsWith applies the HasEdge predicate on the "fields" edge with a given conditions (other predicates).
|
||||
func HasFieldsWith(preds ...predicate.TemplateField) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(func(s *sql.Selector) {
|
||||
step := newFieldsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasLocation applies the HasEdge predicate on the "location" edge.
|
||||
func HasLocation() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, false, LocationTable, LocationColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasLocationWith applies the HasEdge predicate on the "location" edge with a given conditions (other predicates).
|
||||
func HasLocationWith(preds ...predicate.Location) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(func(s *sql.Selector) {
|
||||
step := newLocationStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ItemTemplate) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.ItemTemplate) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.ItemTemplate) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.NotPredicates(p))
|
||||
}
|
||||
691
backend/internal/data/ent/itemtemplate_create.go
generated
Normal file
691
backend/internal/data/ent/itemtemplate_create.go
generated
Normal file
@@ -0,0 +1,691 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
// ItemTemplateCreate is the builder for creating a ItemTemplate entity.
|
||||
type ItemTemplateCreate struct {
|
||||
config
|
||||
mutation *ItemTemplateMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *ItemTemplateCreate) SetCreatedAt(v time.Time) *ItemTemplateCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableCreatedAt(v *time.Time) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *ItemTemplateCreate) SetUpdatedAt(v time.Time) *ItemTemplateCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableUpdatedAt(v *time.Time) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_c *ItemTemplateCreate) SetName(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_c *ItemTemplateCreate) SetDescription(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDescription(v *string) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNotes sets the "notes" field.
|
||||
func (_c *ItemTemplateCreate) SetNotes(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetNotes(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableNotes(v *string) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetNotes(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultQuantity sets the "default_quantity" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultQuantity(v int) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultQuantity(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultQuantity sets the "default_quantity" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultQuantity(v *int) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultQuantity(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultInsured sets the "default_insured" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultInsured(v bool) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultInsured(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultInsured sets the "default_insured" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultInsured(v *bool) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultInsured(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultName sets the "default_name" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultName(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultName sets the "default_name" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultName(v *string) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultName(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultDescription sets the "default_description" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultDescription(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultDescription sets the "default_description" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultDescription(v *string) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultDescription(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultManufacturer sets the "default_manufacturer" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultManufacturer(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultManufacturer(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultManufacturer sets the "default_manufacturer" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultManufacturer(v *string) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultManufacturer(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultModelNumber sets the "default_model_number" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultModelNumber(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultModelNumber(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultModelNumber sets the "default_model_number" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultModelNumber(v *string) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultModelNumber(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultLifetimeWarranty sets the "default_lifetime_warranty" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultLifetimeWarranty(v bool) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultLifetimeWarranty(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultLifetimeWarranty sets the "default_lifetime_warranty" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultLifetimeWarranty(v *bool) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultLifetimeWarranty(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultWarrantyDetails sets the "default_warranty_details" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultWarrantyDetails(v string) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultWarrantyDetails(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDefaultWarrantyDetails sets the "default_warranty_details" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableDefaultWarrantyDetails(v *string) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetDefaultWarrantyDetails(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIncludeWarrantyFields sets the "include_warranty_fields" field.
|
||||
func (_c *ItemTemplateCreate) SetIncludeWarrantyFields(v bool) *ItemTemplateCreate {
|
||||
_c.mutation.SetIncludeWarrantyFields(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIncludeWarrantyFields sets the "include_warranty_fields" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableIncludeWarrantyFields(v *bool) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetIncludeWarrantyFields(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIncludePurchaseFields sets the "include_purchase_fields" field.
|
||||
func (_c *ItemTemplateCreate) SetIncludePurchaseFields(v bool) *ItemTemplateCreate {
|
||||
_c.mutation.SetIncludePurchaseFields(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIncludePurchaseFields sets the "include_purchase_fields" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableIncludePurchaseFields(v *bool) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetIncludePurchaseFields(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIncludeSoldFields sets the "include_sold_fields" field.
|
||||
func (_c *ItemTemplateCreate) SetIncludeSoldFields(v bool) *ItemTemplateCreate {
|
||||
_c.mutation.SetIncludeSoldFields(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIncludeSoldFields sets the "include_sold_fields" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableIncludeSoldFields(v *bool) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetIncludeSoldFields(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultLabelIds sets the "default_label_ids" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultLabelIds(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *ItemTemplateCreate) SetID(v uuid.UUID) *ItemTemplateCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableID(v *uuid.UUID) *ItemTemplateCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (_c *ItemTemplateCreate) SetGroupID(id uuid.UUID) *ItemTemplateCreate {
|
||||
_c.mutation.SetGroupID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (_c *ItemTemplateCreate) SetGroup(v *Group) *ItemTemplateCreate {
|
||||
return _c.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddFieldIDs adds the "fields" edge to the TemplateField entity by IDs.
|
||||
func (_c *ItemTemplateCreate) AddFieldIDs(ids ...uuid.UUID) *ItemTemplateCreate {
|
||||
_c.mutation.AddFieldIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddFields adds the "fields" edges to the TemplateField entity.
|
||||
func (_c *ItemTemplateCreate) AddFields(v ...*TemplateField) *ItemTemplateCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddFieldIDs(ids...)
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by ID.
|
||||
func (_c *ItemTemplateCreate) SetLocationID(id uuid.UUID) *ItemTemplateCreate {
|
||||
_c.mutation.SetLocationID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
|
||||
func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateCreate {
|
||||
if id != nil {
|
||||
_c = _c.SetLocationID(*id)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetLocation sets the "location" edge to the Location entity.
|
||||
func (_c *ItemTemplateCreate) SetLocation(v *Location) *ItemTemplateCreate {
|
||||
return _c.SetLocationID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ItemTemplateMutation object of the builder.
|
||||
func (_c *ItemTemplateCreate) Mutation() *ItemTemplateMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the ItemTemplate in the database.
|
||||
func (_c *ItemTemplateCreate) Save(ctx context.Context) (*ItemTemplate, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *ItemTemplateCreate) SaveX(ctx context.Context) *ItemTemplate {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *ItemTemplateCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *ItemTemplateCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *ItemTemplateCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := itemtemplate.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := itemtemplate.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.DefaultQuantity(); !ok {
|
||||
v := itemtemplate.DefaultDefaultQuantity
|
||||
_c.mutation.SetDefaultQuantity(v)
|
||||
}
|
||||
if _, ok := _c.mutation.DefaultInsured(); !ok {
|
||||
v := itemtemplate.DefaultDefaultInsured
|
||||
_c.mutation.SetDefaultInsured(v)
|
||||
}
|
||||
if _, ok := _c.mutation.DefaultLifetimeWarranty(); !ok {
|
||||
v := itemtemplate.DefaultDefaultLifetimeWarranty
|
||||
_c.mutation.SetDefaultLifetimeWarranty(v)
|
||||
}
|
||||
if _, ok := _c.mutation.IncludeWarrantyFields(); !ok {
|
||||
v := itemtemplate.DefaultIncludeWarrantyFields
|
||||
_c.mutation.SetIncludeWarrantyFields(v)
|
||||
}
|
||||
if _, ok := _c.mutation.IncludePurchaseFields(); !ok {
|
||||
v := itemtemplate.DefaultIncludePurchaseFields
|
||||
_c.mutation.SetIncludePurchaseFields(v)
|
||||
}
|
||||
if _, ok := _c.mutation.IncludeSoldFields(); !ok {
|
||||
v := itemtemplate.DefaultIncludeSoldFields
|
||||
_c.mutation.SetIncludeSoldFields(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := itemtemplate.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *ItemTemplateCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ItemTemplate.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ItemTemplate.updated_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ItemTemplate.name"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := itemtemplate.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.Description(); ok {
|
||||
if err := itemtemplate.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.Notes(); ok {
|
||||
if err := itemtemplate.NotesValidator(v); err != nil {
|
||||
return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.notes": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.DefaultQuantity(); !ok {
|
||||
return &ValidationError{Name: "default_quantity", err: errors.New(`ent: missing required field "ItemTemplate.default_quantity"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.DefaultInsured(); !ok {
|
||||
return &ValidationError{Name: "default_insured", err: errors.New(`ent: missing required field "ItemTemplate.default_insured"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.DefaultName(); ok {
|
||||
if err := itemtemplate.DefaultNameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "default_name", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.DefaultDescription(); ok {
|
||||
if err := itemtemplate.DefaultDescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "default_description", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.DefaultManufacturer(); ok {
|
||||
if err := itemtemplate.DefaultManufacturerValidator(v); err != nil {
|
||||
return &ValidationError{Name: "default_manufacturer", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_manufacturer": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.DefaultModelNumber(); ok {
|
||||
if err := itemtemplate.DefaultModelNumberValidator(v); err != nil {
|
||||
return &ValidationError{Name: "default_model_number", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_model_number": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.DefaultLifetimeWarranty(); !ok {
|
||||
return &ValidationError{Name: "default_lifetime_warranty", err: errors.New(`ent: missing required field "ItemTemplate.default_lifetime_warranty"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.DefaultWarrantyDetails(); ok {
|
||||
if err := itemtemplate.DefaultWarrantyDetailsValidator(v); err != nil {
|
||||
return &ValidationError{Name: "default_warranty_details", err: fmt.Errorf(`ent: validator failed for field "ItemTemplate.default_warranty_details": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.IncludeWarrantyFields(); !ok {
|
||||
return &ValidationError{Name: "include_warranty_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_warranty_fields"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.IncludePurchaseFields(); !ok {
|
||||
return &ValidationError{Name: "include_purchase_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_purchase_fields"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.IncludeSoldFields(); !ok {
|
||||
return &ValidationError{Name: "include_sold_fields", err: errors.New(`ent: missing required field "ItemTemplate.include_sold_fields"`)}
|
||||
}
|
||||
if len(_c.mutation.GroupIDs()) == 0 {
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "ItemTemplate.group"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *ItemTemplateCreate) sqlSave(ctx context.Context) (*ItemTemplate, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *ItemTemplateCreate) createSpec() (*ItemTemplate, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &ItemTemplate{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(itemtemplate.Table, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(itemtemplate.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(itemtemplate.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(itemtemplate.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := _c.mutation.Notes(); ok {
|
||||
_spec.SetField(itemtemplate.FieldNotes, field.TypeString, value)
|
||||
_node.Notes = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultQuantity(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultQuantity, field.TypeInt, value)
|
||||
_node.DefaultQuantity = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultInsured(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultInsured, field.TypeBool, value)
|
||||
_node.DefaultInsured = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultName(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultName, field.TypeString, value)
|
||||
_node.DefaultName = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultDescription(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultDescription, field.TypeString, value)
|
||||
_node.DefaultDescription = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultManufacturer(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultManufacturer, field.TypeString, value)
|
||||
_node.DefaultManufacturer = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultModelNumber(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultModelNumber, field.TypeString, value)
|
||||
_node.DefaultModelNumber = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultLifetimeWarranty(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultLifetimeWarranty, field.TypeBool, value)
|
||||
_node.DefaultLifetimeWarranty = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultWarrantyDetails(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultWarrantyDetails, field.TypeString, value)
|
||||
_node.DefaultWarrantyDetails = value
|
||||
}
|
||||
if value, ok := _c.mutation.IncludeWarrantyFields(); ok {
|
||||
_spec.SetField(itemtemplate.FieldIncludeWarrantyFields, field.TypeBool, value)
|
||||
_node.IncludeWarrantyFields = value
|
||||
}
|
||||
if value, ok := _c.mutation.IncludePurchaseFields(); ok {
|
||||
_spec.SetField(itemtemplate.FieldIncludePurchaseFields, field.TypeBool, value)
|
||||
_node.IncludePurchaseFields = value
|
||||
}
|
||||
if value, ok := _c.mutation.IncludeSoldFields(); ok {
|
||||
_spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value)
|
||||
_node.IncludeSoldFields = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultLabelIds(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value)
|
||||
_node.DefaultLabelIds = value
|
||||
}
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: itemtemplate.GroupTable,
|
||||
Columns: []string{itemtemplate.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.group_item_templates = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.FieldsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: itemtemplate.FieldsTable,
|
||||
Columns: []string{itemtemplate.FieldsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.LocationIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: false,
|
||||
Table: itemtemplate.LocationTable,
|
||||
Columns: []string{itemtemplate.LocationColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.item_template_location = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// ItemTemplateCreateBulk is the builder for creating many ItemTemplate entities in bulk.
|
||||
type ItemTemplateCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*ItemTemplateCreate
|
||||
}
|
||||
|
||||
// Save creates the ItemTemplate entities in the database.
|
||||
func (_c *ItemTemplateCreateBulk) Save(ctx context.Context) ([]*ItemTemplate, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*ItemTemplate, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ItemTemplateMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *ItemTemplateCreateBulk) SaveX(ctx context.Context) []*ItemTemplate {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *ItemTemplateCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *ItemTemplateCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/itemtemplate_delete.go
generated
Normal file
88
backend/internal/data/ent/itemtemplate_delete.go
generated
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// ItemTemplateDelete is the builder for deleting a ItemTemplate entity.
|
||||
type ItemTemplateDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ItemTemplateMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ItemTemplateDelete builder.
|
||||
func (_d *ItemTemplateDelete) Where(ps ...predicate.ItemTemplate) *ItemTemplateDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *ItemTemplateDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *ItemTemplateDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *ItemTemplateDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(itemtemplate.Table, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ItemTemplateDeleteOne is the builder for deleting a single ItemTemplate entity.
|
||||
type ItemTemplateDeleteOne struct {
|
||||
_d *ItemTemplateDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ItemTemplateDelete builder.
|
||||
func (_d *ItemTemplateDeleteOne) Where(ps ...predicate.ItemTemplate) *ItemTemplateDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *ItemTemplateDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{itemtemplate.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *ItemTemplateDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
766
backend/internal/data/ent/itemtemplate_query.go
generated
Normal file
766
backend/internal/data/ent/itemtemplate_query.go
generated
Normal file
@@ -0,0 +1,766 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
// ItemTemplateQuery is the builder for querying ItemTemplate entities.
|
||||
type ItemTemplateQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []itemtemplate.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ItemTemplate
|
||||
withGroup *GroupQuery
|
||||
withFields *TemplateFieldQuery
|
||||
withLocation *LocationQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the ItemTemplateQuery builder.
|
||||
func (_q *ItemTemplateQuery) Where(ps ...predicate.ItemTemplate) *ItemTemplateQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *ItemTemplateQuery) Limit(limit int) *ItemTemplateQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *ItemTemplateQuery) Offset(offset int) *ItemTemplateQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *ItemTemplateQuery) Unique(unique bool) *ItemTemplateQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *ItemTemplateQuery) Order(o ...itemtemplate.OrderOption) *ItemTemplateQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryGroup chains the current query on the "group" edge.
|
||||
func (_q *ItemTemplateQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, itemtemplate.GroupTable, itemtemplate.GroupColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryFields chains the current query on the "fields" edge.
|
||||
func (_q *ItemTemplateQuery) QueryFields() *TemplateFieldQuery {
|
||||
query := (&TemplateFieldClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
|
||||
sqlgraph.To(templatefield.Table, templatefield.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, itemtemplate.FieldsTable, itemtemplate.FieldsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLocation chains the current query on the "location" edge.
|
||||
func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery {
|
||||
query := (&LocationClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
|
||||
sqlgraph.To(location.Table, location.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first ItemTemplate entity from the query.
|
||||
// Returns a *NotFoundError when no ItemTemplate was found.
|
||||
func (_q *ItemTemplateQuery) First(ctx context.Context) (*ItemTemplate, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{itemtemplate.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) FirstX(ctx context.Context) *ItemTemplate {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first ItemTemplate ID from the query.
|
||||
// Returns a *NotFoundError when no ItemTemplate ID was found.
|
||||
func (_q *ItemTemplateQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{itemtemplate.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single ItemTemplate entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one ItemTemplate entity is found.
|
||||
// Returns a *NotFoundError when no ItemTemplate entities are found.
|
||||
func (_q *ItemTemplateQuery) Only(ctx context.Context) (*ItemTemplate, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{itemtemplate.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{itemtemplate.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) OnlyX(ctx context.Context) *ItemTemplate {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only ItemTemplate ID in the query.
|
||||
// Returns a *NotSingularError when more than one ItemTemplate ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *ItemTemplateQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{itemtemplate.Label}
|
||||
default:
|
||||
err = &NotSingularError{itemtemplate.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of ItemTemplates.
|
||||
func (_q *ItemTemplateQuery) All(ctx context.Context) ([]*ItemTemplate, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*ItemTemplate, *ItemTemplateQuery]()
|
||||
return withInterceptors[[]*ItemTemplate](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) AllX(ctx context.Context) []*ItemTemplate {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of ItemTemplate IDs.
|
||||
func (_q *ItemTemplateQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(itemtemplate.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *ItemTemplateQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*ItemTemplateQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *ItemTemplateQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *ItemTemplateQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the ItemTemplateQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *ItemTemplateQuery) Clone() *ItemTemplateQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &ItemTemplateQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]itemtemplate.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.ItemTemplate{}, _q.predicates...),
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
withFields: _q.withFields.Clone(),
|
||||
withLocation: _q.withLocation.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ItemTemplateQuery) WithGroup(opts ...func(*GroupQuery)) *ItemTemplateQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withGroup = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithFields tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "fields" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ItemTemplateQuery) WithFields(opts ...func(*TemplateFieldQuery)) *ItemTemplateQuery {
|
||||
query := (&TemplateFieldClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withFields = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithLocation tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "location" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ItemTemplateQuery) WithLocation(opts ...func(*LocationQuery)) *ItemTemplateQuery {
|
||||
query := (&LocationClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withLocation = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ItemTemplate.Query().
|
||||
// GroupBy(itemtemplate.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ItemTemplateQuery) GroupBy(field string, fields ...string) *ItemTemplateGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &ItemTemplateGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = itemtemplate.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ItemTemplate.Query().
|
||||
// Select(itemtemplate.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ItemTemplateQuery) Select(fields ...string) *ItemTemplateSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &ItemTemplateSelect{ItemTemplateQuery: _q}
|
||||
sbuild.label = itemtemplate.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a ItemTemplateSelect configured with the given aggregations.
|
||||
func (_q *ItemTemplateQuery) Aggregate(fns ...AggregateFunc) *ItemTemplateSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *ItemTemplateQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !itemtemplate.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *ItemTemplateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ItemTemplate, error) {
|
||||
var (
|
||||
nodes = []*ItemTemplate{}
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [3]bool{
|
||||
_q.withGroup != nil,
|
||||
_q.withFields != nil,
|
||||
_q.withLocation != nil,
|
||||
}
|
||||
)
|
||||
if _q.withGroup != nil || _q.withLocation != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ItemTemplate).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ItemTemplate{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withGroup; query != nil {
|
||||
if err := _q.loadGroup(ctx, query, nodes, nil,
|
||||
func(n *ItemTemplate, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withFields; query != nil {
|
||||
if err := _q.loadFields(ctx, query, nodes,
|
||||
func(n *ItemTemplate) { n.Edges.Fields = []*TemplateField{} },
|
||||
func(n *ItemTemplate, e *TemplateField) { n.Edges.Fields = append(n.Edges.Fields, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withLocation; query != nil {
|
||||
if err := _q.loadLocation(ctx, query, nodes, nil,
|
||||
func(n *ItemTemplate, e *Location) { n.Edges.Location = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *ItemTemplateQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Group)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*ItemTemplate)
|
||||
for i := range nodes {
|
||||
if nodes[i].group_item_templates == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].group_item_templates
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(group.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "group_item_templates" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *ItemTemplateQuery) loadFields(ctx context.Context, query *TemplateFieldQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *TemplateField)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*ItemTemplate)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.TemplateField(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(itemtemplate.FieldsColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.item_template_fields
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "item_template_fields" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "item_template_fields" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Location)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*ItemTemplate)
|
||||
for i := range nodes {
|
||||
if nodes[i].item_template_location == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].item_template_location
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(location.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "item_template_location" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *ItemTemplateQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *ItemTemplateQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(itemtemplate.Table, itemtemplate.Columns, sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, itemtemplate.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != itemtemplate.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *ItemTemplateQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(itemtemplate.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = itemtemplate.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// ItemTemplateGroupBy is the group-by builder for ItemTemplate entities.
|
||||
type ItemTemplateGroupBy struct {
|
||||
selector
|
||||
build *ItemTemplateQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *ItemTemplateGroupBy) Aggregate(fns ...AggregateFunc) *ItemTemplateGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *ItemTemplateGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ItemTemplateQuery, *ItemTemplateGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *ItemTemplateGroupBy) sqlScan(ctx context.Context, root *ItemTemplateQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// ItemTemplateSelect is the builder for selecting fields of ItemTemplate entities.
|
||||
type ItemTemplateSelect struct {
|
||||
*ItemTemplateQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *ItemTemplateSelect) Aggregate(fns ...AggregateFunc) *ItemTemplateSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *ItemTemplateSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ItemTemplateQuery, *ItemTemplateSelect](ctx, _s.ItemTemplateQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *ItemTemplateSelect) sqlScan(ctx context.Context, root *ItemTemplateQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
1361
backend/internal/data/ent/itemtemplate_update.go
generated
Normal file
1361
backend/internal/data/ent/itemtemplate_update.go
generated
Normal file
File diff suppressed because it is too large
Load Diff
80
backend/internal/data/ent/migrate/schema.go
generated
80
backend/internal/data/ent/migrate/schema.go
generated
@@ -246,6 +246,56 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// ItemTemplatesColumns holds the columns for the "item_templates" table.
|
||||
ItemTemplatesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "default_quantity", Type: field.TypeInt, Default: 1},
|
||||
{Name: "default_insured", Type: field.TypeBool, Default: false},
|
||||
{Name: "default_name", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "default_description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "default_manufacturer", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "default_model_number", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "default_lifetime_warranty", Type: field.TypeBool, Default: false},
|
||||
{Name: "default_warranty_details", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "include_warranty_fields", Type: field.TypeBool, Default: false},
|
||||
{Name: "include_purchase_fields", Type: field.TypeBool, Default: false},
|
||||
{Name: "include_sold_fields", Type: field.TypeBool, Default: false},
|
||||
{Name: "default_label_ids", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "group_item_templates", Type: field.TypeUUID},
|
||||
{Name: "item_template_location", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// ItemTemplatesTable holds the schema information for the "item_templates" table.
|
||||
ItemTemplatesTable = &schema.Table{
|
||||
Name: "item_templates",
|
||||
Columns: ItemTemplatesColumns,
|
||||
PrimaryKey: []*schema.Column{ItemTemplatesColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "item_templates_groups_item_templates",
|
||||
Columns: []*schema.Column{ItemTemplatesColumns[18]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "item_templates_locations_location",
|
||||
Columns: []*schema.Column{ItemTemplatesColumns[19]},
|
||||
RefColumns: []*schema.Column{LocationsColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "itemtemplate_name",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ItemTemplatesColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// LabelsColumns holds the columns for the "labels" table.
|
||||
LabelsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
@@ -379,6 +429,31 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// TemplateFieldsColumns holds the columns for the "template_fields" table.
|
||||
TemplateFieldsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "type", Type: field.TypeEnum, Enums: []string{"text"}},
|
||||
{Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500},
|
||||
{Name: "item_template_fields", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// TemplateFieldsTable holds the schema information for the "template_fields" table.
|
||||
TemplateFieldsTable = &schema.Table{
|
||||
Name: "template_fields",
|
||||
Columns: TemplateFieldsColumns,
|
||||
PrimaryKey: []*schema.Column{TemplateFieldsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "template_fields_item_templates_fields",
|
||||
Columns: []*schema.Column{TemplateFieldsColumns[7]},
|
||||
RefColumns: []*schema.Column{ItemTemplatesColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// UsersColumns holds the columns for the "users" table.
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
@@ -450,10 +525,12 @@ var (
|
||||
GroupInvitationTokensTable,
|
||||
ItemsTable,
|
||||
ItemFieldsTable,
|
||||
ItemTemplatesTable,
|
||||
LabelsTable,
|
||||
LocationsTable,
|
||||
MaintenanceEntriesTable,
|
||||
NotifiersTable,
|
||||
TemplateFieldsTable,
|
||||
UsersTable,
|
||||
LabelItemsTable,
|
||||
}
|
||||
@@ -469,12 +546,15 @@ func init() {
|
||||
ItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||
ItemsTable.ForeignKeys[2].RefTable = LocationsTable
|
||||
ItemFieldsTable.ForeignKeys[0].RefTable = ItemsTable
|
||||
ItemTemplatesTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
ItemTemplatesTable.ForeignKeys[1].RefTable = LocationsTable
|
||||
LabelsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
|
||||
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
|
||||
NotifiersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
NotifiersTable.ForeignKeys[1].RefTable = UsersTable
|
||||
TemplateFieldsTable.ForeignKeys[0].RefTable = ItemTemplatesTable
|
||||
UsersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
|
||||
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||
|
||||
2418
backend/internal/data/ent/mutation.go
generated
2418
backend/internal/data/ent/mutation.go
generated
File diff suppressed because it is too large
Load Diff
6
backend/internal/data/ent/predicate/predicate.go
generated
6
backend/internal/data/ent/predicate/predicate.go
generated
@@ -27,6 +27,9 @@ type Item func(*sql.Selector)
|
||||
// ItemField is the predicate function for itemfield builders.
|
||||
type ItemField func(*sql.Selector)
|
||||
|
||||
// ItemTemplate is the predicate function for itemtemplate builders.
|
||||
type ItemTemplate func(*sql.Selector)
|
||||
|
||||
// Label is the predicate function for label builders.
|
||||
type Label func(*sql.Selector)
|
||||
|
||||
@@ -39,5 +42,8 @@ type MaintenanceEntry func(*sql.Selector)
|
||||
// Notifier is the predicate function for notifier builders.
|
||||
type Notifier func(*sql.Selector)
|
||||
|
||||
// TemplateField is the predicate function for templatefield builders.
|
||||
type TemplateField func(*sql.Selector)
|
||||
|
||||
// User is the predicate function for user builders.
|
||||
type User func(*sql.Selector)
|
||||
|
||||
140
backend/internal/data/ent/runtime.go
generated
140
backend/internal/data/ent/runtime.go
generated
@@ -12,11 +12,13 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
|
||||
@@ -310,6 +312,97 @@ func init() {
|
||||
itemfieldDescID := itemfieldMixinFields0[0].Descriptor()
|
||||
// itemfield.DefaultID holds the default value on creation for the id field.
|
||||
itemfield.DefaultID = itemfieldDescID.Default.(func() uuid.UUID)
|
||||
itemtemplateMixin := schema.ItemTemplate{}.Mixin()
|
||||
itemtemplateMixinFields0 := itemtemplateMixin[0].Fields()
|
||||
_ = itemtemplateMixinFields0
|
||||
itemtemplateMixinFields1 := itemtemplateMixin[1].Fields()
|
||||
_ = itemtemplateMixinFields1
|
||||
itemtemplateFields := schema.ItemTemplate{}.Fields()
|
||||
_ = itemtemplateFields
|
||||
// itemtemplateDescCreatedAt is the schema descriptor for created_at field.
|
||||
itemtemplateDescCreatedAt := itemtemplateMixinFields0[1].Descriptor()
|
||||
// itemtemplate.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
itemtemplate.DefaultCreatedAt = itemtemplateDescCreatedAt.Default.(func() time.Time)
|
||||
// itemtemplateDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
itemtemplateDescUpdatedAt := itemtemplateMixinFields0[2].Descriptor()
|
||||
// itemtemplate.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
itemtemplate.DefaultUpdatedAt = itemtemplateDescUpdatedAt.Default.(func() time.Time)
|
||||
// itemtemplate.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
itemtemplate.UpdateDefaultUpdatedAt = itemtemplateDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// itemtemplateDescName is the schema descriptor for name field.
|
||||
itemtemplateDescName := itemtemplateMixinFields1[0].Descriptor()
|
||||
// itemtemplate.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
itemtemplate.NameValidator = func() func(string) error {
|
||||
validators := itemtemplateDescName.Validators
|
||||
fns := [...]func(string) error{
|
||||
validators[0].(func(string) error),
|
||||
validators[1].(func(string) error),
|
||||
}
|
||||
return func(name string) error {
|
||||
for _, fn := range fns {
|
||||
if err := fn(name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// itemtemplateDescDescription is the schema descriptor for description field.
|
||||
itemtemplateDescDescription := itemtemplateMixinFields1[1].Descriptor()
|
||||
// itemtemplate.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||
itemtemplate.DescriptionValidator = itemtemplateDescDescription.Validators[0].(func(string) error)
|
||||
// itemtemplateDescNotes is the schema descriptor for notes field.
|
||||
itemtemplateDescNotes := itemtemplateFields[0].Descriptor()
|
||||
// itemtemplate.NotesValidator is a validator for the "notes" field. It is called by the builders before save.
|
||||
itemtemplate.NotesValidator = itemtemplateDescNotes.Validators[0].(func(string) error)
|
||||
// itemtemplateDescDefaultQuantity is the schema descriptor for default_quantity field.
|
||||
itemtemplateDescDefaultQuantity := itemtemplateFields[1].Descriptor()
|
||||
// itemtemplate.DefaultDefaultQuantity holds the default value on creation for the default_quantity field.
|
||||
itemtemplate.DefaultDefaultQuantity = itemtemplateDescDefaultQuantity.Default.(int)
|
||||
// itemtemplateDescDefaultInsured is the schema descriptor for default_insured field.
|
||||
itemtemplateDescDefaultInsured := itemtemplateFields[2].Descriptor()
|
||||
// itemtemplate.DefaultDefaultInsured holds the default value on creation for the default_insured field.
|
||||
itemtemplate.DefaultDefaultInsured = itemtemplateDescDefaultInsured.Default.(bool)
|
||||
// itemtemplateDescDefaultName is the schema descriptor for default_name field.
|
||||
itemtemplateDescDefaultName := itemtemplateFields[3].Descriptor()
|
||||
// itemtemplate.DefaultNameValidator is a validator for the "default_name" field. It is called by the builders before save.
|
||||
itemtemplate.DefaultNameValidator = itemtemplateDescDefaultName.Validators[0].(func(string) error)
|
||||
// itemtemplateDescDefaultDescription is the schema descriptor for default_description field.
|
||||
itemtemplateDescDefaultDescription := itemtemplateFields[4].Descriptor()
|
||||
// itemtemplate.DefaultDescriptionValidator is a validator for the "default_description" field. It is called by the builders before save.
|
||||
itemtemplate.DefaultDescriptionValidator = itemtemplateDescDefaultDescription.Validators[0].(func(string) error)
|
||||
// itemtemplateDescDefaultManufacturer is the schema descriptor for default_manufacturer field.
|
||||
itemtemplateDescDefaultManufacturer := itemtemplateFields[5].Descriptor()
|
||||
// itemtemplate.DefaultManufacturerValidator is a validator for the "default_manufacturer" field. It is called by the builders before save.
|
||||
itemtemplate.DefaultManufacturerValidator = itemtemplateDescDefaultManufacturer.Validators[0].(func(string) error)
|
||||
// itemtemplateDescDefaultModelNumber is the schema descriptor for default_model_number field.
|
||||
itemtemplateDescDefaultModelNumber := itemtemplateFields[6].Descriptor()
|
||||
// itemtemplate.DefaultModelNumberValidator is a validator for the "default_model_number" field. It is called by the builders before save.
|
||||
itemtemplate.DefaultModelNumberValidator = itemtemplateDescDefaultModelNumber.Validators[0].(func(string) error)
|
||||
// itemtemplateDescDefaultLifetimeWarranty is the schema descriptor for default_lifetime_warranty field.
|
||||
itemtemplateDescDefaultLifetimeWarranty := itemtemplateFields[7].Descriptor()
|
||||
// itemtemplate.DefaultDefaultLifetimeWarranty holds the default value on creation for the default_lifetime_warranty field.
|
||||
itemtemplate.DefaultDefaultLifetimeWarranty = itemtemplateDescDefaultLifetimeWarranty.Default.(bool)
|
||||
// itemtemplateDescDefaultWarrantyDetails is the schema descriptor for default_warranty_details field.
|
||||
itemtemplateDescDefaultWarrantyDetails := itemtemplateFields[8].Descriptor()
|
||||
// itemtemplate.DefaultWarrantyDetailsValidator is a validator for the "default_warranty_details" field. It is called by the builders before save.
|
||||
itemtemplate.DefaultWarrantyDetailsValidator = itemtemplateDescDefaultWarrantyDetails.Validators[0].(func(string) error)
|
||||
// itemtemplateDescIncludeWarrantyFields is the schema descriptor for include_warranty_fields field.
|
||||
itemtemplateDescIncludeWarrantyFields := itemtemplateFields[9].Descriptor()
|
||||
// itemtemplate.DefaultIncludeWarrantyFields holds the default value on creation for the include_warranty_fields field.
|
||||
itemtemplate.DefaultIncludeWarrantyFields = itemtemplateDescIncludeWarrantyFields.Default.(bool)
|
||||
// itemtemplateDescIncludePurchaseFields is the schema descriptor for include_purchase_fields field.
|
||||
itemtemplateDescIncludePurchaseFields := itemtemplateFields[10].Descriptor()
|
||||
// itemtemplate.DefaultIncludePurchaseFields holds the default value on creation for the include_purchase_fields field.
|
||||
itemtemplate.DefaultIncludePurchaseFields = itemtemplateDescIncludePurchaseFields.Default.(bool)
|
||||
// itemtemplateDescIncludeSoldFields is the schema descriptor for include_sold_fields field.
|
||||
itemtemplateDescIncludeSoldFields := itemtemplateFields[11].Descriptor()
|
||||
// itemtemplate.DefaultIncludeSoldFields holds the default value on creation for the include_sold_fields field.
|
||||
itemtemplate.DefaultIncludeSoldFields = itemtemplateDescIncludeSoldFields.Default.(bool)
|
||||
// itemtemplateDescID is the schema descriptor for id field.
|
||||
itemtemplateDescID := itemtemplateMixinFields0[0].Descriptor()
|
||||
// itemtemplate.DefaultID holds the default value on creation for the id field.
|
||||
itemtemplate.DefaultID = itemtemplateDescID.Default.(func() uuid.UUID)
|
||||
labelMixin := schema.Label{}.Mixin()
|
||||
labelMixinFields0 := labelMixin[0].Fields()
|
||||
_ = labelMixinFields0
|
||||
@@ -504,6 +597,53 @@ func init() {
|
||||
notifierDescID := notifierMixinFields0[0].Descriptor()
|
||||
// notifier.DefaultID holds the default value on creation for the id field.
|
||||
notifier.DefaultID = notifierDescID.Default.(func() uuid.UUID)
|
||||
templatefieldMixin := schema.TemplateField{}.Mixin()
|
||||
templatefieldMixinFields0 := templatefieldMixin[0].Fields()
|
||||
_ = templatefieldMixinFields0
|
||||
templatefieldMixinFields1 := templatefieldMixin[1].Fields()
|
||||
_ = templatefieldMixinFields1
|
||||
templatefieldFields := schema.TemplateField{}.Fields()
|
||||
_ = templatefieldFields
|
||||
// templatefieldDescCreatedAt is the schema descriptor for created_at field.
|
||||
templatefieldDescCreatedAt := templatefieldMixinFields0[1].Descriptor()
|
||||
// templatefield.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
templatefield.DefaultCreatedAt = templatefieldDescCreatedAt.Default.(func() time.Time)
|
||||
// templatefieldDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
templatefieldDescUpdatedAt := templatefieldMixinFields0[2].Descriptor()
|
||||
// templatefield.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
templatefield.DefaultUpdatedAt = templatefieldDescUpdatedAt.Default.(func() time.Time)
|
||||
// templatefield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
templatefield.UpdateDefaultUpdatedAt = templatefieldDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// templatefieldDescName is the schema descriptor for name field.
|
||||
templatefieldDescName := templatefieldMixinFields1[0].Descriptor()
|
||||
// templatefield.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
templatefield.NameValidator = func() func(string) error {
|
||||
validators := templatefieldDescName.Validators
|
||||
fns := [...]func(string) error{
|
||||
validators[0].(func(string) error),
|
||||
validators[1].(func(string) error),
|
||||
}
|
||||
return func(name string) error {
|
||||
for _, fn := range fns {
|
||||
if err := fn(name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// templatefieldDescDescription is the schema descriptor for description field.
|
||||
templatefieldDescDescription := templatefieldMixinFields1[1].Descriptor()
|
||||
// templatefield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||
templatefield.DescriptionValidator = templatefieldDescDescription.Validators[0].(func(string) error)
|
||||
// templatefieldDescTextValue is the schema descriptor for text_value field.
|
||||
templatefieldDescTextValue := templatefieldFields[1].Descriptor()
|
||||
// templatefield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
|
||||
templatefield.TextValueValidator = templatefieldDescTextValue.Validators[0].(func(string) error)
|
||||
// templatefieldDescID is the schema descriptor for id field.
|
||||
templatefieldDescID := templatefieldMixinFields0[0].Descriptor()
|
||||
// templatefield.DefaultID holds the default value on creation for the id field.
|
||||
templatefield.DefaultID = templatefieldDescID.Default.(func() uuid.UUID)
|
||||
userMixin := schema.User{}.Mixin()
|
||||
userMixinFields0 := userMixin[0].Fields()
|
||||
_ = userMixinFields0
|
||||
|
||||
@@ -48,6 +48,7 @@ func (Group) Edges() []ent.Edge {
|
||||
owned("labels", Label.Type),
|
||||
owned("invitation_tokens", GroupInvitationToken.Type),
|
||||
owned("notifiers", Notifier.Type),
|
||||
owned("item_templates", ItemTemplate.Type),
|
||||
// $scaffold_edge
|
||||
}
|
||||
}
|
||||
|
||||
111
backend/internal/data/ent/schema/item_template.go
Normal file
111
backend/internal/data/ent/schema/item_template.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// ItemTemplate holds the schema definition for the ItemTemplate entity.
|
||||
type ItemTemplate struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (ItemTemplate) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
mixins.DetailsMixin{},
|
||||
GroupMixin{ref: "item_templates"},
|
||||
}
|
||||
}
|
||||
|
||||
func (ItemTemplate) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("name"),
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the ItemTemplate.
|
||||
func (ItemTemplate) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
// Notes for the template (instructions, hints, etc.)
|
||||
field.String("notes").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
|
||||
// ------------------------------------
|
||||
// Default values for item fields
|
||||
field.Int("default_quantity").
|
||||
Default(1),
|
||||
field.Bool("default_insured").
|
||||
Default(false),
|
||||
|
||||
// ------------------------------------
|
||||
// Default item name/description (templates for item identity)
|
||||
field.String("default_name").
|
||||
MaxLen(255).
|
||||
Optional().
|
||||
Comment("Default name template for items (can use placeholders)"),
|
||||
field.Text("default_description").
|
||||
MaxLen(1000).
|
||||
Optional().
|
||||
Comment("Default description for items created from this template"),
|
||||
|
||||
// ------------------------------------
|
||||
// Default item identification
|
||||
field.String("default_manufacturer").
|
||||
MaxLen(255).
|
||||
Optional(),
|
||||
field.String("default_model_number").
|
||||
MaxLen(255).
|
||||
Optional().
|
||||
Comment("Default model number for items created from this template"),
|
||||
|
||||
// ------------------------------------
|
||||
// Default warranty settings
|
||||
field.Bool("default_lifetime_warranty").
|
||||
Default(false),
|
||||
field.Text("default_warranty_details").
|
||||
MaxLen(1000).
|
||||
Optional(),
|
||||
|
||||
// ------------------------------------
|
||||
// Template metadata
|
||||
field.Bool("include_warranty_fields").
|
||||
Default(false).
|
||||
Comment("Whether to include warranty fields in items created from this template"),
|
||||
field.Bool("include_purchase_fields").
|
||||
Default(false).
|
||||
Comment("Whether to include purchase fields in items created from this template"),
|
||||
field.Bool("include_sold_fields").
|
||||
Default(false).
|
||||
Comment("Whether to include sold fields in items created from this template"),
|
||||
|
||||
// ------------------------------------
|
||||
// Default labels (stored as JSON array of UUIDs to allow reuse across templates)
|
||||
field.JSON("default_label_ids", []uuid.UUID{}).
|
||||
Optional().
|
||||
Comment("Default label IDs for items created from this template"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the ItemTemplate.
|
||||
func (ItemTemplate) Edges() []ent.Edge {
|
||||
owned := func(s string, t any) ent.Edge {
|
||||
return edge.To(s, t).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
})
|
||||
}
|
||||
|
||||
return []ent.Edge{
|
||||
owned("fields", TemplateField.Type),
|
||||
// Default location for items created from this template
|
||||
edge.To("location", Location.Type).
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
41
backend/internal/data/ent/schema/template_field.go
Normal file
41
backend/internal/data/ent/schema/template_field.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// TemplateField holds the schema definition for the TemplateField entity.
|
||||
// Template fields define custom fields that will be added to items created from a template.
|
||||
type TemplateField struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (TemplateField) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
mixins.DetailsMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the TemplateField.
|
||||
func (TemplateField) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Enum("type").
|
||||
Values("text"),
|
||||
field.String("text_value").
|
||||
MaxLen(500).
|
||||
Optional(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the TemplateField.
|
||||
func (TemplateField) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("item_template", ItemTemplate.Type).
|
||||
Ref("fields").
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
201
backend/internal/data/ent/templatefield.go
generated
Normal file
201
backend/internal/data/ent/templatefield.go
generated
Normal file
@@ -0,0 +1,201 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
// TemplateField is the model entity for the TemplateField schema.
|
||||
type TemplateField struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Description holds the value of the "description" field.
|
||||
Description string `json:"description,omitempty"`
|
||||
// Type holds the value of the "type" field.
|
||||
Type templatefield.Type `json:"type,omitempty"`
|
||||
// TextValue holds the value of the "text_value" field.
|
||||
TextValue string `json:"text_value,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the TemplateFieldQuery when eager-loading is set.
|
||||
Edges TemplateFieldEdges `json:"edges"`
|
||||
item_template_fields *uuid.UUID
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// TemplateFieldEdges holds the relations/edges for other nodes in the graph.
|
||||
type TemplateFieldEdges struct {
|
||||
// ItemTemplate holds the value of the item_template edge.
|
||||
ItemTemplate *ItemTemplate `json:"item_template,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// ItemTemplateOrErr returns the ItemTemplate value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e TemplateFieldEdges) ItemTemplateOrErr() (*ItemTemplate, error) {
|
||||
if e.ItemTemplate != nil {
|
||||
return e.ItemTemplate, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: itemtemplate.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "item_template"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*TemplateField) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case templatefield.FieldName, templatefield.FieldDescription, templatefield.FieldType, templatefield.FieldTextValue:
|
||||
values[i] = new(sql.NullString)
|
||||
case templatefield.FieldCreatedAt, templatefield.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case templatefield.FieldID:
|
||||
values[i] = new(uuid.UUID)
|
||||
case templatefield.ForeignKeys[0]: // item_template_fields
|
||||
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the TemplateField fields.
|
||||
func (_m *TemplateField) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case templatefield.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case templatefield.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case templatefield.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case templatefield.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Name = value.String
|
||||
}
|
||||
case templatefield.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Description = value.String
|
||||
}
|
||||
case templatefield.FieldType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Type = templatefield.Type(value.String)
|
||||
}
|
||||
case templatefield.FieldTextValue:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field text_value", values[i])
|
||||
} else if value.Valid {
|
||||
_m.TextValue = value.String
|
||||
}
|
||||
case templatefield.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field item_template_fields", values[i])
|
||||
} else if value.Valid {
|
||||
_m.item_template_fields = new(uuid.UUID)
|
||||
*_m.item_template_fields = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the TemplateField.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *TemplateField) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryItemTemplate queries the "item_template" edge of the TemplateField entity.
|
||||
func (_m *TemplateField) QueryItemTemplate() *ItemTemplateQuery {
|
||||
return NewTemplateFieldClient(_m.config).QueryItemTemplate(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this TemplateField.
|
||||
// Note that you need to call TemplateField.Unwrap() before calling this method if this TemplateField
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *TemplateField) Update() *TemplateFieldUpdateOne {
|
||||
return NewTemplateFieldClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the TemplateField entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *TemplateField) Unwrap() *TemplateField {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: TemplateField is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *TemplateField) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("TemplateField(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(_m.Description)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Type))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("text_value=")
|
||||
builder.WriteString(_m.TextValue)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// TemplateFields is a parsable slice of TemplateField.
|
||||
type TemplateFields []*TemplateField
|
||||
165
backend/internal/data/ent/templatefield/templatefield.go
generated
Normal file
165
backend/internal/data/ent/templatefield/templatefield.go
generated
Normal file
@@ -0,0 +1,165 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package templatefield
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the templatefield type in the database.
|
||||
Label = "template_field"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldDescription holds the string denoting the description field in the database.
|
||||
FieldDescription = "description"
|
||||
// FieldType holds the string denoting the type field in the database.
|
||||
FieldType = "type"
|
||||
// FieldTextValue holds the string denoting the text_value field in the database.
|
||||
FieldTextValue = "text_value"
|
||||
// EdgeItemTemplate holds the string denoting the item_template edge name in mutations.
|
||||
EdgeItemTemplate = "item_template"
|
||||
// Table holds the table name of the templatefield in the database.
|
||||
Table = "template_fields"
|
||||
// ItemTemplateTable is the table that holds the item_template relation/edge.
|
||||
ItemTemplateTable = "template_fields"
|
||||
// ItemTemplateInverseTable is the table name for the ItemTemplate entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "itemtemplate" package.
|
||||
ItemTemplateInverseTable = "item_templates"
|
||||
// ItemTemplateColumn is the table column denoting the item_template relation/edge.
|
||||
ItemTemplateColumn = "item_template_fields"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for templatefield fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldName,
|
||||
FieldDescription,
|
||||
FieldType,
|
||||
FieldTextValue,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "template_fields"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"item_template_fields",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
NameValidator func(string) error
|
||||
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||
DescriptionValidator func(string) error
|
||||
// TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
|
||||
TextValueValidator func(string) error
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// Type defines the type for the "type" enum field.
|
||||
type Type string
|
||||
|
||||
// Type values.
|
||||
const (
|
||||
TypeText Type = "text"
|
||||
)
|
||||
|
||||
func (_type Type) String() string {
|
||||
return string(_type)
|
||||
}
|
||||
|
||||
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
|
||||
func TypeValidator(_type Type) error {
|
||||
switch _type {
|
||||
case TypeText:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("templatefield: invalid enum value for type field: %q", _type)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the TemplateField queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDescription orders the results by the description field.
|
||||
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDescription, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByType orders the results by the type field.
|
||||
func ByType(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldType, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTextValue orders the results by the text_value field.
|
||||
func ByTextValue(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTextValue, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByItemTemplateField orders the results by item_template field.
|
||||
func ByItemTemplateField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newItemTemplateStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newItemTemplateStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ItemTemplateInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ItemTemplateTable, ItemTemplateColumn),
|
||||
)
|
||||
}
|
||||
435
backend/internal/data/ent/templatefield/where.go
generated
Normal file
435
backend/internal/data/ent/templatefield/where.go
generated
Normal file
@@ -0,0 +1,435 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package templatefield
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
|
||||
func Description(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// TextValue applies equality check predicate on the "text_value" field. It's identical to TextValueEQ.
|
||||
func TextValue(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// DescriptionEQ applies the EQ predicate on the "description" field.
|
||||
func DescriptionEQ(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionNEQ applies the NEQ predicate on the "description" field.
|
||||
func DescriptionNEQ(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIn applies the In predicate on the "description" field.
|
||||
func DescriptionIn(vs ...string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionNotIn applies the NotIn predicate on the "description" field.
|
||||
func DescriptionNotIn(vs ...string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionGT applies the GT predicate on the "description" field.
|
||||
func DescriptionGT(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionGTE applies the GTE predicate on the "description" field.
|
||||
func DescriptionGTE(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLT applies the LT predicate on the "description" field.
|
||||
func DescriptionLT(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLTE applies the LTE predicate on the "description" field.
|
||||
func DescriptionLTE(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContains applies the Contains predicate on the "description" field.
|
||||
func DescriptionContains(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldContains(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
|
||||
func DescriptionHasPrefix(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldHasPrefix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
|
||||
func DescriptionHasSuffix(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldHasSuffix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIsNil applies the IsNil predicate on the "description" field.
|
||||
func DescriptionIsNil() predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIsNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionNotNil applies the NotNil predicate on the "description" field.
|
||||
func DescriptionNotNil() predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
|
||||
func DescriptionEqualFold(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEqualFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
|
||||
func DescriptionContainsFold(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldContainsFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// TypeEQ applies the EQ predicate on the "type" field.
|
||||
func TypeEQ(v Type) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeNEQ applies the NEQ predicate on the "type" field.
|
||||
func TypeNEQ(v Type) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeIn applies the In predicate on the "type" field.
|
||||
func TypeIn(vs ...Type) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// TypeNotIn applies the NotIn predicate on the "type" field.
|
||||
func TypeNotIn(vs ...Type) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// TextValueEQ applies the EQ predicate on the "text_value" field.
|
||||
func TextValueEQ(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEQ(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueNEQ applies the NEQ predicate on the "text_value" field.
|
||||
func TextValueNEQ(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNEQ(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueIn applies the In predicate on the "text_value" field.
|
||||
func TextValueIn(vs ...string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIn(FieldTextValue, vs...))
|
||||
}
|
||||
|
||||
// TextValueNotIn applies the NotIn predicate on the "text_value" field.
|
||||
func TextValueNotIn(vs ...string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotIn(FieldTextValue, vs...))
|
||||
}
|
||||
|
||||
// TextValueGT applies the GT predicate on the "text_value" field.
|
||||
func TextValueGT(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGT(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueGTE applies the GTE predicate on the "text_value" field.
|
||||
func TextValueGTE(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldGTE(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueLT applies the LT predicate on the "text_value" field.
|
||||
func TextValueLT(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLT(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueLTE applies the LTE predicate on the "text_value" field.
|
||||
func TextValueLTE(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldLTE(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueContains applies the Contains predicate on the "text_value" field.
|
||||
func TextValueContains(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldContains(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueHasPrefix applies the HasPrefix predicate on the "text_value" field.
|
||||
func TextValueHasPrefix(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldHasPrefix(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueHasSuffix applies the HasSuffix predicate on the "text_value" field.
|
||||
func TextValueHasSuffix(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldHasSuffix(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueIsNil applies the IsNil predicate on the "text_value" field.
|
||||
func TextValueIsNil() predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldIsNull(FieldTextValue))
|
||||
}
|
||||
|
||||
// TextValueNotNil applies the NotNil predicate on the "text_value" field.
|
||||
func TextValueNotNil() predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldNotNull(FieldTextValue))
|
||||
}
|
||||
|
||||
// TextValueEqualFold applies the EqualFold predicate on the "text_value" field.
|
||||
func TextValueEqualFold(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldEqualFold(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// TextValueContainsFold applies the ContainsFold predicate on the "text_value" field.
|
||||
func TextValueContainsFold(v string) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.FieldContainsFold(FieldTextValue, v))
|
||||
}
|
||||
|
||||
// HasItemTemplate applies the HasEdge predicate on the "item_template" edge.
|
||||
func HasItemTemplate() predicate.TemplateField {
|
||||
return predicate.TemplateField(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ItemTemplateTable, ItemTemplateColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasItemTemplateWith applies the HasEdge predicate on the "item_template" edge with a given conditions (other predicates).
|
||||
func HasItemTemplateWith(preds ...predicate.ItemTemplate) predicate.TemplateField {
|
||||
return predicate.TemplateField(func(s *sql.Selector) {
|
||||
step := newItemTemplateStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.TemplateField) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.TemplateField) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.TemplateField) predicate.TemplateField {
|
||||
return predicate.TemplateField(sql.NotPredicates(p))
|
||||
}
|
||||
370
backend/internal/data/ent/templatefield_create.go
generated
Normal file
370
backend/internal/data/ent/templatefield_create.go
generated
Normal file
@@ -0,0 +1,370 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
// TemplateFieldCreate is the builder for creating a TemplateField entity.
|
||||
type TemplateFieldCreate struct {
|
||||
config
|
||||
mutation *TemplateFieldMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *TemplateFieldCreate) SetCreatedAt(v time.Time) *TemplateFieldCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *TemplateFieldCreate) SetNillableCreatedAt(v *time.Time) *TemplateFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *TemplateFieldCreate) SetUpdatedAt(v time.Time) *TemplateFieldCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *TemplateFieldCreate) SetNillableUpdatedAt(v *time.Time) *TemplateFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_c *TemplateFieldCreate) SetName(v string) *TemplateFieldCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_c *TemplateFieldCreate) SetDescription(v string) *TemplateFieldCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_c *TemplateFieldCreate) SetNillableDescription(v *string) *TemplateFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (_c *TemplateFieldCreate) SetType(v templatefield.Type) *TemplateFieldCreate {
|
||||
_c.mutation.SetType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTextValue sets the "text_value" field.
|
||||
func (_c *TemplateFieldCreate) SetTextValue(v string) *TemplateFieldCreate {
|
||||
_c.mutation.SetTextValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
|
||||
func (_c *TemplateFieldCreate) SetNillableTextValue(v *string) *TemplateFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetTextValue(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *TemplateFieldCreate) SetID(v uuid.UUID) *TemplateFieldCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *TemplateFieldCreate) SetNillableID(v *uuid.UUID) *TemplateFieldCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID.
|
||||
func (_c *TemplateFieldCreate) SetItemTemplateID(id uuid.UUID) *TemplateFieldCreate {
|
||||
_c.mutation.SetItemTemplateID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil.
|
||||
func (_c *TemplateFieldCreate) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldCreate {
|
||||
if id != nil {
|
||||
_c = _c.SetItemTemplateID(*id)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity.
|
||||
func (_c *TemplateFieldCreate) SetItemTemplate(v *ItemTemplate) *TemplateFieldCreate {
|
||||
return _c.SetItemTemplateID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the TemplateFieldMutation object of the builder.
|
||||
func (_c *TemplateFieldCreate) Mutation() *TemplateFieldMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the TemplateField in the database.
|
||||
func (_c *TemplateFieldCreate) Save(ctx context.Context) (*TemplateField, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *TemplateFieldCreate) SaveX(ctx context.Context) *TemplateField {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *TemplateFieldCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *TemplateFieldCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *TemplateFieldCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := templatefield.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := templatefield.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := templatefield.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *TemplateFieldCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "TemplateField.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "TemplateField.updated_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "TemplateField.name"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := templatefield.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.Description(); ok {
|
||||
if err := templatefield.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.GetType(); !ok {
|
||||
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "TemplateField.type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.GetType(); ok {
|
||||
if err := templatefield.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.TextValue(); ok {
|
||||
if err := templatefield.TextValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *TemplateFieldCreate) sqlSave(ctx context.Context) (*TemplateField, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *TemplateFieldCreate) createSpec() (*TemplateField, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &TemplateField{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(templatefield.Table, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(templatefield.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(templatefield.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(templatefield.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := _c.mutation.GetType(); ok {
|
||||
_spec.SetField(templatefield.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if value, ok := _c.mutation.TextValue(); ok {
|
||||
_spec.SetField(templatefield.FieldTextValue, field.TypeString, value)
|
||||
_node.TextValue = value
|
||||
}
|
||||
if nodes := _c.mutation.ItemTemplateIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: templatefield.ItemTemplateTable,
|
||||
Columns: []string{templatefield.ItemTemplateColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.item_template_fields = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// TemplateFieldCreateBulk is the builder for creating many TemplateField entities in bulk.
|
||||
type TemplateFieldCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*TemplateFieldCreate
|
||||
}
|
||||
|
||||
// Save creates the TemplateField entities in the database.
|
||||
func (_c *TemplateFieldCreateBulk) Save(ctx context.Context) ([]*TemplateField, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*TemplateField, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*TemplateFieldMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *TemplateFieldCreateBulk) SaveX(ctx context.Context) []*TemplateField {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *TemplateFieldCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *TemplateFieldCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/templatefield_delete.go
generated
Normal file
88
backend/internal/data/ent/templatefield_delete.go
generated
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
// TemplateFieldDelete is the builder for deleting a TemplateField entity.
|
||||
type TemplateFieldDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *TemplateFieldMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TemplateFieldDelete builder.
|
||||
func (_d *TemplateFieldDelete) Where(ps ...predicate.TemplateField) *TemplateFieldDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *TemplateFieldDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *TemplateFieldDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *TemplateFieldDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(templatefield.Table, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// TemplateFieldDeleteOne is the builder for deleting a single TemplateField entity.
|
||||
type TemplateFieldDeleteOne struct {
|
||||
_d *TemplateFieldDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TemplateFieldDelete builder.
|
||||
func (_d *TemplateFieldDeleteOne) Where(ps ...predicate.TemplateField) *TemplateFieldDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *TemplateFieldDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{templatefield.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *TemplateFieldDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
615
backend/internal/data/ent/templatefield_query.go
generated
Normal file
615
backend/internal/data/ent/templatefield_query.go
generated
Normal file
@@ -0,0 +1,615 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
// TemplateFieldQuery is the builder for querying TemplateField entities.
|
||||
type TemplateFieldQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []templatefield.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.TemplateField
|
||||
withItemTemplate *ItemTemplateQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the TemplateFieldQuery builder.
|
||||
func (_q *TemplateFieldQuery) Where(ps ...predicate.TemplateField) *TemplateFieldQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *TemplateFieldQuery) Limit(limit int) *TemplateFieldQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *TemplateFieldQuery) Offset(offset int) *TemplateFieldQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *TemplateFieldQuery) Unique(unique bool) *TemplateFieldQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *TemplateFieldQuery) Order(o ...templatefield.OrderOption) *TemplateFieldQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryItemTemplate chains the current query on the "item_template" edge.
|
||||
func (_q *TemplateFieldQuery) QueryItemTemplate() *ItemTemplateQuery {
|
||||
query := (&ItemTemplateClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(templatefield.Table, templatefield.FieldID, selector),
|
||||
sqlgraph.To(itemtemplate.Table, itemtemplate.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, templatefield.ItemTemplateTable, templatefield.ItemTemplateColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first TemplateField entity from the query.
|
||||
// Returns a *NotFoundError when no TemplateField was found.
|
||||
func (_q *TemplateFieldQuery) First(ctx context.Context) (*TemplateField, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{templatefield.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) FirstX(ctx context.Context) *TemplateField {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first TemplateField ID from the query.
|
||||
// Returns a *NotFoundError when no TemplateField ID was found.
|
||||
func (_q *TemplateFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{templatefield.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single TemplateField entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one TemplateField entity is found.
|
||||
// Returns a *NotFoundError when no TemplateField entities are found.
|
||||
func (_q *TemplateFieldQuery) Only(ctx context.Context) (*TemplateField, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{templatefield.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{templatefield.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) OnlyX(ctx context.Context) *TemplateField {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only TemplateField ID in the query.
|
||||
// Returns a *NotSingularError when more than one TemplateField ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *TemplateFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{templatefield.Label}
|
||||
default:
|
||||
err = &NotSingularError{templatefield.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of TemplateFields.
|
||||
func (_q *TemplateFieldQuery) All(ctx context.Context) ([]*TemplateField, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*TemplateField, *TemplateFieldQuery]()
|
||||
return withInterceptors[[]*TemplateField](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) AllX(ctx context.Context) []*TemplateField {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of TemplateField IDs.
|
||||
func (_q *TemplateFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(templatefield.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *TemplateFieldQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*TemplateFieldQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *TemplateFieldQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *TemplateFieldQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the TemplateFieldQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *TemplateFieldQuery) Clone() *TemplateFieldQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &TemplateFieldQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]templatefield.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.TemplateField{}, _q.predicates...),
|
||||
withItemTemplate: _q.withItemTemplate.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithItemTemplate tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "item_template" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *TemplateFieldQuery) WithItemTemplate(opts ...func(*ItemTemplateQuery)) *TemplateFieldQuery {
|
||||
query := (&ItemTemplateClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withItemTemplate = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.TemplateField.Query().
|
||||
// GroupBy(templatefield.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *TemplateFieldQuery) GroupBy(field string, fields ...string) *TemplateFieldGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &TemplateFieldGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = templatefield.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.TemplateField.Query().
|
||||
// Select(templatefield.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *TemplateFieldQuery) Select(fields ...string) *TemplateFieldSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &TemplateFieldSelect{TemplateFieldQuery: _q}
|
||||
sbuild.label = templatefield.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a TemplateFieldSelect configured with the given aggregations.
|
||||
func (_q *TemplateFieldQuery) Aggregate(fns ...AggregateFunc) *TemplateFieldSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *TemplateFieldQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !templatefield.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *TemplateFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*TemplateField, error) {
|
||||
var (
|
||||
nodes = []*TemplateField{}
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
_q.withItemTemplate != nil,
|
||||
}
|
||||
)
|
||||
if _q.withItemTemplate != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, templatefield.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*TemplateField).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &TemplateField{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withItemTemplate; query != nil {
|
||||
if err := _q.loadItemTemplate(ctx, query, nodes, nil,
|
||||
func(n *TemplateField, e *ItemTemplate) { n.Edges.ItemTemplate = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *TemplateFieldQuery) loadItemTemplate(ctx context.Context, query *ItemTemplateQuery, nodes []*TemplateField, init func(*TemplateField), assign func(*TemplateField, *ItemTemplate)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*TemplateField)
|
||||
for i := range nodes {
|
||||
if nodes[i].item_template_fields == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].item_template_fields
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(itemtemplate.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "item_template_fields" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *TemplateFieldQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *TemplateFieldQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, templatefield.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != templatefield.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *TemplateFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(templatefield.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = templatefield.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// TemplateFieldGroupBy is the group-by builder for TemplateField entities.
|
||||
type TemplateFieldGroupBy struct {
|
||||
selector
|
||||
build *TemplateFieldQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *TemplateFieldGroupBy) Aggregate(fns ...AggregateFunc) *TemplateFieldGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *TemplateFieldGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*TemplateFieldQuery, *TemplateFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *TemplateFieldGroupBy) sqlScan(ctx context.Context, root *TemplateFieldQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// TemplateFieldSelect is the builder for selecting fields of TemplateField entities.
|
||||
type TemplateFieldSelect struct {
|
||||
*TemplateFieldQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *TemplateFieldSelect) Aggregate(fns ...AggregateFunc) *TemplateFieldSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *TemplateFieldSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*TemplateFieldQuery, *TemplateFieldSelect](ctx, _s.TemplateFieldQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *TemplateFieldSelect) sqlScan(ctx context.Context, root *TemplateFieldQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
550
backend/internal/data/ent/templatefield_update.go
generated
Normal file
550
backend/internal/data/ent/templatefield_update.go
generated
Normal file
@@ -0,0 +1,550 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
// TemplateFieldUpdate is the builder for updating TemplateField entities.
|
||||
type TemplateFieldUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *TemplateFieldMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TemplateFieldUpdate builder.
|
||||
func (_u *TemplateFieldUpdate) Where(ps ...predicate.TemplateField) *TemplateFieldUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *TemplateFieldUpdate) SetUpdatedAt(v time.Time) *TemplateFieldUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *TemplateFieldUpdate) SetName(v string) *TemplateFieldUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdate) SetNillableName(v *string) *TemplateFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_u *TemplateFieldUpdate) SetDescription(v string) *TemplateFieldUpdate {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdate) SetNillableDescription(v *string) *TemplateFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (_u *TemplateFieldUpdate) ClearDescription() *TemplateFieldUpdate {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (_u *TemplateFieldUpdate) SetType(v templatefield.Type) *TemplateFieldUpdate {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdate) SetNillableType(v *templatefield.Type) *TemplateFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTextValue sets the "text_value" field.
|
||||
func (_u *TemplateFieldUpdate) SetTextValue(v string) *TemplateFieldUpdate {
|
||||
_u.mutation.SetTextValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdate) SetNillableTextValue(v *string) *TemplateFieldUpdate {
|
||||
if v != nil {
|
||||
_u.SetTextValue(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearTextValue clears the value of the "text_value" field.
|
||||
func (_u *TemplateFieldUpdate) ClearTextValue() *TemplateFieldUpdate {
|
||||
_u.mutation.ClearTextValue()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID.
|
||||
func (_u *TemplateFieldUpdate) SetItemTemplateID(id uuid.UUID) *TemplateFieldUpdate {
|
||||
_u.mutation.SetItemTemplateID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdate) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldUpdate {
|
||||
if id != nil {
|
||||
_u = _u.SetItemTemplateID(*id)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity.
|
||||
func (_u *TemplateFieldUpdate) SetItemTemplate(v *ItemTemplate) *TemplateFieldUpdate {
|
||||
return _u.SetItemTemplateID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the TemplateFieldMutation object of the builder.
|
||||
func (_u *TemplateFieldUpdate) Mutation() *TemplateFieldMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity.
|
||||
func (_u *TemplateFieldUpdate) ClearItemTemplate() *TemplateFieldUpdate {
|
||||
_u.mutation.ClearItemTemplate()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *TemplateFieldUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *TemplateFieldUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *TemplateFieldUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *TemplateFieldUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *TemplateFieldUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := templatefield.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *TemplateFieldUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := templatefield.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := templatefield.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := templatefield.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.TextValue(); ok {
|
||||
if err := templatefield.TextValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *TemplateFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(templatefield.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(templatefield.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(templatefield.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(templatefield.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TextValue(); ok {
|
||||
_spec.SetField(templatefield.FieldTextValue, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.TextValueCleared() {
|
||||
_spec.ClearField(templatefield.FieldTextValue, field.TypeString)
|
||||
}
|
||||
if _u.mutation.ItemTemplateCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: templatefield.ItemTemplateTable,
|
||||
Columns: []string{templatefield.ItemTemplateColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ItemTemplateIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: templatefield.ItemTemplateTable,
|
||||
Columns: []string{templatefield.ItemTemplateColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{templatefield.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// TemplateFieldUpdateOne is the builder for updating a single TemplateField entity.
|
||||
type TemplateFieldUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *TemplateFieldMutation
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *TemplateFieldUpdateOne) SetUpdatedAt(v time.Time) *TemplateFieldUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *TemplateFieldUpdateOne) SetName(v string) *TemplateFieldUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdateOne) SetNillableName(v *string) *TemplateFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_u *TemplateFieldUpdateOne) SetDescription(v string) *TemplateFieldUpdateOne {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdateOne) SetNillableDescription(v *string) *TemplateFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (_u *TemplateFieldUpdateOne) ClearDescription() *TemplateFieldUpdateOne {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (_u *TemplateFieldUpdateOne) SetType(v templatefield.Type) *TemplateFieldUpdateOne {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdateOne) SetNillableType(v *templatefield.Type) *TemplateFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTextValue sets the "text_value" field.
|
||||
func (_u *TemplateFieldUpdateOne) SetTextValue(v string) *TemplateFieldUpdateOne {
|
||||
_u.mutation.SetTextValue(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdateOne) SetNillableTextValue(v *string) *TemplateFieldUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTextValue(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearTextValue clears the value of the "text_value" field.
|
||||
func (_u *TemplateFieldUpdateOne) ClearTextValue() *TemplateFieldUpdateOne {
|
||||
_u.mutation.ClearTextValue()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID.
|
||||
func (_u *TemplateFieldUpdateOne) SetItemTemplateID(id uuid.UUID) *TemplateFieldUpdateOne {
|
||||
_u.mutation.SetItemTemplateID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableItemTemplateID sets the "item_template" edge to the ItemTemplate entity by ID if the given value is not nil.
|
||||
func (_u *TemplateFieldUpdateOne) SetNillableItemTemplateID(id *uuid.UUID) *TemplateFieldUpdateOne {
|
||||
if id != nil {
|
||||
_u = _u.SetItemTemplateID(*id)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetItemTemplate sets the "item_template" edge to the ItemTemplate entity.
|
||||
func (_u *TemplateFieldUpdateOne) SetItemTemplate(v *ItemTemplate) *TemplateFieldUpdateOne {
|
||||
return _u.SetItemTemplateID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the TemplateFieldMutation object of the builder.
|
||||
func (_u *TemplateFieldUpdateOne) Mutation() *TemplateFieldMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearItemTemplate clears the "item_template" edge to the ItemTemplate entity.
|
||||
func (_u *TemplateFieldUpdateOne) ClearItemTemplate() *TemplateFieldUpdateOne {
|
||||
_u.mutation.ClearItemTemplate()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TemplateFieldUpdate builder.
|
||||
func (_u *TemplateFieldUpdateOne) Where(ps ...predicate.TemplateField) *TemplateFieldUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (_u *TemplateFieldUpdateOne) Select(field string, fields ...string) *TemplateFieldUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated TemplateField entity.
|
||||
func (_u *TemplateFieldUpdateOne) Save(ctx context.Context) (*TemplateField, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *TemplateFieldUpdateOne) SaveX(ctx context.Context) *TemplateField {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *TemplateFieldUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *TemplateFieldUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *TemplateFieldUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := templatefield.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *TemplateFieldUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := templatefield.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TemplateField.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := templatefield.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "TemplateField.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := templatefield.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "TemplateField.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.TextValue(); ok {
|
||||
if err := templatefield.TextValueValidator(v); err != nil {
|
||||
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "TemplateField.text_value": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *TemplateFieldUpdateOne) sqlSave(ctx context.Context) (_node *TemplateField, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(templatefield.Table, templatefield.Columns, sqlgraph.NewFieldSpec(templatefield.FieldID, field.TypeUUID))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "TemplateField.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, templatefield.FieldID)
|
||||
for _, f := range fields {
|
||||
if !templatefield.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != templatefield.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(templatefield.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(templatefield.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(templatefield.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(templatefield.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(templatefield.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TextValue(); ok {
|
||||
_spec.SetField(templatefield.FieldTextValue, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.TextValueCleared() {
|
||||
_spec.ClearField(templatefield.FieldTextValue, field.TypeString)
|
||||
}
|
||||
if _u.mutation.ItemTemplateCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: templatefield.ItemTemplateTable,
|
||||
Columns: []string{templatefield.ItemTemplateColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ItemTemplateIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: templatefield.ItemTemplateTable,
|
||||
Columns: []string{templatefield.ItemTemplateColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(itemtemplate.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &TemplateField{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{templatefield.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
6
backend/internal/data/ent/tx.go
generated
6
backend/internal/data/ent/tx.go
generated
@@ -26,6 +26,8 @@ type Tx struct {
|
||||
Item *ItemClient
|
||||
// ItemField is the client for interacting with the ItemField builders.
|
||||
ItemField *ItemFieldClient
|
||||
// ItemTemplate is the client for interacting with the ItemTemplate builders.
|
||||
ItemTemplate *ItemTemplateClient
|
||||
// Label is the client for interacting with the Label builders.
|
||||
Label *LabelClient
|
||||
// Location is the client for interacting with the Location builders.
|
||||
@@ -34,6 +36,8 @@ type Tx struct {
|
||||
MaintenanceEntry *MaintenanceEntryClient
|
||||
// Notifier is the client for interacting with the Notifier builders.
|
||||
Notifier *NotifierClient
|
||||
// TemplateField is the client for interacting with the TemplateField builders.
|
||||
TemplateField *TemplateFieldClient
|
||||
// User is the client for interacting with the User builders.
|
||||
User *UserClient
|
||||
|
||||
@@ -174,10 +178,12 @@ func (tx *Tx) init() {
|
||||
tx.GroupInvitationToken = NewGroupInvitationTokenClient(tx.config)
|
||||
tx.Item = NewItemClient(tx.config)
|
||||
tx.ItemField = NewItemFieldClient(tx.config)
|
||||
tx.ItemTemplate = NewItemTemplateClient(tx.config)
|
||||
tx.Label = NewLabelClient(tx.config)
|
||||
tx.Location = NewLocationClient(tx.config)
|
||||
tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config)
|
||||
tx.Notifier = NewNotifierClient(tx.config)
|
||||
tx.TemplateField = NewTemplateFieldClient(tx.config)
|
||||
tx.User = NewUserClient(tx.config)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
-- +goose Up
|
||||
-- Create "item_templates" table
|
||||
CREATE TABLE IF NOT EXISTS "item_templates" (
|
||||
"id" uuid NOT NULL,
|
||||
"created_at" timestamptz NOT NULL,
|
||||
"updated_at" timestamptz NOT NULL,
|
||||
"name" character varying NOT NULL,
|
||||
"description" character varying NULL,
|
||||
"notes" character varying NULL,
|
||||
"default_quantity" bigint NOT NULL DEFAULT 1,
|
||||
"default_insured" boolean NOT NULL DEFAULT false,
|
||||
"default_name" character varying NULL,
|
||||
"default_description" character varying NULL,
|
||||
"default_manufacturer" character varying NULL,
|
||||
"default_model_number" character varying NULL,
|
||||
"default_lifetime_warranty" boolean NOT NULL DEFAULT false,
|
||||
"default_warranty_details" character varying NULL,
|
||||
"include_warranty_fields" boolean NOT NULL DEFAULT false,
|
||||
"include_purchase_fields" boolean NOT NULL DEFAULT false,
|
||||
"include_sold_fields" boolean NOT NULL DEFAULT false,
|
||||
"default_label_ids" jsonb NULL,
|
||||
"item_template_location" uuid NULL,
|
||||
"group_item_templates" uuid NOT NULL,
|
||||
PRIMARY KEY ("id"),
|
||||
CONSTRAINT "item_templates_groups_item_templates" FOREIGN KEY ("group_item_templates") REFERENCES "groups" ("id") ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT "item_templates_locations_location" FOREIGN KEY ("item_template_location") REFERENCES "locations" ("id") ON UPDATE NO ACTION ON DELETE SET NULL
|
||||
);
|
||||
-- Create "template_fields" table
|
||||
CREATE TABLE IF NOT EXISTS "template_fields" ("id" uuid NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, "name" character varying NOT NULL, "description" character varying NULL, "type" character varying NOT NULL, "text_value" character varying NULL, "item_template_fields" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "template_fields_item_templates_fields" FOREIGN KEY ("item_template_fields") REFERENCES "item_templates" ("id") ON UPDATE NO ACTION ON DELETE CASCADE);
|
||||
@@ -0,0 +1,46 @@
|
||||
-- +goose Up
|
||||
create table if not exists item_templates
|
||||
(
|
||||
id uuid not null
|
||||
primary key,
|
||||
created_at datetime not null,
|
||||
updated_at datetime not null,
|
||||
name text not null,
|
||||
description text,
|
||||
notes text,
|
||||
default_quantity integer default 1 not null,
|
||||
default_insured bool default false not null,
|
||||
default_name text,
|
||||
default_description text,
|
||||
default_manufacturer text,
|
||||
default_model_number text,
|
||||
default_lifetime_warranty bool default false not null,
|
||||
default_warranty_details text,
|
||||
include_warranty_fields bool default false not null,
|
||||
include_purchase_fields bool default false not null,
|
||||
include_sold_fields bool default false not null,
|
||||
default_label_ids json,
|
||||
item_template_location uuid
|
||||
references locations(id)
|
||||
on delete set null,
|
||||
group_item_templates uuid not null
|
||||
constraint item_templates_groups_item_templates
|
||||
references groups
|
||||
on delete cascade
|
||||
);
|
||||
|
||||
create table if not exists template_fields
|
||||
(
|
||||
id uuid not null
|
||||
primary key,
|
||||
created_at datetime not null,
|
||||
updated_at datetime not null,
|
||||
name text not null,
|
||||
description text,
|
||||
type text not null,
|
||||
text_value text,
|
||||
item_template_fields uuid
|
||||
constraint template_fields_item_templates_fields
|
||||
references item_templates
|
||||
on delete cascade
|
||||
);
|
||||
451
backend/internal/data/repo/repo_item_templates.go
Normal file
451
backend/internal/data/repo/repo_item_templates.go
Normal file
@@ -0,0 +1,451 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
type ItemTemplatesRepository struct {
|
||||
db *ent.Client
|
||||
bus *eventbus.EventBus
|
||||
}
|
||||
|
||||
type (
|
||||
TemplateField struct {
|
||||
ID *uuid.UUID `json:"id,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
TextValue string `json:"textValue"`
|
||||
}
|
||||
|
||||
TemplateLabelSummary struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
TemplateLocationSummary struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
ItemTemplateCreate struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
Description string `json:"description" validate:"max=1000"`
|
||||
Notes string `json:"notes" validate:"max=1000"`
|
||||
|
||||
// Default values for items
|
||||
DefaultQuantity *int `json:"defaultQuantity,omitempty" extensions:"x-nullable"`
|
||||
DefaultInsured bool `json:"defaultInsured"`
|
||||
DefaultName *string `json:"defaultName,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
|
||||
DefaultDescription *string `json:"defaultDescription,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
|
||||
DefaultManufacturer *string `json:"defaultManufacturer,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
|
||||
DefaultModelNumber *string `json:"defaultModelNumber,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
|
||||
DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
|
||||
DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
|
||||
|
||||
// Default location and labels
|
||||
DefaultLocationID *uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`
|
||||
DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"`
|
||||
|
||||
// Metadata flags
|
||||
IncludeWarrantyFields bool `json:"includeWarrantyFields"`
|
||||
IncludePurchaseFields bool `json:"includePurchaseFields"`
|
||||
IncludeSoldFields bool `json:"includeSoldFields"`
|
||||
|
||||
// Custom fields
|
||||
Fields []TemplateField `json:"fields"`
|
||||
}
|
||||
|
||||
ItemTemplateUpdate struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
Description string `json:"description" validate:"max=1000"`
|
||||
Notes string `json:"notes" validate:"max=1000"`
|
||||
|
||||
// Default values for items
|
||||
DefaultQuantity *int `json:"defaultQuantity,omitempty" extensions:"x-nullable"`
|
||||
DefaultInsured bool `json:"defaultInsured"`
|
||||
DefaultName *string `json:"defaultName,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
|
||||
DefaultDescription *string `json:"defaultDescription,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
|
||||
DefaultManufacturer *string `json:"defaultManufacturer,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
|
||||
DefaultModelNumber *string `json:"defaultModelNumber,omitempty" extensions:"x-nullable" validate:"omitempty,max=255"`
|
||||
DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
|
||||
DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
|
||||
|
||||
// Default location and labels
|
||||
DefaultLocationID *uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`
|
||||
DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"`
|
||||
|
||||
// Metadata flags
|
||||
IncludeWarrantyFields bool `json:"includeWarrantyFields"`
|
||||
IncludePurchaseFields bool `json:"includePurchaseFields"`
|
||||
IncludeSoldFields bool `json:"includeSoldFields"`
|
||||
|
||||
// Custom fields
|
||||
Fields []TemplateField `json:"fields"`
|
||||
}
|
||||
|
||||
ItemTemplateSummary struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
ItemTemplateOut struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Notes string `json:"notes"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
|
||||
// Default values for items
|
||||
DefaultQuantity int `json:"defaultQuantity"`
|
||||
DefaultInsured bool `json:"defaultInsured"`
|
||||
DefaultName string `json:"defaultName"`
|
||||
DefaultDescription string `json:"defaultDescription"`
|
||||
DefaultManufacturer string `json:"defaultManufacturer"`
|
||||
DefaultModelNumber string `json:"defaultModelNumber"`
|
||||
DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
|
||||
DefaultWarrantyDetails string `json:"defaultWarrantyDetails"`
|
||||
|
||||
// Default location and labels
|
||||
DefaultLocation *TemplateLocationSummary `json:"defaultLocation"`
|
||||
DefaultLabels []TemplateLabelSummary `json:"defaultLabels"`
|
||||
|
||||
// Metadata flags
|
||||
IncludeWarrantyFields bool `json:"includeWarrantyFields"`
|
||||
IncludePurchaseFields bool `json:"includePurchaseFields"`
|
||||
IncludeSoldFields bool `json:"includeSoldFields"`
|
||||
|
||||
// Custom fields
|
||||
Fields []TemplateField `json:"fields"`
|
||||
}
|
||||
)
|
||||
|
||||
func mapTemplateField(field *ent.TemplateField) TemplateField {
|
||||
id := field.ID
|
||||
return TemplateField{
|
||||
ID: &id,
|
||||
Type: string(field.Type),
|
||||
Name: field.Name,
|
||||
TextValue: field.TextValue,
|
||||
}
|
||||
}
|
||||
|
||||
func mapTemplateFieldSlice(fields []*ent.TemplateField) []TemplateField {
|
||||
result := make([]TemplateField, len(fields))
|
||||
for i, field := range fields {
|
||||
result[i] = mapTemplateField(field)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func mapTemplateSummary(template *ent.ItemTemplate) ItemTemplateSummary {
|
||||
return ItemTemplateSummary{
|
||||
ID: template.ID,
|
||||
Name: template.Name,
|
||||
Description: template.Description,
|
||||
CreatedAt: template.CreatedAt,
|
||||
UpdatedAt: template.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ItemTemplatesRepository) mapTemplateOut(ctx context.Context, template *ent.ItemTemplate) ItemTemplateOut {
|
||||
fields := make([]TemplateField, 0)
|
||||
if template.Edges.Fields != nil {
|
||||
fields = mapTemplateFieldSlice(template.Edges.Fields)
|
||||
}
|
||||
|
||||
// Map location if present
|
||||
var location *TemplateLocationSummary
|
||||
if template.Edges.Location != nil {
|
||||
location = &TemplateLocationSummary{
|
||||
ID: template.Edges.Location.ID,
|
||||
Name: template.Edges.Location.Name,
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch labels from database using stored IDs
|
||||
labels := make([]TemplateLabelSummary, 0)
|
||||
if len(template.DefaultLabelIds) > 0 {
|
||||
labelEntities, err := r.db.Label.Query().
|
||||
Where(label.IDIn(template.DefaultLabelIds...)).
|
||||
All(ctx)
|
||||
if err == nil {
|
||||
for _, l := range labelEntities {
|
||||
labels = append(labels, TemplateLabelSummary{
|
||||
ID: l.ID,
|
||||
Name: l.Name,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ItemTemplateOut{
|
||||
ID: template.ID,
|
||||
Name: template.Name,
|
||||
Description: template.Description,
|
||||
Notes: template.Notes,
|
||||
CreatedAt: template.CreatedAt,
|
||||
UpdatedAt: template.UpdatedAt,
|
||||
DefaultQuantity: template.DefaultQuantity,
|
||||
DefaultInsured: template.DefaultInsured,
|
||||
DefaultName: template.DefaultName,
|
||||
DefaultDescription: template.DefaultDescription,
|
||||
DefaultManufacturer: template.DefaultManufacturer,
|
||||
DefaultModelNumber: template.DefaultModelNumber,
|
||||
DefaultLifetimeWarranty: template.DefaultLifetimeWarranty,
|
||||
DefaultWarrantyDetails: template.DefaultWarrantyDetails,
|
||||
DefaultLocation: location,
|
||||
DefaultLabels: labels,
|
||||
IncludeWarrantyFields: template.IncludeWarrantyFields,
|
||||
IncludePurchaseFields: template.IncludePurchaseFields,
|
||||
IncludeSoldFields: template.IncludeSoldFields,
|
||||
Fields: fields,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ItemTemplatesRepository) publishMutationEvent(gid uuid.UUID) {
|
||||
if r.bus != nil {
|
||||
r.bus.Publish(eventbus.EventItemMutation, eventbus.GroupMutationEvent{GID: gid})
|
||||
}
|
||||
}
|
||||
|
||||
// GetAll returns all templates for a group
|
||||
func (r *ItemTemplatesRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]ItemTemplateSummary, error) {
|
||||
templates, err := r.db.ItemTemplate.Query().
|
||||
Where(itemtemplate.HasGroupWith(group.ID(gid))).
|
||||
Order(ent.Asc(itemtemplate.FieldName)).
|
||||
All(ctx)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]ItemTemplateSummary, len(templates))
|
||||
for i, template := range templates {
|
||||
result[i] = mapTemplateSummary(template)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetOne returns a single template by ID, verified to belong to the specified group
|
||||
func (r *ItemTemplatesRepository) GetOne(ctx context.Context, gid uuid.UUID, id uuid.UUID) (ItemTemplateOut, error) {
|
||||
template, err := r.db.ItemTemplate.Query().
|
||||
Where(
|
||||
itemtemplate.ID(id),
|
||||
itemtemplate.HasGroupWith(group.ID(gid)),
|
||||
).
|
||||
WithFields().
|
||||
WithLocation().
|
||||
Only(ctx)
|
||||
|
||||
if err != nil {
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
|
||||
return r.mapTemplateOut(ctx, template), nil
|
||||
}
|
||||
|
||||
// Create creates a new template
|
||||
func (r *ItemTemplatesRepository) Create(ctx context.Context, gid uuid.UUID, data ItemTemplateCreate) (ItemTemplateOut, error) {
|
||||
q := r.db.ItemTemplate.Create().
|
||||
SetName(data.Name).
|
||||
SetDescription(data.Description).
|
||||
SetNotes(data.Notes).
|
||||
SetNillableDefaultQuantity(data.DefaultQuantity).
|
||||
SetDefaultInsured(data.DefaultInsured).
|
||||
SetNillableDefaultName(data.DefaultName).
|
||||
SetNillableDefaultDescription(data.DefaultDescription).
|
||||
SetNillableDefaultManufacturer(data.DefaultManufacturer).
|
||||
SetNillableDefaultModelNumber(data.DefaultModelNumber).
|
||||
SetDefaultLifetimeWarranty(data.DefaultLifetimeWarranty).
|
||||
SetNillableDefaultWarrantyDetails(data.DefaultWarrantyDetails).
|
||||
SetIncludeWarrantyFields(data.IncludeWarrantyFields).
|
||||
SetIncludePurchaseFields(data.IncludePurchaseFields).
|
||||
SetIncludeSoldFields(data.IncludeSoldFields).
|
||||
SetGroupID(gid).
|
||||
SetNillableLocationID(data.DefaultLocationID)
|
||||
|
||||
// Set default label IDs (stored as JSON)
|
||||
if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 {
|
||||
q.SetDefaultLabelIds(*data.DefaultLabelIDs)
|
||||
}
|
||||
|
||||
template, err := q.Save(ctx)
|
||||
if err != nil {
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
|
||||
// Create template fields
|
||||
for _, field := range data.Fields {
|
||||
_, err = r.db.TemplateField.Create().
|
||||
SetItemTemplateID(template.ID).
|
||||
SetType(templatefield.Type(field.Type)).
|
||||
SetName(field.Name).
|
||||
SetTextValue(field.TextValue).
|
||||
Save(ctx)
|
||||
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to create template field")
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
}
|
||||
|
||||
r.publishMutationEvent(gid)
|
||||
return r.GetOne(ctx, gid, template.ID)
|
||||
}
|
||||
|
||||
// Update updates an existing template
|
||||
func (r *ItemTemplatesRepository) Update(ctx context.Context, gid uuid.UUID, data ItemTemplateUpdate) (ItemTemplateOut, error) {
|
||||
// Verify template belongs to group
|
||||
template, err := r.db.ItemTemplate.Query().
|
||||
Where(
|
||||
itemtemplate.ID(data.ID),
|
||||
itemtemplate.HasGroupWith(group.ID(gid)),
|
||||
).
|
||||
Only(ctx)
|
||||
|
||||
if err != nil {
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
|
||||
// Update template
|
||||
updateQ := template.Update().
|
||||
SetName(data.Name).
|
||||
SetDescription(data.Description).
|
||||
SetNotes(data.Notes).
|
||||
SetNillableDefaultQuantity(data.DefaultQuantity).
|
||||
SetDefaultInsured(data.DefaultInsured).
|
||||
SetNillableDefaultName(data.DefaultName).
|
||||
SetNillableDefaultDescription(data.DefaultDescription).
|
||||
SetNillableDefaultManufacturer(data.DefaultManufacturer).
|
||||
SetNillableDefaultModelNumber(data.DefaultModelNumber).
|
||||
SetDefaultLifetimeWarranty(data.DefaultLifetimeWarranty).
|
||||
SetNillableDefaultWarrantyDetails(data.DefaultWarrantyDetails).
|
||||
SetIncludeWarrantyFields(data.IncludeWarrantyFields).
|
||||
SetIncludePurchaseFields(data.IncludePurchaseFields).
|
||||
SetIncludeSoldFields(data.IncludeSoldFields)
|
||||
|
||||
// Update location
|
||||
if data.DefaultLocationID != nil {
|
||||
updateQ.SetLocationID(*data.DefaultLocationID)
|
||||
} else {
|
||||
updateQ.ClearLocation()
|
||||
}
|
||||
|
||||
// Update default label IDs (stored as JSON)
|
||||
if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 {
|
||||
updateQ.SetDefaultLabelIds(*data.DefaultLabelIDs)
|
||||
} else {
|
||||
updateQ.ClearDefaultLabelIds()
|
||||
}
|
||||
|
||||
_, err = updateQ.Save(ctx)
|
||||
if err != nil {
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
|
||||
// Get existing fields
|
||||
existingFields, err := r.db.TemplateField.Query().
|
||||
Where(templatefield.HasItemTemplateWith(itemtemplate.ID(data.ID))).
|
||||
All(ctx)
|
||||
|
||||
if err != nil {
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
|
||||
// Create a map of existing field IDs for quick lookup
|
||||
existingFieldMap := make(map[uuid.UUID]bool)
|
||||
for _, field := range existingFields {
|
||||
existingFieldMap[field.ID] = true
|
||||
}
|
||||
|
||||
// Track which fields are being updated
|
||||
updatedFieldIDs := make(map[uuid.UUID]bool)
|
||||
|
||||
// Create or update fields
|
||||
for _, field := range data.Fields {
|
||||
if field.ID == nil || *field.ID == uuid.Nil {
|
||||
// Create new field
|
||||
_, err = r.db.TemplateField.Create().
|
||||
SetItemTemplateID(data.ID).
|
||||
SetType(templatefield.Type(field.Type)).
|
||||
SetName(field.Name).
|
||||
SetTextValue(field.TextValue).
|
||||
Save(ctx)
|
||||
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to create template field")
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
} else {
|
||||
// Update existing field
|
||||
updatedFieldIDs[*field.ID] = true
|
||||
_, err = r.db.TemplateField.Update().
|
||||
Where(
|
||||
templatefield.ID(*field.ID),
|
||||
templatefield.HasItemTemplateWith(itemtemplate.ID(data.ID)),
|
||||
).
|
||||
SetType(templatefield.Type(field.Type)).
|
||||
SetName(field.Name).
|
||||
SetTextValue(field.TextValue).
|
||||
Save(ctx)
|
||||
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to update template field")
|
||||
return ItemTemplateOut{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete fields that are no longer present
|
||||
for _, field := range existingFields {
|
||||
if !updatedFieldIDs[field.ID] {
|
||||
err = r.db.TemplateField.DeleteOne(field).Exec(ctx)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to delete template field")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r.publishMutationEvent(gid)
|
||||
return r.GetOne(ctx, gid, template.ID)
|
||||
}
|
||||
|
||||
// Delete deletes a template
|
||||
func (r *ItemTemplatesRepository) Delete(ctx context.Context, gid uuid.UUID, id uuid.UUID) error {
|
||||
// Verify template belongs to group
|
||||
_, err := r.db.ItemTemplate.Query().
|
||||
Where(
|
||||
itemtemplate.ID(id),
|
||||
itemtemplate.HasGroupWith(group.ID(gid)),
|
||||
).
|
||||
Only(ctx)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete template (fields will be cascade deleted)
|
||||
err = r.db.ItemTemplate.DeleteOneID(id).Exec(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.publishMutationEvent(gid)
|
||||
return nil
|
||||
}
|
||||
337
backend/internal/data/repo/repo_item_templates_test.go
Normal file
337
backend/internal/data/repo/repo_item_templates_test.go
Normal file
@@ -0,0 +1,337 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func templateFactory() ItemTemplateCreate {
|
||||
qty := 1
|
||||
name := fk.Str(20)
|
||||
desc := fk.Str(50)
|
||||
mfr := fk.Str(15)
|
||||
model := fk.Str(10)
|
||||
warranty := ""
|
||||
|
||||
return ItemTemplateCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(100),
|
||||
Notes: fk.Str(50),
|
||||
DefaultQuantity: &qty,
|
||||
DefaultInsured: false,
|
||||
DefaultName: &name,
|
||||
DefaultDescription: &desc,
|
||||
DefaultManufacturer: &mfr,
|
||||
DefaultModelNumber: &model,
|
||||
DefaultLifetimeWarranty: false,
|
||||
DefaultWarrantyDetails: &warranty,
|
||||
IncludeWarrantyFields: false,
|
||||
IncludePurchaseFields: false,
|
||||
IncludeSoldFields: false,
|
||||
Fields: []TemplateField{},
|
||||
}
|
||||
}
|
||||
|
||||
func useTemplates(t *testing.T, count int) []ItemTemplateOut {
|
||||
t.Helper()
|
||||
|
||||
templates := make([]ItemTemplateOut, count)
|
||||
for i := 0; i < count; i++ {
|
||||
data := templateFactory()
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
templates[i] = template
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
for _, template := range templates {
|
||||
_ = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
}
|
||||
})
|
||||
|
||||
return templates
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_GetAll(t *testing.T) {
|
||||
useTemplates(t, 5)
|
||||
|
||||
all, err := tRepos.ItemTemplates.GetAll(context.Background(), tGroup.ID)
|
||||
require.NoError(t, err)
|
||||
assert.GreaterOrEqual(t, len(all), 5)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_GetOne(t *testing.T) {
|
||||
templates := useTemplates(t, 1)
|
||||
template := templates[0]
|
||||
|
||||
found, err := tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, template.ID, found.ID)
|
||||
assert.Equal(t, template.Name, found.Name)
|
||||
assert.Equal(t, template.Description, found.Description)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_Create(t *testing.T) {
|
||||
data := templateFactory()
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotEqual(t, uuid.Nil, template.ID)
|
||||
assert.Equal(t, data.Name, template.Name)
|
||||
assert.Equal(t, data.Description, template.Description)
|
||||
assert.Equal(t, *data.DefaultQuantity, template.DefaultQuantity)
|
||||
assert.Equal(t, data.DefaultInsured, template.DefaultInsured)
|
||||
assert.Equal(t, *data.DefaultName, template.DefaultName)
|
||||
assert.Equal(t, *data.DefaultDescription, template.DefaultDescription)
|
||||
assert.Equal(t, *data.DefaultManufacturer, template.DefaultManufacturer)
|
||||
assert.Equal(t, *data.DefaultModelNumber, template.DefaultModelNumber)
|
||||
|
||||
// Cleanup
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_CreateWithFields(t *testing.T) {
|
||||
data := templateFactory()
|
||||
data.Fields = []TemplateField{
|
||||
{Name: "Field 1", Type: "text", TextValue: "Value 1"},
|
||||
{Name: "Field 2", Type: "text", TextValue: "Value 2"},
|
||||
}
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Len(t, template.Fields, 2)
|
||||
assert.Equal(t, "Field 1", template.Fields[0].Name)
|
||||
assert.Equal(t, "Value 1", template.Fields[0].TextValue)
|
||||
assert.Equal(t, "Field 2", template.Fields[1].Name)
|
||||
assert.Equal(t, "Value 2", template.Fields[1].TextValue)
|
||||
|
||||
// Cleanup
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_Update(t *testing.T) {
|
||||
templates := useTemplates(t, 1)
|
||||
template := templates[0]
|
||||
|
||||
qty := 5
|
||||
defaultName := "Default Item Name"
|
||||
defaultDesc := "Default Item Description"
|
||||
defaultMfr := "Updated Manufacturer"
|
||||
defaultModel := "MODEL-123"
|
||||
defaultWarranty := "Lifetime coverage"
|
||||
|
||||
updateData := ItemTemplateUpdate{
|
||||
ID: template.ID,
|
||||
Name: "Updated Name",
|
||||
Description: "Updated Description",
|
||||
Notes: "Updated Notes",
|
||||
DefaultQuantity: &qty,
|
||||
DefaultInsured: true,
|
||||
DefaultName: &defaultName,
|
||||
DefaultDescription: &defaultDesc,
|
||||
DefaultManufacturer: &defaultMfr,
|
||||
DefaultModelNumber: &defaultModel,
|
||||
DefaultLifetimeWarranty: true,
|
||||
DefaultWarrantyDetails: &defaultWarranty,
|
||||
IncludeWarrantyFields: true,
|
||||
IncludePurchaseFields: true,
|
||||
IncludeSoldFields: false,
|
||||
Fields: []TemplateField{},
|
||||
}
|
||||
|
||||
updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, template.ID, updated.ID)
|
||||
assert.Equal(t, "Updated Name", updated.Name)
|
||||
assert.Equal(t, "Updated Description", updated.Description)
|
||||
assert.Equal(t, "Updated Notes", updated.Notes)
|
||||
assert.Equal(t, 5, updated.DefaultQuantity)
|
||||
assert.True(t, updated.DefaultInsured)
|
||||
assert.Equal(t, "Default Item Name", updated.DefaultName)
|
||||
assert.Equal(t, "Default Item Description", updated.DefaultDescription)
|
||||
assert.Equal(t, "Updated Manufacturer", updated.DefaultManufacturer)
|
||||
assert.Equal(t, "MODEL-123", updated.DefaultModelNumber)
|
||||
assert.True(t, updated.DefaultLifetimeWarranty)
|
||||
assert.Equal(t, "Lifetime coverage", updated.DefaultWarrantyDetails)
|
||||
assert.True(t, updated.IncludeWarrantyFields)
|
||||
assert.True(t, updated.IncludePurchaseFields)
|
||||
assert.False(t, updated.IncludeSoldFields)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_UpdateWithFields(t *testing.T) {
|
||||
data := templateFactory()
|
||||
data.Fields = []TemplateField{
|
||||
{Name: "Original Field", Type: "text", TextValue: "Original Value"},
|
||||
}
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, template.Fields, 1)
|
||||
|
||||
// Update with new fields
|
||||
qty := template.DefaultQuantity
|
||||
updateData := ItemTemplateUpdate{
|
||||
ID: template.ID,
|
||||
Name: template.Name,
|
||||
Description: template.Description,
|
||||
DefaultQuantity: &qty,
|
||||
Fields: []TemplateField{
|
||||
{ID: template.Fields[0].ID, Name: "Updated Field", Type: "text", TextValue: "Updated Value"},
|
||||
{Name: "New Field", Type: "text", TextValue: "New Value"},
|
||||
},
|
||||
}
|
||||
|
||||
updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Len(t, updated.Fields, 2)
|
||||
|
||||
// Cleanup
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_Delete(t *testing.T) {
|
||||
data := templateFactory()
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify it's deleted
|
||||
_, err = tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_DeleteCascadesFields(t *testing.T) {
|
||||
data := templateFactory()
|
||||
data.Fields = []TemplateField{
|
||||
{Name: "Field 1", Type: "text", TextValue: "Value 1"},
|
||||
{Name: "Field 2", Type: "text", TextValue: "Value 2"},
|
||||
}
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, template.Fields, 2)
|
||||
|
||||
// Delete template - fields should be cascade deleted
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify template is deleted
|
||||
_, err = tRepos.ItemTemplates.GetOne(context.Background(), tGroup.ID, template.ID)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_CreateWithLocation(t *testing.T) {
|
||||
// First create a location
|
||||
loc, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(50),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = tRepos.Locations.delete(context.Background(), loc.ID)
|
||||
})
|
||||
|
||||
// Create template with location
|
||||
data := templateFactory()
|
||||
data.DefaultLocationID = &loc.ID
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NotNil(t, template.DefaultLocation)
|
||||
assert.Equal(t, loc.ID, template.DefaultLocation.ID)
|
||||
assert.Equal(t, loc.Name, template.DefaultLocation.Name)
|
||||
|
||||
// Cleanup
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_CreateWithLabels(t *testing.T) {
|
||||
// Create some labels
|
||||
label1, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(50),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
label2, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(50),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = tRepos.Labels.delete(context.Background(), label1.ID)
|
||||
_ = tRepos.Labels.delete(context.Background(), label2.ID)
|
||||
})
|
||||
|
||||
// Create template with labels
|
||||
data := templateFactory()
|
||||
labelIDs := []uuid.UUID{label1.ID, label2.ID}
|
||||
data.DefaultLabelIDs = &labelIDs
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Len(t, template.DefaultLabels, 2)
|
||||
|
||||
// Cleanup
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_UpdateRemoveLocation(t *testing.T) {
|
||||
// First create a location
|
||||
loc, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(50),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = tRepos.Locations.delete(context.Background(), loc.ID)
|
||||
})
|
||||
|
||||
// Create template with location
|
||||
data := templateFactory()
|
||||
data.DefaultLocationID = &loc.ID
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, template.DefaultLocation)
|
||||
|
||||
// Update to remove location
|
||||
qty := template.DefaultQuantity
|
||||
updateData := ItemTemplateUpdate{
|
||||
ID: template.ID,
|
||||
Name: template.Name,
|
||||
DefaultQuantity: &qty,
|
||||
DefaultLocationID: nil, // Remove location
|
||||
}
|
||||
|
||||
updated, err := tRepos.ItemTemplates.Update(context.Background(), tGroup.ID, updateData)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Nil(t, updated.DefaultLocation)
|
||||
|
||||
// Cleanup
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
@@ -654,6 +654,90 @@ func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCr
|
||||
return e.GetOne(ctx, result.ID)
|
||||
}
|
||||
|
||||
// ItemCreateFromTemplate contains all data needed to create an item from a template.
|
||||
type ItemCreateFromTemplate struct {
|
||||
Name string
|
||||
Description string
|
||||
Quantity int
|
||||
LocationID uuid.UUID
|
||||
LabelIDs []uuid.UUID
|
||||
Insured bool
|
||||
Manufacturer string
|
||||
ModelNumber string
|
||||
LifetimeWarranty bool
|
||||
WarrantyDetails string
|
||||
Fields []ItemField
|
||||
}
|
||||
|
||||
// CreateFromTemplate creates an item with all template data in a single transaction.
|
||||
func (e *ItemsRepository) CreateFromTemplate(ctx context.Context, gid uuid.UUID, data ItemCreateFromTemplate) (ItemOut, error) {
|
||||
tx, err := e.db.Tx(ctx)
|
||||
if err != nil {
|
||||
return ItemOut{}, err
|
||||
}
|
||||
committed := false
|
||||
defer func() {
|
||||
if !committed {
|
||||
if err := tx.Rollback(); err != nil {
|
||||
log.Warn().Err(err).Msg("failed to rollback transaction during template item creation")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Get next asset ID within transaction
|
||||
nextAssetID, err := e.GetHighestAssetIDTx(ctx, tx, gid)
|
||||
if err != nil {
|
||||
return ItemOut{}, err
|
||||
}
|
||||
nextAssetID++
|
||||
|
||||
// Create item with all template data
|
||||
newItemID := uuid.New()
|
||||
itemBuilder := tx.Item.Create().
|
||||
SetID(newItemID).
|
||||
SetName(data.Name).
|
||||
SetDescription(data.Description).
|
||||
SetQuantity(data.Quantity).
|
||||
SetLocationID(data.LocationID).
|
||||
SetGroupID(gid).
|
||||
SetAssetID(int(nextAssetID)).
|
||||
SetInsured(data.Insured).
|
||||
SetManufacturer(data.Manufacturer).
|
||||
SetModelNumber(data.ModelNumber).
|
||||
SetLifetimeWarranty(data.LifetimeWarranty).
|
||||
SetWarrantyDetails(data.WarrantyDetails)
|
||||
|
||||
if len(data.LabelIDs) > 0 {
|
||||
itemBuilder.AddLabelIDs(data.LabelIDs...)
|
||||
}
|
||||
|
||||
_, err = itemBuilder.Save(ctx)
|
||||
if err != nil {
|
||||
return ItemOut{}, err
|
||||
}
|
||||
|
||||
// Create custom fields
|
||||
for _, field := range data.Fields {
|
||||
_, err = tx.ItemField.Create().
|
||||
SetItemID(newItemID).
|
||||
SetType(itemfield.Type(field.Type)).
|
||||
SetName(field.Name).
|
||||
SetTextValue(field.TextValue).
|
||||
Save(ctx)
|
||||
if err != nil {
|
||||
return ItemOut{}, fmt.Errorf("failed to create field %s: %w", field.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err = tx.Commit(); err != nil {
|
||||
return ItemOut{}, err
|
||||
}
|
||||
committed = true
|
||||
|
||||
e.publishMutationEvent(gid)
|
||||
return e.GetOne(ctx, newItemID)
|
||||
}
|
||||
|
||||
func (e *ItemsRepository) Delete(ctx context.Context, id uuid.UUID) error {
|
||||
// Get the item with its group and attachments before deletion
|
||||
itm, err := e.db.Item.Query().
|
||||
|
||||
@@ -9,28 +9,30 @@ import (
|
||||
|
||||
// AllRepos is a container for all the repository interfaces
|
||||
type AllRepos struct {
|
||||
Users *UserRepository
|
||||
AuthTokens *TokenRepository
|
||||
Groups *GroupRepository
|
||||
Locations *LocationRepository
|
||||
Labels *LabelRepository
|
||||
Items *ItemsRepository
|
||||
Attachments *AttachmentRepo
|
||||
MaintEntry *MaintenanceEntryRepository
|
||||
Notifiers *NotifierRepository
|
||||
Users *UserRepository
|
||||
AuthTokens *TokenRepository
|
||||
Groups *GroupRepository
|
||||
Locations *LocationRepository
|
||||
Labels *LabelRepository
|
||||
Items *ItemsRepository
|
||||
ItemTemplates *ItemTemplatesRepository
|
||||
Attachments *AttachmentRepo
|
||||
MaintEntry *MaintenanceEntryRepository
|
||||
Notifiers *NotifierRepository
|
||||
}
|
||||
|
||||
func New(db *ent.Client, bus *eventbus.EventBus, storage config.Storage, pubSubConn string, thumbnail config.Thumbnail) *AllRepos {
|
||||
attachments := &AttachmentRepo{db, storage, pubSubConn, thumbnail}
|
||||
return &AllRepos{
|
||||
Users: &UserRepository{db},
|
||||
AuthTokens: &TokenRepository{db},
|
||||
Groups: NewGroupRepository(db),
|
||||
Locations: &LocationRepository{db, bus},
|
||||
Labels: &LabelRepository{db, bus},
|
||||
Items: &ItemsRepository{db, bus, attachments},
|
||||
Attachments: attachments,
|
||||
MaintEntry: &MaintenanceEntryRepository{db},
|
||||
Notifiers: NewNotifierRepository(db),
|
||||
Users: &UserRepository{db},
|
||||
AuthTokens: &TokenRepository{db},
|
||||
Groups: NewGroupRepository(db),
|
||||
Locations: &LocationRepository{db, bus},
|
||||
Labels: &LabelRepository{db, bus},
|
||||
Items: &ItemsRepository{db, bus, attachments},
|
||||
ItemTemplates: &ItemTemplatesRepository{db, bus},
|
||||
Attachments: attachments,
|
||||
MaintEntry: &MaintenanceEntryRepository{db},
|
||||
Notifiers: NewNotifierRepository(db),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user