This commit is contained in:
@@ -21,7 +21,7 @@ export class AdminService {
|
||||
) { }
|
||||
|
||||
async create(dto: CreateAdminDto) {
|
||||
const { phone, firstName, lastName, roleId } = dto;
|
||||
const { phone, firstName, lastName, roleId, avatarUrl } = dto;
|
||||
|
||||
|
||||
const currentAdmin = await this.adminRepository.findOne({
|
||||
@@ -47,6 +47,7 @@ export class AdminService {
|
||||
phone,
|
||||
firstName,
|
||||
lastName,
|
||||
avatarUrl,
|
||||
role,
|
||||
});
|
||||
await this.em.persistAndFlush(admin);
|
||||
@@ -81,13 +82,16 @@ export class AdminService {
|
||||
|
||||
const { roleId, ...rest } = dto;
|
||||
|
||||
// Update scalar fields (firstName, lastName, phone)
|
||||
// Update scalar fields (firstName, lastName, phone, avatarUrl)
|
||||
if (rest.firstName !== undefined) {
|
||||
admin.firstName = rest.firstName;
|
||||
}
|
||||
if (rest.lastName !== undefined) {
|
||||
admin.lastName = rest.lastName;
|
||||
}
|
||||
if (rest.avatarUrl !== undefined) {
|
||||
admin.avatarUrl = rest.avatarUrl;
|
||||
}
|
||||
|
||||
if (rest.phone !== undefined && rest.phone !== admin.phone) {
|
||||
const exists = await this.adminRepository.findOne({ phone: rest.phone,id: { $ne: adminId } });
|
||||
|
||||
Reference in New Issue
Block a user