Files
JGE-RS-SL-API/account/get_account.js
2025-12-25 18:20:37 +08:00

39 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @ts-ignore 获取账号信息
export async function execute(http_message) {
let username = HttpReQUtils.check_auth(http_message);
if (username && username.length > 0) {
try {
// 从数据库查询完整的账号信息
// @ts-ignore
let accounts = await _database_.execute_sql_by_name("accounts",`
SELECT * FROM accounts WHERE username = '${username}'
`);
// 检查查询结果
if (!accounts || accounts === "[]") {
return HttpResUtils.err_code(404, "账号不存在");
}
// 解析查询结果
let accountData = JSON.parse(accounts)[0];
// 返回完整的账号信息
return HttpResUtils.ok({
id: accountData.id,
username: accountData.username,
invite_code: accountData.invite_code || "",
reg_time: accountData.reg_time || "",
login_time: accountData.login_time || "",
out_time: accountData.out_time || "",
last_login_time: accountData.last_login_time || "",
status: accountData.status ? 1 : 0, // 1为启用0为禁用
is_online: accountData.is_online ? 1 : 0, // 1为在线0为离线
json_data: accountData.json_data || {}
});
} catch (error) {
console.error("获取账号信息失败:", error);
return HttpResUtils.err_code(500, "获取账号信息失败");
}
}
return HttpResUtils.err_code(402);
}