package main

import (
	"ai_xhs/config"
	"ai_xhs/utils"
	"flag"
	"fmt"
	"log"
)

func main() {
	// 解析命令行参数
	env := flag.String("env", "dev", "运行环境: dev, prod")
	employeeID := flag.Int("id", 1, "员工ID")
	flag.Parse()

	// 加载配置
	if err := config.LoadConfig(*env); err != nil {
		log.Fatalf("配置加载失败: %v", err)
	}

	// 生成Token
	token, err := utils.GenerateToken(*employeeID)
	if err != nil {
		log.Fatalf("生成Token失败: %v", err)
	}

	fmt.Println("========================================")
	fmt.Printf("环境: %s\n", *env)
	fmt.Printf("员工ID: %d\n", *employeeID)
	fmt.Println("========================================")
	fmt.Printf("JWT Token:\n%s\n", token)
	fmt.Println("========================================")
	fmt.Println("\n使用方式:")
	fmt.Println("在请求头中添加: Authorization: Bearer " + token)
	fmt.Println("\ncURL示例:")
	fmt.Printf("curl -H \"Authorization: Bearer %s\" http://localhost:8080/api/employee/profile\n", token)
	fmt.Println("========================================")
}
