mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add gdtSum query
This commit is contained in:
parent
9a040bb84d
commit
8277773006
@ -24,6 +24,7 @@ export enum RIGHTS {
|
|||||||
QUERY_TRANSACTION_LINK = 'QUERY_TRANSACTION_LINK',
|
QUERY_TRANSACTION_LINK = 'QUERY_TRANSACTION_LINK',
|
||||||
REDEEM_TRANSACTION_LINK = 'REDEEM_TRANSACTION_LINK',
|
REDEEM_TRANSACTION_LINK = 'REDEEM_TRANSACTION_LINK',
|
||||||
LIST_TRANSACTION_LINKS = 'LIST_TRANSACTION_LINKS',
|
LIST_TRANSACTION_LINKS = 'LIST_TRANSACTION_LINKS',
|
||||||
|
GDT_SUM = 'GDT_SUM',
|
||||||
// Admin
|
// Admin
|
||||||
SEARCH_USERS = 'SEARCH_USERS',
|
SEARCH_USERS = 'SEARCH_USERS',
|
||||||
CREATE_PENDING_CREATION = 'CREATE_PENDING_CREATION',
|
CREATE_PENDING_CREATION = 'CREATE_PENDING_CREATION',
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export const ROLE_USER = new Role('user', [
|
|||||||
RIGHTS.DELETE_TRANSACTION_LINK,
|
RIGHTS.DELETE_TRANSACTION_LINK,
|
||||||
RIGHTS.REDEEM_TRANSACTION_LINK,
|
RIGHTS.REDEEM_TRANSACTION_LINK,
|
||||||
RIGHTS.LIST_TRANSACTION_LINKS,
|
RIGHTS.LIST_TRANSACTION_LINKS,
|
||||||
|
RIGHTS.GDT_SUM,
|
||||||
])
|
])
|
||||||
export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights
|
export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights
|
||||||
|
|
||||||
|
|||||||
@ -13,13 +13,11 @@ import { RIGHTS } from '@/auth/RIGHTS'
|
|||||||
export class GdtResolver {
|
export class GdtResolver {
|
||||||
@Authorized([RIGHTS.LIST_GDT_ENTRIES])
|
@Authorized([RIGHTS.LIST_GDT_ENTRIES])
|
||||||
@Query(() => GdtEntryList)
|
@Query(() => GdtEntryList)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
async listGDTEntries(
|
async listGDTEntries(
|
||||||
@Args()
|
@Args()
|
||||||
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
||||||
@Ctx() context: any,
|
@Ctx() context: any,
|
||||||
): Promise<GdtEntryList> {
|
): Promise<GdtEntryList> {
|
||||||
// load user
|
|
||||||
const userEntity = context.user
|
const userEntity = context.user
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -35,6 +33,25 @@ export class GdtResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Authorized([RIGHTS.GDT_SUM])
|
||||||
|
@Query(() => Number | null)
|
||||||
|
async gdtSum(@Ctx() context: any): Promise<number | null> {
|
||||||
|
const { user } = context
|
||||||
|
try {
|
||||||
|
const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, {
|
||||||
|
email: user.email,
|
||||||
|
})
|
||||||
|
if (!resultGDTSum.success) {
|
||||||
|
throw new Error('Call not successful')
|
||||||
|
}
|
||||||
|
return Number(resultGDTSum.data.sum) || 0
|
||||||
|
} catch (err: any) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('Could not query GDT Server', err)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Authorized([RIGHTS.EXIST_PID])
|
@Authorized([RIGHTS.EXIST_PID])
|
||||||
@Query(() => Number)
|
@Query(() => Number)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user