1- import {
2- BadRequestException ,
3- Inject ,
4- Injectable ,
5- Logger ,
6- forwardRef ,
7- NotFoundException ,
8- } from "@nestjs/common" ;
1+ import { BadRequestException , Inject , Injectable , Logger , forwardRef , NotFoundException } from "@nestjs/common" ;
92import { InjectRepository } from "@nestjs/typeorm" ;
103import { In , Repository } from "typeorm" ;
114
@@ -24,6 +17,7 @@ import { PermissionService } from "./permission.service";
2417import { User } from "@entities/user.entity" ;
2518import { UserService } from "./user.service" ;
2619import { Permission } from "@entities/permissions/permission.entity" ;
20+ import { AuthenticatedRequest } from "@dto/internal/authenticated-request" ;
2721
2822@Injectable ( )
2923export class OrganizationService {
@@ -55,22 +49,15 @@ export class OrganizationService {
5549 }
5650 }
5751
58- async update (
59- id : number ,
60- dto : UpdateOrganizationDto ,
61- userId : number
62- ) : Promise < Organization > {
52+ async update ( id : number , dto : UpdateOrganizationDto , userId : number ) : Promise < Organization > {
6353 const org = await this . findByIdWithRelations ( id ) ;
6454 org . name = dto . name ;
6555 org . updatedBy = userId ;
6656
6757 return await this . organizationRepository . save ( org ) ;
6858 }
6959
70- async updateOpenDataDkRegistered (
71- id : number ,
72- userId : number
73- ) : Promise < Organization > {
60+ async updateOpenDataDkRegistered ( id : number , userId : number ) : Promise < Organization > {
7461 const org = await this . findByIdWithRelations ( id ) ;
7562 org . openDataDkRegistered = true ;
7663 org . updatedBy = userId ;
@@ -84,14 +71,9 @@ export class OrganizationService {
8471 return await this . organizationRepository . save ( org ) ;
8572 }
8673
87- async rejectAwaitingUser (
88- user : User ,
89- organization : Organization
90- ) : Promise < Organization > {
74+ async rejectAwaitingUser ( user : User , organization : Organization ) : Promise < Organization > {
9175 if ( organization . awaitingUsers . find ( dbUser => dbUser . id === user . id ) ) {
92- const index = organization . awaitingUsers . findIndex (
93- dbUser => dbUser . id === user . id
94- ) ;
76+ const index = organization . awaitingUsers . findIndex ( dbUser => dbUser . id === user . id ) ;
9577 organization . awaitingUsers . splice ( index , 1 ) ;
9678 await this . userService . sendRejectionMail ( user , organization ) ;
9779 return await this . organizationRepository . save ( organization ) ;
@@ -110,9 +92,7 @@ export class OrganizationService {
11092 } ;
11193 }
11294
113- mapPermissionsToOrganizations (
114- permissions : Permission [ ]
115- ) : Organization [ ] {
95+ mapPermissionsToOrganizations ( permissions : Permission [ ] ) : Organization [ ] {
11696 const requestedOrganizations : Organization [ ] = [ ] ;
11797
11898 for ( let index = 0 ; index < permissions . length ; index ++ ) {
@@ -141,14 +121,12 @@ export class OrganizationService {
141121 return requestedOrganizations ;
142122 }
143123
144- mapPermissionsToOneOrganization (
145- permissions : Permission [ ]
146- ) : Organization {
124+ mapPermissionsToOneOrganization ( permissions : Permission [ ] ) : Organization {
147125 const org : Organization = new Organization ( ) ;
148126
149127 permissions . map ( permission => {
150128 org . id = permission . organization . id ;
151- org . name = permission . organization . name
129+ org . name = permission . organization . name ;
152130 } ) ;
153131
154132 org . permissions = [ ] ;
@@ -163,9 +141,7 @@ export class OrganizationService {
163141 return org ;
164142 }
165143
166- async findAllPaginated (
167- query ?: ListAllEntitiesDto
168- ) : Promise < ListAllOrganizationsResponseDto > {
144+ async findAllPaginated ( query ?: ListAllEntitiesDto ) : Promise < ListAllOrganizationsResponseDto > {
169145 const sorting : { [ id : string ] : string | number } = this . getSorting ( query ) ;
170146
171147 const [ data , count ] = await this . organizationRepository . findAndCount ( {
@@ -182,6 +158,7 @@ export class OrganizationService {
182158 }
183159
184160 async findAllMinimal ( ) : Promise < ListAllMinimalOrganizationsResponseDto > {
161+
185162 const [ data , count ] = await this . organizationRepository . findAndCount ( {
186163 select : [ "id" , "name" ] ,
187164 } ) ;
@@ -218,9 +195,7 @@ export class OrganizationService {
218195 const sorting : { [ id : string ] : string | number } = { } ;
219196 if (
220197 query ?. orderOn != null &&
221- ( query . orderOn == "id" ||
222- query . orderOn == "name" ||
223- query . orderOn == "lastLogin" )
198+ ( query . orderOn == "id" || query . orderOn == "name" || query . orderOn == "lastLogin" )
224199 ) {
225200 sorting [ query . orderOn ] = query . sort . toLocaleUpperCase ( ) ;
226201 } else {
@@ -230,7 +205,7 @@ export class OrganizationService {
230205 }
231206
232207 async findById ( organizationId : number ) : Promise < Organization > {
233- return await this . organizationRepository . findOneByOrFail ( { id : organizationId } ) ;
208+ return await this . organizationRepository . findOneByOrFail ( { id : organizationId } ) ;
234209 }
235210
236211 async findByIdWithRelations ( organizationId : number ) : Promise < Organization > {
0 commit comments