列表增强: 快捷标签页(全部/今日/有效人员/推荐/待定/已打招呼), 当天数据高亮+今徽章, 日期按北京时间显示, 导出同步支持
This commit is contained in:
@@ -166,11 +166,16 @@ app.get('/api/stats', requireAuth, (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/api/candidates', requireAuth, (req, res) => {
|
||||
const { level, greeted, account, date_from, date_to, q } = req.query;
|
||||
const { level, greeted, account, date_from, date_to, q, today } = req.query;
|
||||
const where = []; const params = [];
|
||||
if (level) { where.push('score_level = ?'); params.push(level); }
|
||||
if (level === '有效') { where.push("score_level IN ('推荐','待定')"); }
|
||||
else if (level) { where.push('score_level = ?'); params.push(level); }
|
||||
if (greeted === '1' || greeted === '0') { where.push('greeted = ?'); params.push(greeted); }
|
||||
if (account) { where.push('account = ?'); params.push(account); }
|
||||
if (today === '1') { // 北京时间的"今天"(库里是UTC时间戳)
|
||||
const bjToday = new Date(Date.now() + 8 * 3600e3).toISOString().slice(0, 10);
|
||||
where.push('scraped_at >= ?'); params.push(new Date(bjToday + 'T00:00:00+08:00').toISOString());
|
||||
}
|
||||
if (date_from) { where.push('scraped_at >= ?'); params.push(date_from + 'T00:00'); }
|
||||
if (date_to) { where.push('scraped_at <= ?'); params.push(date_to + 'T23:59'); }
|
||||
if (q) { where.push('(name LIKE ? OR school LIKE ? OR notes LIKE ?)'); const like = `%${q}%`; params.push(like, like, like); }
|
||||
@@ -179,8 +184,11 @@ app.get('/api/candidates', requireAuth, (req, res) => {
|
||||
const size = Math.min(100, Math.max(10, parseInt(req.query.size) || 20));
|
||||
const total = rdb.prepare(`SELECT COUNT(*) c FROM candidates ${w}`).get(...params).c;
|
||||
const rows = rdb.prepare(`SELECT id, name, age, education, experience, school, expected_city, expected_salary,
|
||||
score, score_level, role_tag, greeted, account, substr(scraped_at,1,10) scraped_at, notes
|
||||
score, score_level, role_tag, greeted, account, scraped_at, notes
|
||||
FROM candidates ${w} ORDER BY scraped_at DESC, rowid DESC LIMIT ? OFFSET ?`).all(...params, size, (page - 1) * size);
|
||||
const bjToday = new Date(Date.now() + 8 * 3600e3).toISOString().slice(0, 10);
|
||||
const toBjDay = (s) => s ? new Date(new Date(s).getTime() + 8 * 3600e3).toISOString().slice(0, 10) : '';
|
||||
for (const r of rows) { r.scraped_at = toBjDay(r.scraped_at); r.is_today = r.scraped_at === bjToday ? 1 : 0; }
|
||||
res.json({ total, page, size, rows });
|
||||
});
|
||||
|
||||
@@ -194,10 +202,15 @@ app.get('/api/candidates/:id', requireAuth, (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/api/export.csv', requireAuth, (req, res) => {
|
||||
const { level, greeted, date_from, date_to, q } = req.query;
|
||||
const { level, greeted, date_from, date_to, q, today } = req.query;
|
||||
const where = []; const params = [];
|
||||
if (level) { where.push('score_level = ?'); params.push(level); }
|
||||
if (level === '有效') { where.push("score_level IN ('推荐','待定')"); }
|
||||
else if (level) { where.push('score_level = ?'); params.push(level); }
|
||||
if (greeted === '1' || greeted === '0') { where.push('greeted = ?'); params.push(greeted); }
|
||||
if (today === '1') {
|
||||
const bjToday = new Date(Date.now() + 8 * 3600e3).toISOString().slice(0, 10);
|
||||
where.push('scraped_at >= ?'); params.push(new Date(bjToday + 'T00:00:00+08:00').toISOString());
|
||||
}
|
||||
if (date_from) { where.push('scraped_at >= ?'); params.push(date_from + 'T00:00'); }
|
||||
if (date_to) { where.push('scraped_at <= ?'); params.push(date_to + 'T23:59'); }
|
||||
if (q) { where.push('(name LIKE ? OR school LIKE ? OR notes LIKE ?)'); const like = `%${q}%`; params.push(like, like, like); }
|
||||
|
||||
Reference in New Issue
Block a user