This commit is contained in:
aditya.siregar
2025-07-18 20:10:29 +07:00
parent 1bceae010b
commit 4f5950543e
511 changed files with 24132 additions and 34137 deletions
BIN
View File
Binary file not shown.
-12
View File
@@ -1,12 +0,0 @@
package branch
type BranchStatus string
const (
Active BranchStatus = "Active"
Inactive BranchStatus = "Inactive"
)
func (b BranchStatus) toString() string {
return string(b)
}
+63
View File
@@ -0,0 +1,63 @@
package constants
type BusinessType string
const (
BusinessTypeRestaurant BusinessType = "restaurant"
BusinessTypeRetail BusinessType = "retail"
BusinessTypeCafe BusinessType = "cafe"
BusinessTypeBar BusinessType = "bar"
)
type Currency string
const (
CurrencyUSD Currency = "USD"
CurrencyEUR Currency = "EUR"
CurrencyGBP Currency = "GBP"
CurrencyIDR Currency = "IDR"
)
const (
DefaultBusinessType = BusinessTypeRestaurant
DefaultCurrency = CurrencyUSD
DefaultTaxRate = 0.0
MaxNameLength = 255
MaxDescriptionLength = 1000
)
func GetAllBusinessTypes() []BusinessType {
return []BusinessType{
BusinessTypeRestaurant,
BusinessTypeRetail,
BusinessTypeCafe,
BusinessTypeBar,
}
}
func GetAllCurrencies() []Currency {
return []Currency{
CurrencyUSD,
CurrencyEUR,
CurrencyGBP,
CurrencyIDR,
}
}
func IsValidBusinessType(businessType BusinessType) bool {
for _, validType := range GetAllBusinessTypes() {
if businessType == validType {
return true
}
}
return false
}
func IsValidCurrency(currency Currency) bool {
for _, validCurrency := range GetAllCurrencies() {
if currency == validCurrency {
return true
}
}
return false
}
+17
View File
@@ -0,0 +1,17 @@
package constants
const (
RequestMethod = "RequestMethod"
RequestPath = "RequestPath"
RequestURLQueryParam = "RequestURLQueryParam"
ResponseStatusCode = "ResponseStatusCode"
ResponseStatusText = "ResponseStatusText"
ResponseTimeTaken = "ResponseTimeTaken"
)
var ValidCountryCodeMap = map[string]bool{
"ID": true,
"VI": true,
"SG": true,
"TH": true,
}
-66
View File
@@ -1,66 +0,0 @@
package constants
import (
"github.com/google/uuid"
"time"
)
const (
ContextRequestID string = "requestId"
)
type UserType string
func (u UserType) toString() string {
return string(u)
}
const (
StatusPending = "PENDING"
StatusPaid = "PAID"
StatusCanceled = "CANCELED"
StatusExpired = "EXPIRED"
StatusExecuted = "EXECUTED"
)
const (
PaymentCash = "CASH"
PaymentCreditCard = "CREDIT_CARD"
PaymentDebitCard = "DEBIT_CARD"
PaymentEWallet = "E_WALLET"
)
const (
SourcePOS = "POS"
SourceMobile = "MOBILE"
SourceWeb = "WEB"
)
const (
DefaultInquiryExpiryDuration = 30 * time.Minute
)
func GenerateUUID() string {
return uuid.New().String()
}
func GenerateRefID() string {
now := time.Now()
return now.Format("20060102") + "-" + uuid.New().String()[:8]
}
var TimeNow = func() time.Time {
return time.Now()
}
type RegistrationStatus string
const (
RegistrationSuccess RegistrationStatus = "SUCCESS"
RegistrationPending RegistrationStatus = "PENDING"
RegistrationFailed RegistrationStatus = "FAILED"
)
func (u RegistrationStatus) String() string {
return string(u)
}
-12
View File
@@ -1,12 +0,0 @@
package device
type DeviceStatus string
const (
On DeviceStatus = "On"
Off DeviceStatus = "Off"
)
func (b DeviceStatus) toString() string {
return string(b)
}
@@ -1,12 +0,0 @@
package device
type DeviceConnectionStatus string
const (
Connected DeviceConnectionStatus = "Connected"
Disconnected DeviceConnectionStatus = "Disconnected"
)
func (b DeviceConnectionStatus) toString() string {
return string(b)
}
+57
View File
@@ -0,0 +1,57 @@
package constants
import (
"fmt"
"net/http"
)
const (
InternalServerErrorCode = "900"
MissingFieldErrorCode = "303"
MalformedFieldErrorCode = "310"
ValidationErrorCode = "304"
InvalidFieldErrorCode = "305"
)
const (
RequestEntity = "request"
UserServiceEntity = "user_service"
OrganizationServiceEntity = "organization_service"
CategoryServiceEntity = "category_service"
ProductServiceEntity = "product_service"
ProductVariantServiceEntity = "product_variant_service"
InventoryServiceEntity = "inventory_service"
OrderServiceEntity = "order_service"
CustomerServiceEntity = "customer_service"
UserValidatorEntity = "user_validator"
AuthHandlerEntity = "auth_handler"
UserHandlerEntity = "user_handler"
CategoryHandlerEntity = "category_handler"
ProductHandlerEntity = "product_handler"
ProductVariantHandlerEntity = "product_variant_handler"
InventoryHandlerEntity = "inventory_handler"
OrderValidatorEntity = "order_validator"
OrderHandlerEntity = "order_handler"
OrganizationValidatorEntity = "organization_validator"
OrgHandlerEntity = "organization_handler"
PaymentMethodValidatorEntity = "payment_method_validator"
PaymentMethodHandlerEntity = "payment_method_handler"
OutletServiceEntity = "outlet_service"
)
var HttpErrorMap = map[string]int{
InternalServerErrorCode: http.StatusInternalServerError,
MissingFieldErrorCode: http.StatusBadRequest,
MalformedFieldErrorCode: http.StatusBadRequest,
ValidationErrorCode: http.StatusBadRequest,
InvalidFieldErrorCode: http.StatusBadRequest,
}
// Error messages
var (
ErrPaymentMethodNameRequired = fmt.Errorf("payment method name is required")
ErrPaymentMethodTypeRequired = fmt.Errorf("payment method type is required")
ErrInvalidPaymentMethodType = fmt.Errorf("invalid payment method type")
ErrInvalidPageNumber = fmt.Errorf("page number must be greater than 0")
ErrInvalidLimit = fmt.Errorf("limit must be between 1 and 100")
)
+80
View File
@@ -0,0 +1,80 @@
package constants
type FileType string
const (
FileTypeImage FileType = "image"
FileTypeDocument FileType = "document"
FileTypeVideo FileType = "video"
FileTypeAudio FileType = "audio"
FileTypeArchive FileType = "archive"
FileTypeOther FileType = "other"
)
func GetAllFileTypes() []FileType {
return []FileType{
FileTypeImage,
FileTypeDocument,
FileTypeVideo,
FileTypeAudio,
FileTypeArchive,
FileTypeOther,
}
}
func IsValidFileType(fileType FileType) bool {
for _, validType := range GetAllFileTypes() {
if fileType == validType {
return true
}
}
return false
}
// MIME type mappings
var MimeTypeToFileType = map[string]FileType{
// Images
"image/jpeg": FileTypeImage,
"image/jpg": FileTypeImage,
"image/png": FileTypeImage,
"image/gif": FileTypeImage,
"image/webp": FileTypeImage,
"image/svg+xml": FileTypeImage,
// Documents
"application/pdf": FileTypeDocument,
"application/msword": FileTypeDocument,
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": FileTypeDocument,
"application/vnd.ms-excel": FileTypeDocument,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": FileTypeDocument,
"text/plain": FileTypeDocument,
"text/csv": FileTypeDocument,
// Videos
"video/mp4": FileTypeVideo,
"video/avi": FileTypeVideo,
"video/mov": FileTypeVideo,
"video/wmv": FileTypeVideo,
"video/flv": FileTypeVideo,
"video/webm": FileTypeVideo,
// Audio
"audio/mpeg": FileTypeAudio,
"audio/mp3": FileTypeAudio,
"audio/wav": FileTypeAudio,
"audio/ogg": FileTypeAudio,
"audio/aac": FileTypeAudio,
// Archives
"application/zip": FileTypeArchive,
"application/x-rar-compressed": FileTypeArchive,
"application/x-7z-compressed": FileTypeArchive,
"application/gzip": FileTypeArchive,
}
func GetFileTypeFromMimeType(mimeType string) FileType {
if fileType, exists := MimeTypeToFileType[mimeType]; exists {
return fileType
}
return FileTypeOther
}
+27
View File
@@ -0,0 +1,27 @@
package constants
const (
CorrelationIDHeader = "debug-id"
XAppVersionHeader = "x-appversion"
XDeviceOSHeader = "X-DeviceOS"
XPlatformHeader = "X-Platform"
XAppTypeHeader = "X-AppType"
XAppIDHeader = "x-appid"
XPhoneModelHeader = "X-PhoneModel"
OrganizationID = "x_organization_id"
OutletID = "x_owner_id"
CountryCodeHeader = "country-code"
AcceptedLanguageHeader = "accept-language"
XUserLocaleHeader = "x-user-locale"
LocaleHeader = "locale"
GojekTimezoneHeader = "Gojek-Timezone"
UserTypeHeader = "User-Type"
AccountIDHeader = "Account-Id"
GopayUserType = "gopay"
XCorrelationIDHeader = "X-Correlation-Id"
XRequestIDHeader = "X-Request-Id"
XCountryCodeHeader = "X-Country-Code"
XAppVersionHeaderPOP = "X-App-Version"
XOwnerIDHeader = "X-Owner-Id"
XAppIDHeaderPOP = "X-App-Id"
)
+87
View File
@@ -0,0 +1,87 @@
package constants
type OrderType string
const (
OrderTypeDineIn OrderType = "dine_in"
OrderTypeTakeout OrderType = "takeout"
OrderTypeDelivery OrderType = "delivery"
)
type OrderStatus string
const (
OrderStatusPending OrderStatus = "pending"
OrderStatusPreparing OrderStatus = "preparing"
OrderStatusReady OrderStatus = "ready"
OrderStatusCompleted OrderStatus = "completed"
OrderStatusCancelled OrderStatus = "cancelled"
OrderStatusPaid OrderStatus = "paid"
)
type OrderItemStatus string
const (
OrderItemStatusPending OrderItemStatus = "pending"
OrderItemStatusPreparing OrderItemStatus = "preparing"
OrderItemStatusReady OrderItemStatus = "ready"
OrderItemStatusServed OrderItemStatus = "served"
OrderItemStatusCancelled OrderItemStatus = "cancelled"
OrderItemStatusCompleted OrderItemStatus = "completed"
)
func GetAllOrderTypes() []OrderType {
return []OrderType{
OrderTypeDineIn,
OrderTypeTakeout,
OrderTypeDelivery,
}
}
func GetAllOrderStatuses() []OrderStatus {
return []OrderStatus{
OrderStatusPending,
OrderStatusPreparing,
OrderStatusReady,
OrderStatusCompleted,
OrderStatusCancelled,
OrderStatusPaid,
}
}
func GetAllOrderItemStatuses() []OrderItemStatus {
return []OrderItemStatus{
OrderItemStatusPending,
OrderItemStatusPreparing,
OrderItemStatusReady,
OrderItemStatusServed,
OrderItemStatusCancelled,
}
}
func (o OrderType) IsValidOrderType() bool {
for _, validType := range GetAllOrderTypes() {
if o == validType {
return true
}
}
return false
}
func IsValidOrderStatus(status OrderStatus) bool {
for _, validStatus := range GetAllOrderStatuses() {
if status == validStatus {
return true
}
}
return false
}
func IsValidOrderItemStatus(status OrderItemStatus) bool {
for _, validStatus := range GetAllOrderItemStatuses() {
if status == validStatus {
return true
}
}
return false
}
-87
View File
@@ -1,87 +0,0 @@
package order
type OrderStatus string
const (
New OrderStatus = "NEW"
Paid OrderStatus = "PAID"
Cancel OrderStatus = "CANCEL"
Pending OrderStatus = "PENDING"
Refunded OrderStatus = "REFUNDED"
Voided OrderStatus = "VOIDED"
Partial OrderStatus = "PARTIAL"
)
func (b OrderStatus) toString() string {
return string(b)
}
func (i *OrderStatus) IsNew() bool {
if i == nil {
return false
}
if *i == New {
return true
}
return false
}
func (i OrderStatus) String() string {
return string(i)
}
type ItemType string
const (
Product ItemType = "PRODUCT"
Studio ItemType = "STUDIO"
)
func (b ItemType) toString() string {
return string(b)
}
func (i *ItemType) IsProduct() bool {
if i == nil {
return false
}
if *i == Product {
return true
}
return false
}
func (i *ItemType) IsStudio() bool {
if i == nil {
return false
}
if *i == Studio {
return true
}
return false
}
type OrderSearchStatus string
const (
Active OrderSearchStatus = "ACTIVE"
Inactive OrderSearchStatus = "INACTIVE"
)
func (i *OrderSearchStatus) IsActive() bool {
if i == nil {
return false
}
if *i == Active {
return true
}
return false
}
+26
View File
@@ -0,0 +1,26 @@
package constants
type PlanType string
const (
PlanBasic PlanType = "basic"
PlanPremium PlanType = "premium"
PlanEnterprise PlanType = "enterprise"
)
func GetAllPlanTypes() []PlanType {
return []PlanType{
PlanBasic,
PlanPremium,
PlanEnterprise,
}
}
func IsValidPlanType(planType PlanType) bool {
for _, validType := range GetAllPlanTypes() {
if planType == validType {
return true
}
}
return false
}
-9
View File
@@ -1,9 +0,0 @@
package constants
const (
OssLogLevelLogOff = "LogOff"
OssLogLevelDebug = "Debug"
OssLogLevelError = "Error"
OssLogLevelWarn = "Warn"
OssLogLevelInfo = "Info"
)
+27
View File
@@ -0,0 +1,27 @@
package constants
// Outlet printer setting keys
const (
PRINTER_OUTLET_NAME = "printer_outlet_name"
PRINTER_ADDRESS = "printer_address"
PRINTER_PHONE_NUMBER = "printer_phone_number"
PRINTER_PAPER_SIZE = "printer_paper_size"
PRINTER_FOOTER = "printer_footer"
PRINTER_FOOTER_HASHTAG = "printer_footer_hashtag"
)
// Default printer settings
const (
DEFAULT_PAPER_SIZE = "80mm"
DEFAULT_FOOTER = "Thank you for your purchase!"
DEFAULT_FOOTER_HASHTAG = "#ThankYou"
)
// Valid paper sizes
var ValidPaperSizes = []string{
"58mm",
"80mm",
"A4",
"A5",
"Letter",
}
+82
View File
@@ -0,0 +1,82 @@
package constants
type PaymentMethodType string
const (
PaymentMethodTypeCash PaymentMethodType = "cash"
PaymentMethodTypeCard PaymentMethodType = "card"
PaymentMethodTypeDigitalWallet PaymentMethodType = "digital_wallet"
PaymentMethodTypeQR PaymentMethodType = "qr"
PaymentMethodTypeEDC PaymentMethodType = "edc"
)
type PaymentStatus string
const (
PaymentStatusPending PaymentStatus = "pending"
PaymentStatusCompleted PaymentStatus = "completed"
PaymentStatusFailed PaymentStatus = "failed"
PaymentStatusRefunded PaymentStatus = "refunded"
)
type PaymentTransactionStatus string
const (
PaymentTransactionStatusPending PaymentTransactionStatus = "pending"
PaymentTransactionStatusCompleted PaymentTransactionStatus = "completed"
PaymentTransactionStatusFailed PaymentTransactionStatus = "failed"
PaymentTransactionStatusRefunded PaymentTransactionStatus = "refunded"
)
func GetAllPaymentMethodTypes() []PaymentMethodType {
return []PaymentMethodType{
PaymentMethodTypeCash,
PaymentMethodTypeCard,
PaymentMethodTypeDigitalWallet,
}
}
func GetAllPaymentStatuses() []PaymentStatus {
return []PaymentStatus{
PaymentStatusPending,
PaymentStatusCompleted,
PaymentStatusFailed,
PaymentStatusRefunded,
}
}
func GetAllPaymentTransactionStatuses() []PaymentTransactionStatus {
return []PaymentTransactionStatus{
PaymentTransactionStatusPending,
PaymentTransactionStatusCompleted,
PaymentTransactionStatusFailed,
PaymentTransactionStatusRefunded,
}
}
func IsValidPaymentMethodType(methodType PaymentMethodType) bool {
for _, validType := range GetAllPaymentMethodTypes() {
if methodType == validType {
return true
}
}
return false
}
func IsValidPaymentStatus(status PaymentStatus) bool {
for _, validStatus := range GetAllPaymentStatuses() {
if status == validStatus {
return true
}
}
return false
}
func IsValidPaymentTransactionStatus(status PaymentTransactionStatus) bool {
for _, validStatus := range GetAllPaymentTransactionStatuses() {
if status == validStatus {
return true
}
}
return false
}
-58
View File
@@ -1,58 +0,0 @@
package product
type ProductStatus string
const (
Active ProductStatus = "Active"
Inactive ProductStatus = "Inactive"
)
func (b ProductStatus) toString() string {
return string(b)
}
type ProductType string
const (
Food ProductType = "FOOD"
Beverage ProductType = "BEVERAGE"
)
func (b ProductType) toString() string {
return string(b)
}
type ProductStock string
const (
Available ProductStock = "AVAILABLE"
Unavailable ProductStock = "UNAVAILABLE"
)
func (b ProductStock) toString() string {
return string(b)
}
func (i *ProductStock) IsAvailable() bool {
if i == nil {
return false
}
if *i == Available {
return true
}
return false
}
func (i *ProductStock) IsUnavailable() bool {
if i == nil {
return false
}
if *i == Unavailable {
return true
}
return false
}
-12
View File
@@ -1,12 +0,0 @@
package role
type Role int64
const (
SuperAdmin Role = 1
Admin Role = 2
PartnerAdmin Role = 3
SiteAdmin Role = 4
Casheer Role = 5
Customer Role = 6
)
-12
View File
@@ -1,12 +0,0 @@
package studio
type StudioStatus string
const (
Active StudioStatus = "active"
Inactive StudioStatus = "inactive"
)
func (b StudioStatus) toString() string {
return string(b)
}
@@ -1,29 +0,0 @@
package transaction
type PaymentStatus string
const (
New PaymentStatus = "NEW"
Paid PaymentStatus = "PAID"
Cancel PaymentStatus = "CANCEL"
Refund PaymentStatus = "REFUND"
)
func (b PaymentStatus) toString() string {
return string(b)
}
type PaymentMethod string
const (
Cash PaymentMethod = "CASH"
Debit PaymentMethod = "DEBIT"
Transfer PaymentMethod = "TRANSFER"
QRIS PaymentMethod = "QRIS"
Online PaymentMethod = "ONLINE"
VA PaymentMethod = "VA"
)
func (b PaymentMethod) toString() string {
return string(b)
}
+28
View File
@@ -0,0 +1,28 @@
package constants
type UserRole string
const (
RoleAdmin UserRole = "admin"
RoleManager UserRole = "manager"
RoleCashier UserRole = "cashier"
RoleWaiter UserRole = "waiter"
)
func GetAllUserRoles() []UserRole {
return []UserRole{
RoleAdmin,
RoleManager,
RoleCashier,
RoleWaiter,
}
}
func IsValidUserRole(role UserRole) bool {
for _, validRole := range GetAllUserRoles() {
if role == validRole {
return true
}
}
return false
}
@@ -1,12 +0,0 @@
package userstatus
type UserStatus string
const (
Active UserStatus = "Active"
Inactive UserStatus = "Inactive"
)
func (u UserStatus) toString() string {
return string(u)
}