pg

package
v0.0.0-...-ed0dbbb Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCampaignCreator

func NewCampaignCreator(impl *CampaignRepoImpl) (command.CampaignCreator, error)

NewCampaignCreator is used to create a new CampaignCreator.

func NewCampaignDeleter

func NewCampaignDeleter(impl *CampaignRepoImpl) (command.CampaignDeleter, error)

NewCampaignDeleter is used to create a new CampaignDeleter.

func NewCampaignGetter

func NewCampaignGetter(impl *CampaignRepoImpl) (query.CampaignGetter, error)

NewCampaignGetter is used to create a new CampaignGetter.

func NewCampaignUpdater

func NewCampaignUpdater(impl *CampaignRepoImpl) (command.CampaignUpdater, error)

NewCampaignUpdater is used to create a new CampaignUpdater.

func NewRewardGetter

func NewRewardGetter(impl *RewardRepoImpl) (query.RewardGetter, error)

NewRewardGetter is used to create a new RewardGetter.

func NewTaskCreator

func NewTaskCreator(impl *TaskRepoImpl) command.TaskCreator

NewTaskCreator creates a new TaskCreator

func NewTaskGetter

func NewTaskGetter(impl *TaskRepoImpl) query.TaskGetter

NewTaskGetter creates a new TaskGetter

Types

type CampaignDAO

type CampaignDAO struct {
	ID          string    `db:"id"`
	Name        string    `db:"name"`
	Description string    `db:"description"`
	StartTime   time.Time `db:"start_time"`
	EndTime     time.Time `db:"end_time"`
	Mode        int32     `db:"mode"`
	Status      int32     `db:"status"`
	PoolID      string    `db:"pool_id"`
}

CampaignDAO 定義 campaigns 表對應的結構

func FromBizModelToDAO

func FromBizModelToDAO(campaign *biz.Campaign) *CampaignDAO

FromBizModelToDAO 將 biz.Campaign 轉換為 DAO

func (*CampaignDAO) ToBizModel

func (dao *CampaignDAO) ToBizModel(tasks []*biz.Task) *biz.Campaign

ToBizModel 將 DAO 轉換為 biz.Campaign

type CampaignRepoImpl

type CampaignRepoImpl struct {
	// contains filtered or unexported fields
}

CampaignRepoImpl is the implementation of CampaignRepo.

func NewCampaignRepo

func NewCampaignRepo(rw *sqlx.DB) (*CampaignRepoImpl, error)

func (*CampaignRepoImpl) CleanReward

func (i *CampaignRepoImpl) CleanReward(c context.Context, campaignID string) error

func (*CampaignRepoImpl) Create

func (i *CampaignRepoImpl) Create(c context.Context, campaign *biz.Campaign) error

func (*CampaignRepoImpl) DistributeReward

func (i *CampaignRepoImpl) DistributeReward(c context.Context, reward *model.Reward) error

func (*CampaignRepoImpl) GetByID

func (i *CampaignRepoImpl) GetByID(c context.Context, id string) (*biz.Campaign, error)

func (*CampaignRepoImpl) List

func (i *CampaignRepoImpl) List(
	c context.Context,
	cond query.ListCampaignCondition,
) (items []*biz.Campaign, total int, err error)

func (*CampaignRepoImpl) UpdateStatus

func (i *CampaignRepoImpl) UpdateStatus(c context.Context, campaign *biz.Campaign, status model.CampaignStatus) error

type RewardDAO

type RewardDAO struct {
	ID          string     `db:"id"`
	UserAddress string     `db:"user_address"`
	CampaignID  string     `db:"campaign_id"`
	Points      int64      `db:"points"`
	RedeemedAt  *time.Time `db:"redeemed_at"` // 可為 NULL
	CreatedAt   time.Time  `db:"created_at"`
	UpdatedAt   time.Time  `db:"updated_at"`
}

RewardDAO 定義 rewards 表對應的結構

func FromModelRewardToDAO

func FromModelRewardToDAO(reward *model.Reward) *RewardDAO

FromModelRewardToDAO 將 biz.Reward 轉換為 DAO

func (*RewardDAO) ToAggregate

func (dao *RewardDAO) ToAggregate() *biz.Reward

ToAggregate 將 RewardDAO 轉換為 biz.Reward

func (*RewardDAO) ToModel

func (dao *RewardDAO) ToModel() *model.Reward

ToModel 將 RewardDAO 轉換為 model.Reward

type RewardRepoImpl

type RewardRepoImpl struct {
	// contains filtered or unexported fields
}

RewardRepoImpl is the implementation of RewardRepo.

func NewRewardRepo

func NewRewardRepo(rw *sqlx.DB) (*RewardRepoImpl, error)

NewRewardRepo is used to create a new RewardRepo.

func (*RewardRepoImpl) GetByAddress

func (i *RewardRepoImpl) GetByAddress(c context.Context, address string) ([]*biz.Reward, error)

