项目仓库初始化
This commit is contained in:
39
account/get_account.js
Normal file
39
account/get_account.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// @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);
|
||||
}
|
||||
Reference in New Issue
Block a user