Documentation
¶
Overview ¶
Package entity defines main entities for business logic (services), data base mapping and HTTP response objects if suitable. Each logic group entities in own file.
Package entity defines main entities for business logic (services), data base mapping and HTTP response objects if suitable. Each logic group entities in own file.
Index ¶
- Constants
- type Payment
- type PaymentEvent
- type PaymentRequest
- type PaymentResponse
- type PaymentStatus
- type PaymentType
- type RedisValue
- type ShipperLocation
- type Translation
- type TranslationEvent
- type TranslationHistory
- type User
- type UserEvent
- type UserHistory
- type VietQR
- type VietQRGenerateRequest
- type VietQRStatus
Constants ¶
const ( UserCreatedEvent = "user.created" UserUpdatedEvent = "user.updated" UserDeletedEvent = "user.deleted" TranslationRequestEvent = "translation.requested" TranslationCompletedEvent = "translation.completed" )
Event types
const ( PaymentCreatedEvent = "payment.created" PaymentProcessedEvent = "payment.processed" PaymentCompletedEvent = "payment.completed" PaymentFailedEvent = "payment.failed" )
Event types for payment
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Payment ¶
type Payment struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
PaymentType PaymentType `json:"payment_type"`
Status PaymentStatus `json:"status"`
MeterNumber string `json:"meter_number"`
CustomerCode string `json:"customer_code"`
Description string `json:"description"`
TransactionID string `json:"transaction_id"`
PaymentMethod string `json:"payment_method"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Payment represents payment entity
type PaymentEvent ¶
type PaymentEvent struct {
ID int64 `json:"id"`
EventType string `json:"event_type"`
UserID int64 `json:"user_id"`
PaymentID int64 `json:"payment_id"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
PaymentType PaymentType `json:"payment_type"`
Status PaymentStatus `json:"status"`
MeterNumber string `json:"meter_number"`
CustomerCode string `json:"customer_code"`
Description string `json:"description"`
TransactionID string `json:"transaction_id"`
PaymentMethod string `json:"payment_method"`
Timestamp time.Time `json:"timestamp"`
}
PaymentEvent represents payment event for Kafka
type PaymentRequest ¶
type PaymentRequest struct {
UserID int64 `json:"user_id" binding:"required"`
Amount float64 `json:"amount" binding:"required"`
Currency string `json:"currency" binding:"required"`
PaymentType PaymentType `json:"payment_type" binding:"required"`
MeterNumber string `json:"meter_number" binding:"required"`
CustomerCode string `json:"customer_code" binding:"required"`
Description string `json:"description"`
PaymentMethod string `json:"payment_method" binding:"required"`
}
PaymentRequest represents payment request from API
type PaymentResponse ¶
type PaymentResponse struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
PaymentType PaymentType `json:"payment_type"`
Status PaymentStatus `json:"status"`
MeterNumber string `json:"meter_number"`
CustomerCode string `json:"customer_code"`
Description string `json:"description"`
TransactionID string `json:"transaction_id"`
PaymentMethod string `json:"payment_method"`
CreatedAt time.Time `json:"created_at"`
}
PaymentResponse represents payment response
type PaymentStatus ¶
type PaymentStatus string
PaymentStatus represents payment status
const ( PaymentStatusPending PaymentStatus = "pending" PaymentStatusProcessing PaymentStatus = "processing" PaymentStatusCompleted PaymentStatus = "completed" PaymentStatusFailed PaymentStatus = "failed" PaymentStatusCancelled PaymentStatus = "cancelled" )
type PaymentType ¶
type PaymentType string
PaymentType represents payment type
const ( PaymentTypeElectric PaymentType = "electric" PaymentTypeWater PaymentType = "water" PaymentTypeGas PaymentType = "gas" )
type RedisValue ¶
RedisValue represents a key-value pair for Redis.
type ShipperLocation ¶
type ShipperLocation struct {
ShipperID string `json:"shipper_id"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Timestamp time.Time `json:"timestamp"`
}
ShipperLocation represents a shipper's location (for Redis and DB)
type Translation ¶
type Translation struct {
Source string `json:"source" example:"auto"`
Destination string `json:"destination" example:"en"`
Original string `json:"original" example:"текст для перевода"`
Translation string `json:"translation" example:"text for translation"`
}
Translation -.
type TranslationEvent ¶
type TranslationEvent struct {
ID int64 `json:"id"`
EventType string `json:"event_type"`
UserID int64 `json:"user_id"`
Source string `json:"source"`
Target string `json:"target"`
Original string `json:"original"`
Translated string `json:"translated"`
Timestamp time.Time `json:"timestamp"`
}
TranslationEvent -.
type TranslationHistory ¶
type TranslationHistory struct {
History []Translation `json:"history"`
}
TranslationHistory -.
type User ¶
type User struct {
ID int64 `json:"id"`
Email string `json:"email"`
Username string `json:"username"`
Password string `json:"-"` // Password is not exposed in JSON
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents user entity
type UserEvent ¶
type UserEvent struct {
ID int64 `json:"id"`
EventType string `json:"event_type"`
UserID int64 `json:"user_id"`
Email string `json:"email"`
Data any `json:"data"`
Timestamp time.Time `json:"timestamp"`
}
UserEvent -.
type UserHistory ¶
type UserHistory struct {
Users []User `json:"users"`
}
UserHistory represents user history entity
type VietQR ¶
type VietQR struct {
ID string `json:"id"`
Status VietQRStatus `json:"status"`
Content string `json:"content"`
}
VietQR represents the vietqr entity.
type VietQRGenerateRequest ¶
type VietQRGenerateRequest struct {
AccountNo string
Amount string
Description string
MCC string
ReceiverName string
}
VietQRGenerateRequest represents the data needed to generate a VietQR code.
type VietQRStatus ¶
type VietQRStatus string
VietQRStatus represents the status of a VietQR code.
const ( VietQRStatusGenerated VietQRStatus = "generated" VietQRStatusInProcess VietQRStatus = "in-process" VietQRStatusPaid VietQRStatus = "paid" VietQRStatusFail VietQRStatus = "fail" VietQRStatusTimeout VietQRStatus = "timeout" )