-
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
Showing
21 changed files
with
245 additions
and
4 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
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
14 changes: 14 additions & 0 deletions
14
apps/hcdc-access-service/src/domain/entity/print-form/auth.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,14 @@ | ||
import '@casl/mongoose' | ||
|
||
export enum PrintFormAction { | ||
Create = 'Create', | ||
Read = 'Read', | ||
Update = 'Update', | ||
Delete = 'Delete', | ||
} | ||
|
||
declare module '@casl/mongoose' { | ||
interface RecordTypes { | ||
PrintForm: true | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
apps/hcdc-access-service/src/domain/entity/print-form/entity.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,25 @@ | ||
import { BaseEntity } from '../base-entity' | ||
import { Branch } from '../branch' | ||
|
||
export enum PrintTemplate { | ||
FormChung = 'FormChung', | ||
FormHIV = 'FormHIV', | ||
FormPap = 'FormPap', | ||
FormSoiNhuom = 'FormSoiNhuom', | ||
FormTD = 'FormTD', | ||
} | ||
|
||
export type PrintForm = BaseEntity & { | ||
displayIndex: number | ||
name: string | ||
isA4: boolean | ||
isAuthorLocked: boolean | ||
authorTitle: string | ||
authorName: string | ||
titleMargin: number | ||
|
||
template: PrintTemplate | ||
|
||
branchId: string | ||
branch?: Branch | null | ||
} |
29 changes: 29 additions & 0 deletions
29
apps/hcdc-access-service/src/domain/entity/print-form/example.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,29 @@ | ||
import { exampleMongoObjectId } from '@diut/nest-core' | ||
|
||
import { EntityDataExample } from '../base-entity' | ||
import { PrintForm, PrintTemplate } from './entity' | ||
|
||
export const examplePrintForm = { | ||
displayIndex: { | ||
example: 1, | ||
}, | ||
name: { | ||
example: 'CHIV Advia centaur', | ||
}, | ||
isA4: {}, | ||
isAuthorLocked: {}, | ||
authorTitle: { | ||
example: 'Chức vụ', | ||
}, | ||
authorName: { | ||
example: 'Nguyễn Văn A', | ||
}, | ||
titleMargin: { example: 12 }, | ||
template: { | ||
enum: PrintTemplate, | ||
}, | ||
branchId: exampleMongoObjectId, | ||
branch: { | ||
required: false, | ||
}, | ||
} satisfies EntityDataExample<PrintForm> |
3 changes: 3 additions & 0 deletions
3
apps/hcdc-access-service/src/domain/entity/print-form/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,3 @@ | ||
export * from './entity' | ||
export * from './example' | ||
export * from './auth' |
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,14 @@ | ||
import '@casl/mongoose' | ||
|
||
export enum TestAction { | ||
Create = 'Create', | ||
Read = 'Read', | ||
Update = 'Update', | ||
Delete = 'Delete', | ||
} | ||
|
||
declare module '@casl/mongoose' { | ||
interface RecordTypes { | ||
Test: true | ||
} | ||
} |
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,12 @@ | ||
import { BaseEntity } from '../base-entity' | ||
import { Branch } from '../branch' | ||
|
||
export type Test = BaseEntity & { | ||
displayIndex: number | ||
name: string | ||
shouldNotPrint: boolean | ||
shouldDisplayWithChildren: boolean | ||
|
||
branchId: string | ||
branch?: Branch | null | ||
} |
19 changes: 19 additions & 0 deletions
19
apps/hcdc-access-service/src/domain/entity/test/example.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,19 @@ | ||
import { exampleMongoObjectId } from '@diut/nest-core' | ||
|
||
import { EntityDataExample } from '../base-entity' | ||
import { Test } from './entity' | ||
|
||
export const exampleTest = { | ||
displayIndex: { | ||
example: 1, | ||
}, | ||
name: { | ||
example: 'CHIV Advia centaur', | ||
}, | ||
shouldNotPrint: {}, | ||
shouldDisplayWithChildren: {}, | ||
branchId: exampleMongoObjectId, | ||
branch: { | ||
required: false, | ||
}, | ||
} satisfies EntityDataExample<Test> |
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 @@ | ||
export * from './entity' | ||
export * from './example' | ||
export * from './auth' |
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
6 changes: 6 additions & 0 deletions
6
apps/hcdc-access-service/src/domain/interface/repository/print-form.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,6 @@ | ||
import { PrintForm } from 'src/domain/entity' | ||
import { IRepository } from './interface' | ||
|
||
export const PrintFormRepositoryToken = Symbol('PrintFormRepository') | ||
|
||
export interface IPrintFormRepository extends IRepository<PrintForm> {} |
6 changes: 6 additions & 0 deletions
6
apps/hcdc-access-service/src/domain/interface/repository/test.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,6 @@ | ||
import { Test } from 'src/domain/entity' | ||
import { IRepository } from './interface' | ||
|
||
export const TestRepositoryToken = Symbol('TestRepository') | ||
|
||
export interface ITestRepository extends IRepository<Test> {} |
2 changes: 2 additions & 0 deletions
2
apps/hcdc-access-service/src/infrastructure/mongo/print-form/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,2 @@ | ||
export * from './repository' | ||
export * from './schema' |
17 changes: 17 additions & 0 deletions
17
apps/hcdc-access-service/src/infrastructure/mongo/print-form/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,17 @@ | ||
import { InjectModel } from '@nestjs/mongoose' | ||
import { MongoRepository } from '@diut/nest-core' | ||
import { Model } from 'mongoose' | ||
|
||
import { IPrintFormRepository } from 'src/domain' | ||
import { PrintFormSchema } from './schema' | ||
|
||
export class PrintFormRepository | ||
extends MongoRepository<PrintFormSchema> | ||
implements IPrintFormRepository | ||
{ | ||
constructor( | ||
@InjectModel(PrintFormSchema.name) model: Model<PrintFormSchema>, | ||
) { | ||
super(model) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
apps/hcdc-access-service/src/infrastructure/mongo/print-form/schema.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,32 @@ | ||
import { Prop, Schema } from '@nestjs/mongoose' | ||
import { BaseSchema, baseSchemaOptions } from '@diut/nest-core' | ||
import { Types } from 'mongoose' | ||
|
||
import { COLLECTION } from '../collections' | ||
import { BranchSchema } from '../branch' | ||
|
||
@Schema({ | ||
...baseSchemaOptions, | ||
collection: COLLECTION.BIO_PRODUCT, | ||
virtuals: { | ||
branch: { | ||
options: { | ||
ref: BranchSchema.name, | ||
localField: 'branchId', | ||
foreignField: '_id', | ||
justOne: true, | ||
}, | ||
}, | ||
}, | ||
}) | ||
export class PrintFormSchema extends BaseSchema { | ||
@Prop({ required: true }) | ||
displayIndex: number | ||
|
||
@Prop({ required: true }) | ||
name: string | ||
|
||
@Prop({ required: true, type: Types.ObjectId }) | ||
branchId: string | ||
branch?: BranchSchema | null | ||
} |
2 changes: 2 additions & 0 deletions
2
apps/hcdc-access-service/src/infrastructure/mongo/test/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,2 @@ | ||
export * from './repository' | ||
export * from './schema' |
15 changes: 15 additions & 0 deletions
15
apps/hcdc-access-service/src/infrastructure/mongo/test/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,15 @@ | ||
import { InjectModel } from '@nestjs/mongoose' | ||
import { MongoRepository } from '@diut/nest-core' | ||
import { Model } from 'mongoose' | ||
|
||
import { ITestRepository } from 'src/domain' | ||
import { TestSchema } from './schema' | ||
|
||
export class TestRepository | ||
extends MongoRepository<TestSchema> | ||
implements ITestRepository | ||
{ | ||
constructor(@InjectModel(TestSchema.name) model: Model<TestSchema>) { | ||
super(model) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
apps/hcdc-access-service/src/infrastructure/mongo/test/schema.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,32 @@ | ||
import { Prop, Schema } from '@nestjs/mongoose' | ||
import { BaseSchema, baseSchemaOptions } from '@diut/nest-core' | ||
import { Types } from 'mongoose' | ||
|
||
import { COLLECTION } from '../collections' | ||
import { BranchSchema } from '../branch' | ||
|
||
@Schema({ | ||
...baseSchemaOptions, | ||
collection: COLLECTION.BIO_PRODUCT, | ||
virtuals: { | ||
branch: { | ||
options: { | ||
ref: BranchSchema.name, | ||
localField: 'branchId', | ||
foreignField: '_id', | ||
justOne: true, | ||
}, | ||
}, | ||
}, | ||
}) | ||
export class TestSchema extends BaseSchema { | ||
@Prop({ required: true }) | ||
displayIndex: number | ||
|
||
@Prop({ required: true }) | ||
name: string | ||
|
||
@Prop({ required: true, type: Types.ObjectId }) | ||
branchId: string | ||
branch?: BranchSchema | null | ||
} |