init: 初始化 AssetX 项目仓库

包含 webapp(Next.js 用户端)、webapp-back(Go 后端)、
antdesign(管理后台)、landingpage(营销落地页)、
数据库 SQL 和配置文件。
This commit is contained in:
2026-03-27 11:26:43 +00:00
commit 2ee4553b71
634 changed files with 988255 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
package main
import (
"fmt"
"log"
"github.com/gothinkster/golang-gin-realworld-example-app/common"
"github.com/gothinkster/golang-gin-realworld-example-app/config"
)
type Asset struct {
ID int64 `gorm:"column:id"`
AssetCode string `gorm:"column:asset_code"`
Name string `gorm:"column:name"`
ContractAddress string `gorm:"column:contract_address"`
}
func main() {
// Load configuration
cfg := config.Load()
// Initialize database
if cfg.DBType == "mysql" {
common.InitMySQL()
} else {
common.Init()
}
db := common.GetDB()
// Query YT assets
var assets []Asset
err := db.Table("assets").
Where("asset_code IN (?, ?, ?)", "YT-A", "YT-B", "YT-C").
Find(&assets).Error
if err != nil {
log.Fatalf("Failed to query assets: %v", err)
}
fmt.Println("=== 数据库中的 YT 合约地址 ===")
for _, asset := range assets {
fmt.Printf("%s: %s\n", asset.AssetCode, asset.ContractAddress)
}
// Query YTLPToken from system_contracts
var ytlp struct {
Name string `gorm:"column:name"`
Address string `gorm:"column:address"`
}
err = db.Table("system_contracts").
Where("name = ? AND is_active = ?", "YTLPToken", 1).
Select("name, address").
First(&ytlp).Error
if err != nil {
log.Printf("Failed to query YTLPToken: %v", err)
} else {
fmt.Println("\n=== ytLP 地址 ===")
fmt.Printf("%s: %s\n", ytlp.Name, ytlp.Address)
}
}