feat: 统一sql命名、函数命名

This commit is contained in:
2026-08-02 12:02:04 +08:00
parent d39342ce5f
commit 0e674e9d56
68 changed files with 1985 additions and 1720 deletions

View File

@@ -22,7 +22,7 @@ WITH paginated_posts AS (
)
-- 第二步:用这极少量的记录去进行 JOIN
SELECT p.*,
f.file_path AS cover,
f.file_url AS cover,
c.name AS category_name,
c.id AS category_id,
COALESCE(ps.view, 0) AS view,
@@ -54,7 +54,7 @@ GROUP BY p.id,
p.published_at,
p.created_at,
p.updated_at,
f.file_path,
f.file_url,
c.name,
c.id,
ps.view
@@ -64,9 +64,9 @@ ORDER BY p.sort DESC, p.published_at DESC, p.id DESC;
SELECT COUNT(*)
FROM posts;
-- name: GetPostById :one
-- name: GetPostByID :one
SELECT p.*,
f.file_path AS cover,
f.file_url AS cover,
c.name AS category_name,
c.id AS category_id,
COALESCE(
@@ -80,7 +80,7 @@ FROM posts p
LEFT JOIN post_tag pt ON pt.post_id = p.id
WHERE p.id = $1
GROUP BY p.id,
f.file_path,
f.file_url,
c.name,
c.id
LIMIT 1;
@@ -106,7 +106,7 @@ WHERE id = $1;
-- name: GetPublicPostBySlug :one
SELECT p.*,
f.file_path AS cover,
f.file_url AS cover,
COALESCE(ps.view, 0) AS view
FROM posts p
LEFT JOIN files f ON f.id = p.cover_id
@@ -132,7 +132,7 @@ WITH paginated_posts AS (
ORDER BY sort DESC, published_at DESC, id DESC
LIMIT $1 OFFSET $2)
SELECT p.*,
f.file_path AS cover,
f.file_url AS cover,
c.name AS category_name,
c.id AS category_id,
COALESCE(ps.view, 0) AS view,
@@ -161,7 +161,7 @@ GROUP BY p.id,
p.summary,
p.sort,
p.published_at,
f.file_path,
f.file_url,
c.name,
c.id,
ps.view