package main

import (
	"fmt"
	"log"

	"verification-platform-backend/internal/database"
	"verification-platform-backend/internal/model"
)

func main() {
	database.Init()

	var dynamicCodes []model.DynamicCode
	if err := database.DB.Preload("Creator").Preload("Application").Find(&dynamicCodes).Error; err != nil {
		log.Printf("查询失败: %v", err)
		return
	}

	log.Println("=== 动态代码列表 ===")
	for _, dc := range dynamicCodes {
		fmt.Printf("ID: %d\n", dc.ID)
		fmt.Printf("  Name: %s\n", dc.Name)
		fmt.Printf("  ApplicationID: %d\n", dc.ApplicationID)
		fmt.Printf("  UserID: %d\n", dc.UserID)
		fmt.Printf("  Application Name: %s\n", dc.Application.Name)
		if dc.Creator.ID != 0 {
			fmt.Printf("  Creator ID: %d\n", dc.Creator.ID)
			fmt.Printf("  Creator Username: %s\n", dc.Creator.Username)
		} else {
			fmt.Printf("  Creator: (empty)\n")
		}
		fmt.Printf("  Status: %s\n", dc.Status)
		fmt.Println()
	}
}
