Browse Source

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

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

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

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

Loading…
Cancel
Save