Commit 5abdeeab authored by zhengyaoqiu's avatar zhengyaoqiu

feat(colorway): 代码调整

parent e715f459
......@@ -12,7 +12,7 @@ type siteGroupMarginConfigModel interface {
type defaultSiteGroupMarginConfigModel struct {
conn *mon.Model
model.Base[SiteGroupMarginConfig]
*model.Base[SiteGroupMarginConfig]
}
func newDefaultSiteGroupMarginConfigModel(conn *mon.Model) *defaultSiteGroupMarginConfigModel {
......
......@@ -12,7 +12,7 @@ type brandDataModel interface {
type defaultBrandDataModel struct {
conn *mon.Model
model.Base[BrandData]
*model.Base[BrandData]
}
func newDefaultBrandDataModel(conn *mon.Model) *defaultBrandDataModel {
......
......@@ -12,7 +12,7 @@ type siteComboMarginConfigModel interface {
type defaultSiteComboMarginConfigModel struct {
conn *mon.Model
model.Base[SiteComboMarginConfig]
*model.Base[SiteComboMarginConfig]
}
func newDefaultSiteComboMarginConfigModel(conn *mon.Model) *defaultSiteComboMarginConfigModel {
......
......@@ -12,7 +12,7 @@ type siteFloatMarginConfigModel interface {
type defaultSiteFloatMarginConfigModel struct {
conn *mon.Model
model.Base[SiteFloatMarginConfig]
*model.Base[SiteFloatMarginConfig]
}
func newDefaultSiteFloatMarginConfigModel(conn *mon.Model) *defaultSiteFloatMarginConfigModel {
......
......@@ -12,7 +12,7 @@ type subjectModel interface {
type defaultSubjectModel struct {
conn *mon.Model
model.Base[Subject]
*model.Base[Subject]
}
func newDefaultSubjectModel(conn *mon.Model) *defaultSubjectModel {
......
......@@ -14,7 +14,7 @@ type {{.lowerType}}Model interface{
type default{{.Type}}Model struct {
conn {{if .Cache}}*monc.Model{{else}}*mon.Model{{end}}
model.Base[{{.Type}}]
*model.Base[{{.Type}}]
}
func newDefault{{.Type}}Model(conn {{if .Cache}}*monc.Model{{else}}*mon.Model{{end}}) *default{{.Type}}Model {
......
......@@ -16,7 +16,7 @@ type BrandRank struct {
middleBrands []string
}
func NewBrandData(brandDataModel model.BrandDataModel) *BrandRank {
func NewBrandRank(brandDataModel model.BrandDataModel) *BrandRank {
return &BrandRank{brandDataModel: brandDataModel, rwMutex: new(sync.RWMutex)}
}
......
......@@ -20,12 +20,12 @@ type Cache struct {
func InitCache(config Config) {
s := NewSource(config.Source)
bd := NewBrandData(config.BrandDataModel)
br := NewBrandRank(config.BrandDataModel)
// 注册缓存刷新 Map
_cache = &Cache{
refreshMap: map[RefreshKey]Refresh{
RefreshKeySource: s,
RefreshKeyRankBrandIds: bd,
RefreshKeyRankBrandIds: br,
},
Source: s,
}
......
......@@ -29,11 +29,11 @@ import (
type PlatformStoreSku struct {
mongoManager *mongo.Manager
rate rate.Rate
brandRankCache cache.BrandRank
rate *rate.Rate
brandRankCache *cache.BrandRank
}
func NewPlatformStoreSku(mongoManager *mongo.Manager, rate rate.Rate, brandRankCache cache.BrandRank) *PlatformStoreSku {
func NewPlatformStoreSku(mongoManager *mongo.Manager, rate *rate.Rate, brandRankCache *cache.BrandRank) *PlatformStoreSku {
return &PlatformStoreSku{mongoManager: mongoManager, rate: rate, brandRankCache: brandRankCache}
}
......
......@@ -18,11 +18,11 @@ import (
type Product struct {
cache *cache.Cache
mongoManager *mongo.Manager
rate rate.Rate
brandRankCache cache.BrandRank
rate *rate.Rate
brandRankCache *cache.BrandRank
}
func NewProduct(cache *cache.Cache, mongoManager *mongo.Manager, rate rate.Rate, brandRankCache cache.BrandRank) *Product {
func NewProduct(cache *cache.Cache, mongoManager *mongo.Manager, rate *rate.Rate, brandRankCache *cache.BrandRank) *Product {
return &Product{cache: cache, mongoManager: mongoManager, rate: rate, brandRankCache: brandRankCache}
}
......
......@@ -10,6 +10,10 @@ type Rate struct {
rateClient *rate.Client
}
func NewRate(rateClient *rate.Client) *Rate {
return &Rate{rateClient: rateClient}
}
func (receiver *Rate) GetRate(store types.Store, from, to string) (float64, error) {
switch store {
case types.StoreTmall2cStore1, types.StoreJDStoreGongxiao:
......
......@@ -2,12 +2,14 @@ package svc
import (
"git.chillcy.com/golang/chillcy/pkg/etcd"
rate2 "git.chillcy.com/golang/chillcy/pkg/sdk/rate"
"git.chillcy.com/golang/chillcy/project/pc4/pkg/rpc/client/product"
"git.chillcy.com/golang/chillcy/project/pc4/pkg/rpc/client/source"
"git.chillcy.com/golang/colorway/internal/pkg/database/mongo"
"git.chillcy.com/golang/colorway/internal/rpc/internal/config"
"git.chillcy.com/golang/colorway/internal/rpc/internal/svc/cache"
"git.chillcy.com/golang/colorway/internal/rpc/internal/svc/convert"
"git.chillcy.com/golang/colorway/internal/rpc/internal/svc/rate"
"github.com/zeromicro/go-zero/zrpc"
)
......@@ -45,7 +47,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
})
svc.Cache = cache.GetCache()
svc.SpuConvert = convert.NewSpu(svc.Cache)
svc.ProductConvert = convert.NewProduct(svc.Cache)
rateClient := rate2.NewClient(etcd.Get(etcd.KeyHttpRateApiUri))
brandRank := cache.NewBrandRank(svc.MongoManager.BrandDataModel)
svc.ProductConvert = convert.NewProduct(svc.Cache, svc.MongoManager, rate.NewRate(rateClient), brandRank)
return svc
}
......
......@@ -20,7 +20,8 @@ func MemberMethodCall(obj any, methodName string, in []reflect.Value) error {
// 检查是否有 methodName 方法
method := field.MethodByName(methodName)
if !method.IsValid() {
return fmt.Errorf("字段 %s 没有 %s 方法\n", fieldType.Name, methodName)
//log.Println(fmt.Errorf("字段 %s 没有 %s 方法\n", fieldType.Name, methodName))
return nil
}
// 调用 methodName 方法
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment