统一前后端代码格式化配置
This commit is contained in:
@@ -26,12 +26,16 @@ type ClaimTokenCreateInput = {
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
type ClaimTokenPatch = Partial<Pick<
|
||||
ClaimTokenRow,
|
||||
'status' | 'expired_at' | 'used_at' | 'max_use_count' | 'used_count' | 'updated_at'
|
||||
>>
|
||||
type ClaimTokenPatch = Partial<
|
||||
Pick<
|
||||
ClaimTokenRow,
|
||||
'status' | 'expired_at' | 'used_at' | 'max_use_count' | 'used_count' | 'updated_at'
|
||||
>
|
||||
>
|
||||
|
||||
export async function createClaimToken(input: ClaimTokenCreateInput): Promise<ClaimTokenRow | null> {
|
||||
export async function createClaimToken(
|
||||
input: ClaimTokenCreateInput,
|
||||
): Promise<ClaimTokenRow | null> {
|
||||
const result = await query<ClaimTokenRow>(
|
||||
`
|
||||
INSERT INTO claim_tokens (
|
||||
@@ -74,16 +78,23 @@ export async function createClaimToken(input: ClaimTokenCreateInput): Promise<Cl
|
||||
}
|
||||
|
||||
export async function getClaimTokenById(tokenId: number | string): Promise<ClaimTokenRow | null> {
|
||||
const result = await query<ClaimTokenRow>('SELECT * FROM claim_tokens WHERE id = $1 LIMIT 1', [Number(tokenId)])
|
||||
const result = await query<ClaimTokenRow>('SELECT * FROM claim_tokens WHERE id = $1 LIMIT 1', [
|
||||
Number(tokenId),
|
||||
])
|
||||
return result.rows[0] || null
|
||||
}
|
||||
|
||||
export async function findClaimTokenByToken(token: string): Promise<ClaimTokenRow | null> {
|
||||
const result = await query<ClaimTokenRow>('SELECT * FROM claim_tokens WHERE token = $1 LIMIT 1', [String(token || '').trim()])
|
||||
const result = await query<ClaimTokenRow>('SELECT * FROM claim_tokens WHERE token = $1 LIMIT 1', [
|
||||
String(token || '').trim(),
|
||||
])
|
||||
return result.rows[0] || null
|
||||
}
|
||||
|
||||
export async function updateClaimToken(tokenId: number | string, patch: ClaimTokenPatch): Promise<ClaimTokenRow | null> {
|
||||
export async function updateClaimToken(
|
||||
tokenId: number | string,
|
||||
patch: ClaimTokenPatch,
|
||||
): Promise<ClaimTokenRow | null> {
|
||||
const current = await getClaimTokenById(tokenId)
|
||||
if (!current) {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user