37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { HouseRepository } from "~/server/db/mysql/repository/HouseRepository";
|
|
import { House } from "../../../domain/house";
|
|
|
|
export class ConstrueHouseCommandHandler {
|
|
public static async create() {
|
|
const houseRepository = new HouseRepository();
|
|
const houseList = await houseRepository.findAll();
|
|
|
|
const houseCandidates: House[] = [];
|
|
let i = 0;
|
|
|
|
houseList.forEach((houseCandidate: object) => {
|
|
houseCandidates.push(
|
|
House.create(
|
|
`${++i}`,
|
|
houseCandidate.title,
|
|
houseCandidate.url,
|
|
houseCandidate.neighborhood,
|
|
houseCandidate.area,
|
|
houseCandidate.rooms,
|
|
houseCandidate.price,
|
|
houseCandidate.description,
|
|
houseCandidate.pic,
|
|
houseCandidate.baths,
|
|
houseCandidate.level,
|
|
houseCandidate.phone
|
|
));
|
|
});
|
|
|
|
const proposedHouses = houseRepository.filterHouseByTitleAndExactPriceAndRoomsAndBaths(houseCandidates);
|
|
|
|
return proposedHouses;
|
|
}
|
|
|
|
async execute(): Promise<void> {
|
|
}
|
|
} |