Init Eslogad
This commit is contained in:
@@ -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,
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package constants
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
InternalServerErrorCode = "900"
|
||||
MissingFieldErrorCode = "303"
|
||||
MalformedFieldErrorCode = "310"
|
||||
ValidationErrorCode = "304"
|
||||
InvalidFieldErrorCode = "305"
|
||||
NotFoundErrorCode = "404"
|
||||
)
|
||||
|
||||
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"
|
||||
TableEntity = "table"
|
||||
)
|
||||
|
||||
var HttpErrorMap = map[string]int{
|
||||
InternalServerErrorCode: http.StatusInternalServerError,
|
||||
MissingFieldErrorCode: http.StatusBadRequest,
|
||||
MalformedFieldErrorCode: http.StatusBadRequest,
|
||||
ValidationErrorCode: http.StatusBadRequest,
|
||||
InvalidFieldErrorCode: http.StatusBadRequest,
|
||||
NotFoundErrorCode: http.StatusNotFound,
|
||||
}
|
||||
|
||||
// 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")
|
||||
)
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user