utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortContextWithError

func AbortContextWithError(ctx *gin.Context, err error)

func CORS

func CORS(r *gin.Engine)

func Code

func Code(i InternalMessage) int

func ConvertToJST

func ConvertToJST(utcTime time.Time) string

func DBInit

func DBInit() (db *gorm.DB, err error)

func DBInitTest

func DBInitTest() (db *gorm.DB, err error)

func GenerateRandomString

func GenerateRandomString() string

func GetParams

func GetParams(params string, ctx *gin.Context) (*string, error)

func GetPayloadFromBody

func GetPayloadFromBody[T any](ctx *gin.Context, p *T) (result T, err error)

func GetQuery

func GetQuery(params string, ctx *gin.Context) (*string, error)

func HistoryDBInitTest

func HistoryDBInitTest() (db *gorm.DB, err error)

func ReturnErrorResponse

func ReturnErrorResponse(ctx *gin.Context, err error)

Types

type Cart

type Cart struct {
	Id              int    `gorm:"id"`
	PurchaserUserId string `gorm:"purchaser_user_id; type:varchar(100)"`
	ItemId          string `gorm:"item_id;type:varchar(100)"`
	Quantity        int    `gorm:"quantity"`
}

type IDBUtils

type IDBUtils interface {
}

type InternalCart

type InternalCart struct {
	Cart Cart `gorm:"embedded"`
	Item Item `gorm:"embedded"`
	User User `gorm:"embedded"`
}

type InternalError

type InternalError struct {
	Message InternalMessage `json:"message"`
}

func (*InternalError) Error

func (r *InternalError) Error() string

type InternalItem

type InternalItem struct {
	Item Item `gorm:"embedded"`
	User User `gorm:"embedded"`
}

type InternalMessage

type InternalMessage string
const (
	InternalErrorInvalidItem     InternalMessage = "invalid item"
	InternalErrorStockOver       InternalMessage = "stock over"
	InternalErrorInvalidQuantity InternalMessage = "invalid quantity"
	InternalErrorNoStock         InternalMessage = "no stock"
)

在庫管理系

const (
	InternalErrorInvalidPayload         InternalMessage = "The request payload is malformed or contains invalid data."
	InternalErrorInvalidQuery           InternalMessage = "invalid Query"
	InternalErrorInvalidParams          InternalMessage = "invalid Params"
	InternalErrorInvalidCart            InternalMessage = "invalid cart"
	InternalErrorInvalidUserRequest     InternalMessage = "invalid user request"
	InternalErrorUnAuthorized           InternalMessage = "unauthorized"
	InternalErrorEmailIsNotVerified     InternalMessage = "email is not verified"
	InternalErrorAddressIsNotRegistered InternalMessage = "address is not registered"
	InternalErrorNotLogined             InternalMessage = "not logined"
)

リクエスト系

const (
	InternalErrorNotFound    InternalMessage = "record not found"
	InternalErrorDB          InternalMessage = "DB error"
	InternalErrorCartIsEmpty InternalMessage = "cart is empty"
)

DB系

const (
	InternalErrorManufacturerAlreadyHasBank  InternalMessage = "manufacturer already has bank"
	InternalErrorManufacturerDoesNotHaveBank InternalMessage = "manufacturer does not have bank"
	InternalErrorAccountIsNotSatisfied       InternalMessage = "account is not satisfied"
	InternalErrorFromStripe                  InternalMessage = "error from stripe"
)

ストライプ系

const (
	InternalErrorIncident InternalMessage = "incident"
)
const (
	InternalErrorR2 InternalMessage = "r2 error"
)

type InternalTransaction

type InternalTransaction struct {
	Transaction      Transaction     `gorm:"embedded"`
	TransactionItems TransactionItem `gorm:"embedded"`
}

type Item

type Item struct {
	Id                 string `gorm:"id"`
	ManufacturerUserId string `gorm:"manufacturer_user_id;type:varchar(100)"`
	Name               string `gorm:"name"`
	Price              int    `gorm:"price"`
	Status             string `gorm:"status"`
	Stock              int    `gorm:"stock"`
	Size               int    `gorm:"size"`
	Description        string `gorm:"description"`
	Tags               string `gorm:"type:json"`
}

type Shipping

type Shipping struct {
	Id            string `gorm:"id"`
	ZipCode       string `gorm:"zip_code"`
	Address_1     string `gorm:"address_1"`
	Address_2     string `gorm:"address_2"`
	Address_3     string `gorm:"address_3" null:"true"`
	PhoneNumber   string `gorm:"phone_number"`
	FirstName     string `gorm:"first_name"`
	FirstNameKana string `gorm:"first_name_kana"`
	LastName      string `gorm:"last_name"`
	LastNameKana  string `gorm:"last_name_kana"`
}

type Transaction

type Transaction struct {
	TransactionId   string    `gorm:"column:transaction_id;type:varchar(100);primaryKey"`
	PurchaserUserId string    `gorm:"purchaser_user_id;type:varchar(100)"`
	Email           string    `gorm:"email"`
	TrackingId      string    `gorm:"tracking_id;type:varchar(100)"`
	CreatedAt       time.Time `gorm:"created_at"`
	ZipCode         string    `gorm:"zip_code"`
	Address         string    `gorm:"address"`
	PhoneNumber     string    `gorm:"phone_number"`
	RealName        string    `gorm:"real_name"`
	Status          string    `gorm:"status"`
	TotalPrice      int       `gorm:"total_price"`
	TotalAmount     int       `gorm:"total_amount"`
}

type TransactionItem

type TransactionItem struct {
	Id                          int    `gorm:"id"`
	TransactionId               string `gorm:"transaction_id;type:varchar(100)"`
	ItemId                      string `gorm:"item_id;type:varchar(100)"`
	Name                        string `gorm:"name"`
	Price                       int    `gorm:"price"`
	Size                        int    `gorm:"size"`
	Quantity                    int    `gorm:"quantity"`
	Description                 string `gorm:"description"`
	Tags                        string `gorm:"tags"`
	ManufacturerUserId          string `gorm:"manufacturer_user_id;type:varchar(100)"`
	ManufacturerName            string `gorm:"manufacturer_name"`
	ManufacturerDescription     string `gorm:"manufacturer_description"`
	ManufacturerStripeAccountId string `gorm:"manufacturer_stripe_account_id;type:varchar(100)"`
	StripeTransferId            string `gorm:"stripe_transfer_id;type:varchar(100)"`
	Status                      string `gorm:"status"`
}

type User

type User struct {
	Id              string    `gorm:"id;type:varchar(100)"`
	DisplayName     string    `gorm:"display_name"`
	Description     string    `gorm:"description"`
	StripeAccountId string    `gorm:"stripe_account_id"`
	CreatedAt       time.Time `gorm:"created_at"`
}

Jump to

Keyboard shortcuts

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