-
Notifications
You must be signed in to change notification settings - Fork 17
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
Showing
17 changed files
with
311 additions
and
92 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
apps/server/src/modules/school/api/controller/mapper/federal-state.mapper.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,33 @@ | ||
import { County } from '@src/modules/school/domain'; | ||
import { FederalStateDto } from '@src/modules/school/domain/dto'; | ||
import { FederalStateResponse } from '../response'; | ||
import { CountyResponse } from '../response/county.response'; | ||
|
||
export class FederalStateMapper { | ||
public static mapToResponse(federalState: FederalStateDto): FederalStateResponse { | ||
const counties = federalState.counties && this.mapToCountyResponses(federalState.counties); | ||
|
||
const res = new FederalStateResponse({ | ||
...federalState, | ||
counties, | ||
}); | ||
|
||
return res; | ||
} | ||
|
||
private static mapToCountyResponses(counties: County[]): CountyResponse[] { | ||
const res = counties.map((county) => this.mapToCountyResponse(county)); | ||
|
||
return res; | ||
} | ||
|
||
private static mapToCountyResponse(county: County): CountyResponse { | ||
const res = new CountyResponse({ | ||
name: county.name, | ||
countyId: county.countyId, | ||
antaresKey: county.antaresKey, | ||
}); | ||
|
||
return res; | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
apps/server/src/modules/school/api/controller/mapper/school-year.mapper.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,10 @@ | ||
import { SchoolYearDto } from '@src/modules/school/domain'; | ||
import { SchoolYearResponse } from '../response'; | ||
|
||
export class SchoolYearMapper { | ||
public static mapToResponse(schoolYear: SchoolYearDto): SchoolYearResponse { | ||
const res = new SchoolYearResponse(schoolYear); | ||
|
||
return res; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
apps/server/src/modules/school/api/controller/mapper/system.mapper.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,10 @@ | ||
import { SystemDto } from '@src/modules/school/domain'; | ||
import { SystemResponse } from '../response'; | ||
|
||
export class SystemMapper { | ||
public static mapToResponse(system: SystemDto): SystemResponse { | ||
const res = new SystemResponse(system); | ||
|
||
return res; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
apps/server/src/modules/school/api/controller/response/index.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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export * from './federal-state.response'; | ||
export * from './school.response'; | ||
export * from './school-list.response'; | ||
export * from './school-year.response'; | ||
export * from './system.response'; |
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
21 changes: 21 additions & 0 deletions
21
apps/server/src/modules/school/domain/dto/federal-state.dto.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,21 @@ | ||
import { County } from '../type'; | ||
|
||
export class FederalStateDto { | ||
constructor({ id, name, abbreviation, logoUrl, counties }: FederalStateDto) { | ||
this.id = id; | ||
this.name = name; | ||
this.abbreviation = abbreviation; | ||
this.logoUrl = logoUrl; | ||
this.counties = counties; | ||
} | ||
|
||
id: string; | ||
|
||
name: string; | ||
|
||
abbreviation: string; | ||
|
||
logoUrl: string; | ||
|
||
counties?: County[]; | ||
} |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
export * from './federal-state.dto'; | ||
export * from './school.dto'; | ||
export * from './school-year.dto'; | ||
export * from './slim-school.dto'; | ||
export * from './system.dto'; |
16 changes: 16 additions & 0 deletions
16
apps/server/src/modules/school/domain/dto/school-year.dto.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,16 @@ | ||
export class SchoolYearDto { | ||
constructor({ id, name, startDate, endDate }: SchoolYearDto) { | ||
this.id = id; | ||
this.name = name; | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
} | ||
|
||
id: string; | ||
|
||
name: string; | ||
|
||
startDate: Date; | ||
|
||
endDate: Date; | ||
} |
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,58 @@ | ||
import { County, SchoolFeature, SchoolPurpose } from '../type'; | ||
import { FederalStateDto } from './federal-state.dto'; | ||
import { SchoolYearDto } from './school-year.dto'; | ||
import { SystemDto } from './system.dto'; | ||
|
||
export class SchoolDto { | ||
constructor({ | ||
id, | ||
name, | ||
officialSchoolNumber, | ||
federalState, | ||
currentYear, | ||
purpose, | ||
features, | ||
county, | ||
systems, | ||
inMaintenance, | ||
isExternal, | ||
logo_dataUrl, | ||
}: SchoolDto) { | ||
this.id = id; | ||
this.name = name; | ||
this.officialSchoolNumber = officialSchoolNumber; | ||
this.federalState = federalState; | ||
this.currentYear = currentYear; | ||
this.purpose = purpose; | ||
this.features = features; | ||
this.county = county; | ||
this.systems = systems; | ||
this.inMaintenance = inMaintenance; | ||
this.isExternal = isExternal; | ||
this.logo_dataUrl = logo_dataUrl; | ||
} | ||
|
||
id: string; | ||
|
||
name: string; | ||
|
||
officialSchoolNumber?: string; | ||
|
||
currentYear?: SchoolYearDto; | ||
|
||
federalState: FederalStateDto; | ||
|
||
county?: County; | ||
|
||
purpose?: SchoolPurpose; | ||
|
||
features?: SchoolFeature[]; | ||
|
||
systems?: SystemDto[]; | ||
|
||
inMaintenance: boolean; | ||
|
||
isExternal: boolean; | ||
|
||
logo_dataUrl?: string; | ||
} |
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,48 @@ | ||
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; | ||
import { LdapConfig, OauthConfig, OidcConfig } from '../type'; | ||
|
||
export class SystemDto { | ||
constructor({ | ||
id, | ||
type, | ||
url, | ||
alias, | ||
displayName, | ||
oauthConfig, | ||
oidcConfig, | ||
ldapConfig, | ||
provisioningStrategy, | ||
provisioningUrl, | ||
}: SystemDto) { | ||
this.id = id; | ||
this.type = type; | ||
this.url = url; | ||
this.alias = alias; | ||
this.displayName = displayName; | ||
this.oauthConfig = oauthConfig; | ||
this.oidcConfig = oidcConfig; | ||
this.ldapConfig = ldapConfig; | ||
this.provisioningStrategy = provisioningStrategy; | ||
this.provisioningUrl = provisioningUrl; | ||
} | ||
|
||
id: string; | ||
|
||
type: string; | ||
|
||
url?: string; | ||
|
||
alias?: string; | ||
|
||
displayName?: string; | ||
|
||
oauthConfig?: OauthConfig; | ||
|
||
oidcConfig?: OidcConfig; | ||
|
||
ldapConfig?: LdapConfig; | ||
|
||
provisioningStrategy?: SystemProvisioningStrategy; | ||
|
||
provisioningUrl?: string; | ||
} |
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
18 changes: 18 additions & 0 deletions
18
apps/server/src/modules/school/domain/mapper/federal-state.mapper.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,18 @@ | ||
import { FederalState } from '../do'; | ||
import { FederalStateDto } from '../dto'; | ||
|
||
export class FederalStateMapper { | ||
public static mapToDto(federalState: FederalState): FederalStateDto { | ||
const federalStateProps = federalState.getProps(); | ||
|
||
const dto = new FederalStateDto({ | ||
id: federalState.id, | ||
name: federalStateProps.name, | ||
abbreviation: federalStateProps.abbreviation, | ||
logoUrl: federalStateProps.logoUrl, | ||
counties: federalStateProps.counties, | ||
}); | ||
|
||
return dto; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
apps/server/src/modules/school/domain/mapper/school-year.mapper.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,17 @@ | ||
import { SchoolYear } from '../do'; | ||
import { SchoolYearDto } from '../dto'; | ||
|
||
export class SchoolYearMapper { | ||
public static mapToDto(schoolYear: SchoolYear): SchoolYearDto { | ||
const schoolYearProps = schoolYear.getProps(); | ||
|
||
const dto = new SchoolYearDto({ | ||
id: schoolYear.id, | ||
name: schoolYearProps.name, | ||
startDate: schoolYearProps.startDate, | ||
endDate: schoolYearProps.endDate, | ||
}); | ||
|
||
return dto; | ||
} | ||
} |
Oops, something went wrong.