diff --git a/api/app/lib/controllers/member/index.js b/api/app/lib/controllers/member/index.js index 749e9f2..09edb9a 100644 --- a/api/app/lib/controllers/member/index.js +++ b/api/app/lib/controllers/member/index.js @@ -198,12 +198,39 @@ async function nativePlaceList (ctx) { const { models } = ctx.fs.dc; const nRes = await models.Member.findAll({ - attributes: [''], - group: '' + attributes: ['nativePlace'], + group: 'nativePlace', + where: { + nativePlace: { $ne: null } + } }) ctx.status = 200; - ctx.body = [] + ctx.body = nRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +async function workPlaceList (ctx) { + // 获取已有的工作地列表 + try { + const { models } = ctx.fs.dc; + + const wRes = await models.Member.findAll({ + attributes: ['workPlace'], + group: 'workPlace', + where: { + workPlace: { $ne: null } + } + }) + + ctx.status = 200; + ctx.body = wRes } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.status = 400; @@ -217,7 +244,10 @@ async function list (ctx) { try { const { models } = ctx.fs.dc; const { judgeHoliday, memberList } = ctx.app.fs.utils - const { keywordTarget, keyword, limit, page, state } = ctx.query + const { + keywordTarget, keyword, limit, page, state, + + } = ctx.query const curDay = moment().format('YYYY-MM-DD') const nowTime = moment() @@ -366,6 +396,10 @@ async function overTimeStatistics (ctx) { INNER JOIN overtime ON overtime.id = overtime_day.overtime_id AND overtime.pep_user_id = ${pepUserId} + ${startDate && endDate ? ` + WHERE overtime_day.day >= '${moment(startDate).format('YYYY-MM-DD')}' + AND overtime_day.day <= '${moment(endDate).format('YYYY-MM-DD')}' + ` : ''} GROUP BY overtime_day.day, overtime.compensate `).toPromise() @@ -436,6 +470,10 @@ async function vacateStatistics (ctx) { INNER JOIN vacate ON vacate.id = vacate_day.vacate_id AND vacate.pep_user_id = ${pepUserId} + ${startDate && endDate ? ` + WHERE vacate_day.day >= '${moment(startDate).format('YYYY-MM-DD')}' + AND vacate_day.day <= '${moment(endDate).format('YYYY-MM-DD')}' + ` : ''} GROUP BY vacate_day.day `).toPromise() @@ -679,5 +717,7 @@ module.exports = { overTimeStatistics, vacateStatistics, exportData, - addMembersBulk + addMembersBulk, + nativePlaceList, + workPlaceList, } \ 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 6bd9b0f..4d367d0 100644 --- a/api/app/lib/routes/member/index.js +++ b/api/app/lib/routes/member/index.js @@ -15,6 +15,12 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/member/search'] = { content: '搜索项企用户', visible: true }; router.get('/member/search', member.searchPepMember); + app.fs.api.logAttr['GET/member/native_place'] = { content: '查询籍贯列表', visible: true }; + router.get('/member/native_place', member.nativePlaceList); + + app.fs.api.logAttr['GET/member/work_place'] = { content: '查询工作地列表', visible: true }; + router.get('/member/work_place', member.workPlaceList); + app.fs.api.logAttr['GET/member/list'] = { content: '查询人员列表', visible: true }; router.get('/member/list', member.list);