-
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
c13b880
commit 31b5b45
Showing
24 changed files
with
324 additions
and
42 deletions.
There are no files selected for viewing
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
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
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
8 changes: 4 additions & 4 deletions
8
src/application/common/interfaces/core-system-configs-repository.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,6 +1,6 @@ | ||
import { ConfigSystem } from '@domain/entities'; | ||
import { CoreSystemConfigEntity } from '@domain/entities'; | ||
|
||
export interface ConfigSystemsRepository { | ||
website(): Promise<{ data: Array<ConfigSystem> }>; | ||
registration(): Promise<{ data: Array<ConfigSystem> }>; | ||
export interface CoreSystemConfigsRepository { | ||
website(): Promise<CoreSystemConfigEntity[] | []>; | ||
registration(): Promise<CoreSystemConfigEntity[] | []>; | ||
} |
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
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,11 @@ | ||
import { makeGetWebsiteQuery } from "./queries/get-website"; | ||
import { makeGetRegistrationQuery } from "./queries/get-registration"; | ||
|
||
export function makeCoreSystemConfigsUseCases(dependencies: Dependencies) { | ||
return { | ||
queries: { | ||
getWebsite: makeGetWebsiteQuery(dependencies), | ||
getRegistration: makeGetRegistrationQuery(dependencies), | ||
}, | ||
}; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/application/core-system-config/queries/get-registration/get-registration-query-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,21 @@ | ||
import { CoreSystemConfigEntity } from "@domain/entities"; | ||
import { CoreSystemConfigDTO } from "@domain/dtos/core-system-config"; | ||
|
||
export function map(coreSystemConfig: CoreSystemConfigEntity): CoreSystemConfigDTO { | ||
return { | ||
id: Number(coreSystemConfig.id), | ||
group: coreSystemConfig.group, | ||
type: coreSystemConfig.type, | ||
value: coreSystemConfig.value, | ||
image: coreSystemConfig.image || "", | ||
description_vi: coreSystemConfig.description_vi || "", | ||
description_en: coreSystemConfig.description_en || "", | ||
order: Number(coreSystemConfig.order), | ||
block_delete: coreSystemConfig.block_delete || 0, | ||
status: Number(coreSystemConfig.status), | ||
created_at: coreSystemConfig.created_at?.toISOString() || null, | ||
updated_at: coreSystemConfig.updated_at?.toISOString() || null, | ||
created_by: coreSystemConfig.created_by || "", | ||
updated_by: coreSystemConfig.updated_by || "" | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/application/core-system-config/queries/get-registration/get-registration-query.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 { map } from "./get-registration-query-mapper"; | ||
|
||
export function makeGetRegistrationQuery({ coreSystemConfigsRepository }: Pick<Dependencies, 'coreSystemConfigsRepository'>) { | ||
return async function getRegistrationQuery() { | ||
|
||
const coreRegistrationSystemConfig = await coreSystemConfigsRepository.registration(); | ||
|
||
return coreRegistrationSystemConfig.map((item) => map(item)); | ||
}; | ||
} |
1 change: 1 addition & 0 deletions
1
src/application/core-system-config/queries/get-registration/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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './get-registration-query'; |
21 changes: 21 additions & 0 deletions
21
src/application/core-system-config/queries/get-website/get-website-query-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,21 @@ | ||
import { CoreSystemConfigEntity } from "@domain/entities"; | ||
import { CoreSystemConfigDTO } from "@domain/dtos/core-system-config"; | ||
|
||
export function map(coreSystemConfig: CoreSystemConfigEntity): CoreSystemConfigDTO { | ||
return { | ||
id: Number(coreSystemConfig.id), | ||
group: coreSystemConfig.group, | ||
type: coreSystemConfig.type, | ||
value: coreSystemConfig.value, | ||
image: coreSystemConfig.image || "", | ||
description_vi: coreSystemConfig.description_vi || "", | ||
description_en: coreSystemConfig.description_en || "", | ||
order: Number(coreSystemConfig.order), | ||
block_delete: coreSystemConfig.block_delete || 0, | ||
status: Number(coreSystemConfig.status), | ||
created_at: coreSystemConfig.created_at?.toISOString() || null, | ||
updated_at: coreSystemConfig.updated_at?.toISOString() || null, | ||
created_by: coreSystemConfig.created_by || "", | ||
updated_by: coreSystemConfig.updated_by || "" | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/application/core-system-config/queries/get-website/get-website-query.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 { map } from "./get-website-query-mapper"; | ||
|
||
export function makeGetWebsiteQuery({ coreSystemConfigsRepository }: Pick<Dependencies, 'coreSystemConfigsRepository'>) { | ||
return async function getWebsiteQuery() { | ||
|
||
const coreWebsiteSystemConfig = await coreSystemConfigsRepository.website(); | ||
|
||
return coreWebsiteSystemConfig.map((item) => map(item)); | ||
}; | ||
} |
1 change: 1 addition & 0 deletions
1
src/application/core-system-config/queries/get-website/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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './get-website-query'; |
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
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
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
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
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 interface CoreSystemConfigDTO { | ||
id: number; | ||
group: string; | ||
type: string; | ||
value: string; | ||
image: null | string; | ||
description_vi: string; | ||
description_en: string; | ||
order: number; | ||
block_delete: number; | ||
status: number; | ||
created_at: string | null; | ||
updated_at: string | null; | ||
created_by: string | null; | ||
updated_by: string | null; | ||
} |
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
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,48 +1,48 @@ | ||
export class ConfigSystem { | ||
export class CoreSystemConfigEntity { | ||
public id?: number; | ||
public group: string; | ||
public type: string; | ||
public value: string; | ||
public image?: string; | ||
public descriptionVi: string; | ||
public descriptionEn?: string; | ||
public order?: number; | ||
public blockDelete?: boolean; | ||
public status?: boolean; | ||
public createdAt?: Date; | ||
public updatedAt?: Date; | ||
public createdBy?: string; | ||
public updatedBy?: string; | ||
public image?: string | null; | ||
public description_vi: string; | ||
public description_en?: string | null; | ||
public order?: number | null; | ||
public block_delete?: number | null; | ||
public status?: boolean | null; | ||
public created_at?: Date | null; | ||
public updated_at?: Date | null; | ||
public created_by?: string | null; | ||
public updated_by?: string | null; | ||
|
||
constructor(config: { | ||
constructor(coreSystemConfigEntity: { | ||
id?: number; | ||
group: string; | ||
type: string; | ||
value: string; | ||
image?: string; | ||
descriptionVi: string; | ||
descriptionEn?: string; | ||
description_vi: string; | ||
description_en?: string; | ||
order?: number; | ||
blockDelete?: boolean; | ||
block_delete?: number; | ||
status?: boolean; | ||
createdAt?: Date; | ||
updatedAt?: Date; | ||
createdBy?: string; | ||
updatedBy?: string; | ||
created_at?: Date; | ||
updated_at?: Date; | ||
created_by?: string; | ||
updated_by?: string; | ||
}) { | ||
this.id = config.id; | ||
this.group = config.group; | ||
this.type = config.type; | ||
this.value = config.value; | ||
this.image = config.image; | ||
this.descriptionVi = config.descriptionVi; | ||
this.descriptionEn = config.descriptionEn; | ||
this.order = config.order; | ||
this.blockDelete = config.blockDelete; | ||
this.status = config.status; | ||
this.createdAt = config.createdAt; | ||
this.updatedAt = config.updatedAt; | ||
this.createdBy = config.createdBy; | ||
this.updatedBy = config.updatedBy; | ||
this.id = coreSystemConfigEntity.id; | ||
this.group = coreSystemConfigEntity.group; | ||
this.type = coreSystemConfigEntity.type; | ||
this.value = coreSystemConfigEntity.value; | ||
this.image = coreSystemConfigEntity.image; | ||
this.description_vi = coreSystemConfigEntity.description_vi; | ||
this.description_en = coreSystemConfigEntity.description_en; | ||
this.order = coreSystemConfigEntity.order; | ||
this.block_delete = coreSystemConfigEntity.block_delete; | ||
this.status = coreSystemConfigEntity.status; | ||
this.created_at = coreSystemConfigEntity.created_at; | ||
this.updated_at = coreSystemConfigEntity.updated_at; | ||
this.created_by = coreSystemConfigEntity.created_by; | ||
this.updated_by = coreSystemConfigEntity.updated_by; | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
src/infrastructure/repositories/core-system-config-repository.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,43 @@ | ||
import { CoreSystemConfigsRepository } from '@application/common/interfaces'; | ||
|
||
export function makeCoreSystemConfigRepository({ db }: Dependencies): CoreSystemConfigsRepository { | ||
return { | ||
async website() { | ||
const coreSystemConfig = await db.core_system_config.findMany({ | ||
where: { | ||
group: 'Website', | ||
type: 'Footer', | ||
status: 1, | ||
}, | ||
orderBy: { | ||
order: 'asc', | ||
}, | ||
}); | ||
|
||
return coreSystemConfig.map((config) => ({ | ||
...config, | ||
status: config.status === 1, | ||
id: Number(config.id), | ||
})); | ||
}, | ||
|
||
|
||
async registration() { | ||
const coreSystemConfig = await db.core_system_config.findMany({ | ||
where: { | ||
group: 'Registration', | ||
status: 1, | ||
}, | ||
orderBy: { | ||
order: 'asc', | ||
}, | ||
}); | ||
|
||
return coreSystemConfig.map((config) => ({ | ||
...config, | ||
status: config.status === 1, | ||
id: Number(config.id), | ||
})); | ||
}, | ||
}; | ||
} |
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
Oops, something went wrong.