This commit is contained in:
@@ -1381,6 +1381,16 @@
|
|||||||
"length": 255,
|
"length": 255,
|
||||||
"mappedType": "string"
|
"mappedType": "string"
|
||||||
},
|
},
|
||||||
|
"avatar_url": {
|
||||||
|
"name": "avatar_url",
|
||||||
|
"type": "varchar(255)",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"length": 255,
|
||||||
|
"mappedType": "string"
|
||||||
|
},
|
||||||
"role_id": {
|
"role_id": {
|
||||||
"name": "role_id",
|
"name": "role_id",
|
||||||
"type": "char(26)",
|
"type": "char(26)",
|
||||||
@@ -1672,6 +1682,16 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"length": 255,
|
"length": 255,
|
||||||
"mappedType": "string"
|
"mappedType": "string"
|
||||||
|
},
|
||||||
|
"avatar_url": {
|
||||||
|
"name": "avatar_url",
|
||||||
|
"type": "varchar(255)",
|
||||||
|
"unsigned": false,
|
||||||
|
"autoincrement": false,
|
||||||
|
"primary": false,
|
||||||
|
"nullable": true,
|
||||||
|
"length": 255,
|
||||||
|
"mappedType": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name": "users",
|
"name": "users",
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ export class CreateAdminDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
lastName?: string;
|
lastName?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Avatar S3 key', required: false })
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
avatarUrl?: string;
|
||||||
|
|
||||||
@ApiProperty({ description: 'Role id for the admin' })
|
@ApiProperty({ description: 'Role id for the admin' })
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ export class Admin extends BaseEntity {
|
|||||||
@Property({ unique: true })
|
@Property({ unique: true })
|
||||||
phone: string
|
phone: string
|
||||||
|
|
||||||
|
@Property({ nullable: true })
|
||||||
|
avatarUrl?: string;
|
||||||
|
|
||||||
@ManyToOne(() => Role)
|
@ManyToOne(() => Role)
|
||||||
role: Role
|
role: Role
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class AdminService {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
async create(dto: CreateAdminDto) {
|
async create(dto: CreateAdminDto) {
|
||||||
const { phone, firstName, lastName, roleId } = dto;
|
const { phone, firstName, lastName, roleId, avatarUrl } = dto;
|
||||||
|
|
||||||
|
|
||||||
const currentAdmin = await this.adminRepository.findOne({
|
const currentAdmin = await this.adminRepository.findOne({
|
||||||
@@ -47,6 +47,7 @@ export class AdminService {
|
|||||||
phone,
|
phone,
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
|
avatarUrl,
|
||||||
role,
|
role,
|
||||||
});
|
});
|
||||||
await this.em.persistAndFlush(admin);
|
await this.em.persistAndFlush(admin);
|
||||||
@@ -81,13 +82,16 @@ export class AdminService {
|
|||||||
|
|
||||||
const { roleId, ...rest } = dto;
|
const { roleId, ...rest } = dto;
|
||||||
|
|
||||||
// Update scalar fields (firstName, lastName, phone)
|
// Update scalar fields (firstName, lastName, phone, avatarUrl)
|
||||||
if (rest.firstName !== undefined) {
|
if (rest.firstName !== undefined) {
|
||||||
admin.firstName = rest.firstName;
|
admin.firstName = rest.firstName;
|
||||||
}
|
}
|
||||||
if (rest.lastName !== undefined) {
|
if (rest.lastName !== undefined) {
|
||||||
admin.lastName = rest.lastName;
|
admin.lastName = rest.lastName;
|
||||||
}
|
}
|
||||||
|
if (rest.avatarUrl !== undefined) {
|
||||||
|
admin.avatarUrl = rest.avatarUrl;
|
||||||
|
}
|
||||||
|
|
||||||
if (rest.phone !== undefined && rest.phone !== admin.phone) {
|
if (rest.phone !== undefined && rest.phone !== admin.phone) {
|
||||||
const exists = await this.adminRepository.findOne({ phone: rest.phone,id: { $ne: adminId } });
|
const exists = await this.adminRepository.findOne({ phone: rest.phone,id: { $ne: adminId } });
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ export class CreateUserDto {
|
|||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
gender: boolean;
|
gender: boolean;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'Avatar S3 key', required: false, example: 'uploads/avatar.png' })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
avatarUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,4 +42,7 @@ export class User extends BaseEntity {
|
|||||||
|
|
||||||
@Property({ type: 'string', nullable: true })
|
@Property({ type: 'string', nullable: true })
|
||||||
addresse?: string
|
addresse?: string
|
||||||
|
|
||||||
|
@Property({ nullable: true })
|
||||||
|
avatarUrl?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ export interface CreateUser {
|
|||||||
address?: string;
|
address?: string;
|
||||||
gender: boolean;
|
gender: boolean;
|
||||||
maxCredit: number;
|
maxCredit: number;
|
||||||
|
avatarUrl?: string;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,8 @@ export class UserService {
|
|||||||
lastName: param.lastName,
|
lastName: param.lastName,
|
||||||
gender: param.gender,
|
gender: param.gender,
|
||||||
maxCredit: param.maxCredit,
|
maxCredit: param.maxCredit,
|
||||||
addresse:param.address
|
addresse: param.address,
|
||||||
|
avatarUrl: param.avatarUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
const user = this.userRepository.create(createData);
|
const user = this.userRepository.create(createData);
|
||||||
|
|||||||
Reference in New Issue
Block a user