Browse Source

(+) 房屋信息登记api

master
liujiangyong 1 year ago
parent
commit
53a0876221
  1. 18
      api/app/lib/controllers/superScreen/community.js
  2. 1
      api/app/lib/middlewares/authenticator.js
  3. 3
      api/app/lib/routes/superScreen/community.js

18
api/app/lib/controllers/superScreen/community.js

@ -2,6 +2,23 @@
const request = require("superagent"); const request = require("superagent");
const cheerio = require('cheerio'); 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) { function getPersonAge(opts) {
return async function (ctx, next) { return async function (ctx, next) {
@ -182,6 +199,7 @@ function getFgjvNotice(opts) {
} }
module.exports = { module.exports = {
addAffordableHousing,
getPersonAge, getPersonAge,
getHomePerson, getHomePerson,
getHomeInfo, getHomeInfo,

1
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: '/home/person', o: 'GET' });
excludeOpts.push({ p: '/community/info', o: 'GET' }); excludeOpts.push({ p: '/community/info', o: 'GET' });
excludeOpts.push({ p: '/community/fgjv/notice', o: 'GET' }); excludeOpts.push({ p: '/community/fgjv/notice', o: 'GET' });
excludeOpts.push({ p: '/affordable/housing/add', o: 'POST' });
excludes = new ExcludesUrls(excludeOpts); excludes = new ExcludesUrls(excludeOpts);
} }

3
api/app/lib/routes/superScreen/community.js

@ -3,6 +3,9 @@
const community = require('../../controllers/superScreen/community'); const community = require('../../controllers/superScreen/community');
module.exports = function (app, router, opts, AuthCode) { 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 }; app.fs.api.logAttr['GET/home/person'] = { content: '获取租户家庭人口统计', visible: true };

Loading…
Cancel
Save