Compare commits
2 Commits
77783549fa
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f78691f91 | |||
| aef712ca1d |
@@ -10,6 +10,8 @@ import { PermissionEnum } from '../../users/enums/permission.enum';
|
||||
import { UserDec } from '../../../common/decorators/user.decorator';
|
||||
import { AuthGuards } from '../../../common/decorators/auth-guard.decorator';
|
||||
import { ITokenPayload } from '../../auth/interfaces/IToken-payload';
|
||||
import { ParamDto } from '../../../common/DTO/param.dto';
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
|
||||
@AuthGuards()
|
||||
@AdminRoute()
|
||||
@@ -28,6 +30,14 @@ export class WorkspaceController {
|
||||
return this.workspaceService.findOneOrFail(id);
|
||||
}
|
||||
|
||||
@Get(':id/users')
|
||||
@ApiOperation({ summary: 'Get workspace users' })
|
||||
@ApiResponse({ status: 200, description: 'Got Workspace Users Successfully!' })
|
||||
@ApiResponse({ status: 404, description: 'Workspace Not Found!' })
|
||||
getWorkspaceUsers(@Param() paramDto: ParamDto): Promise<User[]> {
|
||||
return this.workspaceService.getWorkspaceUsers(paramDto.id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@PermissionsDec(PermissionEnum.WORKSPACE_CREATE)
|
||||
@ApiOperation({ summary: 'Create a new workspace' })
|
||||
|
||||
@@ -71,4 +71,9 @@ export class WorkspaceService {
|
||||
}
|
||||
return await this.workspaceRepository.findByUser(userId);
|
||||
}
|
||||
|
||||
async getWorkspaceUsers(workspaceId: string): Promise<User[]> {
|
||||
const workspace = await this.findOneOrFail(workspaceId);
|
||||
return workspace.users;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ export class WorkspaceRepository extends Repository<TMWorkspace> {
|
||||
'workspace',
|
||||
'user.id',
|
||||
'user.firstName',
|
||||
'user.lastName'
|
||||
'user.lastName',
|
||||
'user.profilePic',
|
||||
]).where('workspace.id = :workspaceId', {workspaceId})
|
||||
.getOne();
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ export class CustomersService {
|
||||
password,
|
||||
phone,
|
||||
birthDate,
|
||||
nationalCode,
|
||||
};
|
||||
|
||||
// const addressUpdateData = {
|
||||
@@ -169,7 +170,7 @@ export class CustomersService {
|
||||
|
||||
if (nationalCode) {
|
||||
const existingNationalCode = await queryRunner.manager.findOne(this.realUserRepository.target, {
|
||||
where: { nationalCode: nationalCode, id: Not(user.id) },
|
||||
where: { nationalCode: nationalCode, user: { id: Not(user.id) } },
|
||||
});
|
||||
if (existingNationalCode) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST);
|
||||
}
|
||||
@@ -180,6 +181,15 @@ export class CustomersService {
|
||||
await queryRunner.manager.update(this.userRepository.target, { id: customerId }, { password: hashPassword });
|
||||
}
|
||||
|
||||
if (nationalCode) {
|
||||
const realUser = await queryRunner.manager.findOne(this.realUserRepository.target, {
|
||||
where: { user: { id: customerId } },
|
||||
});
|
||||
if (realUser) {
|
||||
await queryRunner.manager.update(this.realUserRepository.target, { id: realUser.id }, { nationalCode });
|
||||
}
|
||||
}
|
||||
|
||||
const hasLegalUpdateData = Boolean(
|
||||
registrationName || economicCode || nationalIdentity || registrationCode || postalCode || address || cityId,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user