feat(SPG-953): penyesuaian API Create dan Update pengguna baru dengan menambahkan opsi admin antrian
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
283b783007
commit
52c82a9a41
|
@ -13,6 +13,8 @@ import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
|||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
||||
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
||||
import { UserLoginEvent } from '../entities/login.event';
|
||||
import { Not } from 'typeorm';
|
||||
import { UserRole } from 'src/modules/user-related/user/constants';
|
||||
|
||||
@Injectable()
|
||||
export class LoginManager extends BaseCustomManager<UserEntity> {
|
||||
|
@ -36,6 +38,7 @@ export class LoginManager extends BaseCustomManager<UserEntity> {
|
|||
where: {
|
||||
username: this.data.username,
|
||||
status: STATUS.ACTIVE,
|
||||
role: Not(UserRole.QUEUE_ADMIN),
|
||||
},
|
||||
relations: [
|
||||
'user_privilege',
|
||||
|
|
|
@ -15,12 +15,7 @@ import { SALT_OR_ROUNDS } from 'src/core/strings/constants/base.constants';
|
|||
@Injectable()
|
||||
export class CreateUserManager extends BaseCreateManager<UserEntity> {
|
||||
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,
|
||||
password: await hashPassword(this.data.password, SALT_OR_ROUNDS),
|
||||
});
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ export class DetailUserManager extends BaseDetailManager<UserEntity> {
|
|||
`${this.tableName}.status`,
|
||||
`${this.tableName}.name`,
|
||||
`${this.tableName}.username`,
|
||||
`${this.tableName}.role`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
|
|
|
@ -41,6 +41,7 @@ export class IndexUserManager extends BaseIndexManager<UserEntity> {
|
|||
`${this.tableName}.status`,
|
||||
`${this.tableName}.name`,
|
||||
`${this.tableName}.username`,
|
||||
`${this.tableName}.role`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
|
|
|
@ -8,7 +8,6 @@ import {
|
|||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { UserRole } from '../../../constants';
|
||||
|
||||
@Injectable()
|
||||
export class UpdateUserManager extends BaseUpdateManager<UserEntity> {
|
||||
|
@ -17,14 +16,6 @@ export class UpdateUserManager extends BaseUpdateManager<UserEntity> {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,9 @@ export class UpdateUserDto extends BaseStatusDto implements UserEntity {
|
|||
@IsString()
|
||||
username: string;
|
||||
|
||||
@ApiProperty({
|
||||
name: 'is_super_admin',
|
||||
type: Boolean,
|
||||
required: true,
|
||||
example: false,
|
||||
})
|
||||
@IsBoolean()
|
||||
is_super_admin: boolean;
|
||||
@ApiProperty({ name: 'role', required: true, example: UserRole.STAFF })
|
||||
@IsString()
|
||||
role: UserRole;
|
||||
|
||||
@ApiProperty({
|
||||
name: 'user_privilege',
|
||||
|
@ -45,9 +40,6 @@ export class UpdateUserDto extends BaseStatusDto implements UserEntity {
|
|||
@Exclude()
|
||||
password: string;
|
||||
|
||||
@Exclude()
|
||||
role: UserRole;
|
||||
|
||||
@Exclude()
|
||||
refresh_token: string;
|
||||
}
|
||||
|
|
|
@ -31,14 +31,9 @@ export class UserDto extends BaseStatusDto implements UserEntity {
|
|||
@ValidateIf((body) => body.user_privilege)
|
||||
user_privilege: UserPrivilegeModel;
|
||||
|
||||
@ApiProperty({
|
||||
name: 'is_super_admin',
|
||||
type: Boolean,
|
||||
required: true,
|
||||
example: false,
|
||||
})
|
||||
@IsBoolean()
|
||||
is_super_admin: boolean;
|
||||
@ApiProperty({ name: 'role', required: true, example: UserRole.STAFF })
|
||||
@IsString()
|
||||
role: UserRole;
|
||||
|
||||
@Exclude()
|
||||
share_margin: number;
|
||||
|
@ -46,9 +41,6 @@ export class UserDto extends BaseStatusDto implements UserEntity {
|
|||
@Exclude()
|
||||
email: string;
|
||||
|
||||
@Exclude()
|
||||
role: UserRole;
|
||||
|
||||
@Exclude()
|
||||
refresh_token: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue