39 lines
1.6 KiB
JavaScript
39 lines
1.6 KiB
JavaScript
// @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);
|
||
} |