This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
-- name: CreateProject :one
|
-- name: CreateProject :one
|
||||||
INSERT INTO projects (
|
WITH inserted_project AS (
|
||||||
|
INSERT INTO projects (
|
||||||
title, description, project_status, user_id
|
title, description, project_status, user_id
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4
|
$1, $2, $3, $4
|
||||||
|
)
|
||||||
|
RETURNING *
|
||||||
)
|
)
|
||||||
RETURNING
|
SELECT
|
||||||
*,
|
p.*,
|
||||||
json_build_object(
|
json_build_object(
|
||||||
'id', u.id,
|
'id', u.id,
|
||||||
'email', u.email,
|
'email', u.email,
|
||||||
@@ -15,7 +18,10 @@ RETURNING
|
|||||||
)::json AS user,
|
)::json AS user,
|
||||||
'[]'::json AS commits,
|
'[]'::json AS commits,
|
||||||
'{}'::uuid[] AS submission_ids,
|
'{}'::uuid[] AS submission_ids,
|
||||||
'[]'::json AS members;
|
'[]'::json AS members
|
||||||
|
FROM inserted_project p
|
||||||
|
JOIN users u ON p.user_id = u.id
|
||||||
|
LEFT JOIN user_profiles up ON u.id = up.user_id;
|
||||||
|
|
||||||
-- name: GetProjectById :one
|
-- name: GetProjectById :one
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@@ -118,13 +118,16 @@ func (q *Queries) CountProjects(ctx context.Context, arg CountProjectsParams) (i
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createProject = `-- name: CreateProject :one
|
const createProject = `-- name: CreateProject :one
|
||||||
INSERT INTO projects (
|
WITH inserted_project AS (
|
||||||
|
INSERT INTO projects (
|
||||||
title, description, project_status, user_id
|
title, description, project_status, user_id
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$1, $2, $3, $4
|
$1, $2, $3, $4
|
||||||
|
)
|
||||||
|
RETURNING id, title, description, latest_commit_id, project_status, locked_by, is_deleted, user_id, created_at, updated_at
|
||||||
)
|
)
|
||||||
RETURNING
|
SELECT
|
||||||
id, title, description, latest_commit_id, project_status, locked_by, is_deleted, user_id, created_at, updated_at,
|
p.id, p.title, p.description, p.latest_commit_id, p.project_status, p.locked_by, p.is_deleted, p.user_id, p.created_at, p.updated_at,
|
||||||
json_build_object(
|
json_build_object(
|
||||||
'id', u.id,
|
'id', u.id,
|
||||||
'email', u.email,
|
'email', u.email,
|
||||||
@@ -135,6 +138,9 @@ RETURNING
|
|||||||
'[]'::json AS commits,
|
'[]'::json AS commits,
|
||||||
'{}'::uuid[] AS submission_ids,
|
'{}'::uuid[] AS submission_ids,
|
||||||
'[]'::json AS members
|
'[]'::json AS members
|
||||||
|
FROM inserted_project p
|
||||||
|
JOIN users u ON p.user_id = u.id
|
||||||
|
LEFT JOIN user_profiles up ON u.id = up.user_id
|
||||||
`
|
`
|
||||||
|
|
||||||
type CreateProjectParams struct {
|
type CreateProjectParams struct {
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ func ProjectRoutes(
|
|||||||
|
|
||||||
route.Get(
|
route.Get(
|
||||||
"/",
|
"/",
|
||||||
|
middlewares.JwtAccess(userRepo),
|
||||||
middlewares.RequireAnyRole(constants.RoleTypeAdmin, constants.RoleTypeMod),
|
middlewares.RequireAnyRole(constants.RoleTypeAdmin, constants.RoleTypeMod),
|
||||||
controller.SearchProject,
|
controller.SearchProject,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user