sky/scripts/check_articles.go
root 6ed55254a0 chore: initial import of sky project
Go + PostgreSQL + Valkey backend (cmd/internal/migrations),
uni-app mobile frontend, PC web (web/), admin console (admin/),
Android WebView container (android_project/).
Build artifacts, node_modules, local env and debug screenshots excluded.
2026-11-09 22:22:44 +08:00

49 lines
1.5 KiB
Go

package main
import (
"context"
"fmt"
"github.com/jackc/pgx/v5"
)
func main() {
conn, err := pgx.Connect(context.Background(), "postgres://postgres@127.0.0.1:55432/article_platform?sslmode=disable")
if err != nil {
fmt.Println("connect err:", err)
return
}
defer conn.Close(context.Background())
fmt.Println("\n=== 乱码检查 (chr(65533)) ===")
badUsers, err := conn.Query(context.Background(), "SELECT id, account, nickname FROM users WHERE nickname LIKE '%'||chr(65533)||'%'")
if err == nil {
defer badUsers.Close()
for badUsers.Next() {
var uid, acc, nick string
badUsers.Scan(&uid, &acc, &nick)
fmt.Printf("Bad user: id=%s acc=%s nick=%s\n", uid, acc, nick)
}
}
badArticles, err := conn.Query(context.Background(), "SELECT id, mask_id, title FROM articles WHERE title LIKE '%'||chr(65533)||'%' OR summary LIKE '%'||chr(65533)||'%'")
if err == nil {
defer badArticles.Close()
for badArticles.Next() {
var id, maskID, title string
badArticles.Scan(&id, &maskID, &title)
fmt.Printf("Bad article: id=%s mask=%s title=%s\n", id, maskID, title)
}
}
fmt.Println("\n=== 全部用户列表 ===")
uRows, err := conn.Query(context.Background(), "SELECT id, account, nickname, role, status FROM users ORDER BY created_at DESC LIMIT 10")
if err == nil {
defer uRows.Close()
for uRows.Next() {
var uid, acc, nick, role, st string
uRows.Scan(&uid, &acc, &nick, &role, &st)
fmt.Printf("uid=%s | acc=%s | nick=%s | hex=%x | role=%s | status=%s\n", uid, acc, nick, []byte(nick), role, st)
}
}
}