2024-07-24 10:43:43 +08:00
|
|
|
package dw_sdk
|
|
|
|
|
2024-09-02 20:16:06 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2024-07-24 10:43:43 +08:00
|
|
|
type Client struct {
|
|
|
|
articleServiceClient ArticleServiceClient
|
|
|
|
consignBidClient BidClient
|
2024-09-02 14:34:11 +08:00
|
|
|
preSaleBidClient BidClient
|
2024-07-24 10:43:43 +08:00
|
|
|
}
|
|
|
|
|
2024-09-02 20:16:06 +08:00
|
|
|
func InitDefaultDWClient() (*Client, error) {
|
|
|
|
path := os.Getenv(ConfigPathEnvKey)
|
|
|
|
if path == "" {
|
|
|
|
path = DefaultConfigPath
|
|
|
|
}
|
|
|
|
cfg, err := LoadDWConfig(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("获取得物配置失败:%v", err)
|
|
|
|
}
|
|
|
|
cli := NewClient(*cfg)
|
|
|
|
|
|
|
|
return cli, nil
|
|
|
|
}
|
|
|
|
|
2024-07-24 10:43:43 +08:00
|
|
|
func NewClient(cfg Config) *Client {
|
|
|
|
return &Client{
|
|
|
|
articleServiceClient: NewArticleServiceClient(cfg),
|
|
|
|
consignBidClient: NewConsignBidClient(cfg),
|
2024-09-02 14:34:11 +08:00
|
|
|
preSaleBidClient: NewPreSaleBidClient(cfg),
|
2024-07-24 10:43:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) ArticleService() ArticleServiceClient {
|
|
|
|
return c.articleServiceClient
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) ConsignBidClient() BidClient {
|
|
|
|
return c.consignBidClient
|
|
|
|
}
|
2024-09-02 21:12:53 +08:00
|
|
|
|
|
|
|
func (c *Client) PreSaleBidClient() BidClient {
|
|
|
|
return c.preSaleBidClient
|
|
|
|
}
|