Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move GET admin/users api to nest #4776

Merged
merged 87 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5871229
Move GET admin/users api to nest
Feb 20, 2024
2fcb562
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 20, 2024
7485f7d
fix imports
Feb 20, 2024
fba2cfe
rename path
Feb 20, 2024
a46845a
fix modules
Feb 20, 2024
9cfd25c
fix date queries
Feb 20, 2024
f5dc04e
remove unused methods
Feb 20, 2024
5a39f1c
provide range type
Feb 20, 2024
a06db8b
fix lint
Feb 21, 2024
4059194
fix import
Feb 21, 2024
38179ac
add api tests
Feb 21, 2024
f0b5809
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 21, 2024
e1234e3
fix nest lint
Feb 21, 2024
34f6789
fix nest lint
Feb 21, 2024
49e1326
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 22, 2024
c0bbd37
fix tests
Feb 22, 2024
f6e6297
fix lint
Feb 22, 2024
83c6ec8
remove unused code
Feb 22, 2024
8ed06de
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 22, 2024
7e7b918
fix tests
Feb 22, 2024
036efd5
remove feathers tests
Feb 22, 2024
32f906b
add tests
Feb 22, 2024
4cac15e
remove feathers tests
Feb 22, 2024
9cf9907
fix tests
Feb 22, 2024
a168bc3
fix tests
Feb 22, 2024
cf1b028
fix tests
Feb 22, 2024
e775bd4
fix error message
Feb 22, 2024
6e394cd
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 23, 2024
1ef65d9
add unit test
Feb 23, 2024
6f34cf0
fix tests
Feb 23, 2024
8b21795
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 23, 2024
f62e54f
add unit test
Feb 23, 2024
b0dc161
refactor aggregationHelper
Feb 23, 2024
109f4f9
remove lint comment
Feb 23, 2024
9d4463e
fix tests
Feb 26, 2024
3168f22
restore searching by users
Feb 26, 2024
337fb56
fix lint
Feb 26, 2024
a84c52d
fix tests
Feb 26, 2024
43c7907
fix api description
Feb 26, 2024
19ee7dd
code refactor
Feb 26, 2024
049f0f6
fix returned authorization exception
Feb 26, 2024
8649a05
fix lint and restore methods
Feb 26, 2024
c6fb9af
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 26, 2024
f3a6b9f
remove unused code
Feb 26, 2024
6fd00a9
add missing property
Feb 26, 2024
674c7bf
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 26, 2024
5b03f8b
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 26, 2024
9825997
fix module
Feb 27, 2024
e3f1f93
code refactor
Feb 27, 2024
7818532
Merge branch 'main' into BC-5388-move-admin-users-get-api
Feb 27, 2024
e876b1e
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Feb 27, 2024
3f9342c
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 4, 2024
12ae3cb
refactor
Mar 4, 2024
fc0372c
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 4, 2024
8bad397
refactor tests
Mar 4, 2024
2f5d4a3
fix tests
Mar 4, 2024
b4cfa4c
remove class constructor
Mar 4, 2024
ae804c6
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 4, 2024
079b235
add comment
Mar 5, 2024
6961aa4
refactor
Mar 5, 2024
ecd5231
rename controller methods
Mar 5, 2024
f8e6513
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 7, 2024
4ca4633
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 11, 2024
c984429
add tests for repo
Mar 11, 2024
0334c8b
rename searchQuery sort param
Mar 11, 2024
4a017c0
fix test
Mar 11, 2024
a0c1eaf
Merge branch 'main' into BC-5388-move-admin-users-get-api
Mar 11, 2024
24b0ccc
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 11, 2024
5fad785
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 11, 2024
f7e98df
fix searching by searchQuery
Mar 11, 2024
b22dad9
fix searching by searchQuery
Mar 11, 2024
2a73f7f
remove console log
Mar 11, 2024
b03273e
Merge branch 'main' into BC-5388-move-admin-users-get-api
Mar 12, 2024
f93cb01
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 13, 2024
2512d6f
add unit test for search-query-helper
Mar 13, 2024
654fe92
fix lint
Mar 13, 2024
68ad068
refactor and add tests
Mar 13, 2024
39153b0
fix skip test
Mar 14, 2024
95eba50
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 15, 2024
4eda5b3
move test to repo tests
Mar 15, 2024
15e00d4
removed duplicated test
Mar 15, 2024
80c9bd3
add test
Mar 15, 2024
7870926
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 15, 2024
fc0a66c
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 18, 2024
55c76e6
Merge branch 'main' into BC-5388-move-admin-users-get-api
wiaderwek Mar 18, 2024
bf0ef54
rerun
Mar 18, 2024
b219122
fix import
Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/doc/file-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ The use of a mapper gives us the guarantee, that
- no additional data beside the known properties is published.
- A plain object might contain more properties than defined in TS-interfaces.
Sample: All school properties are published while only name & id are intended to be published.
- the API definition is complete
- the API definition is complete
2 changes: 2 additions & 0 deletions apps/server/src/modules/server/server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { UsersAdminApiModule } from '@modules/user/legacy/users-admin-api.module';
import { ServerConfigController, ServerController, ServerUc } from './api';
import { SERVER_CONFIG_TOKEN, serverConfig } from './server.config';

