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