diff options
Diffstat (limited to 'lib/admin-users/service.ts')
| -rw-r--r-- | lib/admin-users/service.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/admin-users/service.ts b/lib/admin-users/service.ts index 44111bef..b67aef20 100644 --- a/lib/admin-users/service.ts +++ b/lib/admin-users/service.ts @@ -5,8 +5,7 @@ import db from "@/db/db"; import logger from '@/lib/logger'; import { Role, roles, users, userView, type User, type UserView } from "@/db/schema/users"; // User 테이블 -import { type Company } from "@/db/schema/companies"; // User 테이블 -import { asc, desc, ilike, inArray, and, gte, lte, not, or, eq } from "drizzle-orm"; +import { asc, desc, ilike, and, or, eq } from "drizzle-orm"; import { headers } from 'next/headers'; // 레포지토리 함수들 (예시) - 아래처럼 작성했다고 가정 @@ -99,7 +98,7 @@ export async function getUsers(input: GetUsersSchema) { const pageCount = Math.ceil(total / input.perPage); return { data, pageCount }; - } catch (err) { + } catch { return { data: [], pageCount: 0 }; } }, @@ -185,7 +184,7 @@ export async function findUserById(id: number) { // } // } -export async function createAdminUser(input: CreateUserSchema & { language?: string }) { +export async function createAdminUser(input: CreateUserSchema & { language?: string; phone?: string }) { unstable_noStore(); // Next.js 캐싱 방지 try { @@ -252,6 +251,7 @@ export async function createAdminUser(input: CreateUserSchema & { language?: str const [newUser] = await insertUser(tx, { name: input.name, email: input.email, + phone: input.phone, // 전화번호 필드 추가 domain: input.domain, companyId: input.companyId ?? null, // 기타 필요한 필드 추가 @@ -300,7 +300,7 @@ export async function getUserCountGroupByCompany() { return obj; }); return result; - } catch (err) { + } catch { return {}; } }, @@ -335,8 +335,7 @@ export async function getUserCountGroupByRole() { // 여기서 result를 반환해 줘야 함! return result; - } catch (err) { - console.error("getUserCountGroupByRole error:", err); + } catch { return {}; } }, @@ -349,7 +348,7 @@ export async function getUserCountGroupByRole() { /** * 단건 업데이트 */ -export async function modifiUser(input: UpdateUserSchema & { id: number } & { language?: string }) { +export async function modifiUser(input: UpdateUserSchema & { id: number } & { language?: string; phone?: string }) { unstable_noStore(); try { @@ -363,6 +362,7 @@ export async function modifiUser(input: UpdateUserSchema & { id: number } & { la name: input.name, companyId: input.companyId, email: input.email, + phone: input.phone, // 전화번호 필드 추가 }); // 2) roles가 함께 왔다면, 기존 roles 삭제 → 새 roles 삽입 @@ -507,7 +507,7 @@ export async function removeUsers(input: { ids: number[] }) { export async function getAllCompanies(): Promise<Vendor[]> { try { return await findAllCompanies(); // Company[] - } catch (err) { + } catch { throw new Error("Failed to get companies"); } } @@ -515,7 +515,7 @@ export async function getAllCompanies(): Promise<Vendor[]> { export async function getAllRoles(): Promise<Role[]> { try { return await findAllRoles(); - } catch (err) { + } catch { throw new Error("Failed to get roles"); } } |
