#!/bin/bash

echo "=== 时间格式统一修复最终验证 ==="
echo

echo "1. 检查是否还有实体类使用Date类型的字段..."
echo "查找 'private Date' 字段："
find src/main/java -name "*.java" -path "*/entity/*" -exec grep -Hn "private Date " {} \; | head -10

echo
echo "2. 检查是否还有重复的LocalDateTime导入..."
echo "查找重复导入："
find src/main/java -name "*.java" -exec sh -c 'count=$(grep -c "import java.time.LocalDateTime" "$1"); if [ "$count" -gt 1 ]; then echo "$1: $count 次导入"; fi' _ {} \;

echo
echo "3. 检查工具类中合理的Date使用..."
echo "工具类中的Date使用（这些是合理的）："
find src/main/java -name "*Util.java" -o -name "*Utils.java" -o -name "*Helper.java" | xargs grep -l "Date" | head -5

echo
echo "4. 检查证书相关类的修复状态..."
echo "证书服务类："
if grep -q "convertToLocalDateTime" src/main/java/com/gxwebsoft/common/core/service/CertificateService.java; then
    echo "✅ CertificateService.java - 已修复"
else
    echo "❌ CertificateService.java - 需要检查"
fi

echo
echo "5. 检查JWT工具类..."
if grep -q "import java.util.Date" src/main/java/com/gxwebsoft/common/core/security/JwtUtil.java; then
    echo "✅ JwtUtil.java - 正确使用Date"
else
    echo "❌ JwtUtil.java - 需要检查"
fi

echo
echo "6. 统计修复结果..."
echo "实体类总数："
find src/main/java -name "*.java" -path "*/entity/*" | wc -l

echo "使用LocalDateTime的实体类数："
find src/main/java -name "*.java" -path "*/entity/*" -exec grep -l "LocalDateTime" {} \; | wc -l

echo "使用Date的实体类数："
find src/main/java -name "*.java" -path "*/entity/*" -exec grep -l "import java.util.Date" {} \; | wc -l

echo
echo "=== 验证完成 ==="
