refactor(server/db): 多库(2/4)— 时间等 DB 端计算退回 Go(可移植)
auth/admin/httpapi:把 UTC_TIMESTAMP(6) 等 DB 端取值改为 Go time.Now().UTC() 作为 ? 参数传入(两库精度一致、可测、天然跨方言)。仅这三个文件不涉及 upsert/锁,故独立成提交;其余域文件的同类改动与 dialect 改动同语句交错,合入(3/4)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -77,10 +77,10 @@ func (a *AccountAPI) GetMe(w http.ResponseWriter, r *http.Request) {
|
||||
SELECT p.code, p.max_devices, p.daily_minutes, s.expires_at
|
||||
FROM subscriptions s
|
||||
JOIN plans p ON p.id = s.plan_id
|
||||
WHERE s.user_id = ? AND s.expires_at > UTC_TIMESTAMP()
|
||||
WHERE s.user_id = ? AND s.expires_at > ?
|
||||
ORDER BY s.expires_at DESC
|
||||
LIMIT 1
|
||||
`, uid).Scan(&planCode, &maxDevices, &dailyMinutes, &expiresAt)
|
||||
`, uid, time.Now().UTC()).Scan(&planCode, &maxDevices, &dailyMinutes, &expiresAt)
|
||||
if err == sql.ErrNoRows {
|
||||
planCode = "free"
|
||||
if err := a.db.QueryRowContext(ctx,
|
||||
|
||||
Reference in New Issue
Block a user