Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
diagram: add class diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhhTien committed Dec 10, 2024
1 parent 5f92537 commit 83abd83
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .plantuml/class-diagram/garden-manager.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
@startuml Garden Manager Module

skinparam classAttributeIconSize 0

skinparam class {
BackgroundColor White
ArrowColor Black
BorderColor Black
}

' Controllers
class ManagementGardenManagerController {
-gardenManagerService: IGardenManagerService
-userTokenService: IUserTokenService
-gardenService: IGardenService
+list()
+getDetail()
+create()
+update()
+deactivate()
+activate()
}

' Interfaces
interface IGardenManagerService {
+create(createGardenManagerDto: CreateGardenManagerDto): Promise<GardenManagerDocument>
+findById(gardenManagerId: string, projection?, populates?): Promise<GardenManagerDocument>
+findByEmail(email: string, projection?): Promise<GardenManagerDocument>
+update(conditions: FilterQuery, payload: UpdateQuery, options?): Promise<GardenManagerDocument>
+list(pagination: PaginationParams, queryGardenManagerDto: QueryGardenManagerDto)
}

interface IGardenManagerRepository {
}

class GardenManagerService {
-gardenManagerRepository: IGardenManagerRepository
-helperService: HelperService
-notificationService: INotificationService
+create()
+findById()
+findByEmail()
+update()
+list()
}

class GardenManagerRepository {
+model: PaginateModel<GardenManagerDocument>
}

abstract class AbstractRepository {
+model: PaginateModel<T>
+constructor(model: PaginateModel<T>)
+findOne(params: {conditions, projection?, populates?, options?}): Promise<T | undefined>
+findMany(params: {conditions, projection?, populates?, sort?, options?}): Promise<Array<T>>
+create(payload: Record<string, any>, options?: SaveOptions): Promise<T>
+findOneAndUpdate(conditions: FilterQuery<T>, payload: UpdateQuery<T>, options?: QueryOptions): Promise<T>
}

' DTOs
class BaseGardenManagerDto {
+_id: string
+name: string
+password: string
+email: string
+idCardPhoto: string
+avatar: string
+status: GardenManagerStatus
+createdAt: Date
+updatedAt: Date
}

' Schemas
entity GardenManager {
+_id: string
+name: string
+email: string
+password: string
+idCardPhoto: string
+status: GardenManagerStatus
}

' Relationships
ManagementGardenManagerController ..> IGardenManagerService

IGardenManagerService <|.. GardenManagerService

GardenManagerService ..> IGardenManagerRepository

IGardenManagerRepository <|.. GardenManagerRepository
IGardenManagerRepository --|> AbstractRepository
GardenManagerRepository --|> AbstractRepository

GardenManagerRepository ..> GardenManager
BaseGardenManagerDto -- GardenManager

@enduml
110 changes: 110 additions & 0 deletions .plantuml/class-diagram/learner.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
@startuml Learner Module

skinparam classAttributeIconSize 0

skinparam class {
BackgroundColor White
ArrowColor Black
BorderColor Black
}

' Controllers
class ManagementLearnerController {
-learnerService: ILearnerService
-userTokenService: IUserTokenService
-reportService: IReportService
+list()
+getDetail()
+deactivate()
+activate()
}

class InstructorLearnerController {
-learnerService: ILearnerService
+getDetail()
}

class LearnerController {
-learnerService: ILearnerService
+viewProfile()
+updateProfile()
}

' Interfaces
interface ILearnerService {
+create(learner: any): Promise<LearnerDocument>
+findById(learnerId: string): Promise<LearnerDocument>
+findByEmail(email: string): Promise<LearnerDocument>
+update(conditions: FilterQuery, payload: UpdateQuery): Promise<LearnerDocument>
+list(pagination: PaginationParams, queryLearnerDto: QueryLearnerDto)
+findMany(conditions: FilterQuery): Promise<LearnerDocument[]>
}

interface ILearnerRepository {
}

class LearnerService {
-learnerRepository: ILearnerRepository
+create()
+findById()
+findByEmail()
+update()
+list()
+findMany()
}

class LearnerRepository {
+model: PaginateModel<LearnerDocument>
}

abstract class AbstractRepository {
+model: PaginateModel<T>
+constructor(model: PaginateModel<T>)
+findOne(params: {conditions, projection?, populates?, options?}): Promise<T>
+findMany(params: {conditions, projection?, populates?, sort?, options?}): Promise<Array<T>>
+create(payload: Record<string, any>, options?: SaveOptions): Promise<T>
+findOneAndUpdate(conditions: FilterQuery<T>, payload: UpdateQuery<T>, options?: QueryOptions): Promise<T>
}

' DTOs
class BaseLearnerDto {
+_id: string
+name: string
+email: string
+password: string
+avatar: string
+dateOfBirth: Date
+phone: string
+status: LearnerStatus
+createdAt: Date
+updatedAt: Date
}

' Schemas
entity Learner {
+_id: string
+name: string
+email: string
+password: string
+avatar: string
+dateOfBirth: Date
+phone: string
+status: LearnerStatus
}

' Relationships
ManagementLearnerController ..> ILearnerService
InstructorLearnerController ..> ILearnerService
LearnerController ..> ILearnerService

ILearnerService <|.. LearnerService
LearnerService ..> ILearnerRepository

ILearnerRepository <|.. LearnerRepository
ILearnerRepository --|> AbstractRepository
LearnerRepository --|> AbstractRepository

LearnerRepository ..> Learner
BaseLearnerDto -- Learner

@enduml

0 comments on commit 83abd83

Please sign in to comment.