Commit a030e2cb authored by 李尚科's avatar 李尚科

二期 rental_house residential fix

parent 412fe50f
Pipeline #8508 passed with stage
in 11 seconds
'use strict';
const Service = require('egg').Service;
const R = require('ramda');
class DeveloperService extends Service {
/**
* 通過城市编号获取小区列表
* @param {object} condition {type: XX, connect_id: XX}
* @param {object} elements [id, path, ...]//需要筛选出的元素
*/
async getDevelopers(condition, elements = []) {
const { ctx } = this;
const { city_code, district_code, bizcircle_code } = condition;
let where = {};
if (bizcircle_code) {
const residentials = await ctx.realestateModel.ResidentialDeveloper.all({ where: { region: bizcircle_code } });
const residentials_ids = R.pluck('developer_id', residentials);
where.id = { $in: residentials_ids }
} else if (district_code) {
const residentials = await ctx.realestateModel.ResidentialDeveloper.all({ where: { county: district_code } });
const residentials_ids = R.pluck('developer_id', residentials);
where.id = { $in: residentials_ids }
} else if (city_code) {
const residentials = await ctx.realestateModel.ResidentialDeveloper.all({ where: { city: city_code } });
const residentials_ids = R.pluck('developer_id', residentials);
where.id = { $in: residentials_ids }
}
let ret = await ctx.realestateModel.Developer.all({ where: where });
if (Array.isArray(elements) && elements.length !== 0) {
ret = R.project(elements)(ret);
}
return ret;
}
}
module.exports = DeveloperService;
'use strict';
const Service = require('egg').Service;
const R = require('ramda');
class HouseImageService extends Service {
/**
* 获取图片相册
* @param {object} condition {type: XX, connect_id: XX}
* @param {object} elements [id, path, ...]//需要筛选出的元素
*/
async getAll(condition, elements = []) {
const { ctx } = this;
const { type, connect_id } = condition;
if (type === undefined || !connect_id) {
return [];
}
let ret = await ctx.realestateModel.HouseImage.all({ where: { status: 'online', valid: 1, type: type, connect_id: connect_id } });
if (Array.isArray(elements) && elements.length !== 0) {
ret = R.project(elements)(ret);
}
return ret;
}
}
module.exports = HouseImageService;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment