const { ShareDB } = require('./database');

// 测试过期验证
console.log('=== 测试分享过期验证 ===\n');

// 获取所有分享
const { db } = require('./database');
const allShares = db.prepare('SELECT share_code, created_at, expires_at, datetime("now") as current_time FROM shares LIMIT 5').all();

console.log('数据库中的分享:');
allShares.forEach(share => {
  console.log(`\n分享码: ${share.share_code}`);
  console.log(`创建时间: ${share.created_at}`);
  console.log(`到期时间: ${share.expires_at || '永久'}`);
  console.log(`当前时间: ${share.current_time}`);

  if (share.expires_at) {
    const isExpired = share.expires_at <= share.current_time;
    console.log(`是否过期: ${isExpired ? '是' : '否'}`);
  }

  // 测试findByCode
  const found = ShareDB.findByCode(share.share_code);
  console.log(`findByCode结果: ${found ? '找到' : '未找到(已过滤)'}`);
});

console.log('\n=== 测试完成 ===');
