Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1322 fix type of studentnumber from number to string #1323

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api/src/common/util/decorators/param-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface StudentProfile {
email: string;
type: string;
studentId: number;
studentNumber: number;
studentNumber: string;
}
export type GetStudent = StudentProfile;
interface ExecutiveProfile {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/drizzle/schema/user.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const User = mysqlTable("user", {
export const Student = mysqlTable("student", {
id: int("id").autoincrement().primaryKey(),
userId: int("user_id").references(() => User.id),
number: int("number").unique(),
number: varchar("number", { length: 10 }).unique().notNull(),
name: varchar("name", { length: 255 }).notNull(),
email: varchar("email", { length: 255 }),
phoneNumber: varchar("phone_number", { length: 30 }),
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/feature/auth/dto/auth.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface User {
name: string;
email: string;
studentId?: number;
studentNumber?: number;
studentNumber?: string;
executiveId?: number;
}

Expand Down
34 changes: 17 additions & 17 deletions packages/api/src/feature/auth/repository/auth.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ interface FindOrCreateUserReturn {
email: string;
undergraduate?: {
id: number;
number: number;
number: string;
};
master?: {
id: number;
number: number;
number: string;
};
doctor?: {
id: number;
number: number;
number: string;
};
executive?: {
id: number;
Expand Down Expand Up @@ -101,15 +101,15 @@ export class AuthRepository {
.insert(Student)
.values({
name,
number: parseInt(studentNumber),
number: studentNumber,
userId: user.id,
email,
})
.onDuplicateKeyUpdate({ set: { userId: user.id, name } });
const student = await this.db
.select()
.from(Student)
.where(eq(Student.number, parseInt(studentNumber)))
.where(eq(Student.number, studentNumber))
.then(takeUnique);

// studentNumber의 뒤 네자리가 2000 미만일 경우 studentEnum을 1, 5000미만일 경우 2, 6000미만일 경우 1, 나머지는 3으로 설정
Expand All @@ -132,9 +132,9 @@ export class AuthRepository {
for (const student of students) {
// eslint-disable-next-line @typescript-eslint/no-shadow
let studentEnum = 3;
if (student.number % 10000 < 2000) studentEnum = 1;
else if (student.number % 10000 < 6000) studentEnum = 2;
else if (student.number % 10000 < 7000) studentEnum = 1;
if (parseInt(student.number.slice(-4)) < 2000) studentEnum = 1;
else if (parseInt(student.number.slice(-4)) < 6000) studentEnum = 2;
else if (parseInt(student.number.slice(-4)) < 7000) studentEnum = 1;

if (studentEnum === 1) {
result = {
Expand Down Expand Up @@ -283,15 +283,15 @@ export class AuthRepository {
email: string;
undergraduate?: {
id: number;
number: number;
number: string;
};
master?: {
id: number;
number: number;
number: string;
};
doctor?: {
id: number;
number: number;
number: string;
};
executive?: {
id: number;
Expand Down Expand Up @@ -319,15 +319,15 @@ export class AuthRepository {
email: string;
undergraduate?: {
id: number;
number: number;
number: string;
};
master?: {
id: number;
number: number;
number: string;
};
doctor?: {
id: number;
number: number;
number: string;
};
executive?: {
id: number;
Expand Down Expand Up @@ -356,9 +356,9 @@ export class AuthRepository {
// eslint-disable-next-line no-restricted-syntax, @typescript-eslint/no-shadow
for (const student of await students) {
let studentEnum = 3;
if (student.number % 10000 < 2000) studentEnum = 1;
else if (student.number % 10000 < 6000) studentEnum = 2;
else if (student.number % 10000 < 7000) studentEnum = 1;
if (parseInt(student.number.slice(-4)) < 2000) studentEnum = 1;
else if (parseInt(student.number.slice(-4)) < 6000) studentEnum = 2;
else if (parseInt(student.number.slice(-4)) < 7000) studentEnum = 1;

if (studentEnum === 1) {
result.undergraduate = { id: student.id, number: student.number };
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/feature/auth/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ export class AuthService {
email: string;
undergraduate?: {
id: number;
number: number;
number: string;
};
master?: {
id: number;
number: number;
number: string;
};
doctor?: {
id: number;
number: number;
number: string;
};
executive?: {
id: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class ClubPublicService {
Array<{
studentId: number;
name: string;
studentNumber: number;
studentNumber: string;
}>
> {
const result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from "zod";

import { ActivityCertificateOrderStatusEnum } from "@sparcs-clubs/interface/common/enum/activityCertificate.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand All @@ -25,7 +26,7 @@ const responseBodyMap = {
[HttpStatusCode.Ok]: z.object({
id: z.coerce.number().int().min(1),
clubId: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
studentPhoneNumber: zKrPhoneNumber,
issuedNumber: z.coerce.number().int().min(1),
statusEnum: z.nativeEnum(ActivityCertificateOrderStatusEnum),
Expand Down
3 changes: 2 additions & 1 deletion packages/interface/src/api/activity/endpoint/apiAct002.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ActivityStatusEnum,
ActivityTypeEnum,
} from "@sparcs-clubs/interface/common/enum/activity.enum";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand Down Expand Up @@ -51,7 +52,7 @@ const responseBodyMap = {
participants: z.array(
z.object({
studentId: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(20000000),
studentNumber: zStudentNumber,
name: z.string().max(255),
}),
),
Expand Down
4 changes: 2 additions & 2 deletions packages/interface/src/api/activity/endpoint/apiAct010.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpStatusCode } from "axios";
import { z } from "zod";

import { zUserName } from "@sparcs-clubs/interface/common/commonString";

import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";
/**
* @version v0.1
* @description
Expand All @@ -26,7 +26,7 @@ const responseBodyMap = {
students: z.array(
z.object({
id: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
name: zUserName,
}),
),
Expand Down
3 changes: 2 additions & 1 deletion packages/interface/src/api/club/endpoint/apiClb006.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { zUserName } from "@sparcs-clubs/interface/common/commonString";

import { ClubDelegateEnum } from "@sparcs-clubs/interface/common/enum/club.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand All @@ -28,7 +29,7 @@ const responseBodyMap = {
z.object({
delegateEnumId: z.nativeEnum(ClubDelegateEnum),
studentId: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
name: zUserName,
phoneNumber: zKrPhoneNumber,
}),
Expand Down
3 changes: 2 additions & 1 deletion packages/interface/src/api/club/endpoint/apiClb008.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from "zod";

import { ClubDelegateEnum } from "@sparcs-clubs/interface/common/enum/club.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand Down Expand Up @@ -30,7 +31,7 @@ const responseBodyMap = {
students: z.array(
z.object({
id: z.coerce.number().int(),
studentNumber: z.string(),
studentNumber: zStudentNumber,
name: z.coerce.string().max(20), // studentNumber는 string으로 통일!
phoneNumber: zKrPhoneNumber,
}),
Expand Down
3 changes: 2 additions & 1 deletion packages/interface/src/api/club/endpoint/apiClb010.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HttpStatusCode } from "axios";
import { z } from "zod";

import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";
/**
* @version v0.1
* @description semesterId에 해당하는 학기에 clubId의 동아리에서 활동한 모든 회원 정보를 가져옵니다.
Expand All @@ -26,7 +27,7 @@ const responseBodyMap = {
.object({
name: z.coerce.string().max(30),
studentId: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(20000000).max(30000000),
studentNumber: zStudentNumber,
email: z.coerce.string().max(50),
phoneNumber: zKrPhoneNumber.optional(),
})
Expand Down
3 changes: 2 additions & 1 deletion packages/interface/src/api/club/endpoint/apiClb011.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HttpStatusCode } from "axios";
import { z } from "zod";

import { ClubDelegateChangeRequestStatusEnum } from "@sparcs-clubs/interface/common/enum/club.enum";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand All @@ -25,7 +26,7 @@ const responseBodyMap = {
requests: z
.object({
studentId: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(20000000).max(30000000),
studentNumber: zStudentNumber,
studentName: z.coerce.string(),
clubDelegateChangeRequestStatusEnumId: z.nativeEnum(
ClubDelegateChangeRequestStatusEnum,
Expand Down
3 changes: 2 additions & 1 deletion packages/interface/src/api/club/endpoint/apiClb013.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HttpStatusCode } from "axios";
import { z } from "zod";

import { ClubDelegateChangeRequestStatusEnum } from "@sparcs-clubs/interface/common/enum/club.enum";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand All @@ -23,7 +24,7 @@ const responseBodyMap = {
.object({
id: z.number().int().min(1),
prevStudentId: z.coerce.number().int().min(1),
prevStudentNumber: z.coerce.number().int().min(20000000).max(30000000),
prevStudentNumber: zStudentNumber,
prevStudentName: z.coerce.string(),
clubId: z.coerce.number().int().min(1),
clubName: z.coerce.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { z } from "zod";
import { zUserName } from "@sparcs-clubs/interface/common/commonString";
import { RegistrationApplicationStudentStatusEnum } from "@sparcs-clubs/interface/common/enum/registration.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand Down Expand Up @@ -34,7 +35,7 @@ const responseBodyMap = {
student: z.object({
id: z.coerce.number().int().min(1),
name: zUserName,
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
email: z.string(),
phoneNumber: zKrPhoneNumber.optional(),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {

import { ProfessorEnum } from "@sparcs-clubs/interface/common/enum/user.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

import registrationTypeEnumChecker from "../utils/registrationTypeEnumChecker";

Expand Down Expand Up @@ -43,7 +44,7 @@ const responseBodyMap = {
newClubNameKr: zClubName,
newClubNameEn: zClubName,
representative: z.object({
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
name: z.string().max(30),
phoneNumber: zKrPhoneNumber,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "@sparcs-clubs/interface/common/enum/registration.enum";
import { ProfessorEnum } from "@sparcs-clubs/interface/common/enum/user.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

import registrationTypeEnumChecker from "../utils/registrationTypeEnumChecker";

Expand Down Expand Up @@ -41,7 +42,7 @@ const responseBodyMap = {
newClubNameKr: zClubName,
newClubNameEn: zClubName,
representative: z.object({
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
name: z.string().max(30),
phoneNumber: zKrPhoneNumber,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from "zod";

import { zUserName } from "@sparcs-clubs/interface/common/commonString";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand Down Expand Up @@ -41,7 +42,7 @@ const responseBodyMap = {
isRegularMemberRegistration: z.coerce.boolean(),
student: z.object({
id: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
name: zUserName,
phoneNumber: zKrPhoneNumber.optional(),
email: z.string().email(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "@sparcs-clubs/interface/common/commonString";
import { RegistrationStatusEnum } from "@sparcs-clubs/interface/common/enum/registration.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

/**
* @version v0.1
Expand Down Expand Up @@ -42,7 +43,7 @@ const responseBodyMap = {
newClubNameEn: zClubName,
student: z.object({
id: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
name: zUserName,
phoneNumber: zKrPhoneNumber.optional(),
email: z.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {

import { ProfessorEnum } from "@sparcs-clubs/interface/common/enum/user.enum";
import { zKrPhoneNumber } from "@sparcs-clubs/interface/common/type/phoneNumber.type";
import { zStudentNumber } from "@sparcs-clubs/interface/common/type/user.type";

import registrationTypeEnumChecker from "../utils/registrationTypeEnumChecker";

Expand Down Expand Up @@ -42,7 +43,7 @@ const responseBodyMap = {
newClubNameKr: zClubName,
newClubNameEn: zClubName,
representative: z.object({
studentNumber: z.coerce.number().int().min(1),
studentNumber: zStudentNumber,
name: z.string().max(30),
phoneNumber: zKrPhoneNumber,
}),
Expand Down
Loading