mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add simple filter for list transaction link admin query
This commit is contained in:
parent
3575d2d2aa
commit
d0b2a28ae2
13
backend/src/graphql/arg/TransactionLinkFilters.ts
Normal file
13
backend/src/graphql/arg/TransactionLinkFilters.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { ArgsType, Field } from 'type-graphql'
|
||||||
|
|
||||||
|
@ArgsType()
|
||||||
|
export default class TransactionLinkFilters {
|
||||||
|
@Field(() => Boolean, { nullable: true })
|
||||||
|
withDeleted?: boolean
|
||||||
|
|
||||||
|
@Field(() => Boolean, { nullable: true })
|
||||||
|
withExpired?: boolean
|
||||||
|
|
||||||
|
@Field(() => Boolean, { nullable: true })
|
||||||
|
withRedeemed?: boolean
|
||||||
|
}
|
||||||
@ -9,6 +9,8 @@ import {
|
|||||||
ObjectLiteral,
|
ObjectLiteral,
|
||||||
getConnection,
|
getConnection,
|
||||||
In,
|
In,
|
||||||
|
MoreThan,
|
||||||
|
FindOperator,
|
||||||
} from '@dbTools/typeorm'
|
} from '@dbTools/typeorm'
|
||||||
import { UserAdmin, SearchUsersResult } from '@model/UserAdmin'
|
import { UserAdmin, SearchUsersResult } from '@model/UserAdmin'
|
||||||
import { PendingCreation } from '@model/PendingCreation'
|
import { PendingCreation } from '@model/PendingCreation'
|
||||||
@ -34,6 +36,7 @@ import { TransactionTypeId } from '@enum/TransactionTypeId'
|
|||||||
import Decimal from 'decimal.js-light'
|
import Decimal from 'decimal.js-light'
|
||||||
import { Decay } from '@model/Decay'
|
import { Decay } from '@model/Decay'
|
||||||
import Paginated from '@arg/Paginated'
|
import Paginated from '@arg/Paginated'
|
||||||
|
import TransactionLinkFilters from '@arg/TransactionLinkFilters'
|
||||||
import { Order } from '@enum/Order'
|
import { Order } from '@enum/Order'
|
||||||
import { communityUser } from '@/util/communityUser'
|
import { communityUser } from '@/util/communityUser'
|
||||||
|
|
||||||
@ -377,13 +380,23 @@ export class AdminResolver {
|
|||||||
async listTransactionLinksAdmin(
|
async listTransactionLinksAdmin(
|
||||||
@Args()
|
@Args()
|
||||||
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
||||||
|
@Args()
|
||||||
|
{ withDeleted = true, withExpired = true, withRedeemed = true }: TransactionLinkFilters,
|
||||||
@Arg('userId', () => Int) userId: number,
|
@Arg('userId', () => Int) userId: number,
|
||||||
): Promise<TransactionLink[]> {
|
): Promise<TransactionLink[]> {
|
||||||
const user = await dbUser.findOneOrFail({ id: userId })
|
const user = await dbUser.findOneOrFail({ id: userId })
|
||||||
const transactionLinks = await dbTransactionLink.find({
|
const where: {
|
||||||
where: {
|
userId: number
|
||||||
|
redeemedBy?: number | null
|
||||||
|
validUntil?: FindOperator<Date> | null
|
||||||
|
} = {
|
||||||
userId,
|
userId,
|
||||||
},
|
}
|
||||||
|
if (!withRedeemed) where.redeemedBy = null
|
||||||
|
if (!withExpired) where.validUntil = MoreThan(new Date())
|
||||||
|
const transactionLinks = await dbTransactionLink.find({
|
||||||
|
where,
|
||||||
|
withDeleted,
|
||||||
order: {
|
order: {
|
||||||
createdAt: order,
|
createdAt: order,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user