style: clean up code formatting and remove trailing whitespace
refactor: reorganize imports and fix type imports
This commit is contained in:
1 parent
d3704602fd
commit
47c04de6fe
232 files changed
+7140
-4798
No files matched your search
@@ -33,7 +33,7 @@ export interface UpdateCharacterData {
|
||||
*/
|
||||
export async function createCharacter(
|
||||
userId: number,
|
||||
data: CreateCharacterData
|
||||
data: CreateCharacterData,
|
||||
): Promise<Character> {
|
||||
// Usar transação para garantir atomicidade
|
||||
const { getPool } = await import("../index");
|
||||
@@ -51,7 +51,7 @@ export async function createCharacter(
|
||||
SET is_main = FALSE
|
||||
WHERE user_id = $1
|
||||
`,
|
||||
[userId]
|
||||
[userId],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export async function createCharacter(
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING *
|
||||
`,
|
||||
[userId, data.character_name, data.server_name, data.is_main || false]
|
||||
[userId, data.character_name, data.server_name, data.is_main || false],
|
||||
);
|
||||
|
||||
await client.query("COMMIT");
|
||||
@@ -86,7 +86,7 @@ export async function getUserCharacters(userId: number): Promise<Character[]> {
|
||||
WHERE user_id = $1
|
||||
ORDER BY is_main DESC, created_at ASC
|
||||
`,
|
||||
[userId]
|
||||
[userId],
|
||||
);
|
||||
|
||||
return result.rows;
|
||||
@@ -98,7 +98,7 @@ export async function getUserCharacters(userId: number): Promise<Character[]> {
|
||||
*/
|
||||
export async function getMainCharacterByUserId(
|
||||
userId: number,
|
||||
serverName: string
|
||||
serverName: string,
|
||||
): Promise<Character | null> {
|
||||
const result = await query<Character>(
|
||||
`
|
||||
@@ -107,7 +107,7 @@ export async function getMainCharacterByUserId(
|
||||
ORDER BY is_main DESC, created_at ASC
|
||||
LIMIT 1
|
||||
`,
|
||||
[userId, serverName]
|
||||
[userId, serverName],
|
||||
);
|
||||
|
||||
return result.rows[0] || null;
|
||||
@@ -117,13 +117,13 @@ export async function getMainCharacterByUserId(
|
||||
* Busca personagem por ID
|
||||
*/
|
||||
export async function getCharacterById(
|
||||
characterId: number
|
||||
characterId: number,
|
||||
): Promise<Character | null> {
|
||||
const result = await query<Character>(
|
||||
`
|
||||
SELECT * FROM user_characters WHERE character_id = $1
|
||||
`,
|
||||
[characterId]
|
||||
[characterId],
|
||||
);
|
||||
|
||||
return result.rows[0] || null;
|
||||
@@ -136,7 +136,7 @@ export async function getCharacterById(
|
||||
export async function updateCharacter(
|
||||
characterId: number,
|
||||
userId: number,
|
||||
data: UpdateCharacterData
|
||||
data: UpdateCharacterData,
|
||||
): Promise<Character> {
|
||||
// Verificar ownership primeiro
|
||||
const existing = await getCharacterById(characterId);
|
||||
@@ -164,7 +164,7 @@ export async function updateCharacter(
|
||||
SET is_main = FALSE
|
||||
WHERE user_id = $1 AND character_id != $2
|
||||
`,
|
||||
[userId, characterId]
|
||||
[userId, characterId],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ export async function updateCharacter(
|
||||
WHERE character_id = $${paramIndex}
|
||||
RETURNING *
|
||||
`,
|
||||
values
|
||||
values,
|
||||
);
|
||||
|
||||
await client.query("COMMIT");
|
||||
@@ -223,7 +223,7 @@ export async function updateCharacter(
|
||||
*/
|
||||
export async function deleteCharacter(
|
||||
characterId: number,
|
||||
userId: number
|
||||
userId: number,
|
||||
): Promise<void> {
|
||||
// Verificar ownership
|
||||
const existing = await getCharacterById(characterId);
|
||||
@@ -239,7 +239,6 @@ export async function deleteCharacter(
|
||||
`
|
||||
DELETE FROM user_characters WHERE character_id = $1
|
||||
`,
|
||||
[characterId]
|
||||
[characterId],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user