mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add call for list gdt entries
This commit is contained in:
parent
aa22d9154d
commit
44bce32853
@ -1,4 +1,5 @@
|
||||
PORT=4000
|
||||
GRAPHIQL=false
|
||||
// LOGIN_API_URL=http://login-server:1201/
|
||||
// COMMUNITY_API_URL=http://nginx/api/
|
||||
// COMMUNITY_API_URL=http://nginx/api/
|
||||
// GDT_API_URL=https://gdt.gradido.net
|
||||
@ -10,6 +10,7 @@ const server = {
|
||||
GRAPHIQL: process.env.GRAPHIQL === 'true' || false,
|
||||
LOGIN_API_URL: process.env.LOGIN_API_URL || 'http://login-server:1201/',
|
||||
COMMUNITY_API_URL: process.env.COMMUNITY_API_URL || 'http://ngninx/api/',
|
||||
GDT_API_URL: process.env.GDT_API_URL || 'https://gdt.gradido.net',
|
||||
}
|
||||
|
||||
// This is needed by graphql-directive-auth
|
||||
|
||||
16
backend/src/graphql/inputs/GdtInputs.ts
Normal file
16
backend/src/graphql/inputs/GdtInputs.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { ArgsType, Field } from 'type-graphql'
|
||||
|
||||
@ArgsType()
|
||||
export class GdtTransactionInput {
|
||||
@Field(() => String)
|
||||
email: string
|
||||
|
||||
@Field(() => Number)
|
||||
firstPage: number
|
||||
|
||||
@Field(() => Number)
|
||||
items: number
|
||||
|
||||
@Field(() => String)
|
||||
order: string
|
||||
}
|
||||
57
backend/src/graphql/models/GdtEntry.ts
Normal file
57
backend/src/graphql/models/GdtEntry.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
export enum GdtEntryType {
|
||||
FORM = 1,
|
||||
CVS = 2,
|
||||
ELOPAGE = 3,
|
||||
ELOPAGE_PUBLISHER = 4,
|
||||
DIGISTORE = 5,
|
||||
CVS2 = 6,
|
||||
GLOBAL_MODIFICATOR = 7,
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class GdtEntry {
|
||||
constructor(json: any) {
|
||||
this.amount = json.amount
|
||||
this.date = json.date
|
||||
this.email = json.email
|
||||
this.comment = json.comment
|
||||
this.couponCode = json.coupon_code
|
||||
this.gdtEntryType = json.gdt_entry_type_id
|
||||
this.factor = json.factor
|
||||
this.amount2 = json.amount2
|
||||
this.factor2 = json.factor2
|
||||
this.gdt = json.gdt
|
||||
}
|
||||
|
||||
@Field(() => Number)
|
||||
amount: number
|
||||
|
||||
@Field(() => String)
|
||||
date: string
|
||||
|
||||
@Field(() => String)
|
||||
email: string
|
||||
|
||||
@Field(() => String)
|
||||
comment: string
|
||||
|
||||
@Field(() => String)
|
||||
couponCode: string
|
||||
|
||||
@Field(() => Number)
|
||||
gdtEntryType: GdtEntryType
|
||||
|
||||
@Field(() => Number)
|
||||
factor: number
|
||||
|
||||
@Field(() => Number)
|
||||
amount2: number
|
||||
|
||||
@Field(() => Number)
|
||||
factor2: number
|
||||
|
||||
@Field(() => Number)
|
||||
gdt: number
|
||||
}
|
||||
52
backend/src/graphql/models/GdtEntryList.ts
Normal file
52
backend/src/graphql/models/GdtEntryList.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import { GdtEntry } from './GdtEntry'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@ObjectType()
|
||||
export class GdtSumPerEmail {
|
||||
constructor(email: string, summe: number) {
|
||||
this.email = email
|
||||
this.summe = summe
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
email: string
|
||||
|
||||
@Field(() => Number)
|
||||
summe: number
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class GdtEntryList {
|
||||
constructor(json: any) {
|
||||
this.state = json.state
|
||||
this.moreEntrysAsShown = json.moreEntrysAsShown
|
||||
this.ownEntries = []
|
||||
json.ownEntries.forEach((value: any) => {
|
||||
this.ownEntries.push(new GdtEntry(value))
|
||||
})
|
||||
this.gdtSumPerEmail = []
|
||||
for (const email in json.gdtSumPerEmail) {
|
||||
this.gdtSumPerEmail.push(new GdtSumPerEmail(email, json.gdtSumPerEmail[email]))
|
||||
}
|
||||
this.email = json.email
|
||||
this.timeUsed = json.timeUsed
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
state: string
|
||||
|
||||
@Field(() => Boolean)
|
||||
moreEntrysAsShown: boolean
|
||||
|
||||
@Field(() => [GdtEntry])
|
||||
ownEntries: GdtEntry[]
|
||||
|
||||
@Field(() => [GdtSumPerEmail])
|
||||
gdtSumPerEmail: GdtSumPerEmail[]
|
||||
|
||||
@Field(() => String)
|
||||
email: string
|
||||
|
||||
@Field(() => Number)
|
||||
timeUsed: number
|
||||
}
|
||||
26
backend/src/graphql/resolvers/GdtResolver.ts
Normal file
26
backend/src/graphql/resolvers/GdtResolver.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// import jwt from 'jsonwebtoken'
|
||||
import { Resolver, Query, /* Mutation, */ Args } from 'type-graphql'
|
||||
import CONFIG from '../../config'
|
||||
import { GdtEntryList } from '../models/GdtEntryList'
|
||||
import { GdtTransactionInput } from '../inputs/GdtInputs'
|
||||
import { apiPost, apiGet } from '../../apis/loginAPI'
|
||||
|
||||
@Resolver()
|
||||
export class GdtResolver {
|
||||
@Query(() => GdtEntryList)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async listGDTEntries(
|
||||
@Args() { email, firstPage = 1, items = 5, order = 'DESC' }: GdtTransactionInput,
|
||||
): Promise<GdtEntryList> {
|
||||
email = email.trim().toLowerCase()
|
||||
const result = await apiGet(
|
||||
`${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${email}/${firstPage}/${items}/${order}`,
|
||||
)
|
||||
|
||||
if (!result.success) {
|
||||
throw new Error(result.data)
|
||||
}
|
||||
|
||||
return new GdtEntryList(result.data)
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,7 @@ import CONFIG from './config'
|
||||
// import { BookResolver } from './graphql/resolvers/BookResolver'
|
||||
import { UserResolver } from './graphql/resolvers/UserResolver'
|
||||
import { CommunityTransactionResolver } from './graphql/resolvers/CommunityTransactionResolver'
|
||||
import { GdtResolver } from './graphql/resolvers/GdtResolver'
|
||||
// import { GroupResolver } from './graphql/resolvers/GroupResolver'
|
||||
// TODO implement
|
||||
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
||||
@ -16,7 +17,11 @@ import { CommunityTransactionResolver } from './graphql/resolvers/CommunityTrans
|
||||
async function main() {
|
||||
// const connection = await createConnection()
|
||||
const schema = await buildSchema({
|
||||
resolvers: [/* BookResolver , GroupResolver, */ UserResolver, CommunityTransactionResolver],
|
||||
resolvers: [
|
||||
/* BookResolver , GroupResolver, */ UserResolver,
|
||||
CommunityTransactionResolver,
|
||||
GdtResolver,
|
||||
],
|
||||
})
|
||||
|
||||
// Graphiql interface
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user