优化结构

This commit is contained in:
Yvan
2026-08-28 10:21:59 +08:00
parent a16d362bb5
commit fec3820464
19 changed files with 138 additions and 136 deletions
@@ -213,6 +213,11 @@ func DefaultIntegrationConfig(kind, provider string) map[string]any {
}
func mergeIntegrationDefaults(defaults, values map[string]any) map[string]any {
return MergeIntegrationDefaults(defaults, values)
}
// MergeIntegrationDefaults returns a new map with stored values overriding defaults.
func MergeIntegrationDefaults(defaults, values map[string]any) map[string]any {
out := make(map[string]any, len(defaults)+len(values))
for key, value := range defaults {
out[key] = value
+36 -36
View File
@@ -158,51 +158,51 @@ type PaymentConfirmation struct {
}
type PaymentResult struct {
Provider string `json:"provider"`
Status string `json:"status"`
TradeNo string `json:"tradeNo"`
ProviderTradeNo string `json:"providerTradeNo"`
Amount int64 `json:"amount"`
PayerPaidAmount int64 `json:"payerPaidAmount,omitempty"`
CashPaidAmount int64 `json:"cashPaidAmount,omitempty"`
PointPaidAmount int64 `json:"pointPaidAmount,omitempty"`
DiscountAmount int64 `json:"discountAmount,omitempty"`
ProviderDiscountAmount int64 `json:"providerDiscountAmount,omitempty"`
MerchantDiscountAmount int64 `json:"merchantDiscountAmount,omitempty"`
SettlementAmount int64 `json:"settlementAmount,omitempty"`
Currency string `json:"currency"`
PayerCurrency string `json:"payerCurrency,omitempty"`
AmountBreakdownKnown bool `json:"amountBreakdownKnown"`
Duplicate bool `json:"duplicate"`
Payload json.RawMessage `json:"payload"`
OrderStatus string `json:"orderStatus,omitempty"`
FulfillmentStatus string `json:"fulfillmentStatus,omitempty"`
RefundStatus string `json:"refundStatus,omitempty"`
EventID string `json:"-"`
QueryID string `json:"-"`
SuccessAck PaymentCallbackAck `json:"-"`
FailureAck PaymentCallbackAck `json:"-"`
Provider string
Status string
TradeNo string
ProviderTradeNo string
Amount int64
PayerPaidAmount int64
CashPaidAmount int64
PointPaidAmount int64
DiscountAmount int64
ProviderDiscountAmount int64
MerchantDiscountAmount int64
SettlementAmount int64
Currency string
PayerCurrency string
AmountBreakdownKnown bool
Duplicate bool
Payload json.RawMessage
OrderStatus string
FulfillmentStatus string
RefundStatus string
EventID string
QueryID string
SuccessAck PaymentCallbackAck
FailureAck PaymentCallbackAck
}
// PaymentTestStage is one step of a provider connectivity test. A skipped
// query/refund is reported explicitly because a prepay flow cannot be marked
// paid without a sandbox payer interaction.
type PaymentTestStage struct {
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
TradeNo string `json:"tradeNo,omitempty"`
Duration int64 `json:"durationMs,omitempty"`
Name string
Status string
Message string
TradeNo string
Duration int64
}
type PaymentTestResult struct {
Provider string `json:"provider"`
TradeNo string `json:"tradeNo"`
Passed bool `json:"passed"`
FullFlow bool `json:"fullFlow"`
Mode string `json:"mode,omitempty"`
Stages []PaymentTestStage `json:"stages"`
Result *PaymentResult `json:"result,omitempty"`
Provider string
TradeNo string
Passed bool
FullFlow bool
Mode string
Stages []PaymentTestStage
Result *PaymentResult
}
type PaymentCallbackAck struct {
-20
View File
@@ -1,20 +0,0 @@
package system
import "context"
type AccessControlUsecase struct {
authorities AuthorityAccessRepo
apis APIRepo
}
func NewAccessControlUsecase(authorities AuthorityAccessRepo, apis APIRepo) *AccessControlUsecase {
return &AccessControlUsecase{authorities: authorities, apis: apis}
}
func (uc *AccessControlUsecase) Authorize(ctx context.Context, authorityID uint, path, method string) (bool, error) {
return uc.apis.Authorize(ctx, authorityID, path, method)
}
func (uc *AccessControlUsecase) ResolveDataScope(ctx context.Context, authorityID, userID uint) (DataScope, error) {
return uc.authorities.ResolveDataScope(ctx, authorityID, userID)
}
+17
View File
@@ -45,6 +45,23 @@ func NewAuthorityUsecase(repo AuthorityAccessRepo) *AuthorityUsecase {
return &AuthorityUsecase{AuthorityAccessRepo: repo}
}
type AccessControlUsecase struct {
authorities AuthorityAccessRepo
apis APIRepo
}
func NewAccessControlUsecase(authorities AuthorityAccessRepo, apis APIRepo) *AccessControlUsecase {
return &AccessControlUsecase{authorities: authorities, apis: apis}
}
func (uc *AccessControlUsecase) Authorize(ctx context.Context, authorityID uint, path, method string) (bool, error) {
return uc.apis.Authorize(ctx, authorityID, path, method)
}
func (uc *AccessControlUsecase) ResolveDataScope(ctx context.Context, authorityID, userID uint) (DataScope, error) {
return uc.authorities.ResolveDataScope(ctx, authorityID, userID)
}
func (uc *AuthorityUsecase) AuthorityTree(ctx context.Context) ([]*Authority, error) {
items, err := uc.ListAuthorities(ctx)
if err != nil {
+19
View File
@@ -21,6 +21,25 @@ type MediaRepo interface {
UploadRepo
}
type StoredFile struct {
Name string
Path string
URL string
Size int64
LastModified time.Time
ContentType string
}
// FileStorage owns the persistence boundary for uploaded files.
type FileStorage interface {
Put(context.Context, string, io.Reader) (*StoredFile, error)
Open(context.Context, string) (io.ReadCloser, error)
Delete(context.Context, string) error
Compose(context.Context, []string, string) (*StoredFile, string, error)
DeletePrefix(context.Context, string) error
List(context.Context, string, string, int) ([]*StoredFile, string, bool, error)
}
type MediaUsecase struct {
MediaRepo
files FileStorage
+11 -6
View File
@@ -6,13 +6,18 @@ import (
)
type SystemParameter struct {
ID uint
CreatedAt time.Time
UpdatedAt time.Time
ID uint
CreatedAt time.Time
UpdatedAt time.Time
Name string
Key string
Value string
Desc string
}
type SystemParameterFilter struct {
Name string
Key string
Value string
Desc string
StartCreatedAt *time.Time
EndCreatedAt *time.Time
}
@@ -23,7 +28,7 @@ type ParameterRepo interface {
DeleteParameters(context.Context, []string) error
FindParameterByID(context.Context, string) (*SystemParameter, error)
FindParameterByKey(context.Context, string) (*SystemParameter, error)
ListParameters(context.Context, int, int, *SystemParameter) ([]*SystemParameter, int64, error)
ListParameters(context.Context, int, int, *SystemParameterFilter) ([]*SystemParameter, int64, error)
}
type ParameterUsecase struct{ ParameterRepo }
-26
View File
@@ -1,26 +0,0 @@
package system
import (
"context"
"io"
"time"
)
type StoredFile struct {
Name string
Path string
URL string
Size int64
LastModified time.Time
ContentType string
}
// FileStorage owns the persistence boundary for uploaded files.
type FileStorage interface {
Put(context.Context, string, io.Reader) (*StoredFile, error)
Open(context.Context, string) (io.ReadCloser, error)
Delete(context.Context, string) error
Compose(context.Context, []string, string) (*StoredFile, string, error)
DeletePrefix(context.Context, string) error
List(context.Context, string, string, int) ([]*StoredFile, string, bool, error)
}