From bb0b582381cd838d8faf62bb8666f05e34f0971d Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 5 Sep 2024 10:43:49 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=90=9C=E7=B4=A2=E9=85=92=E5=BA=97?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/services/heytripService.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/services/heytripService.js b/server/services/heytripService.js index 02215c0..1dfdcf5 100644 --- a/server/services/heytripService.js +++ b/server/services/heytripService.js @@ -40,6 +40,7 @@ Hotelinfo.hasMany(Hotelinfo2, { as: 'locale_info', sourceKey: 'hotel_id', foreig // Hotelinfo2.belongsTo(Hotelinfo, { as: 'locale_info2', targetKey: 'hotel_id', foreignKey: 'hotel_id', ...foreignOption, }); Hotelinfo.hasOne(City, { as: 'city', sourceKey: 'city_id', foreignKey: 'id', ...foreignOption, }); // 多语种, 所以实际是 hasMany , 用 hasOne 要指定 lgc= 1 或者2 Hotelinfo.hasOne(Country, { as: 'country', sourceKey: 'country_code', foreignKey: 'id', ...foreignOption, }); // 多语种, 所以实际是 hasMany , 用 hasOne 要指定 lgc= 1 或者2 +Hotelinfo.hasMany(Images, { sourceKey: 'hotel_id', foreignKey: 'hotel_id', ...foreignOption }); Rooms.hasMany(Images, { sourceKey: 'room_id', foreignKey: 'info_source_id', ...foreignOption }); @@ -86,8 +87,16 @@ class Heytrip { required: false, separate: true, }, - { model: City, as: 'city', attributes: ['id', 'name'], where: { lgc: 2 }, required: false, }, // separate: true - { model: Country, as: 'country', attributes: ['id', 'name'], where: { lgc: 2 }, required: false, }, // separate: true + { model: City, as: 'city', attributes: ['id', 'name'], where: { lgc: 2 }, required: false }, // separate: true + { model: Country, as: 'country', attributes: ['id', 'name'], where: { lgc: 2 }, required: false }, // separate: true + { + model: Images, + attributes: { exclude: ['lgc', 'locale'] }, + where: { lgc: [0, 1], type: Sequelize.where(Sequelize.fn('IFNULL', Sequelize.col('type'), 'Mid'), 'Mid') }, + order: ['info_source'], + required: false, + separate: true, + }, // separate: true ], where: { [Op.or]: keywordSearch,