From 719567cf11fce5fac597490ca93acc4403db571f Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Tue, 18 Oct 2022 15:19:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=A9=9A=E8=82=B2=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/member/index.js | 25 +++++++++++++++++++++++++ api/app/lib/routes/member/index.js | 3 +++ api/app/lib/utils/member.js | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/api/app/lib/controllers/member/index.js b/api/app/lib/controllers/member/index.js index 62a7da4..de5d31f 100644 --- a/api/app/lib/controllers/member/index.js +++ b/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, } \ No newline at end of file diff --git a/api/app/lib/routes/member/index.js b/api/app/lib/routes/member/index.js index 4d367d0..9c7bb8a 100644 --- a/api/app/lib/routes/member/index.js +++ b/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); diff --git a/api/app/lib/utils/member.js b/api/app/lib/utils/member.js index 589494b..85d353d 100644 --- a/api/app/lib/utils/member.js +++ b/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}' `: ''} `