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 @@ + +