Files
assetx/webapp-back/models/asset.go
default 2ee4553b71 init: 初始化 AssetX 项目仓库
包含 webapp(Next.js 用户端)、webapp-back(Go 后端)、
antdesign(管理后台)、landingpage(营销落地页)、
数据库 SQL 和配置文件。
2026-03-27 11:26:43 +00:00

206 lines
8.6 KiB
Go

package models
import (
"time"
)
// Asset represents the assets table
type Asset struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AssetCode string `gorm:"size:20;not null;unique;index" json:"asset_code"`
Name string `gorm:"size:255;not null" json:"name"`
Subtitle string `gorm:"type:text" json:"subtitle"`
Description string `gorm:"type:text" json:"description"`
TokenSymbol string `gorm:"size:20" json:"token_symbol"`
Decimals int `gorm:"default:18" json:"decimals"`
ChainID int `gorm:"default:97" json:"chain_id"`
ContractAddress string `gorm:"size:42" json:"contract_address"`
DeployBlock *uint64 `json:"deploy_block"`
Category string `gorm:"size:100" json:"category"`
CategoryColor string `gorm:"size:50" json:"category_color"`
IconURL string `gorm:"type:text" json:"icon_url"`
UnderlyingAssets string `gorm:"size:255" json:"underlying_assets"`
TargetAPY float64 `gorm:"type:decimal(10,2)" json:"target_apy"`
PoolCapUSD float64 `gorm:"type:decimal(30,2)" json:"pool_cap_usd"`
RiskLevel int `json:"risk_level"`
RiskLabel string `gorm:"size:50" json:"risk_label"`
TokenRole string `gorm:"size:20;default:'product'" json:"token_role"`
IsActive bool `gorm:"default:true" json:"is_active"`
IsFeatured bool `gorm:"default:false" json:"is_featured"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (Asset) TableName() string {
return "assets"
}
// AssetPerformance represents the asset_performance table
type AssetPerformance struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AssetID uint `gorm:"not null;index" json:"asset_id"`
CurrentAPY float64 `gorm:"type:decimal(10,2)" json:"current_apy"`
TVLUSD float64 `gorm:"type:decimal(30,2)" json:"tvl_usd"`
TotalInvestedUSD float64 `gorm:"type:decimal(30,2)" json:"total_invested_usd"`
InvestorCount int `gorm:"default:0" json:"investor_count"`
CumulativeYieldUSD float64 `gorm:"type:decimal(30,2)" json:"cumulative_yield_usd"`
Yield24hUSD float64 `gorm:"type:decimal(30,2)" json:"yield_24h_usd"`
PoolCapacityPercent float64 `gorm:"type:decimal(10,4)" json:"pool_capacity_percent"`
CirculatingSupply float64 `gorm:"type:decimal(30,18)" json:"circulating_supply"`
YTPrice float64 `gorm:"column:yt_price;type:decimal(30,18);default:0" json:"yt_price"`
Volume24hUSD float64 `gorm:"column:volume_24h_usd;type:decimal(30,2);default:0" json:"volume_24h_usd"`
SnapshotDate time.Time `gorm:"not null" json:"snapshot_date"`
CreatedAt time.Time `json:"created_at"`
}
func (AssetPerformance) TableName() string {
return "asset_performance"
}
// ProductResponse is the response format for fund market products
type ProductResponse struct {
ID int `json:"id"`
Name string `json:"name"`
TokenSymbol string `json:"tokenSymbol"`
Decimals int `json:"decimals"`
ContractAddress string `json:"contractAddress"`
ChainID int `json:"chainId"`
TokenRole string `json:"token_role"`
Category string `json:"category"`
CategoryColor string `json:"categoryColor"`
IconURL string `json:"iconUrl"`
YieldAPY string `json:"yieldAPY"`
PoolCap string `json:"poolCap"`
Risk string `json:"risk"`
RiskLevel int `json:"riskLevel"`
CirculatingSupply string `json:"circulatingSupply"`
PoolCapacityPercent float64 `json:"poolCapacityPercent"`
}
// StatsResponse is the response format for fund market stats
type StatsResponse struct {
Label string `json:"label"`
Value string `json:"value"`
Change string `json:"change"`
IsPositive bool `json:"isPositive"`
}
// AssetCustody represents the asset_custody table
type AssetCustody struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AssetID uint `gorm:"not null;index" json:"asset_id"`
CustodianName string `gorm:"size:255" json:"custodian_name"`
CustodianAddress string `gorm:"type:text" json:"custodian_address"`
CustodianLicense string `gorm:"size:255" json:"custodian_license"`
CustodyType string `gorm:"size:100" json:"custody_type"`
CustodyLocation string `gorm:"size:255" json:"custody_location"`
AuditorName string `gorm:"size:255" json:"auditor_name"`
LastAuditDate NullTime `json:"last_audit_date"`
AuditReportURL string `gorm:"type:text" json:"audit_report_url"`
AdditionalInfo string `gorm:"type:json" json:"additional_info"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (AssetCustody) TableName() string {
return "asset_custody"
}
// AssetAuditReport represents the asset_audit_reports table
type AssetAuditReport struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
AssetID uint `gorm:"not null;index" json:"asset_id"`
ReportType string `gorm:"size:50;not null" json:"report_type"`
ReportTitle string `gorm:"size:255;not null" json:"report_title"`
ReportDate time.Time `gorm:"not null" json:"report_date"`
ReportURL string `gorm:"type:text" json:"report_url"`
AuditorName string `gorm:"size:255" json:"auditor_name"`
Summary string `gorm:"type:text" json:"summary"`
IsActive bool `gorm:"default:true" json:"is_active"`
DisplayOrder int `gorm:"default:0" json:"display_order"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (AssetAuditReport) TableName() string {
return "asset_audit_reports"
}
// ProductDetailResponse is the detailed response for a single product
type ProductDetailResponse struct {
// Basic Info
ID int `json:"id"`
AssetCode string `json:"assetCode"`
Name string `json:"name"`
Subtitle string `json:"subtitle"`
Description string `json:"description"`
TokenSymbol string `json:"tokenSymbol"`
Decimals int `json:"decimals"`
// Investment Parameters
UnderlyingAssets string `json:"underlyingAssets"`
PoolCapUSD float64 `json:"poolCapUsd"`
RiskLevel int `json:"riskLevel"`
RiskLabel string `json:"riskLabel"`
TargetAPY float64 `json:"targetApy"`
// Contract Info
ContractAddress string `json:"contractAddress"`
ChainID int `json:"chainId"`
// Display Info
Category string `json:"category"`
CategoryColor string `json:"categoryColor"`
IconURL string `json:"iconUrl"`
// Performance Data (from blockchain/database)
CurrentAPY float64 `json:"currentApy"`
TVLUSD float64 `json:"tvlUsd"`
Volume24hUSD float64 `json:"volume24hUsd"`
VolumeChangeVsAvg float64 `json:"volumeChangeVsAvg"`
CirculatingSupply float64 `json:"circulatingSupply"`
PoolCapacityPercent float64 `json:"poolCapacityPercent"`
CurrentPrice float64 `json:"currentPrice"` // e.g., 1.04 USDC per token
// Custody Info
Custody *CustodyInfo `json:"custody,omitempty"`
// Audit Reports
AuditReports []AuditReportInfo `json:"auditReports"`
// Product Links
ProductLinks []ProductLinkInfo `json:"productLinks"`
}
// ProductLinkInfo represents a single product link item
type ProductLinkInfo struct {
LinkText string `json:"linkText"`
LinkURL string `json:"linkUrl"`
Description string `json:"description"`
DisplayArea string `json:"displayArea"`
DisplayOrder int `json:"displayOrder"`
}
// CustodyInfo represents custody information
type CustodyInfo struct {
CustodianName string `json:"custodianName"`
CustodyType string `json:"custodyType"`
CustodyLocation string `json:"custodyLocation"`
AuditorName string `json:"auditorName"`
LastAuditDate string `json:"lastAuditDate"`
AuditReportURL string `json:"auditReportUrl,omitempty"`
AdditionalInfo map[string]interface{} `json:"additionalInfo,omitempty"`
}
// AuditReportInfo represents audit report information
type AuditReportInfo struct {
ReportType string `json:"reportType"`
ReportTitle string `json:"reportTitle"`
ReportDate string `json:"reportDate"`
AuditorName string `json:"auditorName"`
Summary string `json:"summary"`
ReportURL string `json:"reportUrl"`
}