From 53a08762218a3875e5a6ce08fe572617a9919603 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Wed, 1 Nov 2023 16:10:29 +0800 Subject: [PATCH] =?UTF-8?q?(+)=20=E6=88=BF=E5=B1=8B=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=99=BB=E8=AE=B0api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/controllers/superScreen/community.js | 18 ++++++++++++++++++ api/app/lib/middlewares/authenticator.js | 1 + api/app/lib/routes/superScreen/community.js | 3 +++ 3 files changed, 22 insertions(+) diff --git a/api/app/lib/controllers/superScreen/community.js b/api/app/lib/controllers/superScreen/community.js index 6f54307..616daaf 100644 --- a/api/app/lib/controllers/superScreen/community.js +++ b/api/app/lib/controllers/superScreen/community.js @@ -2,6 +2,23 @@ const request = require("superagent"); const cheerio = require('cheerio'); +function addAffordableHousing(opts) { + return async function (ctx, next) { + const models = ctx.fs.dc.models; + let errMsg = { message: '新增住房信息失败' } + try { + const { houseValue, personValue } = ctx.request.body; + const arr = personValue.map(p => ({ ...houseValue, ...p })); + await models.AffordableHousing.bulkCreate(arr); + + ctx.status = 204; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = errMsg + } + } +} function getPersonAge(opts) { return async function (ctx, next) { @@ -182,6 +199,7 @@ function getFgjvNotice(opts) { } module.exports = { + addAffordableHousing, getPersonAge, getHomePerson, getHomeInfo, diff --git a/api/app/lib/middlewares/authenticator.js b/api/app/lib/middlewares/authenticator.js index ac60cfd..b2ac0ca 100644 --- a/api/app/lib/middlewares/authenticator.js +++ b/api/app/lib/middlewares/authenticator.js @@ -74,6 +74,7 @@ let isPathExcluded = function (opts, path, method) { excludeOpts.push({ p: '/home/person', o: 'GET' }); excludeOpts.push({ p: '/community/info', o: 'GET' }); excludeOpts.push({ p: '/community/fgjv/notice', o: 'GET' }); + excludeOpts.push({ p: '/affordable/housing/add', o: 'POST' }); excludes = new ExcludesUrls(excludeOpts); } diff --git a/api/app/lib/routes/superScreen/community.js b/api/app/lib/routes/superScreen/community.js index 0934dff..3abbe83 100644 --- a/api/app/lib/routes/superScreen/community.js +++ b/api/app/lib/routes/superScreen/community.js @@ -3,6 +3,9 @@ const community = require('../../controllers/superScreen/community'); module.exports = function (app, router, opts, AuthCode) { + //新增住房信息 + app.fs.api.logAttr['POST/affordable/housing/add'] = { content: '新增住房信息', visible: true }; + router.post('/affordable/housing/add', community.addAffordableHousing(opts)); //获取租户家庭人口统计 app.fs.api.logAttr['GET/home/person'] = { content: '获取租户家庭人口统计', visible: true };