This commit is contained in:
seb
2026-11-02 00:19:21 +01:00
parent 55f04de8a8
commit d0a33b1f82
35 changed files with 4919 additions and 3739 deletions

View File

@@ -0,0 +1,43 @@
export const ADD = `
INSERT INTO autoinvite (company_id, email, role)
OUTPUT INSERTED.id
VALUES (@companyId, @email, @role)
`;
export const LIST_BY_COMPANY = `
SELECT
id,
email,
role,
created_at AS createdAt
FROM autoinvite
WHERE company_id = @companyId
ORDER BY email
`;
export const LIST_BY_EMAIL = `
SELECT
id,
company_id AS companyId,
role
FROM autoinvite
WHERE email = @email
ORDER BY id
`;
export const GET_IN_COMPANY = `
SELECT id
FROM autoinvite
WHERE id = @id AND company_id = @companyId
`;
export const GET_BY_COMPANY_EMAIL = `
SELECT id
FROM autoinvite
WHERE company_id = @companyId AND email = @email
`;
export const DELETE = `
DELETE FROM autoinvite
WHERE id = @id
`;

View File

@@ -55,7 +55,8 @@ SELECT
l.iso639,
tr.rate AS taxrate,
rtr.rate AS reducedtaxrate,
tfr.rate AS taxfreerate
tfr.rate AS taxfreerate,
cu.role AS role
FROM company c
INNER JOIN companyuser cu ON cu.company_id = c.id
LEFT JOIN language l ON l.id = c.default_language_id

View File

@@ -10,7 +10,8 @@ SELECT
c.root_category_id AS rootCategoryId,
c.default_language_id AS languageId,
c.poscustomergroup_id AS posCustomerGroupId,
cu.id AS companyuserId
cu.id AS companyuserId,
cu.role AS role
FROM company c
LEFT JOIN companyuser cu
ON cu.company_id = c.id AND cu.google_auth_id = @googleAuthId
@@ -18,12 +19,71 @@ WHERE c.id = @companyId
`;
export const ADD = `
INSERT INTO companyuser (google_auth_id, company_id)
INSERT INTO companyuser (google_auth_id, company_id, role)
OUTPUT INSERTED.id
VALUES (@googleAuthId, @companyId)
VALUES (@googleAuthId, @companyId, @role)
`;
export const DELETE = `
DELETE FROM companyuser
WHERE id = @id
`;
export const LIST_BY_COMPANY = `
SELECT
cu.id,
cu.google_auth_id AS googleAuthId,
ga.email,
cu.role
FROM companyuser cu
INNER JOIN google_auth ga ON ga.id = cu.google_auth_id
WHERE cu.company_id = @companyId
ORDER BY ga.email
`;
export const GET_IN_COMPANY = `
SELECT
id,
google_auth_id AS googleAuthId,
role
FROM companyuser
WHERE id = @id AND company_id = @companyId
`;
export const GET_MEMBERSHIP = `
SELECT id, role
FROM companyuser
WHERE google_auth_id = @googleAuthId AND company_id = @companyId
`;
export const COUNT_ADMINS = `
SELECT COUNT(*) AS count
FROM companyuser
WHERE company_id = @companyId AND role = 'admin'
`;
export const SET_ROLE = `
UPDATE companyuser
SET role = @role
WHERE id = @id
`;
export const CLEAR_ENTITYHISTORY_USER = `
UPDATE entityhistory SET companyuser_id = NULL WHERE companyuser_id = @id
`;
export const CLEAR_COMPANYHISTORY_USER = `
UPDATE companyhistory SET companyuser_id = NULL WHERE companyuser_id = @id
`;
export const IS_MEMBER = `
SELECT id
FROM companyuser
WHERE google_auth_id = @googleAuthId AND company_id = @companyId
`;
export const CLEAR_SELECTED_COMPANY = `
UPDATE google_auth
SET selected_company = NULL
WHERE id = @googleAuthId AND selected_company = @companyId
`;