-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afc6c38
commit 9e76721
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
packages/interface/src/api/organization/endpoint/apiOrg002.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { HttpStatusCode } from "axios"; | ||
import { z } from "zod"; | ||
|
||
import { | ||
zOrgName, | ||
zOrgNameEng, | ||
} from "@sparcs-students/interface/common/stringLength"; | ||
import { OrganizationTypeE } from "@sparcs-students/interface/common/enum"; | ||
import { zId } from "@sparcs-students/interface/common/type/ids"; | ||
|
||
/** | ||
* @version v0.1 | ||
* @description 총학생회장 권한으로 새로운 단체를 생성합니다. | ||
*/ | ||
|
||
const url = () => `/uapresident/organizations/organization`; | ||
const method = "POST"; | ||
|
||
const requestParam = z.object({}); | ||
|
||
const requestQuery = z.object({}); | ||
|
||
const requestBody = z.object({ | ||
name: zOrgName, | ||
nameEng: zOrgNameEng, | ||
organizationTypeId: z.nativeEnum(OrganizationTypeE), | ||
foundingYear: z.coerce.number().int(), | ||
startTerm: z.coerce.date(), | ||
endTerm: z.coerce.date().optional(), | ||
}); | ||
|
||
const responseBodyMap = { | ||
[HttpStatusCode.Ok]: z.object({ | ||
organizationId: zId, | ||
}), | ||
}; | ||
|
||
const responseErrorMap = {}; | ||
|
||
const apiOrg002 = { | ||
url, | ||
method, | ||
requestParam, | ||
requestQuery, | ||
requestBody, | ||
responseBodyMap, | ||
responseErrorMap, | ||
}; | ||
|
||
type ApiOrg002RequestParam = z.infer<typeof apiOrg002.requestParam>; | ||
type ApiOrg002RequestQuery = z.infer<typeof apiOrg002.requestQuery>; | ||
type ApiOrg002RequestBody = z.infer<typeof apiOrg002.requestBody>; | ||
type ApiOrg002ResponseOK = z.infer<(typeof apiOrg002.responseBodyMap)[200]>; | ||
|
||
export default apiOrg002; | ||
|
||
export const ApiOrg002RequestUrl = "/uapresident/organizations/organization"; | ||
|
||
export type { | ||
ApiOrg002RequestParam, | ||
ApiOrg002RequestQuery, | ||
ApiOrg002RequestBody, | ||
ApiOrg002ResponseOK, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./organization.enum"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// 조직 유형 E | ||
export enum OrganizationTypeE { | ||
Autonomous = 1, // 자치기구 | ||
Standing, // 상설위원회 | ||
Specialized, // 전문기구 | ||
Special, // 특별기구 | ||
Emergency, // 비상대책위원회 | ||
UA, // 학부 총학생회 | ||
StudentCouncil, // 학과학생회 | ||
Preparatory, // 준비위원회 | ||
Affairs, // 특임위원회 | ||
Inspect, // 조사위원회 | ||
} | ||
|
||
// 조직 대표 유형 E | ||
export enum OrganizationPresidentTypeE { | ||
Chief = 1, // 정 | ||
Vice, // 부 | ||
} | ||
|
||
// OrganizationTypeE | ||
export const getDisplayNameOrganizationTypeE = ( | ||
type: OrganizationTypeE | undefined, | ||
) => { | ||
switch (type) { | ||
case OrganizationTypeE.Autonomous: | ||
return "자치기구"; | ||
case OrganizationTypeE.Standing: | ||
return "상설위원회"; | ||
case OrganizationTypeE.Specialized: | ||
return "전문기구"; | ||
case OrganizationTypeE.Special: | ||
return "특별기구"; | ||
case OrganizationTypeE.Emergency: | ||
return "비상대책위원회"; | ||
case OrganizationTypeE.UA: | ||
return "학부 총학생회"; | ||
case OrganizationTypeE.StudentCouncil: | ||
return "학과학생회"; | ||
case OrganizationTypeE.Preparatory: | ||
return "준비위원회"; | ||
case OrganizationTypeE.Affairs: | ||
return "특임위원회"; | ||
case OrganizationTypeE.Inspect: | ||
return "조사위원회"; | ||
default: | ||
return ""; | ||
} | ||
}; | ||
|
||
// OrganizationPresidentTypeE | ||
export const getDisplayNameOrganizationPresidentTypeE = ( | ||
type: OrganizationPresidentTypeE | undefined, | ||
) => { | ||
switch (type) { | ||
case OrganizationPresidentTypeE.Chief: | ||
return "정"; | ||
case OrganizationPresidentTypeE.Vice: | ||
return "부"; | ||
default: | ||
return ""; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import z from "zod"; | ||
|
||
export const zId = z.coerce.number().int().min(1); |