package dto import "time" // ApiCallResponse API调用响应结构 type ApiCallResponse struct { Code int `json:"code"` Message string `json:"message"` TransactionId string `json:"transaction_id"` Data string `json:"data,omitempty"` } // ApiKeysResponse API密钥响应结构 type ApiKeysResponse struct { ID string `json:"id"` UserID string `json:"user_id"` AccessID string `json:"access_id"` SecretKey string `json:"secret_key"` Status string `json:"status"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // 白名单相关DTO type WhiteListResponse struct { ID string `json:"id"` UserID string `json:"user_id"` IPAddress string `json:"ip_address"` CreatedAt time.Time `json:"created_at"` } type WhiteListRequest struct { IPAddress string `json:"ip_address" binding:"required,ip"` } type WhiteListListResponse struct { Items []WhiteListResponse `json:"items"` Total int `json:"total"` } // API调用记录相关DTO type ApiCallRecordResponse struct { ID string `json:"id"` AccessId string `json:"access_id"` UserId string `json:"user_id"` ProductId *string `json:"product_id,omitempty"` ProductName *string `json:"product_name,omitempty"` TransactionId string `json:"transaction_id"` ClientIp string `json:"client_ip"` Status string `json:"status"` StartAt string `json:"start_at"` EndAt *string `json:"end_at,omitempty"` Cost *string `json:"cost,omitempty"` ErrorType *string `json:"error_type,omitempty"` ErrorMsg *string `json:"error_msg,omitempty"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` } type ApiCallListResponse struct { Items []ApiCallRecordResponse `json:"items"` Total int64 `json:"total"` Page int `json:"page"` Size int `json:"size"` } // EncryptResponse 加密响应 type EncryptResponse struct { EncryptedData string `json:"encrypted_data"` } // NewSuccessResponse 创建成功响应 func NewSuccessResponse(transactionId, data string) *ApiCallResponse { return &ApiCallResponse{ Code: 0, Message: "业务成功", TransactionId: transactionId, Data: data, } } // NewErrorResponse 创建错误响应 func NewErrorResponse(code int, message, transactionId string) *ApiCallResponse { return &ApiCallResponse{ Code: code, Message: message, TransactionId: transactionId, Data: "", } }