78 lines
1.4 KiB
Go
78 lines
1.4 KiB
Go
package queries
|
|
|
|
const USER_CREATE_QUERY string = `
|
|
INSERT INTO ordr_user(sub_id, user_name) VALUES ($1, $2);
|
|
`
|
|
|
|
const USER_UPDATE_QUERY string = `
|
|
UPDATE ordr_user SET user_name = $1 WHERE sub_id = $2;
|
|
`
|
|
|
|
const USER_SET_IS_ADMIN_QUERY string = `
|
|
UPDATE ordr_user SET is_admin = TRUE WHERE id = $1;
|
|
`
|
|
|
|
const USER_REVOKE_ADMIN_QUERY string = `
|
|
UPDATE ordr_user SET is_admin = FALSE WHERE id = $1;
|
|
`
|
|
|
|
const USER_SET_INACTIVE_QUERY string = `
|
|
UPDATE ordr_user SET active = FALSE WHERE id = $1;
|
|
`
|
|
|
|
const USER_SET_ACTIVE_QUERY string = `
|
|
UPDATE ordr_user SET active = TRUE WHERE id = $1;
|
|
`
|
|
|
|
const USER_GET_TABLE_DATA string = `
|
|
SELECT
|
|
ordr_user.id,
|
|
user_name,
|
|
position_name,
|
|
active,
|
|
is_admin
|
|
FROM
|
|
ordr_user
|
|
LEFT JOIN ordr_position
|
|
ON job_position = ordr_position.id
|
|
WHERE
|
|
user_name LIKE '%' || $3 ||'%'
|
|
AND position_name LIKE '%' || $4 || '%'
|
|
ORDER BY user_name
|
|
OFFSET $1
|
|
LIMIT $2;
|
|
`
|
|
|
|
const GET_CURRENT_USER_OBJECT string = `
|
|
SELECT
|
|
ordr_user.id,
|
|
user_name,
|
|
position_name,
|
|
active::boolean,
|
|
is_admin::boolean
|
|
FROM
|
|
ordr_user
|
|
LEFT JOIN ordr_position
|
|
ON job_position = ordr_position.id
|
|
WHERE
|
|
ordr_user.sub_id = $1;
|
|
`
|
|
|
|
const USER_SET_POSITION string = `
|
|
UPDATE ordr_user SET job_position = $1 WHERE id = $2;
|
|
`
|
|
|
|
const POSITION_GET_POSITION string = `
|
|
SELECT
|
|
id,
|
|
position_name
|
|
FROM
|
|
ordr_position
|
|
WHERE
|
|
position_name LIKE '%' || $1 || '%'
|
|
`
|
|
|
|
const CREATE_POSITION string = `
|
|
INSERT INTO ordr_position(position_name) VALUES ($1)
|
|
`
|