domain

package
v0.0.0-...-ec4765f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package domain
- Base model

package domain mail.app.config.go - containing user membership mail app configuration model, request dto and response dto struct

package domain mail.app.go - containing user membership mail app model, request dto and response dto struct

package domain mail.app.status.go - containing user mail membership status model, request dto and response dto struct

package domain mail.app.type.go - containing user mail membership type model, request dto and response dto struct

package domain user.go - containing user model, request dto and response dto struct

package domain
user.role.go
- containing user.role model, request dto and response dto struct

package domain
user.status.go
- containing user.status model and response dto struct
- it only support "get" method since the values was preinstalled in the database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthLoginDTO

type AuthLoginDTO struct {
	Email   string `json:"email"`
	Passkey string `json:"passkey"`
}

AuthLoginDTO is 'DTO' (Data Transfer Object) to verify user on login

type AuthLoginResponse

type AuthLoginResponse struct {
	AccessToken     string `json:"access_token"`
	RefreshToken    string `json:"refresh_token"`
	TransmissionKey string `json:"transmission_key"`
}

AuthLoginResponse is 'DTO' (Data Transfer Object) to 'Response' or sending data to user upon 'login' or request 'refresh token'

type BaseModel

type BaseModel struct {
	ID        int       `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	DeletedAt time.Time `json:"deleted_at"`
}

BaseModel is base model with standard integer primary key

type BaseModelUUID

type BaseModelUUID struct {
	ID        uuid.UUID `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	DeletedAt time.Time `json:"deleted_at"`
}

BaseModelUUID is base model with uuid primary key

type MemberMailApp

type MemberMailApp struct {
	// ID is MemberMailApp primary key as well as 1:1 foreign key to User
	ID uuid.UUID `json:"id"`

	// TypeID is associated id of membership.mail.ap.type
	TypeID int `json:"type_id"`

	// StatusID is associated id of membership.status
	StatusID int `json:"status_id"`

	// Price is the price of the mail.app service
	Price float64 `json:"price"`

	// LastPaidAmount is the last paid amount for using the service
	LastPaidAmount float64 `json:"last_paid_amount"`

	// LastPaidAt is the last paid date and time
	LastPaidAt time.Time `json:"last_paid_at"`

	// SubscribedAt is the datetime User first register/ subscribe to the service
	SubscribedAt time.Time `json:"subscribed_at"`

	// UpdatedAt is datetime of the record last updated
	UpdatedAt time.Time `json:"updated_at"`
}

MemberMailApp hold membership_mail_app table in database

func (*MemberMailApp) IsValid

func (m *MemberMailApp) IsValid() bool

IsValid will check whether MemberMailApp record is valid

type MemberMailAppConfig

type MemberMailAppConfig struct {
	// ID is primary key and foreign key of MemberMailAppConfig which refer to table User
	ID uuid.UUID `json:"id"`

	// CfgID is config id, primary key of MemberMailAppConfig with auto increment value
	// based on record count
	CfgID int `json:"cfg_id"`

	// ConfigName is configuration name of the record
	ConfigName string `json:"config_name"`

	// DefaultConfig is flag to know whether the record is default config or not
	DefaultConfig bool `json:"default_config"`

	// SmtpServer is smtp server of the configuration
	SmtpServer string `json:"smtp_server"`

	// SmtpPort is smtp port of the configuration
	SmtpPort string `json:"smtp_port"`

	// SmtpUsername is smtp username of the configuration
	SmtpUsername string `json:"smtp_username"`

	// SmtpPassword is smtp password of the configuration
	SmtpPassword string `json:"smtp_password"`

	// SmtpSenderEmail is sender mail of the configuration
	SmtpSenderEmail string `json:"smtp_sender_email"`

	// SmtpSenderIdentity is sender identity that shown on 'sent by' header
	SmtpSenderIdentity string `json:"smtp_sender_identity"`

	// ActiveStatus is flag to know whether this configuration active or not
	ActiveStatus bool `json:"active_status"`

	// CreatedAt is datetime the configuration record created
	CreatedAt time.Time `json:"created_at"`

	// UpdatedAt is date time the configuration record last updated
	UpdatedAt time.Time `json:"updated_at"`

	// DeletedAt is datetime the configuration is deleted (soft delete)
	DeletedAt *time.Time `json:"deleted_at"`
}

