43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"gorm.io/driver/mysql"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
const (
|
|
DbDSN = "root:bindbox2025kdy@tcp(150.158.78.154:3306)/dev_game?charset=utf8mb4&parseTime=True&loc=Local"
|
|
)
|
|
|
|
func main() {
|
|
db, err := gorm.Open(mysql.Open(DbDSN), &gorm.Config{})
|
|
if err != nil {
|
|
log.Fatalf("DB connection failed: %v", err)
|
|
}
|
|
|
|
fmt.Println("--- User Coupon Ledger Structure (Cloud DB) ---")
|
|
var columns []struct {
|
|
Field string
|
|
Type string
|
|
Null string
|
|
Key string
|
|
Default *string
|
|
Extra string
|
|
}
|
|
db.Raw("DESC user_coupon_ledger").Scan(&columns)
|
|
for _, col := range columns {
|
|
fmt.Printf("%-15s %-15s %-5s %-5s\n", col.Field, col.Type, col.Null, col.Key)
|
|
}
|
|
|
|
fmt.Println("\n--- User 9090 Coupon 260 Trace (Cloud DB) ---")
|
|
var results []map[string]interface{}
|
|
db.Raw("SELECT id, user_id, user_coupon_id, change_amount, balance_after, order_id, action, created_at FROM user_coupon_ledger WHERE user_coupon_id = 260 ORDER BY id ASC").Scan(&results)
|
|
for _, res := range results {
|
|
fmt.Printf("ID: %v, Action: %v, Change: %v, Bal: %v, Order: %v, Time: %v\n",
|
|
res["id"], res["action"], res["change_amount"], res["balance_after"], res["order_id"], res["created_at"])
|
|
}
|
|
}
|