From a74248a255b3f50e5876b45c943cacdf78dc7eb1 Mon Sep 17 00:00:00 2001 From: Heegeun Park Date: Tue, 13 Aug 2024 23:17:40 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B4=80=EB=A6=AC=ED=99=94=EB=A9=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=8A=B9=EC=88=98=EB=AC=B8=EC=9E=90=20=EC=A0=9C?= =?UTF-8?q?=EB=8C=80=EB=A1=9C=20=EB=82=98=EC=98=A4=EA=B2=8C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20=EA=B7=B8=EB=A3=B9=20ID=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EA=B0=80=EB=8A=A5=ED=95=98=EA=B2=8C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/database/admin/group/list/update.ts | 13 +++++ server/routers/admin/group/list/update.ts | 40 +++++++++++++++- .../admin/group/BoardGroupGeneral.vue | 4 +- .../admin/grouplist/ChangeGroupIdDialog.vue | 37 ++++++++++++++ .../admin/grouplist/GroupListGeneral.vue | 20 ++++++-- src/messages/store/admin/group/list.ts | 1 + src/store/admin/board/general.ts | 5 ++ src/store/admin/group/list.ts | 48 +++++++++++++++++++ tsboard.config.ts | 2 +- 9 files changed, 161 insertions(+), 9 deletions(-) create mode 100644 src/components/admin/grouplist/ChangeGroupIdDialog.vue diff --git a/server/database/admin/group/list/update.ts b/server/database/admin/group/list/update.ts index 1231c359..f1c84161 100644 --- a/server/database/admin/group/list/update.ts +++ b/server/database/admin/group/list/update.ts @@ -34,3 +34,16 @@ export async function removeGroup(groupUid: number): Promise { await remove(`DELETE FROM ${table}group WHERE uid = ? LIMIT 1`, [groupUidQuery]) return true } + +// 그룹 ID 업데이트 +export async function updateGroupId(groupUid: number, newId: string): Promise { + const [group] = await select(`SELECT uid FROM ${table}group WHERE id = ? LIMIT 1`, [newId]) + if (group) { + return false + } + await update(`UPDATE ${table}group SET id = ? WHERE uid = ? LIMIT 1`, [ + newId, + groupUid.toString(), + ]) + return true +} diff --git a/server/routers/admin/group/list/update.ts b/server/routers/admin/group/list/update.ts index a3cb2f86..55787b27 100644 --- a/server/routers/admin/group/list/update.ts +++ b/server/routers/admin/group/list/update.ts @@ -6,7 +6,11 @@ import { Elysia, t } from "elysia" import { jwt } from "@elysiajs/jwt" -import { createGroup, removeGroup } from "../../../../database/admin/group/list/update" +import { + createGroup, + removeGroup, + updateGroupId, +} from "../../../../database/admin/group/list/update" import { fail, success, EXTEND_TYPE_CHECK } from "../../../../util/tools" import { getUserBasic } from "../../../../database/board/list" import { SUPER_ADMIN_UID } from "../../../../database/auth/const" @@ -115,3 +119,37 @@ export const update = new Elysia() }), }, ) + .put( + "/update/group", + async ({ body: { groupUid, changeGroupId }, newAccessToken, accessUserUid }) => { + const response = { + newAccessToken: "", + } + + if (accessUserUid < 1) { + return fail(`Unauthorized access.`, response) + } + if (groupUid < 1) { + return fail(`Invalid group uid.`, response) + } + if (changeGroupId.length < 2) { + return fail(`Invalid group id.`, response) + } + + const result = await updateGroupId(groupUid, changeGroupId.trim()) + if (result === false) { + return fail(`Duplicated group id.`, response) + } + + return success({ + newAccessToken, + }) + }, + { + ...EXTEND_TYPE_CHECK, + body: t.Object({ + groupUid: t.Number(), + changeGroupId: t.String(), + }), + }, + ) diff --git a/src/components/admin/group/BoardGroupGeneral.vue b/src/components/admin/group/BoardGroupGeneral.vue index f80dbb09..891cecf4 100644 --- a/src/components/admin/group/BoardGroupGeneral.vue +++ b/src/components/admin/group/BoardGroupGeneral.vue @@ -100,9 +100,9 @@ {{ board.name }} + >{{ util.unescape(board.name) }} - {{ board.info }} + {{ util.unescape(board.info) }} {{ board.total.post }} posts diff --git a/src/components/admin/grouplist/ChangeGroupIdDialog.vue b/src/components/admin/grouplist/ChangeGroupIdDialog.vue new file mode 100644 index 00000000..d20bf42f --- /dev/null +++ b/src/components/admin/grouplist/ChangeGroupIdDialog.vue @@ -0,0 +1,37 @@ + + + diff --git a/src/components/admin/grouplist/GroupListGeneral.vue b/src/components/admin/grouplist/GroupListGeneral.vue index 7292b647..bb15f054 100644 --- a/src/components/admin/grouplist/GroupListGeneral.vue +++ b/src/components/admin/grouplist/GroupListGeneral.vue @@ -17,7 +17,7 @@ - {{ group.name }} + {{ util.unescape(group.name) }} @@ -37,9 +37,16 @@ > - {{ group.manager.name }} + {{ util.unescape(group.manager.name) }} {{ group.count }} board(s) @@ -74,6 +81,8 @@ + +