Browse Source

(*)删除重复代码+格式化

master
wuqun 2 years ago
parent
commit
82b08d5f64
  1. 36
      api/app/lib/controllers/member/index.js

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

@ -2,7 +2,7 @@
const moment = require('moment') const moment = require('moment')
const fs = require('fs'); const fs = require('fs');
async function add (ctx) { async function add(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { const {
@ -45,7 +45,7 @@ async function add (ctx) {
} }
} }
async function edit (ctx) { async function edit(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { const {
@ -85,7 +85,7 @@ async function edit (ctx) {
} }
} }
async function searchPepMember (ctx) { async function searchPepMember(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
@ -108,7 +108,6 @@ async function searchPepMember (ctx) {
user.name AS userName, user.name AS userName,
role.name AS roleName, role.name AS roleName,
role.id AS roleId, role.id AS roleId,
basicdata_post.name AS userPost,
department.name AS depName, department.name AS depName,
department.id AS depId department.id AS depId
FROM FROM
@ -122,9 +121,7 @@ async function searchPepMember (ctx) {
LEFT JOIN department_user LEFT JOIN department_user
ON department_user.user = user.id ON department_user.user = user.id
LEFT JOIN department LEFT JOIN department
ON department.id = department_user.department ON department.id = department_user.department
LEFT JOIN basicdata_post
ON basicdata_post.id = user.post
WHERE WHERE
user.delete = '0' user.delete = '0'
${whereOption.length ? `AND ${whereOption.join(' OR ')}` : ''} ${whereOption.length ? `AND ${whereOption.join(' OR ')}` : ''}
@ -160,8 +157,7 @@ async function searchPepMember (ctx) {
role: u.roleId ? [{ role: u.roleId ? [{
id: u.roleId, id: u.roleId,
name: u.roleName name: u.roleName
}] : [], }] : []
userPost:u.userPost
}) })
} }
}) })
@ -177,7 +173,7 @@ async function searchPepMember (ctx) {
} }
} }
async function del (ctx) { async function del(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { pepUserId } = ctx.query const { pepUserId } = ctx.query
@ -200,7 +196,7 @@ async function del (ctx) {
} }
} }
async function nativePlaceList (ctx) { async function nativePlaceList(ctx) {
// 获取已有的户籍地列表 // 获取已有的户籍地列表
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
@ -224,7 +220,7 @@ async function nativePlaceList (ctx) {
} }
} }
async function workPlaceList (ctx) { async function workPlaceList(ctx) {
// 获取已有的工作地列表 // 获取已有的工作地列表
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
@ -248,7 +244,7 @@ async function workPlaceList (ctx) {
} }
} }
async function maritalList (ctx) { async function maritalList(ctx) {
// 获取已有的婚育状况列表 // 获取已有的婚育状况列表
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
@ -272,7 +268,7 @@ async function maritalList (ctx) {
} }
} }
async function list (ctx) { async function list(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { judgeHoliday, memberList, packageUserData } = ctx.app.fs.utils const { judgeHoliday, memberList, packageUserData } = ctx.app.fs.utils
@ -307,7 +303,7 @@ async function list (ctx) {
} }
} }
async function overTimeStatistics (ctx) { async function overTimeStatistics(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
@ -383,7 +379,7 @@ async function overTimeStatistics (ctx) {
let returnD = { let returnD = {
...(statisticRes.length ? statisticRes[0] : {}), ...(statisticRes.length ? statisticRes[0] : {}),
data: dataRes, data: dataRes,
dayStatisticData: statisticDayRes.sort((a,b)=>moment(a.day)-moment(b.day)) dayStatisticData: statisticDayRes.sort((a, b) => moment(a.day) - moment(b.day))
} }
ctx.status = 200; ctx.status = 200;
ctx.body = returnD ctx.body = returnD
@ -396,7 +392,7 @@ async function overTimeStatistics (ctx) {
} }
} }
async function vacateStatistics (ctx) { async function vacateStatistics(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
@ -473,7 +469,7 @@ async function vacateStatistics (ctx) {
let returnD = { let returnD = {
statistic: statisticRes, statistic: statisticRes,
data: dataRes, data: dataRes,
dayStatisticData: statisticDayRes.sort((a,b)=>moment(a.day)-moment(b.day)) dayStatisticData: statisticDayRes.sort((a, b) => moment(a.day) - moment(b.day))
} }
ctx.status = 200; ctx.status = 200;
ctx.body = returnD ctx.body = returnD
@ -486,7 +482,7 @@ async function vacateStatistics (ctx) {
} }
} }
async function exportData (ctx) { async function exportData(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse, opts: { qiniu } } = ctx.app.fs const { clickHouse, opts: { qiniu } } = ctx.app.fs
@ -606,7 +602,7 @@ async function exportData (ctx) {
} }
} }
async function addMembersBulk (ctx) { async function addMembersBulk(ctx) {
let errorMsg = { message: '导入员工信息失败' }; let errorMsg = { message: '导入员工信息失败' };
const transaction = await ctx.fs.dc.orm.transaction(); const transaction = await ctx.fs.dc.orm.transaction();
try { try {

Loading…
Cancel
Save