Documentation ¶
Index ¶
- func NewCampaignCreator(impl *CampaignRepoImpl) (command.CampaignCreator, error)
- func NewCampaignDeleter(impl *CampaignRepoImpl) (command.CampaignDeleter, error)
- func NewCampaignGetter(impl *CampaignRepoImpl) (query.CampaignGetter, error)
- func NewCampaignUpdater(impl *CampaignRepoImpl) (command.CampaignUpdater, error)
- func NewRewardGetter(impl *RewardRepoImpl) (query.RewardGetter, error)
- func NewTaskCreator(impl *TaskRepoImpl) command.TaskCreator
- func NewTaskGetter(impl *TaskRepoImpl) query.TaskGetter
- type CampaignDAO
- type CampaignRepoImpl
- func (i *CampaignRepoImpl) CleanReward(c context.Context, campaignID string) error
- func (i *CampaignRepoImpl) Create(c context.Context, campaign *biz.Campaign) error
- func (i *CampaignRepoImpl) DistributeReward(c context.Context, reward *model.Reward) error
- func (i *CampaignRepoImpl) GetByID(c context.Context, id string) (*biz.Campaign, error)
- func (i *CampaignRepoImpl) List(c context.Context, cond query.ListCampaignCondition) (items []*biz.Campaign, total int, err error)
- func (i *CampaignRepoImpl) UpdateStatus(c context.Context, campaign *biz.Campaign, status model.CampaignStatus) error
- type RewardDAO
- type RewardRepoImpl
- type SwapEventDAO
- type TaskDAO
- type TaskRepoImpl
- type TransactionDAO
- type TransactionRepoImpl
- func (i *TransactionRepoImpl) Create(c context.Context, transaction *biz.Transaction) error
- func (i *TransactionRepoImpl) GetByHash(c context.Context, hash string) (item *biz.Transaction, err error)
- func (i *TransactionRepoImpl) GetLogsByAddress(c context.Context, contractAddress string, cond query.GetLogsCondition) (item biz.TransactionList, total int, err error)
- func (i *TransactionRepoImpl) ListByAddress(c context.Context, address string, cond query.ListTransactionCondition) (item biz.TransactionList, total int, err error)
- type UserRepoImpl
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) DistributeReward ¶
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 ¶
FromModelRewardToDAO 將 biz.Reward 轉換為 DAO
func (*RewardDAO) ToAggregate ¶
ToAggregate 將 RewardDAO 轉換為 biz.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 ¶
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 ¶
FromBizTaskToDAO 將 biz.Task 轉換為 DAO
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
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