adapters

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExistHour   = func(err error) error { return fmt.Errorf("unable to get hour from db:%w", err) }
	ErrStartTxnFail   = func(err error) error { return fmt.Errorf("unable to start transaction:%w", err) }
	ErrUpsertHourFail = func(err error) error { return fmt.Errorf("unable to upsert hour:%w", err) }
)

ProviderSet is data providers.

Functions

func NewDatesMysqlRepo

func NewDatesMysqlRepo(pubCfg *conf.Adapter, logger log.Logger) query.QueryRepository

func NewHourRepo

func NewHourRepo(cfg *conf.Adapter, logger log.Logger) hour.CmdRepo

NewTrainingRepo 实现领域层定义的repo,参数通过wire初始化自动注入

Types

type DateModel

type DateModel struct {
	Date         time.Time   `db:"date"`
	HasFreeHours bool        `db:"has_free_hours"`
	Hours        []HourModel `db:"hours"`
}

type DatesMysqlRepo

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

func (DatesMysqlRepo) AvailableHours

func (d DatesMysqlRepo) AvailableHours(ctx context.Context, from time.Time, to time.Time) (query.Date, error)

查询可用的Hour

type HourModel

type HourModel struct {
	Available            bool      `db:"available"`
	HasTrainingScheduled bool      `db:"has_training_scheduled"`
	Hour                 time.Time `db:"hour"`
}

type HourRepo

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

HourRepo 实现领域层repo的数据结构

func (HourRepo) GetHour

func (m HourRepo) GetHour(ctx context.Context, time time.Time) (*hour.Hour, error)

GetHour 查询数据库,并返回领域实体

func (HourRepo) UpdateHour

func (m HourRepo) UpdateHour(
	ctx context.Context,
	hourTime time.Time,
	updateFn func(h *hour.Hour) (*hour.Hour, error),
) error

UpdateHour 更新数据

Jump to

Keyboard shortcuts

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