init project
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package response
|
||||
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
Name string `json:"name"`
|
||||
Role Role `json:"role"`
|
||||
Branch *Branch `json:"branch"`
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
ID int64 `json:"id"`
|
||||
Role string `json:"role_name"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package response
|
||||
|
||||
type BaseResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Code string `json:"response_code,omitempty"`
|
||||
Status int `json:"-"`
|
||||
Message string `json:"message,omitempty"`
|
||||
ErrorMessage string `json:"error_message,omitempty"`
|
||||
ErrorDetail interface{} `json:"error_detail,omitempty"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
PagingMeta *PagingMeta `json:"meta,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package response
|
||||
|
||||
type Branch struct {
|
||||
ID *int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Location string `json:"location"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type BranchList struct {
|
||||
Branches []Branch `json:"branches"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package response
|
||||
|
||||
type Event struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description"`
|
||||
StartDate string `json:"start_date"`
|
||||
EndDate string `json:"end_date"`
|
||||
StartTime string `json:"start_time"`
|
||||
EndTime string `json:"end_time"`
|
||||
Location string `json:"location"`
|
||||
Level string `json:"level"`
|
||||
Included []string `json:"included"`
|
||||
Price float64 `json:"price"`
|
||||
Paid bool `json:"paid"`
|
||||
LocationID *int64 `json:"location_id"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type EventList struct {
|
||||
Events []Event `json:"events"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"furtuna-be/internal/common/errors"
|
||||
)
|
||||
|
||||
type response struct {
|
||||
Status int `json:"status"`
|
||||
Meta interface{} `json:"meta,omitempty"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
Success bool `json:"success,omitempty"`
|
||||
}
|
||||
|
||||
func ErrorWrapper(c *gin.Context, err error) {
|
||||
var customError errors.Error
|
||||
customError = errors.ErrorInternalServer
|
||||
|
||||
status := customError.MapErrorsToHTTPCode()
|
||||
code := customError.MapErrorsToCode()
|
||||
message := err.Error()
|
||||
|
||||
if validErr, ok := err.(errors.Error); ok {
|
||||
status = validErr.MapErrorsToHTTPCode()
|
||||
code = validErr.MapErrorsToCode()
|
||||
message = code.GetMessage()
|
||||
}
|
||||
|
||||
resp := BaseResponse{
|
||||
ErrorMessage: err.Error(),
|
||||
Code: code.GetCode(),
|
||||
Message: message,
|
||||
}
|
||||
|
||||
c.JSON(status, resp)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"furtuna-be/internal/constants/order"
|
||||
"furtuna-be/internal/constants/transaction"
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
ID int64 `json:"id" `
|
||||
BranchID int64 `json:"branch_id" `
|
||||
BranchName string `json:"branch_name" `
|
||||
Amount float64 `json:"amount" `
|
||||
Status order.OrderStatus `json:"status" `
|
||||
CustomerName string `json:"customer_name" `
|
||||
CustomerPhone string `json:"customer_phone" `
|
||||
Pax int `json:"pax" `
|
||||
PaymentMethod transaction.PaymentMethod `json:"payment_method" `
|
||||
OrderItem []OrderItem `json:"order_items" `
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type OrderItem struct {
|
||||
OrderItemID int64 `json:"order_item_id" `
|
||||
ItemID int64 `json:"item_id" `
|
||||
ItemType order.ItemType `json:"item_type" `
|
||||
ItemName string `json:"item_name" `
|
||||
Price float64 `json:"price" `
|
||||
Qty int64 `json:"qty" `
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type OrderList struct {
|
||||
Orders []Order `json:"orders"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
|
||||
type OrderMonthlyRevenue struct {
|
||||
TotalRevenue float64 `json:"total_revenue"`
|
||||
TotalTransaction int64 `json:"total_transaction"`
|
||||
}
|
||||
|
||||
type OrderBranchRevenue struct {
|
||||
BranchID string `json:"branch_id"`
|
||||
BranchName string `json:"name"`
|
||||
BranchLocation string `json:"location"`
|
||||
TotalTransaction int `json:"total_trans"`
|
||||
TotalAmount float64 `json:"total_amount"`
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package response
|
||||
|
||||
type PagingMeta struct {
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
Total int64 `json:"total_data"`
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package response
|
||||
|
||||
type Partner struct {
|
||||
ID *int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Address string `json:"address"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type PartnerList struct {
|
||||
Partners []Partner `json:"partners"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package response
|
||||
|
||||
import "furtuna-be/internal/constants/product"
|
||||
|
||||
type Product struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type product.ProductType `json:"type"`
|
||||
Price float64 `json:"price"`
|
||||
Status product.ProductStatus `json:"status"`
|
||||
Description string `json:"description" `
|
||||
Image string `json:"image" `
|
||||
BranchID int64 `json:"branch_id"`
|
||||
StockQty int64 `json:"stock_qty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type ProductList struct {
|
||||
Products []Product `json:"products"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package response
|
||||
|
||||
type Studio struct {
|
||||
ID *int64 `json:"id"`
|
||||
BranchId *int64 `json:"branch_id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Price float64 `json:"price"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type StudioList struct {
|
||||
Studios []Studio `json:"studios"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package response
|
||||
|
||||
type User struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Status string `json:"status"`
|
||||
RoleID int64 `json:"role_id"`
|
||||
RoleName string `json:"role_name"`
|
||||
PartnerID *int64 `json:"partner_id"`
|
||||
BranchName string `json:"partner_name"`
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
UpdatedAt string `json:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
type UserList struct {
|
||||
Users []User `json:"users"`
|
||||
Total int64 `json:"total"`
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
}
|
||||
Reference in New Issue
Block a user