172 lines
5.3 KiB
Go
172 lines
5.3 KiB
Go
package domain
|
|
|
|
type Branch struct {
|
|
ID int64
|
|
Name string
|
|
Location string
|
|
WalletID int64
|
|
BranchManagerID int64
|
|
CompanyID int64
|
|
IsActive bool
|
|
IsSelfOwned bool
|
|
}
|
|
|
|
type BranchFilter struct {
|
|
CompanyID ValidInt64
|
|
IsActive ValidBool
|
|
BranchManagerID ValidInt64
|
|
Query ValidString
|
|
CreatedBefore ValidTime
|
|
CreatedAfter ValidTime
|
|
}
|
|
|
|
type BranchDetail struct {
|
|
ID int64
|
|
Name string
|
|
Location string
|
|
WalletID int64
|
|
Balance Currency
|
|
BranchManagerID int64
|
|
CompanyID int64
|
|
IsActive bool
|
|
IsSelfOwned bool
|
|
ManagerName string
|
|
ManagerPhoneNumber string
|
|
WalletIsActive bool
|
|
}
|
|
|
|
type SupportedOperation struct {
|
|
ID int64
|
|
Name string
|
|
Description string
|
|
}
|
|
|
|
type BranchOperation struct {
|
|
ID int64
|
|
OperationName string
|
|
OperationDescription string
|
|
}
|
|
|
|
type CreateBranch struct {
|
|
Name string
|
|
Location string
|
|
WalletID int64
|
|
BranchManagerID int64
|
|
CompanyID int64
|
|
IsSelfOwned bool
|
|
}
|
|
|
|
type UpdateBranch struct {
|
|
ID int64
|
|
Name *string
|
|
Location *string
|
|
BranchManagerID *int64
|
|
CompanyID *int64
|
|
IsSelfOwned *bool
|
|
IsActive *bool
|
|
}
|
|
|
|
type CreateSupportedOperation struct {
|
|
Name string
|
|
Description string
|
|
}
|
|
type CreateBranchOperation struct {
|
|
BranchID int64
|
|
OperationID int64
|
|
}
|
|
|
|
type CreateBranchReq struct {
|
|
Name string `json:"name" validate:"required,min=3,max=100" example:"4-kilo Branch"`
|
|
Location string `json:"location" validate:"required,min=3,max=100" example:"Addis Ababa"`
|
|
BranchManagerID int64 `json:"branch_manager_id" validate:"required,gt=0" example:"1"`
|
|
CompanyID *int64 `json:"company_id,omitempty" example:"1"`
|
|
IsSelfOwned *bool `json:"is_self_owned,omitempty" example:"false"`
|
|
Operations []int64 `json:"operations" validate:"required,dive,gt=0"`
|
|
}
|
|
|
|
type UpdateBranchReq struct {
|
|
Name *string `json:"name,omitempty" example:"4-kilo Branch"`
|
|
Location *string `json:"location,omitempty" example:"Addis Ababa"`
|
|
BranchManagerID *int64 `json:"branch_manager_id,omitempty" example:"1"`
|
|
CompanyID *int64 `json:"company_id,omitempty" example:"1"`
|
|
IsSelfOwned *bool `json:"is_self_owned,omitempty" example:"false"`
|
|
IsActive *bool `json:"is_active,omitempty" example:"false"`
|
|
}
|
|
|
|
type CreateSupportedOperationReq struct {
|
|
Name string `json:"name" example:"SportsBook"`
|
|
Description string `json:"description" example:"Betting on sport events"`
|
|
}
|
|
|
|
type SupportedOperationRes struct {
|
|
ID int64 `json:"id" example:"1"`
|
|
Name string `json:"name" example:"SportsBook"`
|
|
Description string `json:"description" example:"Betting on sport events"`
|
|
}
|
|
|
|
type CreateBranchOperationReq struct {
|
|
BranchID int64 `json:"branch_id" example:"1"`
|
|
OperationID int64 `json:"operation_id" example:"1"`
|
|
}
|
|
|
|
type BranchOperationRes struct {
|
|
Name string `json:"name" example:"SportsBook"`
|
|
Description string `json:"description" example:"Betting on sport events"`
|
|
}
|
|
|
|
type BranchRes struct {
|
|
ID int64 `json:"id" example:"1"`
|
|
Name string `json:"name" example:"4-kilo Branch"`
|
|
Location string `json:"location" example:"Addis Ababa"`
|
|
WalletID int64 `json:"wallet_id" example:"1"`
|
|
BranchManagerID int64 `json:"branch_manager_id" example:"1"`
|
|
CompanyID int64 `json:"company_id" example:"1"`
|
|
IsSelfOwned bool `json:"is_self_owned" example:"false"`
|
|
IsActive bool `json:"is_active" example:"false"`
|
|
}
|
|
|
|
type BranchDetailRes struct {
|
|
ID int64 `json:"id" example:"1"`
|
|
Name string `json:"name" example:"4-kilo Branch"`
|
|
Location string `json:"location" example:"Addis Ababa"`
|
|
WalletID int64 `json:"wallet_id" example:"1"`
|
|
BranchManagerID int64 `json:"branch_manager_id" example:"1"`
|
|
CompanyID int64 `json:"company_id" example:"1"`
|
|
IsSelfOwned bool `json:"is_self_owned" example:"false"`
|
|
ManagerName string `json:"manager_name" example:"John Smith"`
|
|
ManagerPhoneNumber string `json:"manager_phone_number" example:"0911111111"`
|
|
Balance float32 `json:"balance" example:"100.5"`
|
|
IsActive bool `json:"is_active" example:"false"`
|
|
WalletIsActive bool `json:"is_wallet_active" example:"false"`
|
|
}
|
|
|
|
func ConvertBranch(branch Branch) BranchRes {
|
|
return BranchRes{
|
|
ID: branch.ID,
|
|
Name: branch.Name,
|
|
Location: branch.Location,
|
|
WalletID: branch.WalletID,
|
|
BranchManagerID: branch.BranchManagerID,
|
|
CompanyID: branch.CompanyID,
|
|
IsSelfOwned: branch.IsSelfOwned,
|
|
IsActive: branch.IsActive,
|
|
}
|
|
}
|
|
|
|
func ConvertBranchDetail(branch BranchDetail) BranchDetailRes {
|
|
return BranchDetailRes{
|
|
ID: branch.ID,
|
|
Name: branch.Name,
|
|
Location: branch.Location,
|
|
WalletID: branch.WalletID,
|
|
BranchManagerID: branch.BranchManagerID,
|
|
CompanyID: branch.CompanyID,
|
|
IsSelfOwned: branch.IsSelfOwned,
|
|
ManagerName: branch.ManagerName,
|
|
ManagerPhoneNumber: branch.ManagerPhoneNumber,
|
|
Balance: branch.Balance.Float32(),
|
|
IsActive: branch.IsActive,
|
|
WalletIsActive: branch.WalletIsActive,
|
|
}
|
|
}
|