Commit d697fd57 authored by 成旭东's avatar 成旭东

楼盘详情 动态 户型图 楼盘图片查询接口分开

parent 996bb819
Pipeline #28262 passed with stage
in 7 minutes 18 seconds
......@@ -246,6 +246,33 @@ export default class EstateListController extends Controller {
ctx.success(data);
}
async showTrends() {
const { ctx, service, serviceGroupName, serviceName } = this;
const { id } = ctx.params;
const where = { project_id: id };
const data = await service[serviceGroupName][serviceName].findProjectTrends(where);
ctx.success(data);
}
async showLayout() {
const { ctx, service, serviceGroupName, serviceName } = this;
const { id } = ctx.params;
const where = { project_id: id };
const data = await service[serviceGroupName][serviceName].findProjectLayout(where);
ctx.success(data);
}
async showImage() {
const { ctx, service, serviceGroupName, serviceName } = this;
const { id } = ctx.params;
const where = { project_id: id };
const data = await service[serviceGroupName][serviceName].findProjectImage(where);
ctx.success(data);
}
async update() {
const { ctx, service, updateRule, serviceGroupName, serviceName } = this;
const { id } = ctx.params;
......
......@@ -14,6 +14,9 @@ export default (app: Application) => {
// 新房房源管理
router.get('/api/estate/list', controller.mpEstate.list.list);
router.get('/api/estate/:id', controller.mpEstate.list.show);
router.get('/api/estate/trends/:id', controller.mpEstate.list.showTrends);
router.get('/api/estate/layout/:id', controller.mpEstate.list.showLayout);
router.get('/api/estate/image/:id', controller.mpEstate.list.showImage);
router.put('/api/estate/update/:id', controller.mpEstate.list.update);
router.get('/api/estate/tag/:type', controller.mpEstate.list.tag);
......
......@@ -141,9 +141,6 @@ export default class EstateListService extends Service {
{ from: 'businessInfo', to: 'businessInfo' },
{ from: 'officeInfo', to: 'officeInfo' },
{ from: 'projectTag', to: 'projectTag' },
{ from: 'projectTrends', to: 'projectTrends' },
{ from: 'houseLayout', to: 'houseLayout' },
{ from: 'houseImage', to: 'houseImage' },
]);
format = newformatConfig;
......@@ -187,21 +184,6 @@ export default class EstateListService extends Service {
as: 'projectTag',
required: false,
where: { valid: 1 },
}, {
model: ctx.wafangModel.WafangProjectTrends,
as: 'projectTrends',
required: false,
where: { valid: 1 },
}, {
model: ctx.wafangModel.WafangLayout,
as: 'houseLayout',
required: false,
where: { valid: 1 },
}, {
model: ctx.wafangModel.WafangImage,
as: 'houseImage',
required: false,
where: { valid: 1 },
}];
const record = await ctx[modelGroupName][modelName].findOne({
......@@ -212,6 +194,51 @@ export default class EstateListService extends Service {
return ctx.service.output.toObject(record, format);
}
async findProjectTrends(where = {}, options = {}, raw = false) {
const { ctx, modelGroupName, formatConfig } = this;
let format: any;
if (!raw) {
format = formatConfig;
}
const record = await ctx[modelGroupName].WafangProjectTrends.findAll({
where: { valid: 1, ...where },
...options,
});
return ctx.service.output.toArray(record, format);
}
async findProjectLayout(where = {}, options = {}, raw = false) {
const { ctx, modelGroupName, formatConfig } = this;
let format: any;
if (!raw) {
format = formatConfig;
}
const record = await ctx[modelGroupName].WafangLayout.findAll({
where: { valid: 1, ...where },
...options,
});
return ctx.service.output.toArray(record, format);
}
async findProjectImage(where = {}, options = {}, raw = false) {
const { ctx, modelGroupName, formatConfig } = this;
let format: any;
if (!raw) {
format = formatConfig;
}
const record = await ctx[modelGroupName].WafangImage.findAll({
where: { valid: 1, ...where },
...options,
});
return ctx.service.output.toArray(record, format);
}
async findTypeTag(where = {}, options = {}, raw = false) {
const { ctx, modelGroupName, formatConfig } = this;
......@@ -235,7 +262,7 @@ export default class EstateListService extends Service {
},
});
const orderArr = [1, 2, 3];
const orderArr = [ 1, 2, 3 ];
if (params.order && orderArr.includes(Number(params.order))) {
const orderRecord = await ctx[modelGroupName][modelName].findOne({
......
......@@ -30,9 +30,9 @@ export default () => {
baseDir: 'model/wafang',
dialect: 'mysql',
host: 'rm-wafang-rds-pubilc.mysql.rds.aliyuncs.com',
database: 'wafang_dev',
username: 'wafang_test',
password: 'ztQ4Y8piePY3521gx74Ii',
database: 'wafang_pro',
username: 'wafang',
password: 'JE2gD1TA1T642',
port: 3306,
}],
};
......
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