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 };