This commit is contained in:
seb
2026-09-27 22:01:56 +02:00
parent 0cafa11a32
commit 87da854de4
12 changed files with 686 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
/** Drop order = reverse of schema create dependency order. */
export const TABLES = [
'manifestattachment',
'labeltemplate',
'file',
'companyuser',
'syncpos',

View File

@@ -0,0 +1,87 @@
export const LABELTEMPLATE_COLUMNS = `
id,
company_id,
name,
width,
height,
dpi,
type,
content,
thumb
`;
export const LIST_BY_COMPANY = `
SELECT
${LABELTEMPLATE_COLUMNS}
FROM labeltemplate
WHERE company_id = @companyId
ORDER BY id ASC
`;
export const GET_BY_COMPANY_AND_ID = `
SELECT
${LABELTEMPLATE_COLUMNS}
FROM labeltemplate
WHERE id = @id AND company_id = @companyId
`;
export const CREATE = `
INSERT INTO labeltemplate (
company_id,
name,
width,
height,
dpi,
type,
content,
thumb
)
OUTPUT
INSERTED.id,
INSERTED.company_id,
INSERTED.name,
INSERTED.width,
INSERTED.height,
INSERTED.dpi,
INSERTED.type,
INSERTED.content,
INSERTED.thumb
VALUES (
@companyId,
@name,
@width,
@height,
@dpi,
@type,
@content,
@thumb
)
`;
export const UPDATE = `
UPDATE labeltemplate
SET
name = @name,
width = @width,
height = @height,
dpi = @dpi,
type = @type,
content = @content,
thumb = @thumb
OUTPUT
INSERTED.id,
INSERTED.company_id,
INSERTED.name,
INSERTED.width,
INSERTED.height,
INSERTED.dpi,
INSERTED.type,
INSERTED.content,
INSERTED.thumb
WHERE id = @id AND company_id = @companyId
`;
export const DELETE_BY_COMPANY_AND_ID = `
DELETE FROM labeltemplate
WHERE id = @id AND company_id = @companyId
`;

View File

@@ -816,6 +816,26 @@ END
`;
export const INIT_LABELTEMPLATE = `
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'labeltemplate')
BEGIN
CREATE TABLE labeltemplate (
id INT IDENTITY(1,1) PRIMARY KEY,
company_id INT NOT NULL,
name NVARCHAR(255) NOT NULL,
width INT NOT NULL,
height INT NOT NULL,
dpi INT NOT NULL,
type NVARCHAR(50) NOT NULL,
content NVARCHAR(MAX) NOT NULL,
thumb VARBINARY(MAX) NULL,
CONSTRAINT FK_labeltemplate_company FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE,
CONSTRAINT CK_labeltemplate_dpi CHECK (dpi IN (203, 300)),
CONSTRAINT CK_labeltemplate_type CHECK (type IN ('zpl'))
);
END
`;
export const INIT_FILE = `
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'file')
BEGIN
@@ -919,6 +939,7 @@ export const SCHEMA_SCRIPTS = [
INIT_POSTERMINAL,
INIT_POSTERMINALCATEGORY,
INIT_PRINTER,
INIT_LABELTEMPLATE,
INIT_FILE,
INIT_MANIFESTATTACHMENT,
INIT_MANIFESTATTACHMENT_TRIGGER,