修复(#128): 兼容促销规则毫秒时间戳
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -12,7 +12,11 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type fakePromoModel struct{}
|
||||
type fakePromoModel struct {
|
||||
insertRule func(context.Context, *promomodel.Rule) error
|
||||
findRule func(context.Context, int64) (*promomodel.Rule, error)
|
||||
updateRule func(context.Context, *promomodel.Rule) error
|
||||
}
|
||||
|
||||
func (fakePromoModel) QueryEligibleRules(context.Context, int64, int64) ([]*promomodel.RuleWithPrice, error) {
|
||||
return nil, nil
|
||||
@@ -22,15 +26,24 @@ func (fakePromoModel) InsertUsage(context.Context, *promomodel.Usage, ...*gorm.D
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fakePromoModel) InsertRule(context.Context, *promomodel.Rule) error {
|
||||
func (m fakePromoModel) InsertRule(ctx context.Context, rule *promomodel.Rule) error {
|
||||
if m.insertRule != nil {
|
||||
return m.insertRule(ctx, rule)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fakePromoModel) FindRule(context.Context, int64) (*promomodel.Rule, error) {
|
||||
func (m fakePromoModel) FindRule(ctx context.Context, id int64) (*promomodel.Rule, error) {
|
||||
if m.findRule != nil {
|
||||
return m.findRule(ctx, id)
|
||||
}
|
||||
return nil, gorm.ErrRecordNotFound
|
||||
}
|
||||
|
||||
func (fakePromoModel) UpdateRule(context.Context, *promomodel.Rule) error {
|
||||
func (m fakePromoModel) UpdateRule(ctx context.Context, rule *promomodel.Rule) error {
|
||||
if m.updateRule != nil {
|
||||
return m.updateRule(ctx, rule)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user