Browse Source

查询婚育列表

master
巴林闲侠 2 years ago
parent
commit
719567cf11
  1. 25
      api/app/lib/controllers/member/index.js
  2. 3
      api/app/lib/routes/member/index.js
  3. 2
      api/app/lib/utils/member.js

25
api/app/lib/controllers/member/index.js

@ -240,6 +240,30 @@ async function workPlaceList (ctx) {
}
}
async function maritalList (ctx) {
// 获取已有的婚育状况列表
try {
const { models } = ctx.fs.dc;
const mRes = await models.Member.findAll({
attributes: ['marital'],
group: 'marital',
where: {
marital: { $ne: null }
}
})
ctx.status = 200;
ctx.body = mRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function list (ctx) {
try {
const { models } = ctx.fs.dc;
@ -731,4 +755,5 @@ module.exports = {
addMembersBulk,
nativePlaceList,
workPlaceList,
maritalList,
}

3
api/app/lib/routes/member/index.js

@ -18,6 +18,9 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/member/native_place'] = { content: '查询籍贯列表', visible: true };
router.get('/member/native_place', member.nativePlaceList);
app.fs.api.logAttr['GET/member/marital'] = { content: '查询婚育列表', visible: true };
router.get('/member/marital', member.maritalList);
app.fs.api.logAttr['GET/member/work_place'] = { content: '查询工作地列表', visible: true };
router.get('/member/work_place', member.workPlaceList);

2
api/app/lib/utils/member.js

@ -129,7 +129,7 @@ module.exports = function (app, opts) {
${native ? `
AND member.native_place = '${native}'
`: ''}
${native ? `
${workPlace ? `
AND member.work_place = '${workPlace}'
`: ''}
`

Loading…
Cancel
Save