mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { Community as DbCommunity } from '@entity/Community'
|
|
import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity'
|
|
import { Resolver, Query, Authorized } from 'type-graphql'
|
|
|
|
import { Community } from '@model/Community'
|
|
import { FederatedCommunity } from '@model/FederatedCommunity'
|
|
|
|
import { RIGHTS } from '@/auth/RIGHTS'
|
|
|
|
@Resolver()
|
|
export class CommunityResolver {
|
|
@Authorized([RIGHTS.COMMUNITIES])
|
|
@Query(() => [FederatedCommunity])
|
|
async getCommunities(): Promise<FederatedCommunity[]> {
|
|
const dbFederatedCommunities: DbFederatedCommunity[] = await DbFederatedCommunity.find({
|
|
order: {
|
|
foreign: 'ASC',
|
|
createdAt: 'DESC',
|
|
lastAnnouncedAt: 'DESC',
|
|
},
|
|
})
|
|
return dbFederatedCommunities.map(
|
|
(dbCom: DbFederatedCommunity) => new FederatedCommunity(dbCom),
|
|
)
|
|
}
|
|
|
|
@Authorized([RIGHTS.COMMUNITIES])
|
|
@Query(() => [Community])
|
|
async getCommunitySelections(): Promise<Community[]> {
|
|
const dbCommunities: DbCommunity[] = await DbCommunity.find({
|
|
order: {
|
|
name: 'ASC',
|
|
},
|
|
})
|
|
return dbCommunities.map((dbCom: DbCommunity) => new Community(dbCom))
|
|
}
|
|
}
|