refactor: extract domain models from provider into internal/model
- Move Server/Domain/DNSRecord/Bucket/StorageInstance/CDNInstance/Order/Error structs to internal/model/ - Provider interfaces now reference model.* types - Rainyun provider implementations import model package for data types - CLI commands updated to use model.DNSRecord directly Separates pure data structures from service contract interfaces, following hexagonal architecture: models (entities) live independently from ports (provider interfaces) and adapters (rainyun/* implementations).
This commit is contained in:
@@ -5,14 +5,14 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.yoresee.cc/nightstar/ry/internal/provider"
|
||||
"git.yoresee.cc/nightstar/ry/internal/model"
|
||||
)
|
||||
|
||||
type BillingService struct {
|
||||
client *client
|
||||
}
|
||||
|
||||
func (b *BillingService) Orders(ctx context.Context) ([]provider.Order, error) {
|
||||
func (b *BillingService) Orders(ctx context.Context) ([]model.Order, error) {
|
||||
type rainyunOrder struct {
|
||||
ID int `json:"id"`
|
||||
ProductName string `json:"product_name"`
|
||||
@@ -24,10 +24,10 @@ func (b *BillingService) Orders(ctx context.Context) ([]provider.Order, error) {
|
||||
if err := b.client.getList(ctx, "/expense/orders/list", &raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orders := make([]provider.Order, len(raw))
|
||||
orders := make([]model.Order, len(raw))
|
||||
for i, r := range raw {
|
||||
t, _ := time.Parse("2006-01-02 15:04:05", r.CreateDate)
|
||||
orders[i] = provider.Order{
|
||||
orders[i] = model.Order{
|
||||
ID: fmt.Sprintf("%d", r.ID),
|
||||
Product: r.ProductName,
|
||||
Amount: r.Amount,
|
||||
|
||||
Reference in New Issue
Block a user