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,

View File

@@ -0,0 +1,12 @@
import * as source from '../../mssql/queries/labeltemplate.js';
import { translateQueries } from './translate.js';
const queries = translateQueries(source, 'labeltemplate');
export const {
CREATE,
DELETE_BY_COMPANY_AND_ID,
GET_BY_COMPANY_AND_ID,
LABELTEMPLATE_COLUMNS,
LIST_BY_COMPANY,
UPDATE,
} = queries;

View File

@@ -565,6 +565,21 @@ CREATE TABLE IF NOT EXISTS printer (
`;
export const INIT_LABELTEMPLATE = `
CREATE TABLE IF NOT EXISTS labeltemplate (
id INTEGER PRIMARY KEY,
company_id INTEGER NOT NULL,
name TEXT NOT NULL,
width INTEGER NOT NULL,
height INTEGER NOT NULL,
dpi INTEGER NOT NULL CHECK (dpi IN (203, 300)),
type TEXT NOT NULL CHECK (type IN ('zpl')),
content TEXT NOT NULL,
thumb BLOB,
FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE
);
`;
export const INIT_FILE = `
CREATE TABLE IF NOT EXISTS "file" (
id INTEGER PRIMARY KEY,
@@ -648,6 +663,7 @@ export const SCHEMA_SCRIPTS = [
INIT_POSTERMINAL,
INIT_POSTERMINALCATEGORY,
INIT_PRINTER,
INIT_LABELTEMPLATE,
INIT_FILE,
INIT_MANIFESTATTACHMENT,
INIT_MANIFESTATTACHMENT_TRIGGER,