MemberMailAppConfig hold membership_mail_app_config table in database

func (*MemberMailAppConfig) IsValid

func (m *MemberMailAppConfig) IsValid() bool

IsValid will check whether MemberMailAppConfig record is valid

type MemberMailAppType

type MemberMailAppType struct {
	// ID is user.role id. it is its primary key
	ID int `json:"id"`

	// TypeName is MemberMailAppType type name
	TypeName string `json:"type_name"`

	// Price is MemberMailAppType subscription fee
	Price float64 `json:"price"`

	// Description is the short description of the member app type
	Description string `json:"description,omitempty"`

	// CreatedAt is the record creation datetime
	CreatedAt time.Time `json:"created_at"`

	// UpdatedAt is the record last update datetime
	UpdatedAt time.Time `json:"updated_at"`

	// DeletedAt is the datetime record has been deleted (soft delete)
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

MemberMailAppType hold membership_mail_app_type table in database

func (*MemberMailAppType) IsDeleted

func (m *MemberMailAppType) IsDeleted() bool

IsDeleted is to check whether data MemberMailAppType already deleted

func (*MemberMailAppType) IsValid

func (m *MemberMailAppType) IsValid() bool

IsValid is to check whether data MemberMailAppType is valid

type MemberStatus

type MemberStatus struct {
	// ID is user.role id. it is its primary key
	ID int `json:"id"`

	// StatusName is MemberStatus status name
	StatusName string `json:"status_name"`

	// Description is the short description of the member status
	Description string `json:"description,omitempty"`
}

MemberStatus hold membership_status table in database

func (*MemberStatus) IsValid

func (m *MemberStatus) IsValid() bool

IsValid is to check whether data MemberStatus record is valid

type TokenDetailsDTO

type TokenDetailsDTO struct {
	AccessToken     string `json:"access_token"`
	RefreshToken    string `json:"refresh_token"`
	AtExpiresTime   time.Time
	RtExpiresTime   time.Time
	TransmissionKey string `json:"transmission_key"`
}

TokenDetailsDTO is 'DTO' (data Transfer Object) containing details of token expiration time

type User

type User struct {
	// ID is the table primary key with uuid type
	ID uuid.UUID `json:"id"`

	// Username is the username for the user, value must be unique
	Username string `json:"username"`

	// FirstName is the first name of the user
	Firstname string `json:"firstname"`

	// LastName is the last name for the user
	Lastname string `json:"lastname"`

	// email is the valid email of the user
	Email string `json:"email"`

	// PassKey is the password for the account
	PassKey string `json:"passkey"`

	// StatusID is id of status held by user
	// ("0=inactive", "1=active", "2=suspended", "3=banned")
	StatusID int `json:"status_id"`

	// RoleID is role given to the user on the system
	RoleID int `json:"role_id"`

	// CreatedAt is creation datetime of the record
	CreatedAt time.Time `json:"created_at"`

	// UpdatedAt is the last updated datetime of the record
	UpdatedAt time.Time `json:"updated_at"`

	// DeletedAt is the datetime record was deleted ('soft delete')
	DeletedAt time.Time `json:"deleted_at"`

	// ActivatedAt is account first activation datetime
	ActivatedAt time.Time `json:"activated_at"`
}

User is user model

func (*User) ConvertToCredential

func (u *User) ConvertToCredential() *UserCredential

ConvertToCredential will convert user data to credential format

func (*User) ConvertToResponse

func (u *User) ConvertToResponse() *UserResponse

ConvertToResponse will convert User model to response dto format

func (*User) IsValid

func (u *User) IsValid() bool

IsValid is to check whether User data is valid

type UserCredential

type UserCredential struct {
	// ID is the table primary key with uuid type
	ID uuid.UUID `json:"id"`

	// Username is the username for the user, value must be unique
	Username string `json:"username"`

	// Status is status held by user
	StatusID int `json:"status_id"`

	// PassKey is the password for the account
	PassKey string `json:"passkey"`
}

UserCredential is struct holding user credential data

func (*UserCredential) IsActive

func (u *UserCredential) IsActive() bool

IsActive is to check whether user credential is active

func (*UserCredential) IsValid

func (u *UserCredential) IsValid() bool

IsValid is to ceck whether credential is valid

func (*UserCredential) NeedActivation

func (u *UserCredential) NeedActivation() bool

NeedActivation is to check whether user credential is not activated yet

type UserRequest

type UserRequest struct {
	// ID is the table primary key with uuid type
	ID uuid.UUID `json:"id"`

	// Username is the username for the user, value must be unique
	Username string `json:"username"`

	// FirstName is the first name of the user
	Firstname string `json:"firstname"`

	// LastName is the last name for the user
	Lastname string `json:"lastname,omitempty"`

	// email is the valid email of the user
	Email string `json:"email"`

	// PassKey is the password for the account
	PassKey string `json:"passkey"`

	// StatusID is id of status held by user
	// ("0=inactive", "1=active", "2=suspended", "3=banned")
	StatusID int `json:"status_id"`

	// RoleID is role given to the user on the system
	RoleID int `json:"role_id"`
}

UserRequest is user request dto

func (*UserRequest) IsValid

func (u *UserRequest) IsValid() bool

IsValid() method will check whether the user request data is validity

func (*UserRequest) RequestToUser

func (u *UserRequest) RequestToUser() *User

RequestToUser will convert user request dto to User

type UserResponse

type UserResponse struct {
	// ID is the table primary key with uuid type
	ID uuid.UUID `json:"id"`

	// Username is the username for the user, value must be unique
	Username string `json:"username"`

	// FirstName is the first name of the user
	Firstname string `json:"firstname"`

	// LastName is the last name for the user
	Lastname string `json:"lastname"`

	// email is the valid email of the user
	Email string `json:"email"`

	// Status is status held by user
	StatusID int `json:"status_id"`

	// RoleID is role given to the user on the system
	RoleID int `json:"role_id"`

	// CreatedAt is creation datetime of the record
	CreatedAt time.Time `json:"created_at"`

	// UpdatedAt is the last updated datetime of the record
	UpdatedAt time.Time `json:"updated_at"`
}

UserResponse is User response dto

type UserRole

type UserRole struct {
	// ID is user.role id. it is its primary key
	ID int `json:"id"`

	// RoleName is user.role role name
	RoleName string `json:"role_name"`

	// Description is the short description of the role
	Description string `json:"description,omitempty"`

	// CreatedAt is the creation datetime of the role
	CreatedAt time.Time `json:"created_at"`

	// UpdatedAt is the last update datetime
	UpdatedAt time.Time `json:"updated_at"`

	// DeletedAt is the datetime the role deleted (soft delete)
	DeletedAt time.Time `json:"deleted_at,omitempty"`
}

UserRole is User Role model

func (*UserRole) ConvertToResponse

func (ur *UserRole) ConvertToResponse() *UserRoleResponse

ConvertToResponse will convert user.role model to response dto

func (*UserRole) IsValid

func (ur *UserRole) IsValid() bool

IsValid is to check whether user role data is valid or not

type UserRoleRequest

type UserRoleRequest struct {
	// RoleName is user.role role name
	RoleName string `json:"role_name"`

	// Description is the short description of the role
	Description string `json:"description,omitempty"`
}

UserRoleRequest is user.role request dto

func (*UserRoleRequest) ConvertToUserRole

func (ur *UserRoleRequest) ConvertToUserRole() *UserRole

ConvertToUserRole will convert user.role request dto to user.role

func (*UserRoleRequest) IsValid

func (ur *UserRoleRequest) IsValid() bool

IsValid is to check whether user.role.request is valid or not

type UserRoleResponse

type UserRoleResponse struct {
	ID          int       `json:"id"`
	RoleName    string    `json:"role_name"`
	Description string    `json:"description,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

UserRoleResponse is user.role response dto

type UserStatus

type UserStatus struct {
	// ID is user status id which is its primary key
	ID int `json:"id"`

	// StatusName is the name of the status
	StatusName string `json:"status"`

	// Description is the short description of the status
	Description string `json:"description"`
}

UserStatus is model for status of the user

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL