This commit is contained in:
parent
ddc538f99b
commit
8934e23bd8
@ -34,7 +34,7 @@ func main() {
|
||||
// coach client
|
||||
client := coach_client.NewClient(pool)
|
||||
|
||||
productCtl := product.NewController(client, db, cfg.Product)
|
||||
productCtl := product.NewController(client, db)
|
||||
|
||||
//r := fiber.New()
|
||||
//r.Use(cors.New())
|
||||
|
@ -1,7 +1,6 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"gitea.timerzz.com/kedaya_haitao/coach-spider/product"
|
||||
"gitea.timerzz.com/kedaya_haitao/common/pkg/database"
|
||||
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
|
||||
"gopkg.in/yaml.v3"
|
||||
@ -11,7 +10,6 @@ import (
|
||||
type Config struct {
|
||||
DB database.DBOption `yaml:"db"`
|
||||
Proxy proxy.Option `yaml:"proxy"`
|
||||
Product product.Option `yaml:"product"`
|
||||
}
|
||||
|
||||
func LoadConfig() (*Config, error) {
|
||||
|
@ -20,12 +20,13 @@ type Controller struct {
|
||||
Option
|
||||
}
|
||||
|
||||
func NewController(client *coach_client.Client, db *gorm.DB, opt Option) *Controller {
|
||||
return &Controller{
|
||||
func NewController(client *coach_client.Client, db *gorm.DB) *Controller {
|
||||
ctl := &Controller{
|
||||
client: client,
|
||||
db: db,
|
||||
Option: opt,
|
||||
}
|
||||
ctl.LoadOption()
|
||||
return ctl
|
||||
}
|
||||
|
||||
func (c *Controller) Run(ctx context.Context) {
|
||||
|
@ -3,7 +3,12 @@ package product
|
||||
import "time"
|
||||
|
||||
type Option struct {
|
||||
ID uint `gorm:"primary_key" json:"id"`
|
||||
Interval time.Duration `yaml:"interval"`
|
||||
ExchangeRate float64 `yaml:"exchangeRate"` //汇率
|
||||
Freight float64 `yaml:"freight"` //运费
|
||||
}
|
||||
|
||||
func (c *Controller) LoadOption() {
|
||||
c.db.FirstOrCreate(&c.Option, Option{Interval: time.Hour * 30, ExchangeRate: 7.3, Freight: 100})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user