v1.12.23 대시보드 간소화 및 멤버 작성 이력 탭 추가
This commit is contained in:
@@ -331,10 +331,10 @@ export const toggleCommentLike = async (input) => {
|
||||
|
||||
/**
|
||||
* 관리자 댓글을 작성자 조건과 최신순 페이지 단위로 조회한다.
|
||||
* @param {{ memberId?: string, page: number, pageSize: number }} options - 조회 조건
|
||||
* @param {{ memberId?: string, q?: string, page: number, pageSize: number }} options - 조회 조건
|
||||
* @returns {Promise<Object>} 댓글과 페이지 정보
|
||||
*/
|
||||
export const listAdminComments = async ({ memberId = null, page, pageSize }) => {
|
||||
export const listAdminComments = async ({ memberId = null, q = '', page, pageSize }) => {
|
||||
const sql = getSql()
|
||||
const empty = { items: [], pagination: { page: 1, pageSize, total: 0, pageCount: 1 } }
|
||||
if (!sql) return empty
|
||||
@@ -343,7 +343,9 @@ export const listAdminComments = async ({ memberId = null, page, pageSize }) =>
|
||||
await transaction`SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY`
|
||||
const [count] = await transaction`
|
||||
SELECT COUNT(*)::int AS total FROM comments
|
||||
WHERE (${memberId}::uuid IS NULL OR user_id = ${memberId}::uuid)
|
||||
INNER JOIN posts ON posts.id = comments.post_id
|
||||
WHERE (${memberId}::uuid IS NULL OR comments.user_id = ${memberId}::uuid)
|
||||
AND (${q} = '' OR strpos(lower(concat_ws(' ', comments.body, posts.title)), lower(${q})) > 0)
|
||||
`
|
||||
const total = Number(count.total)
|
||||
const pageCount = Math.max(1, Math.ceil(total / pageSize))
|
||||
@@ -358,6 +360,7 @@ export const listAdminComments = async ({ memberId = null, page, pageSize }) =>
|
||||
INNER JOIN users ON users.id = comments.user_id
|
||||
INNER JOIN posts ON posts.id = comments.post_id
|
||||
WHERE (${memberId}::uuid IS NULL OR comments.user_id = ${memberId}::uuid)
|
||||
AND (${q} = '' OR strpos(lower(concat_ws(' ', comments.body, posts.title)), lower(${q})) > 0)
|
||||
ORDER BY comments.created_at DESC, comments.id DESC
|
||||
LIMIT ${pageSize} OFFSET ${(currentPage - 1) * pageSize}
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user