type SwapEventDAO

type SwapEventDAO struct {
	ID               int    `db:"id"`                 // Primary key
	TxHash           string `db:"tx_hash"`            // Associated transaction hash
	FromTokenAddress string `db:"from_token_address"` // Source token address
	ToTokenAddress   string `db:"to_token_address"`   // Destination token address
	FromTokenAmount  string `db:"from_token_amount"`  // Source token amount
	ToTokenAmount    string `db:"to_token_amount"`    // Destination token amount
	PoolAddress      string `db:"pool_address"`       // Swap pool address (if applicable)
}

SwapEventDAO represents the swap_events table

func FromModelSwapDetailToDAO

func FromModelSwapDetailToDAO(txHash string, swap *model.SwapDetail) *SwapEventDAO

FromModelSwapDetailToDAO converts a model.SwapDetail to a SwapEventDAO

func (*SwapEventDAO) ToModel

func (dao *SwapEventDAO) ToModel() *model.SwapDetail

ToModel converts a SwapEventDAO to a model.SwapDetail

type TaskDAO

type TaskDAO struct {
	ID          string    `db:"id"`
	CampaignID  string    `db:"campaign_id"`
	Name        string    `db:"name"`
	Description string    `db:"description"`
	Type        int32     `db:"type"`
	Criteria    string    `db:"criteria"` // JSON 格式存儲的 criteria
	Status      int32     `db:"status"`
	CreatedAt   time.Time `db:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"`
}

TaskDAO 定義 tasks 表對應的結構

func FromBizTaskToDAO

func FromBizTaskToDAO(task *biz.Task) (*TaskDAO, error)

FromBizTaskToDAO 將 biz.Task 轉換為 DAO

func (*TaskDAO) ToBizModel

func (dao *TaskDAO) ToBizModel() (*biz.Task, error)

ToBizModel 將 DAO 轉換為 biz.Task

type TaskRepoImpl

type TaskRepoImpl struct {
	// contains filtered or unexported fields
}

TaskRepoImpl is the implementation of TaskRepo

func NewTaskRepo

func NewTaskRepo(rw *sqlx.DB) *TaskRepoImpl

NewTaskRepo creates a new TaskRepoImpl

func (*TaskRepoImpl) Create

func (i *TaskRepoImpl) Create(c context.Context, task *biz.Task) error

func (*TaskRepoImpl) ListTask

func (i *TaskRepoImpl) ListTask(
	c context.Context,
	cond query.ListTaskCondition,
) (items []*biz.Task, total int, err error)

type TransactionDAO

type TransactionDAO struct {
	TxHash      string    `db:"tx_hash"`      // TransactionDAO hash
	BlockNumber int64     `db:"block_number"` // Block number
	Timestamp   time.Time `db:"timestamp"`    // TransactionDAO timestamp
	FromAddress string    `db:"from_address"` // Sender address
	ToAddress   string    `db:"to_address"`   // Receiver address
}

TransactionDAO represents the transactions table

func FromBizTransactionToDAO

func FromBizTransactionToDAO(transaction *biz.Transaction) *TransactionDAO

FromBizTransactionToDAO converts a biz.Transaction to a TransactionDAO

func (*TransactionDAO) ToBizModel

func (dao *TransactionDAO) ToBizModel() *biz.Transaction

ToBizModel converts a TransactionDAO to a biz.Transaction

type TransactionRepoImpl

type TransactionRepoImpl struct {
	// contains filtered or unexported fields
}

TransactionRepoImpl represents the PostgreSQL implementation of the TransactionRepo.

func NewTransactionRepoImpl

func NewTransactionRepoImpl(rw *sqlx.DB) (*TransactionRepoImpl, error)

NewTransactionRepoImpl creates a new TransactionRepoImpl.

func (*TransactionRepoImpl) Create

func (i *TransactionRepoImpl) Create(c context.Context, transaction *biz.Transaction) error

func (*TransactionRepoImpl) GetByHash

func (i *TransactionRepoImpl) GetByHash(c context.Context, hash string) (item *biz.Transaction, err error)

func (*TransactionRepoImpl) GetLogsByAddress

func (i *TransactionRepoImpl) GetLogsByAddress(
	c context.Context,
	contractAddress string,
	cond query.GetLogsCondition,
) (item biz.TransactionList, total int, err error)

func (*TransactionRepoImpl) ListByAddress

func (i *TransactionRepoImpl) ListByAddress(
	c context.Context,
	address string,
	cond query.ListTransactionCondition,
) (item biz.TransactionList, total int, err error)

type UserRepoImpl

type UserRepoImpl struct {
}

UserRepoImpl is a postgres implementation of UserRepo

func NewUserRepo

func NewUserRepo(rw *sqlx.DB) (*UserRepoImpl, error)

NewUserRepo creates a new UserRepoImpl

Jump to

Keyboard shortcuts

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