Documentation ¶
Index ¶
- func GenerateItemID(userID string, kind ItemKind) string
- func ItemHistoryRef(fCli *firestore.Client) *firestore.CollectionRef
- func ItemRef(fCli *firestore.Client) *firestore.CollectionRef
- type Client
- func (c *Client) Exchange(ctx context.Context, userID string, fromKind ItemKind, toKind ItemKind, ...) (map[ItemKind]*Item, error)
- func (c *Client) Get(ctx context.Context, userID string, kind ItemKind) (*Item, error)
- func (c *Client) GetAmount(ctx context.Context, userID string, kind ItemKind) (float64, error)
- func (c *Client) GetMulti(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]*Item, error)
- func (c *Client) GetMultiAmount(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]float64, error)
- func (c *Client) Give(ctx context.Context, userID string, amounts map[ItemKind]float64, ...) (map[ItemKind]*Item, error)
- func (c *Client) HistoriesByCursor(ctx context.Context, userID string, kinds []ItemKind, limit int, cursor string) ([]*ItemHistory, string, error)
- func (c *Client) HistoriesByPeriod(ctx context.Context, userID string, kinds []ItemKind, startAt int64, ...) ([]*ItemHistory, error)
- func (c *Client) Use(ctx context.Context, userID string, amounts map[ItemKind]float64, ...) (map[ItemKind]*Item, error)
- type Item
- type ItemHistory
- type ItemKind
- type Repository
- func (r *Repository) CreateHistory(ctx context.Context, userID string, kind ItemKind, amount float64, ...) (*ItemHistory, error)
- func (r *Repository) GetItem(ctx context.Context, userID string, kind ItemKind) (*Item, error)
- func (r *Repository) GetMultiItem(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]*Item, error)
- func (r *Repository) ListHistoryByCursor(ctx context.Context, userID string, kinds []ItemKind, limit int, cursor string) ([]*ItemHistory, string, error)
- func (r *Repository) ListHistoryByPeriod(ctx context.Context, userID string, kinds []ItemKind, startAt int64, ...) ([]*ItemHistory, error)
- func (r *Repository) ListItem(ctx context.Context, userID string) ([]*Item, error)
- func (r *Repository) SetItem(ctx context.Context, userID string, kind ItemKind, src *Item) (*Item, error)
- type Service
- func (s *Service) Exchange(ctx context.Context, userID string, fromKind ItemKind, toKind ItemKind, ...) (map[ItemKind]*Item, error)
- func (s *Service) Get(ctx context.Context, userID string, kind ItemKind) (*Item, error)
- func (s *Service) GetAmount(ctx context.Context, userID string, kind ItemKind) (float64, error)
- func (s *Service) GetMulti(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]*Item, error)
- func (s *Service) GetMultiAmount(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]float64, error)
- func (s *Service) Give(ctx context.Context, userID string, amounts map[ItemKind]float64, ...) (map[ItemKind]*Item, error)
- func (s *Service) HistoriesByCursor(ctx context.Context, userID string, kinds []ItemKind, limit int, cursor string) ([]*ItemHistory, string, error)
- func (s *Service) HistoriesByPeriod(ctx context.Context, userID string, kinds []ItemKind, startAt int64, ...) ([]*ItemHistory, error)
- func (s *Service) Use(ctx context.Context, userID string, amounts map[ItemKind]float64, ...) (map[ItemKind]*Item, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateItemID ¶
GenerateItemID ... お財布のアイテムIDを作成する
func ItemHistoryRef ¶
func ItemHistoryRef(fCli *firestore.Client) *firestore.CollectionRef
ItemHistoryRef ... コレクションの参照を取得
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client ... ウォレットのクライアント
func (*Client) Exchange ¶
func (c *Client) Exchange( ctx context.Context, userID string, fromKind ItemKind, toKind ItemKind, amount float64, data map[string]interface{}, comment string) (map[ItemKind]*Item, error)
Exchange ... アイテムを両替する
func (*Client) GetMulti ¶
func (c *Client) GetMulti(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]*Item, error)
GetMulti ... 指定のアイテムが入ったウォレットを複数取得する
func (*Client) GetMultiAmount ¶
func (c *Client) GetMultiAmount(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]float64, error)
GetMultiAmount ... 指定のアイテムが入ったウォレット(金額のみ)を複数取得する
func (*Client) Give ¶
func (c *Client) Give( ctx context.Context, userID string, amounts map[ItemKind]float64, data map[string]interface{}, comment string) (map[ItemKind]*Item, error)
Give ... アイテムを配布する
func (*Client) HistoriesByCursor ¶
func (c *Client) HistoriesByCursor( ctx context.Context, userID string, kinds []ItemKind, limit int, cursor string) ([]*ItemHistory, string, error)
HistoriesByCursor ... 履歴リストを取得する
type Item ¶
type Item struct { ID string `firestore:"-" json:"id" cloudfirestore:"id"` Ref *firestore.DocumentRef `firestore:"-" json:"-" cloudfirestore:"ref"` UserID string `firestore:"user_id" json:"user_id"` Kind ItemKind `firestore:"kind" json:"kind"` Amount float64 `firestore:"amount" json:"amount"` TotalGive float64 `firestore:"total_give" json:"total_give"` TotalUse float64 `firestore:"total_use" json:"total_use"` CreatedAt int64 `firestore:"created_at" json:"created_at"` UpdatedAt int64 `firestore:"updated_at" json:"updated_at"` }
Item ... お財布のアイテム
type ItemHistory ¶
type ItemHistory struct { ID string `firestore:"-" json:"id" cloudfirestore:"id"` Ref *firestore.DocumentRef `firestore:"-" json:"-" cloudfirestore:"ref"` UserID string `firestore:"user_id" json:"user_id"` Kind ItemKind `firestore:"kind" json:"kind"` Amount float64 `firestore:"amount" json:"amount"` Data map[string]interface{} `firestore:"data" json:"data"` Comment string `firestore:"comment" json:"comment"` CreatedAt int64 `firestore:"created_at" json:"created_at"` }
ItemHistory ... お財布アイテムの配布/消費履歴
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository ... ウォレットのリポジトリ
func NewRepository ¶
func NewRepository(cFirestore *firestore.Client) *Repository
NewRepository ... リポジトリを作成する
func (*Repository) CreateHistory ¶ added in v1.0.6
func (r *Repository) CreateHistory( ctx context.Context, userID string, kind ItemKind, amount float64, data map[string]interface{}, comment string, createdAt int64) (*ItemHistory, error)
CreateHistory ... 履歴を作成する
func (*Repository) GetMultiItem ¶ added in v1.0.6
func (r *Repository) GetMultiItem( ctx context.Context, userID string, kinds []ItemKind, ) (map[ItemKind]*Item, error)
GetMultiItem ... アイテムを複数取得する
func (*Repository) ListHistoryByCursor ¶
func (r *Repository) ListHistoryByCursor( ctx context.Context, userID string, kinds []ItemKind, limit int, cursor string, ) ([]*ItemHistory, string, error)
ListHistoryByCursor ... 履歴リストを取得する
func (*Repository) ListHistoryByPeriod ¶
func (r *Repository) ListHistoryByPeriod( ctx context.Context, userID string, kinds []ItemKind, startAt int64, endAt int64, ) ([]*ItemHistory, error)
ListHistoryByPeriod ... 履歴リストを期間指定で取得する
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service ... ウォレットのサービス
func (*Service) Exchange ¶
func (s *Service) Exchange( ctx context.Context, userID string, fromKind ItemKind, toKind ItemKind, amount float64, data map[string]interface{}, comment string) (map[ItemKind]*Item, error)
Exchange ... 両替する
func (*Service) GetMulti ¶
func (s *Service) GetMulti(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]*Item, error)
GetMulti ... 複数種類を取得する
func (*Service) GetMultiAmount ¶
func (s *Service) GetMultiAmount(ctx context.Context, userID string, kinds []ItemKind) (map[ItemKind]float64, error)
GetMultiAmount ... 複数種類の金額のみ取得する
func (*Service) Give ¶
func (s *Service) Give( ctx context.Context, userID string, amounts map[ItemKind]float64, data map[string]interface{}, comment string) (map[ItemKind]*Item, error)
Give ... 配布する
func (*Service) HistoriesByCursor ¶
func (s *Service) HistoriesByCursor(ctx context.Context, userID string, kinds []ItemKind, limit int, cursor string) ([]*ItemHistory, string, error)
HistoriesByCursor ... 履歴リストを取得する
Click to show internal directories.
Click to hide internal directories.