Expand All @@ -52,6 +53,7 @@ const serverModules = [
LessonApiModule,
NewsModule,
UserApiModule,
UsersAdminApiModule,
SchulconnexClientModule.register({
apiUrl: Configuration.get('SCHULCONNEX_CLIENT__API_URL') as string,
tokenEndpoint: Configuration.get('SCHULCONNEX_CLIENT__TOKEN_ENDPOINT') as string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { AdminApiUserUc } from '../uc/admin-api-user.uc';
import { AdminApiUserUc } from '../uc';
import { AdminApiUserCreateBodyParams } from './dto/admin-api-user-create.body.params';
import { AdminApiUserCreateResponse } from './dto/admin-api-user-create.response.dto';

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/user/controller/dto/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './user.params';
export * from './user.response';
export * from './resolved-user.response';
export * from './create-user.response';
1 change: 1 addition & 0 deletions apps/server/src/modules/user/controller/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './user.controller';
export * from './admin-api-user.controller';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Controller, Get, Param, Query } from '@nestjs/common';
import { EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common';
import { Authenticate, CurrentUser, ICurrentUser } from '../../../authentication';
import { RequestedRoleEnum } from '../enum';
import { UserByIdParams, UserListResponse, UserResponse, UsersSearchQueryParams } from './dto';
import { UsersAdminApiUc } from '../uc';

@ApiTags('AdminStudents')
@Authenticate('jwt')
@Controller('users/admin/students')
export class AdminApiStudentsController {
dyedwiper marked this conversation as resolved.
Show resolved Hide resolved
constructor(private readonly uc: UsersAdminApiUc) {}

@Get()
@ApiOperation({
summary: 'Returns all students which satisfies the given criteria.',
})
@ApiResponse({ status: 200, type: UserListResponse, description: 'Returns a paged list of students.' })
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Not authorized.' })
async searchStudents(
@CurrentUser() currentUser: ICurrentUser,
@Query() params: UsersSearchQueryParams
): Promise<UserListResponse> {
return this.uc.findUsersByParams(RequestedRoleEnum.STUDENTS, currentUser.userId, params);
}

@Get(':id')
@ApiOperation({ summary: 'Returns an student with given id.' })
@ApiResponse({ status: 200, type: UserResponse, description: 'Returns the student.' })
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Not authorized.' })
@ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Student not found.' })
async findStudentById(
@CurrentUser() currentUser: ICurrentUser,
@Param() params: UserByIdParams
): Promise<UserResponse> {
return this.uc.findUserById(RequestedRoleEnum.STUDENTS, currentUser.userId, params);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Controller, Get, Param, Query } from '@nestjs/common';
import { EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common';
import { Authenticate, CurrentUser, ICurrentUser } from '../../../authentication';
import { RequestedRoleEnum } from '../enum';
import { UserByIdParams, UserListResponse, UserResponse, UsersSearchQueryParams } from './dto';
import { UsersAdminApiUc } from '../uc';

@ApiTags('AdminTeachers')
@Authenticate('jwt')
@Controller('users/admin/teachers')
export class AdminApiTeachersController {
constructor(private readonly uc: UsersAdminApiUc) {}

@Get()
@ApiOperation({
summary: 'Returns all teachers which satisfies the given criteria.',
})
@ApiResponse({ status: 200, type: UserListResponse, description: 'Returns a paged list of teachers.' })
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Not authorized.' })
async searchTeachers(
@CurrentUser() currentUser: ICurrentUser,
@Query() params: UsersSearchQueryParams
): Promise<UserListResponse> {
return this.uc.findUsersByParams(RequestedRoleEnum.TEACHERS, currentUser.userId, params);
}

@Get(':id')
@ApiOperation({ summary: 'Returns a teacher with given id.' })
@ApiResponse({ status: 200, type: UserResponse, description: 'Returns the teacher.' })
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Not authorized.' })
@ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Teacher not found.' })
async findTeacherById(
@CurrentUser() currentUser: ICurrentUser,
@Param() params: UserByIdParams
): Promise<UserResponse> {
return this.uc.findUserById(RequestedRoleEnum.TEACHERS, currentUser.userId, params);
}
}
Loading
Loading