chore: change the real user abd legal user data

This commit is contained in:
mahyargdz
2025-03-02 17:59:02 +03:30
parent c559fdb9e8
commit 0da12b89eb
13 changed files with 203 additions and 187 deletions
@@ -12,5 +12,5 @@ export class Address extends BaseEntity {
postalCode: string;
@Column({ type: "text" })
address: string;
fullAddress: string;
}
+1 -1
View File
@@ -10,6 +10,6 @@ export class City {
@Column({ type: "varchar", length: 255 })
name: string;
@ManyToOne(() => Province, (province) => province.cities, { nullable: false })
@ManyToOne(() => Province, (province) => province.cities, { eager: true, nullable: false })
province: Province;
}
@@ -12,6 +12,7 @@ export class AddressService {
private readonly cityRepository: CityRepository,
private readonly provinceRepository: ProvinceRepository,
) {}
//*********************************** */
async getAllCities(queryDto: SearchCitiesDto) {
const { limit, skip } = PaginationUtils(queryDto);
@@ -32,6 +33,7 @@ export class AddressService {
paginate: true,
};
}
//*********************************** */
async getAllProvinces(queryDto: SearchCitiesDto) {
const { limit, skip } = PaginationUtils(queryDto);
@@ -52,6 +54,7 @@ export class AddressService {
paginate: true,
};
}
//*********************************** */
async getProvince(id: number) {
const province = await this.provinceRepository.findOneBy({
@@ -61,25 +64,25 @@ export class AddressService {
return { province };
}
//*********************************** */
async getCity(id: number) {
const city = await this.cityRepository.findOneBy({
id,
});
const city = await this.cityRepository.findOneBy({ id });
if (!city) throw new BadRequestException(CityMessage.NOT_FOUND);
return { city };
}
//*********************************** */
async getCitiesByProvince(queryDto: SearchCitiesDto, id: number) {
const { limit, skip } = PaginationUtils(queryDto);
const province = await this.provinceRepository.findOneBy({
id,
});
const province = await this.provinceRepository.findOneBy({ id });
if (!province) throw new BadRequestException(CityMessage.NOT_FOUND);
const queryBuilder = this.cityRepository.createQueryBuilder("city").where("city.provinceId = :provinceId", { provinceId: province.id });
//
if (queryDto.q) {
queryBuilder.andWhere("city.name ILIKE :q", { q: `%${queryDto.q}%` });
}
@@ -94,15 +97,9 @@ export class AddressService {
pagination: true,
};
}
//*********************************** */
async getProvinceByCity(id: number) {
const province = await this.provinceRepository.findOne({
where: {
cities: {
id,
},
},
});
const province = await this.provinceRepository.findOne({ where: { cities: { id } } });
if (!province) throw new BadRequestException(ProvinceMessage.NOT_FOUND);
return { province };