59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
|
import { UserEntity } from '../../entities/user.entity';
|
|
import { UserModel } from '../../../data/models/user.model';
|
|
import { UserUpdatedEvent } from '../../entities/event/user-updated.event';
|
|
import {
|
|
EventTopics,
|
|
columnUniques,
|
|
validateRelations,
|
|
} from 'src/core/strings/constants/interface.constants';
|
|
import { UserRole } from '../../../constants';
|
|
|
|
@Injectable()
|
|
export class UpdateUserManager extends BaseUpdateManager<UserEntity> {
|
|
async validateProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
async beforeProcess(): Promise<void> {
|
|
let role = UserRole.STAFF;
|
|
if (this.data.is_super_admin || !this.data.user_privilege)
|
|
role = UserRole.SUPERADMIN;
|
|
|
|
Object.assign(this.data, {
|
|
role: role,
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
async afterProcess(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
get validateRelations(): validateRelations[] {
|
|
return [];
|
|
}
|
|
|
|
get uniqueColumns(): columnUniques[] {
|
|
return [
|
|
{
|
|
column: 'username',
|
|
},
|
|
];
|
|
}
|
|
|
|
get entityTarget(): any {
|
|
return UserModel;
|
|
}
|
|
|
|
get eventTopics(): EventTopics[] {
|
|
return [
|
|
{
|
|
topic: UserUpdatedEvent,
|
|
},
|
|
];
|
|
}
|
|
}
|