@ -1,49 +1,51 @@ |
|||||
{ |
{ |
||||
// 使用 IntelliSense 了解相关属性。 |
// 使用 IntelliSense 了解相关属性。 |
||||
// 悬停以查看现有属性的描述。 |
// 悬停以查看现有属性的描述。 |
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 |
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 |
||||
"version": "0.2.0", |
"version": "0.2.0", |
||||
"configurations": [ |
"configurations": [ |
||||
{ |
{ |
||||
"type": "node", |
"type": "node", |
||||
"request": "launch", |
"request": "launch", |
||||
"name": "启动 API", |
"name": "启动 API", |
||||
"program": "${workspaceRoot}/server.js", |
"program": "${workspaceRoot}/server.js", |
||||
"env": { |
"env": { |
||||
"NODE_ENV": "development" |
"NODE_ENV": "development" |
||||
}, |
}, |
||||
"args": [ |
"args": [ |
||||
"-p 4900", |
"-p 4900", |
||||
// 研发 |
// 研发 |
||||
"-g postgres://postgres:123456@10.8.30.166:5432/XunJian", |
"-g postgres://postgres:123456@10.8.30.166:5432/XunJian", |
||||
// 测试 |
// 测试 |
||||
// "--apiEmisUrl http://10.8.30.161:1111", |
// "--apiEmisUrl http://10.8.30.161:1111", |
||||
"--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", |
// "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", |
||||
"--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", |
// "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", |
||||
"--qnbkt dev-hr", |
// "--qnbkt dev-hr", |
||||
// "--qndmn http://resources.anxinyun.cn", |
// "--qndmn http://resources.anxinyun.cn", |
||||
"--qndmn http://rjkwed13l.hn-bkt.clouddn.com", |
// "--qndmn http://rjkwed13l.hn-bkt.clouddn.com", |
||||
"--aliOssAccessKey LTAI5tNDfn7UhStYQcn3JBtw", |
// "--aliOssAccessKey LTAI5tNDfn7UhStYQcn3JBtw", |
||||
"--aliOssSecretKey rnoXtDWQA1djJ5Xqcdn1OSEol0lVyv", |
// "--aliOssSecretKey rnoXtDWQA1djJ5Xqcdn1OSEol0lVyv", |
||||
"--aliOssBucket test-c371", |
// "--aliOssBucket test-c371", |
||||
"--aliOssRegion oss-cn-hangzhou", |
// "--aliOssRegion oss-cn-hangzhou", |
||||
] |
"--apiAnxinyunUrl https://openapi.anxinyun.cn/api/v1", |
||||
}, |
"--axyProject 1a271f12-52f2-4d16-8dad-ec0c92d3e0cc/03bzzdh/123456", |
||||
{ |
] |
||||
"type": "node", |
}, |
||||
"request": "launch", |
{ |
||||
"name": "run mocha", |
"type": "node", |
||||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", |
"request": "launch", |
||||
"stopOnEntry": false, |
"name": "run mocha", |
||||
"args": [ |
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", |
||||
"app/test/*.test.js", |
"stopOnEntry": false, |
||||
"--no-timeouts" |
"args": [ |
||||
], |
"app/test/*.test.js", |
||||
"cwd": "${workspaceRoot}", |
"--no-timeouts" |
||||
"runtimeExecutable": null, |
], |
||||
"env": { |
"cwd": "${workspaceRoot}", |
||||
"NODE_ENV": "development" |
"runtimeExecutable": null, |
||||
} |
"env": { |
||||
} |
"NODE_ENV": "development" |
||||
] |
} |
||||
|
} |
||||
|
] |
||||
} |
} |
@ -0,0 +1,67 @@ |
|||||
|
'use strict'; |
||||
|
const Hex = require('crypto-js/enc-hex'); |
||||
|
const MD5 = require('crypto-js/md5'); |
||||
|
const moment = require('moment'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
let axyTokenCache = { |
||||
|
token: null, |
||||
|
orgId: null, |
||||
|
expireTime: null //过期时间
|
||||
|
} |
||||
|
|
||||
|
const getAnxinyunToken = async function (ctx) { |
||||
|
try { |
||||
|
|
||||
|
if (!axyTokenCache.token || moment() > moment(axyTokenCache.expireTime)) { |
||||
|
if (ctx.app.fs.opts.axyProject.split('/').length === 3) { |
||||
|
const dataToAxy = { |
||||
|
p: ctx.app.fs.opts.axyProject.split('/')[0], |
||||
|
username: ctx.app.fs.opts.axyProject.split('/')[1], |
||||
|
password: ctx.app.fs.opts.axyProject.split('/')[2], |
||||
|
} |
||||
|
const axyResponse = await ctx.app.fs.anxinyun.post('project/login', { data: dataToAxy }) |
||||
|
if (axyResponse.authorized) { |
||||
|
axyTokenCache.token = axyResponse.token //放进缓存
|
||||
|
axyTokenCache.orgId = axyResponse.orgId //放进缓存
|
||||
|
axyTokenCache.expireTime = moment().add(20, 'hour').format('YYYY-MM-DD HH:mm:ss') |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return axyTokenCache |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`sechedule: laborAttendance, error: ${error}`); |
||||
|
} |
||||
|
} |
||||
|
async function axyData (ctx, next) { |
||||
|
|
||||
|
try { |
||||
|
let { type, url, params = {} } = ctx.request.body; |
||||
|
let data = await getAnxinyunToken(ctx) |
||||
|
if (url && url.indexOf('{orgId}') != -1) { |
||||
|
url = url.replace(`{orgId}`, data.orgId) |
||||
|
} |
||||
|
|
||||
|
const res = await ctx.app.fs.anxinyun[type](`${url}?token=${data.token}`, { data: params.data || {}, query: params.query || {} }) |
||||
|
ctx.status = 200; |
||||
|
ctx.body = res; |
||||
|
} catch (err) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { name: 'FindError', message: '获取安心云数据失败' }; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
module.exports = { |
||||
|
axyData, |
||||
|
} |
@ -1,87 +0,0 @@ |
|||||
async function getResource(ctx, next) { |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
|
|
||||
const res = await models.Resource.findAll({ |
|
||||
where: { parentResource: null }, |
|
||||
include: [{ |
|
||||
model: models.Resource, |
|
||||
}] |
|
||||
}) |
|
||||
|
|
||||
ctx.body = res; |
|
||||
ctx.status = 200; |
|
||||
|
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "查询所有权限数据失败" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
async function getUserResource(ctx, next) { |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { userId } = ctx.query; |
|
||||
|
|
||||
const res = await models.UserResource.findAll({ |
|
||||
where: { userId: userId }, |
|
||||
include: [{ |
|
||||
model: models.Resource, |
|
||||
}] |
|
||||
}) |
|
||||
|
|
||||
ctx.body = res; |
|
||||
ctx.status = 200; |
|
||||
|
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "查询用户权限数据失败" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function updateUserRes(ctx, next) { |
|
||||
const transaction = await ctx.fs.dc.orm.transaction(); |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { userId, resCode } = ctx.request.body; |
|
||||
|
|
||||
const res = await models.UserResource.findAll({ |
|
||||
attributes: ["resourceId"], |
|
||||
raw: true, |
|
||||
where: { userId: userId } |
|
||||
}) |
|
||||
|
|
||||
const addRes = resCode.filter(r => !res.some(rr => rr.resourceId == r)).map(r => { return { userId: userId, resourceId: r } }); |
|
||||
const delRes = res.filter(r => !resCode.includes(r.resourceId)).map(r => r.resourceId); |
|
||||
addRes.length && await models.UserResource.bulkCreate(addRes, { transaction: transaction }); |
|
||||
delRes.length && await models.UserResource.destroy({ |
|
||||
where: { |
|
||||
resourceId: { $in: delRes }, |
|
||||
userId: userId |
|
||||
}, |
|
||||
transaction: transaction |
|
||||
}) |
|
||||
|
|
||||
ctx.status = 204; |
|
||||
await transaction.commit(); |
|
||||
|
|
||||
} catch (error) { |
|
||||
await transaction.rollback(); |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "更新用户权限数据失败" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
module.exports = { |
|
||||
getResource, |
|
||||
getUserResource, |
|
||||
updateUserRes |
|
||||
}; |
|
@ -1,389 +0,0 @@ |
|||||
'use strict'; |
|
||||
const Hex = require('crypto-js/enc-hex'); |
|
||||
const MD5 = require('crypto-js/md5'); |
|
||||
|
|
||||
// async function getDepMessage (ctx, next) {
|
|
||||
// try {
|
|
||||
// const { fs: { api: { userInfo } } } = ctx
|
|
||||
// const models = ctx.fs.dc.models;
|
|
||||
|
|
||||
// let deptWhere = {}
|
|
||||
// if (userInfo.username !== 'SuperAdmin') {
|
|
||||
// deptWhere.id = userInfo.departmentId
|
|
||||
// }
|
|
||||
// let depType1 = await models.Department.findAll({
|
|
||||
// order: [['id', 'asc']],
|
|
||||
// // include: [{
|
|
||||
// // model: models.User,
|
|
||||
// // required: false,
|
|
||||
// // where: { delete: false },
|
|
||||
// // attributes: { exclude: ['password'] },
|
|
||||
// // }],
|
|
||||
// where: deptWhere,
|
|
||||
// })
|
|
||||
|
|
||||
// let depRslt = []
|
|
||||
// const getDep = async (d) => {
|
|
||||
// let subordinate = []
|
|
||||
// let depRes = await models.Department.findAll({
|
|
||||
// order: [['id', 'asc']],
|
|
||||
// // include: [{
|
|
||||
// // model: models.User,
|
|
||||
// // required: false,
|
|
||||
// // where: { delete: false },
|
|
||||
// // attributes: { exclude: ['password'] },
|
|
||||
// // }],
|
|
||||
// where: {
|
|
||||
// dependence: d.id
|
|
||||
// },
|
|
||||
// })
|
|
||||
// if (depRes.length)
|
|
||||
// for (let d of depRes) {
|
|
||||
// let dep = d.dataValues
|
|
||||
// dep.subordinate = await getDep(d.dataValues)
|
|
||||
// subordinate.push(dep)
|
|
||||
// }
|
|
||||
// return subordinate
|
|
||||
// }
|
|
||||
// for (let d of depType1) {
|
|
||||
// let dep_1 = d.dataValues
|
|
||||
// dep_1.subordinate = await getDep(d.dataValues)
|
|
||||
// depRslt.push(dep_1)
|
|
||||
// }
|
|
||||
|
|
||||
// ctx.status = 200;
|
|
||||
// ctx.body = depRslt
|
|
||||
// } catch (error) {
|
|
||||
// ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
|
|
||||
// ctx.status = 400;
|
|
||||
// ctx.body = {
|
|
||||
// "message": "获取部门信息失败"
|
|
||||
// }
|
|
||||
// }
|
|
||||
// }
|
|
||||
|
|
||||
async function getDepMessage(ctx, next) { |
|
||||
let error = { name: 'FindError', message: '获取部门列表失败' }; |
|
||||
let rslt = []; |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
let list = await models.Department.findAll({}); |
|
||||
|
|
||||
let deptMap = [] |
|
||||
list.filter(l => !l.dependence).map(ld => {//一级
|
|
||||
deptMap.push({ |
|
||||
id: ld.id, |
|
||||
name: ld.name, |
|
||||
dependence: ld.dependence, |
|
||||
subordinate: [] |
|
||||
}) |
|
||||
}) |
|
||||
|
|
||||
list.filter(l => l.dependence).map(ld => {//二级
|
|
||||
let parent = deptMap.find(dm => dm.id == ld.dependence); |
|
||||
if (parent) { |
|
||||
parent.subordinate.push({ |
|
||||
id: ld.id, |
|
||||
name: ld.name, |
|
||||
dependence: ld.dependence, |
|
||||
subordinate: [] |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
rslt = deptMap; |
|
||||
|
|
||||
error = null; |
|
||||
} catch (err) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`); |
|
||||
} |
|
||||
if (error) { |
|
||||
ctx.status = 400; |
|
||||
ctx.body = error; |
|
||||
} else { |
|
||||
ctx.status = 200; |
|
||||
ctx.body = rslt; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function createDept(ctx, next) { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
try { |
|
||||
let rslt = ctx.request.body; |
|
||||
await models.Department.create(Object.assign({}, rslt, { read: 1 })) |
|
||||
ctx.status = 204; |
|
||||
ctx.body = { message: '新建部门成功' } |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { message: '新建部门失败' } |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function updateDept(ctx, next) { |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { id } = ctx.params; |
|
||||
const body = ctx.request.body; |
|
||||
await models.Department.update( |
|
||||
body, |
|
||||
{ where: { id: id } } |
|
||||
) |
|
||||
ctx.status = 204; |
|
||||
ctx.body = { message: '修改部门成功' } |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { message: '修改部门失败' } |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function delDept(ctx, next) { |
|
||||
let errMsg = "删除部门失败"; |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { id } = ctx.params; |
|
||||
let list = await models.Department.findAll({}); |
|
||||
let deptIds = list.map(l => l.id); |
|
||||
const allUsers = await models.User.findAll({ |
|
||||
where: { |
|
||||
departmentId: { $in: deptIds }, |
|
||||
delete: false |
|
||||
} |
|
||||
}) |
|
||||
const childrenDept = await models.Department.findAll({ where: { dependence: id } }) |
|
||||
const childrenUser = allUsers.filter(au => au.departmentId == id); |
|
||||
if (childrenUser.length || childrenDept.length) { |
|
||||
errMsg = '请先删除部门下的用户或子部门'; |
|
||||
throw errMsg; |
|
||||
} |
|
||||
await models.Department.destroy({ where: { id: id } }); |
|
||||
await models.Department.destroy({ where: { dependence: id } }); |
|
||||
ctx.status = 204; |
|
||||
ctx.body = { message: '删除部门成功' } |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { message: error } |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function getUser(ctx, next) { |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { depId } = ctx.params; |
|
||||
let userRes = null; |
|
||||
if (depId !== 'null') { |
|
||||
userRes = await models.User.findAll({ |
|
||||
where: { |
|
||||
departmentId: parseInt(depId), |
|
||||
delete: false |
|
||||
}, |
|
||||
attributes: { exclude: ['password'] }, |
|
||||
order: [['id', 'asc']], |
|
||||
}) |
|
||||
} else { |
|
||||
userRes = await models.User.findAll({ |
|
||||
where: { |
|
||||
delete: false |
|
||||
}, |
|
||||
attributes: { exclude: ['password'] }, |
|
||||
order: [['id', 'asc']], |
|
||||
include: [{ |
|
||||
required: true, |
|
||||
model: models.Department, |
|
||||
attributes: ['id', 'name'], |
|
||||
}] |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
ctx.status = 200; |
|
||||
ctx.body = userRes |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "获取用户信息失败" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function creatUser(ctx, next) { |
|
||||
let errMsg = "新建用户失败" |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const data = ctx.request.body; |
|
||||
|
|
||||
let repeatUserNameCount = await models.User.count({ |
|
||||
where: { |
|
||||
username: data.phone, |
|
||||
delete: false |
|
||||
} |
|
||||
}) |
|
||||
|
|
||||
if (repeatUserNameCount) { |
|
||||
errMsg = '已有当前用户名' |
|
||||
throw errMsg |
|
||||
} |
|
||||
|
|
||||
await models.User.create({ |
|
||||
name: data.name, |
|
||||
username: data.phone, |
|
||||
password: Hex.stringify(MD5(data.password)), |
|
||||
departmentId: data.departmentId, |
|
||||
email: data.email, |
|
||||
enable: data.enable, |
|
||||
delete: false, |
|
||||
phone: data.phone, |
|
||||
post: data.post, |
|
||||
}) |
|
||||
|
|
||||
ctx.status = 204; |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": errMsg |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
async function updateUser(ctx, next) { |
|
||||
let errMsg = "修改用户失败" |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const data = ctx.request.body; |
|
||||
const { id } = ctx.params; |
|
||||
|
|
||||
let repeatUserNameCount = await models.User.count({ |
|
||||
where: { |
|
||||
username: data.username |
|
||||
} |
|
||||
}) |
|
||||
|
|
||||
if (repeatUserNameCount) { |
|
||||
errMsg = '已有当前用户名' |
|
||||
throw errMsg |
|
||||
} |
|
||||
|
|
||||
await models.User.update({ |
|
||||
name: data.name, |
|
||||
username: data.phone, |
|
||||
departmentId: data.departmentId, |
|
||||
email: data.email, |
|
||||
enable: data.enable, |
|
||||
delete: false, |
|
||||
phone: data.phone, |
|
||||
post: data.post, |
|
||||
}, { |
|
||||
where: { |
|
||||
id: id |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
ctx.status = 204; |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": errMsg |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function deleteUser(ctx, next) { |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { ids } = ctx.params; |
|
||||
const userIds = ids.split(','); |
|
||||
await models.User.update({ |
|
||||
delete: true, |
|
||||
}, { |
|
||||
where: { |
|
||||
id: { $in: userIds }, |
|
||||
} |
|
||||
}); |
|
||||
ctx.status = 204; |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "删除用户失败" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
async function resetPwd(ctx, next) { |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { id } = ctx.params; |
|
||||
const data = ctx.request.body; |
|
||||
await models.User.update({ |
|
||||
password: Hex.stringify(MD5(data.password)), |
|
||||
}, { |
|
||||
where: { |
|
||||
id: id, |
|
||||
} |
|
||||
}); |
|
||||
ctx.status = 204; |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "重置用户密码失败" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 修改用户密码 |
|
||||
* @params {userId-用户Id} ctx |
|
||||
* @request.body {password-用户新密码} ctx |
|
||||
*/ |
|
||||
async function updateUserPassword(ctx, next) { |
|
||||
try { |
|
||||
const models = ctx.fs.dc.models; |
|
||||
const { userId } = ctx.params; |
|
||||
const { password } = ctx.request.body; |
|
||||
if (!password) { |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { "message": "请输入修改密码" }; |
|
||||
return; |
|
||||
} |
|
||||
const userRes = await models.User.findOne({ |
|
||||
where: { |
|
||||
id: userId |
|
||||
}, |
|
||||
attributes: ['id'] |
|
||||
}); |
|
||||
if (userRes) { |
|
||||
await models.User.update({ password: Hex.stringify(MD5(password)) }, { where: { id: userId, } }); |
|
||||
ctx.status = 204; |
|
||||
} else { |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "用户不存在" |
|
||||
} |
|
||||
} |
|
||||
} catch (error) { |
|
||||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
||||
ctx.status = 400; |
|
||||
ctx.body = { |
|
||||
"message": "修改用户密码失败" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
module.exports = { |
|
||||
getDepMessage, |
|
||||
createDept, |
|
||||
updateDept, |
|
||||
delDept, |
|
||||
getUser, |
|
||||
creatUser, |
|
||||
updateUser, |
|
||||
deleteUser, |
|
||||
resetPwd, |
|
||||
updateUserPassword |
|
||||
} |
|
@ -1,28 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
const Authority = require('../../controllers/organization/authority'); |
|
||||
|
|
||||
module.exports = function (app, router, opts) { |
|
||||
/** |
|
||||
* @api {GET} resource 查询所有权限码. |
|
||||
* @apiVersion 1.0.0 |
|
||||
* @apiGroup Org |
|
||||
*/ |
|
||||
app.fs.api.logAttr['GET/resource'] = { content: '查询所有权限码', visible: true }; |
|
||||
router.get('resource', Authority.getResource); |
|
||||
/** |
|
||||
* @api {GET} user/resource 查询用户权限. |
|
||||
* @apiVersion 1.0.0 |
|
||||
* @apiGroup Org |
|
||||
*/ |
|
||||
app.fs.api.logAttr['GET/user/resource'] = { content: '查询用户权限', visible: true }; |
|
||||
router.get('user/resource', Authority.getUserResource); |
|
||||
|
|
||||
/** |
|
||||
* @api {POST} user/resource 更新用户权限. |
|
||||
* @apiVersion 1.0.0 |
|
||||
* @apiGroup Org |
|
||||
*/ |
|
||||
app.fs.api.logAttr['POST/user/resource'] = { content: '更新用户权限', visible: true }; |
|
||||
router.post('user/resource', Authority.updateUserRes); |
|
||||
}; |
|
@ -0,0 +1,9 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const data = require('../../controllers/bigScreen/index '); |
||||
|
|
||||
|
module.exports = function (app, router, opts) { |
||||
|
|
||||
|
app.fs.api.logAttr['POST/axyData'] = { content: '获取安心云数据', visible: true }; |
||||
|
router.post('/axyData', data.axyData); |
||||
|
}; |
@ -1,41 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
const user = require('../../controllers/organization/user'); |
|
||||
|
|
||||
module.exports = function (app, router, opts) { |
|
||||
|
|
||||
app.fs.api.logAttr['GET/organization/department'] = { content: '获取部门信息', visible: false }; |
|
||||
router.get('/organization/department', user.getDepMessage); |
|
||||
|
|
||||
app.fs.api.logAttr['POST/organization/dept/add'] = { content: '新增部门', visible: true }; |
|
||||
router.post('/organization/dept/add', user.createDept); |
|
||||
|
|
||||
app.fs.api.logAttr['PUT/organization/dept/:id/modify'] = { content: '修改部门', visible: true }; |
|
||||
router.put('/organization/dept/:id/modify', user.updateDept); |
|
||||
|
|
||||
app.fs.api.logAttr['DELETE/organization/dept/:id'] = { content: '删除部门', visible: true }; |
|
||||
router.del('/organization/dept/:id', user.delDept); |
|
||||
|
|
||||
app.fs.api.logAttr['GET/organization/department/:depId/user'] = { content: '获取部门下用户信息', visible: false }; |
|
||||
router.get('/organization/department/:depId/user', user.getUser); |
|
||||
|
|
||||
app.fs.api.logAttr['POST/organization/department/user'] = { content: '创建部门下用户信息', visible: false }; |
|
||||
router.post('/organization/department/user', user.creatUser); |
|
||||
|
|
||||
app.fs.api.logAttr['PUT/organization/department/user/:id'] = { content: '修改部门下用户信息', visible: false }; |
|
||||
router.put('/organization/department/user/:id', user.updateUser); |
|
||||
|
|
||||
app.fs.api.logAttr['DEL/organization/department/user/:ids'] = { content: '删除部门下用户信息', visible: false }; |
|
||||
router.del('/organization/department/user/:ids', user.deleteUser); |
|
||||
|
|
||||
app.fs.api.logAttr['PUT/organization/department/user/resetPwd/:id'] = { content: '重置用户密码', visible: false }; |
|
||||
router.put('/organization/department/user/resetPwd/:id', user.resetPwd); |
|
||||
|
|
||||
/** |
|
||||
* @api {PUT} user/password/:id 修改用户密码 |
|
||||
* @apiVersion 1.0.0 |
|
||||
* @apiGroup Organization |
|
||||
*/ |
|
||||
app.fs.api.logAttr['PUT/user/password/:userId'] = { content: '修改用户密码', visible: false }; |
|
||||
router.put('/user/password/:userId', user.updateUserPassword); |
|
||||
}; |
|
@ -1,53 +0,0 @@ |
|||||
const moment = require('moment') |
|
||||
const rimraf = require('rimraf'); |
|
||||
const fs = require("fs"); |
|
||||
const path = require("path") |
|
||||
|
|
||||
let TEST = false |
|
||||
// TEST = true
|
|
||||
|
|
||||
module.exports = function (app, opts) { |
|
||||
const clearExpiredData = app.fs.scheduleInit( |
|
||||
{ |
|
||||
interval: '42 24 4 */3 * *', |
|
||||
immediate: TEST, |
|
||||
proRun: !TEST, |
|
||||
}, |
|
||||
async () => { |
|
||||
try { |
|
||||
const { models } = app.fs.dc |
|
||||
const now = moment().format('YYYY-MM-DD HH:mm:ss') |
|
||||
await models.UserToken.destroy({ |
|
||||
where: { |
|
||||
expired: { $lt: now } |
|
||||
} |
|
||||
}) |
|
||||
await models.PhoneValidateCode.destroy({ |
|
||||
where: { |
|
||||
expired: { $lt: now } |
|
||||
} |
|
||||
}) |
|
||||
fs.readdir(path.join(__dirname, `../../downloadFiles`), function (err, files) { |
|
||||
if (err) { |
|
||||
return; |
|
||||
} |
|
||||
files.forEach((file) => { |
|
||||
fs.stat(path.join(__dirname, `../../downloadFiles/${file}`), (err, stats) => { |
|
||||
if (err) { |
|
||||
//return;
|
|
||||
} else { |
|
||||
rimraf.sync(path.join(__dirname, `../../downloadFiles/${file}`)); |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
}); |
|
||||
} catch (error) { |
|
||||
app.fs.logger.error(`sechedule: clearExpiredToken, error: ${error}`); |
|
||||
} |
|
||||
} |
|
||||
); |
|
||||
|
|
||||
return { |
|
||||
clearExpiredData |
|
||||
} |
|
||||
} |
|
@ -1,208 +0,0 @@ |
|||||
const fs = require('fs'); |
|
||||
const moment = require('moment') |
|
||||
const path = require('path') |
|
||||
const OSS = require('ali-oss'); |
|
||||
const uuid = require('uuid'); |
|
||||
|
|
||||
const TEST = false |
|
||||
// const TEST = true
|
|
||||
|
|
||||
module.exports = function (app, opts) { |
|
||||
const hideDangerStatistic = app.fs.scheduleInit( |
|
||||
// 按月、季度、年统计隐患整改
|
|
||||
{ |
|
||||
interval: '0 32 4 1 */1 *', |
|
||||
immediate: TEST, |
|
||||
proRun: !TEST, |
|
||||
}, |
|
||||
async () => { |
|
||||
const { aliOss } = opts |
|
||||
const { utils: { simpleExcelDown } } = app.fs; |
|
||||
|
|
||||
try { |
|
||||
const { models } = app.fs.dc |
|
||||
const today = moment() |
|
||||
const date = today.date() |
|
||||
const month = today.month() + 1 |
|
||||
const quarter = today.quarter() |
|
||||
const year = today.year() |
|
||||
|
|
||||
const client = new OSS({ |
|
||||
// yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
|
|
||||
region: aliOss.region, |
|
||||
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
|
|
||||
accessKeyId: aliOss.accessKey, |
|
||||
accessKeySecret: aliOss.secretKey, |
|
||||
// 填写Bucket名称,例如examplebucket。
|
|
||||
bucket: aliOss.bucket, |
|
||||
}); |
|
||||
|
|
||||
|
|
||||
const statistic = async (startTime, endTime, type, timeShow, typeEnglish, time) => { |
|
||||
const siteRectifyRes = await models.HideDangerRectifySites.findAll({ |
|
||||
where: {}, |
|
||||
distinct: true, |
|
||||
include: [{ |
|
||||
model: models.Site, |
|
||||
attributes: ['id', 'name'], |
|
||||
}, { |
|
||||
model: models.HideDangerDispose, |
|
||||
order: [['id', 'ASC']], |
|
||||
// include: [{
|
|
||||
// model: models.User,
|
|
||||
// attributes: ['id', 'displayName'],
|
|
||||
// }]
|
|
||||
}, { |
|
||||
model: models.HideDangerRectify, |
|
||||
where: { |
|
||||
createTime: { |
|
||||
$between: [ |
|
||||
startTime.format('YYYY-MM-DD HH:mm:ss'), |
|
||||
endTime.format('YYYY-MM-DD HH:mm:ss') |
|
||||
] |
|
||||
} |
|
||||
}, |
|
||||
},] |
|
||||
}) |
|
||||
|
|
||||
let reportHeader = [{ |
|
||||
title: "工程项目名称", |
|
||||
key: "siteName", |
|
||||
}, { |
|
||||
title: "整改任务名称", |
|
||||
key: "name", |
|
||||
}, { |
|
||||
title: "提交时间", |
|
||||
key: "submitTime", |
|
||||
}, { |
|
||||
title: "审批状态", |
|
||||
key: "state", |
|
||||
},] |
|
||||
let reportData = [] |
|
||||
|
|
||||
let siteMap = new Set() |
|
||||
let completedRectifyCount = 0 |
|
||||
let uncompletedRectifyCount = 0 |
|
||||
for (let s of siteRectifyRes) { |
|
||||
siteMap.add(s.siteId); |
|
||||
|
|
||||
let sts = s.status |
|
||||
let stsChinese = '' |
|
||||
if (sts == 0) { |
|
||||
stsChinese = '待整改' |
|
||||
} else if (sts == 1) { |
|
||||
stsChinese = '待审批' |
|
||||
} else if (sts == 2) { |
|
||||
stsChinese = '待复审' |
|
||||
} else if (sts == 3 || sts == 4) { |
|
||||
stsChinese = '审批驳回' |
|
||||
} else if (sts == 5) { |
|
||||
stsChinese = '审批通过' |
|
||||
} |
|
||||
|
|
||||
if ( |
|
||||
s.hideDangerDisposes.length |
|
||||
&& s.hideDangerDisposes.some(sd => sd.type == 3 && sd.admit) |
|
||||
) { |
|
||||
completedRectifyCount++ |
|
||||
} else { |
|
||||
uncompletedRectifyCount++ |
|
||||
} |
|
||||
|
|
||||
reportData.push({ |
|
||||
siteName: s.dataValues.site.dataValues.name, |
|
||||
name: s.dataValues.hideDangerRectify.dataValues.name, |
|
||||
submitTime: s.dataValues.lastDisposeTime ? moment(s.dataValues.lastDisposeTime).format('YYYY-MM-DD HH:mm:ss') : '', |
|
||||
state: stsChinese |
|
||||
}) |
|
||||
} |
|
||||
const fileName = `中鼎国际隐患整改数据报表-${type}-${timeShow}` + '.xlsx' |
|
||||
const filePath = await simpleExcelDown({ |
|
||||
data: reportData, header: reportHeader, fileName |
|
||||
}) |
|
||||
// const fileData = fs.readFileSync(filePath);
|
|
||||
|
|
||||
// 保存文件到云
|
|
||||
|
|
||||
let uploadPath = path.posix.join('hideDangerReport', uuid.v4(), fileName); |
|
||||
let uploadResult = await client.put( |
|
||||
uploadPath, |
|
||||
filePath, |
|
||||
// { contentLength: size }
|
|
||||
); |
|
||||
//保存信息到数据库
|
|
||||
const existReportRes = await models.HideDangerReport.findOne({ |
|
||||
where: { |
|
||||
type: typeEnglish, |
|
||||
time: String(time), |
|
||||
} |
|
||||
}) |
|
||||
const storageData = { |
|
||||
siteCount: siteMap.size, |
|
||||
rectifyCount: completedRectifyCount + uncompletedRectifyCount, |
|
||||
completedRectifyCount, |
|
||||
uncompletedRectifyCount, |
|
||||
report: uploadResult.name, |
|
||||
type: typeEnglish, |
|
||||
time: String(time), |
|
||||
} |
|
||||
if (existReportRes) { |
|
||||
await models.HideDangerReport.update(storageData, { |
|
||||
where: { |
|
||||
id: existReportRes.id |
|
||||
} |
|
||||
}) |
|
||||
} else { |
|
||||
await models.HideDangerReport.create(storageData) |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
|
|
||||
if (month == 1) { |
|
||||
// 统计一下上一年
|
|
||||
let startTime = today.clone().subtract(1, 'year').startOf('year') |
|
||||
let endTime = today.clone().subtract(1, 'year').endOf('year') |
|
||||
await statistic( |
|
||||
startTime, |
|
||||
endTime, |
|
||||
'年报', |
|
||||
`${startTime.year()}${startTime.month() + 1}-${endTime.month() + 1}`, |
|
||||
'year', |
|
||||
startTime.year() |
|
||||
) |
|
||||
} |
|
||||
if ([1, 4, 7, 10].includes(month)) { |
|
||||
// 统计一下上季度
|
|
||||
let startTime = today.clone().subtract(3, 'month').startOf('month') |
|
||||
let endTime = today.clone().subtract(1, 'month').endOf('month') |
|
||||
await statistic( |
|
||||
startTime, |
|
||||
endTime, |
|
||||
'季报', |
|
||||
`${startTime.year()}${startTime.month() + 1}-${endTime.month() + 1}`, |
|
||||
'quarter', |
|
||||
`${startTime.year()}-${month == 1 ? 'Q4' : month == 4 ? 'Q1' : month == 7 ? 'Q2' : 'Q3'}` |
|
||||
) |
|
||||
} |
|
||||
// 统计一下上个月
|
|
||||
let startTime = today.clone().subtract(1, 'month').startOf('month') |
|
||||
let endTime = today.clone().subtract(1, 'month').endOf('month') |
|
||||
await statistic( |
|
||||
startTime, |
|
||||
endTime, |
|
||||
'月报', |
|
||||
`${startTime.year()}${startTime.month() + 1}`, |
|
||||
'month', |
|
||||
startTime.format('YYYY-MM') |
|
||||
) |
|
||||
|
|
||||
} catch (error) { |
|
||||
app.fs.logger.error(`sechedule: hideDangerStatistic, error: ${error}`); |
|
||||
} |
|
||||
} |
|
||||
); |
|
||||
|
|
||||
return { |
|
||||
hideDangerStatistic |
|
||||
} |
|
||||
} |
|
@ -1,64 +0,0 @@ |
|||||
const moment = require('moment') |
|
||||
|
|
||||
const TEST = false |
|
||||
// const TEST = true
|
|
||||
|
|
||||
module.exports = function (app, opts) { |
|
||||
const mettingGenerate = app.fs.scheduleInit( |
|
||||
{ |
|
||||
interval: '0 0 0 */1 * *', |
|
||||
immediate: TEST, |
|
||||
proRun: !TEST, |
|
||||
}, |
|
||||
async () => { |
|
||||
try { |
|
||||
const { models } = app.fs.dc |
|
||||
const today = moment() |
|
||||
const date = today.date() |
|
||||
const dateFormat = moment().format('YYYY-MM-DD') |
|
||||
let sites = await models.Site.findAll({ |
|
||||
where: { del: false }, |
|
||||
attributes: ['id', 'name'] |
|
||||
}); |
|
||||
let datasM = [], datasB = [], datasD = [], datas6 = [] |
|
||||
sites.map(s => { |
|
||||
datasM.push({ |
|
||||
siteId: s.id, |
|
||||
type: '月度安全例会', |
|
||||
date: dateFormat |
|
||||
}); |
|
||||
datasB.push({ |
|
||||
siteId: s.id, |
|
||||
type: '班前会', |
|
||||
date: dateFormat |
|
||||
}); |
|
||||
datasD.push({ |
|
||||
siteId: s.id, |
|
||||
type: '日调度会', |
|
||||
date: dateFormat |
|
||||
}); |
|
||||
datas6.push({ |
|
||||
siteId: s.id, |
|
||||
type: '逢六教育培训', |
|
||||
date: dateFormat |
|
||||
}) |
|
||||
}) |
|
||||
if (date == 1) { |
|
||||
await models.Metting.bulkCreate(datasM) |
|
||||
} |
|
||||
await models.Metting.bulkCreate(datasB) |
|
||||
await models.Metting.bulkCreate(datasD) |
|
||||
if (parseInt(date) % 10 == 6) { |
|
||||
await models.Metting.bulkCreate(datas6) |
|
||||
} |
|
||||
|
|
||||
} catch (error) { |
|
||||
app.fs.logger.error(`sechedule: mettingGenerate, error: ${error}`); |
|
||||
} |
|
||||
} |
|
||||
); |
|
||||
|
|
||||
return { |
|
||||
mettingGenerate |
|
||||
} |
|
||||
} |
|
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 2.2 MiB |
Before Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 2.9 MiB |
After Width: | Height: | Size: 192 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 297 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 38 KiB |
@ -1,52 +1,61 @@ |
|||||
'use strict'; |
'use strict'; |
||||
import Immutable from 'immutable'; |
import Immutable from 'immutable'; |
||||
import { INIT_LAYOUT, RESIZE } from '../actions/global'; |
import { INIT_LAYOUT, RESIZE,INIT_API_ROOT } from '../actions/global'; |
||||
import { SET_GLOBAL_SITE_LIST, CLEAR_GLOBAL_SITE_LIST } from '../actions/site' |
import { SET_GLOBAL_SITE_LIST, CLEAR_GLOBAL_SITE_LIST } from '../actions/site' |
||||
function global(state = { |
function global (state = { |
||||
title: '', |
title: '', |
||||
copyright: '', |
copyright: '', |
||||
sections: [], |
sections: [], |
||||
actions: {}, |
actions: {}, |
||||
plugins: {}, |
plugins: {}, |
||||
clientHeight: 768, |
clientHeight: 768, |
||||
clientWidth: 1024, |
clientWidth: 1024, |
||||
sites: [] |
sites: [], |
||||
|
axyApi: '', |
||||
|
axyProject: '' |
||||
}, action) { |
}, action) { |
||||
const payload = action.payload; |
const payload = action.payload; |
||||
switch (action.type) { |
switch (action.type) { |
||||
case RESIZE: |
case RESIZE: |
||||
return Immutable.fromJS(state).merge({ |
return Immutable.fromJS(state).merge({ |
||||
clientHeight: payload.clientHeight, |
clientHeight: payload.clientHeight, |
||||
clientWidth: payload.clientWidth |
clientWidth: payload.clientWidth |
||||
}).toJS(); |
}).toJS(); |
||||
case INIT_LAYOUT: |
case INIT_LAYOUT: |
||||
return { |
return { |
||||
title: payload.title, |
title: payload.title, |
||||
copyright: payload.copyright, |
copyright: payload.copyright, |
||||
sections: payload.sections, |
sections: payload.sections, |
||||
actions: payload.actions, |
actions: payload.actions, |
||||
plugins: payload.plugins, |
plugins: payload.plugins, |
||||
clientHeight: state.clientHeight, |
clientHeight: state.clientHeight, |
||||
detailsComponent: null, |
detailsComponent: null, |
||||
sites: [] |
sites: [], |
||||
}; |
axyApi: payload.axyApi, |
||||
// case INIT_RESOURCE_ROOT:
|
axyProject: payload.axyProject, |
||||
// return Immutable.fromJS(state).merge(payload).toJS();
|
}; |
||||
// case INIT_PAGE_HEADER_DETAILS:
|
case INIT_API_ROOT: |
||||
// return Immutable.fromJS(state).merge({
|
return Immutable.fromJS(state).merge({ |
||||
// detailsComponent: payload.component
|
axyApi: payload.axyApi, |
||||
// }).toJS();
|
axyProject: payload.axyProject, |
||||
case SET_GLOBAL_SITE_LIST: |
}).toJS(); |
||||
return Immutable.fromJS(state).merge({ |
// case INIT_RESOURCE_ROOT:
|
||||
sites: payload.data |
// return Immutable.fromJS(state).merge(payload).toJS();
|
||||
}).toJS(); |
// case INIT_PAGE_HEADER_DETAILS:
|
||||
case CLEAR_GLOBAL_SITE_LIST: |
// return Immutable.fromJS(state).merge({
|
||||
return Immutable.fromJS(state).merge({ |
// detailsComponent: payload.component
|
||||
sites: [] |
// }).toJS();
|
||||
}).toJS(); |
case SET_GLOBAL_SITE_LIST: |
||||
default: |
return Immutable.fromJS(state).merge({ |
||||
return state; |
sites: payload.data |
||||
} |
}).toJS(); |
||||
|
case CLEAR_GLOBAL_SITE_LIST: |
||||
|
return Immutable.fromJS(state).merge({ |
||||
|
sites: [] |
||||
|
}).toJS(); |
||||
|
default: |
||||
|
return state; |
||||
|
} |
||||
} |
} |
||||
|
|
||||
export default global; |
export default global; |
@ -1,62 +1,66 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
import { ApiTable } from '$utils' |
import { ApiTable, AxyRequest, AxyApiTable } from '$utils' |
||||
import { Request } from '@peace/utils' |
import { Request } from '@peace/utils' |
||||
|
import superagent from "superagent" |
||||
|
// import config from "../../../../../config"
|
||||
|
|
||||
export const INIT_AUTH = 'INIT_AUTH'; |
export const INIT_AUTH = 'INIT_AUTH'; |
||||
export function initAuth () { |
export function initAuth () { |
||||
const user = JSON.parse(sessionStorage.getItem('user')) || {}; |
const user = JSON.parse(sessionStorage.getItem('user')) || {}; |
||||
return { |
return { |
||||
type: INIT_AUTH, |
type: INIT_AUTH, |
||||
payload: { |
payload: { |
||||
user: user |
user: user |
||||
} |
} |
||||
}; |
}; |
||||
} |
} |
||||
|
|
||||
|
|
||||
export const REQUEST_LOGIN = 'REQUEST_LOGIN'; |
export const REQUEST_LOGIN = 'REQUEST_LOGIN'; |
||||
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'; |
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'; |
||||
export const LOGIN_ERROR = 'LOGIN_ERROR'; |
export const LOGIN_ERROR = 'LOGIN_ERROR'; |
||||
export function login ({ username, password, phone, code }) { |
export function login ({ username, password, phone, code, axyApi, axyProject }) { |
||||
return dispatch => { |
return dispatch => { |
||||
dispatch({ type: REQUEST_LOGIN }); |
dispatch({ type: REQUEST_LOGIN }); |
||||
|
|
||||
return Request.post(ApiTable.login, { username, password, phone, code }) |
return Request.post(ApiTable.login, { username, password, phone, code }) |
||||
.then(user => { |
.then(user => { |
||||
sessionStorage.setItem('user', JSON.stringify(user)); |
sessionStorage.setItem('user', JSON.stringify(user)); |
||||
dispatch({ |
dispatch({ |
||||
type: LOGIN_SUCCESS, |
type: LOGIN_SUCCESS, |
||||
payload: { user: user }, |
payload: { user: user }, |
||||
}); |
|
||||
}, error => { |
|
||||
let { body } = error.response; |
|
||||
dispatch({ |
|
||||
type: LOGIN_ERROR, |
|
||||
payload: { |
|
||||
error: body && body.message ? body.message : '登录失败' |
|
||||
} |
|
||||
}) |
|
||||
}); |
}); |
||||
} |
}, error => { |
||||
|
let { body } = error.response; |
||||
|
dispatch({ |
||||
|
type: LOGIN_ERROR, |
||||
|
payload: { |
||||
|
error: body && body.message ? body.message : '登录失败' |
||||
|
} |
||||
|
}) |
||||
|
}); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
export const LOGOUT = 'LOGOUT'; |
export const LOGOUT = 'LOGOUT'; |
||||
export function logout (user) { |
export function logout (user) { |
||||
const token = user.token; |
const token = user.token; |
||||
const url = ApiTable.logout; |
const url = ApiTable.logout; |
||||
sessionStorage.removeItem('user'); |
sessionStorage.removeItem('user'); |
||||
localStorage.removeItem('zhongding_selected_sider') |
localStorage.removeItem('zhongding_selected_sider') |
||||
localStorage.removeItem('zhongding_open_sider') |
localStorage.removeItem('zhongding_open_sider') |
||||
Request.put(url, { |
Request.put(url, { |
||||
token: token |
token: token |
||||
}); |
}); |
||||
return { |
|
||||
type: LOGOUT |
return { |
||||
}; |
type: LOGOUT |
||||
|
}; |
||||
} |
} |
||||
|
|
||||
export default { |
export default { |
||||
initAuth, |
initAuth, |
||||
login, |
login, |
||||
logout |
logout |
||||
} |
} |
@ -0,0 +1,28 @@ |
|||||
|
.login { |
||||
|
.ant-form-item-control-input { |
||||
|
background: url(/assets/images/login/input-b.png); |
||||
|
background-size: 100% 108%; |
||||
|
background-position: center; |
||||
|
.ant-input-affix-wrapper, |
||||
|
.ant-input-affix-wrapper-status-success, |
||||
|
.ant-input-affix-wrapper-status-error { |
||||
|
background: transparent; |
||||
|
border: 0; |
||||
|
#username,#password { |
||||
|
background: transparent; |
||||
|
color: white; |
||||
|
} |
||||
|
} |
||||
|
.ant-input-affix-wrapper-status-error:not( |
||||
|
.ant-input-affix-wrapper-disabled |
||||
|
):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper, |
||||
|
.ant-input-affix-wrapper-status-error:not( |
||||
|
.ant-input-affix-wrapper-disabled |
||||
|
):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper:hover { |
||||
|
background: transparent; |
||||
|
} |
||||
|
.ant-input-password-icon{ |
||||
|
color: white; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,51 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
import { basicAction } from '@peace/utils' |
|
||||
import { ApiTable } from '$utils' |
|
||||
|
|
||||
export function getAuthority(orgId) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_MEMBERS', |
|
||||
url: `${ApiTable.getEnterprisesMembers.replace('{enterpriseId}', orgId)}`, |
|
||||
msg: { error: '获取用户列表失败' }, |
|
||||
reducer: { name: 'members' } |
|
||||
}); |
|
||||
} |
|
||||
export function getResource(userId) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_RESOURCE', |
|
||||
url: `${ApiTable.getResource}`, |
|
||||
msg: { error: '获取权限失败' }, |
|
||||
reducer: { name: 'resource' } |
|
||||
}); |
|
||||
} |
|
||||
export function getUserResource(userId) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_USER_RESOURCE', |
|
||||
url: `${ApiTable.getUserResource}?userId=${userId}`, |
|
||||
msg: { error: '获取用户权限失败' }, |
|
||||
reducer: { name: 'userResource' } |
|
||||
}); |
|
||||
} |
|
||||
export function postUserRes(body) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'UPDATE_USER_RESOURCE', |
|
||||
url: `${ApiTable.postUserRes}`, |
|
||||
data: body, |
|
||||
msg: { success: '更新用户权限' } |
|
||||
}); |
|
||||
} |
|
||||
export default { |
|
||||
getAuthority, |
|
||||
getResource, |
|
||||
getUserResource, |
|
||||
postUserRes |
|
||||
} |
|
@ -0,0 +1,19 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
import { basicAction } from '@peace/utils' |
||||
|
import { ApiTable } from '$utils' |
||||
|
|
||||
|
export function axyData (data = {}) { |
||||
|
return dispatch => basicAction({ |
||||
|
type: 'post', |
||||
|
dispatch: dispatch, |
||||
|
actionType: 'POST_AXY_DATA', |
||||
|
url: `${ApiTable.axyData}`, |
||||
|
data: data, |
||||
|
msg: { success: '' } |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
export default { |
||||
|
axyData |
||||
|
} |
@ -1,11 +1,8 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
import * as authority from './authority' |
import * as bigScreen from './bigScreen' |
||||
import { getDepMessage, getDepUser, createUser } from './user' |
|
||||
|
|
||||
export default { |
export default { |
||||
...authority, |
...bigScreen |
||||
getDepMessage, |
|
||||
getDepUser, |
|
||||
createUser, |
|
||||
} |
} |
@ -1,113 +0,0 @@ |
|||||
'use strict'; |
|
||||
|
|
||||
import { basicAction } from '@peace/utils' |
|
||||
import { ApiTable } from '$utils' |
|
||||
|
|
||||
export function getDepMessage() { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_DEPARTMENT_MESSAGE', |
|
||||
url: ApiTable.getDepMessage, |
|
||||
msg: { error: '获取部门信息失败' }, |
|
||||
reducer: { name: 'depMessage' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
//新建部门
|
|
||||
export function createDept(data) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'CREATE_DEPT', |
|
||||
url: ApiTable.createDept, |
|
||||
msg: { option: '新建部门' }, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
//修改部门
|
|
||||
export function updateDept(id, data) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'put', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'UPDATE_DEPT', |
|
||||
url: ApiTable.updateDept.replace('{id}', id), |
|
||||
msg: { option: '修改部门' }, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
//删除部门
|
|
||||
export function delDept(id) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'del', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'DEL_DEPT', |
|
||||
url: ApiTable.delDept.replace('{id}', id), |
|
||||
msg: { option: '删除部门' }, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function getDepUser(depId) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'get', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'GET_DEPARTMENT_USER', |
|
||||
url: ApiTable.getDepUser.replace('{depId}', depId), |
|
||||
msg: { error: '获取部门下用户信息失败' }, |
|
||||
reducer: { name: 'depUser' } |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function createUser(data) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'post', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'CREATE_DEPARTMENT_USER', |
|
||||
url: ApiTable.createUser, |
|
||||
msg: { option: '新建用户' }, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function updateUser(id, data) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'put', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'UPDATE_DEPARTMENT_USER', |
|
||||
url: ApiTable.updateUser.replace('{id}', id), |
|
||||
msg: { option: '修改用户' }, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function delUser(ids) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'del', |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'DEL_DEPARTMENT_USER', |
|
||||
url: ApiTable.delUser.replace('{ids}', ids), |
|
||||
msg: { option: '删除用户' }, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export function resetPwd(id, data) { |
|
||||
return dispatch => basicAction({ |
|
||||
type: 'put', |
|
||||
data, |
|
||||
dispatch: dispatch, |
|
||||
actionType: 'CREATE_DEPARTMENT_USER', |
|
||||
url: ApiTable.resetPwd.replace('{id}', id), |
|
||||
msg: { option: '重置用户密码' }, |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
export default { |
|
||||
getDepMessage, |
|
||||
getDepUser, |
|
||||
createUser, |
|
||||
updateUser, |
|
||||
delUser, |
|
||||
resetPwd |
|
||||
} |
|
@ -0,0 +1,13 @@ |
|||||
|
.site { |
||||
|
.ant-select:not(.ant-select-customize-input) .ant-select-selector { |
||||
|
border: 0.5px solid #89bdef66; |
||||
|
background-image: linear-gradient(180deg, #6187e400 30%, #6187e480 100%); |
||||
|
color: #fff; |
||||
|
} |
||||
|
.ant-select:not(.ant-select-customize-input) .ant-select-selector { |
||||
|
background-color: transparent; |
||||
|
} |
||||
|
.ant-select-arrow { |
||||
|
color: #fff; |
||||
|
} |
||||
|
} |
@ -1,14 +1,15 @@ |
|||||
'use strict'; |
'use strict'; |
||||
import { AuthorizationCode } from './authCode'; |
import { AuthorizationCode } from './authCode'; |
||||
import { ApiTable, RouteTable } from './webapi' |
import { ApiTable, RouteTable, AxyRequest, AxyApiTable } from './webapi' |
||||
import Func from './func'; |
import Func from './func'; |
||||
import { useFsRequest } from './hooks'; |
import { useFsRequest } from './hooks'; |
||||
|
|
||||
const Constans = {} |
const Constans = {} |
||||
export { |
export { |
||||
AuthorizationCode, |
AuthorizationCode, |
||||
Func, |
Func, |
||||
ApiTable, RouteTable, |
ApiTable, RouteTable, |
||||
Constans, |
Constans, |
||||
useFsRequest |
useFsRequest, |
||||
|
AxyRequest, AxyApiTable |
||||
} |
} |
@ -1,107 +1,108 @@ |
|||||
{ |
{ |
||||
"name": "fs-anxincloud-4.0", |
"name": "fs-anxincloud-4.0", |
||||
"version": "1.0.0", |
"version": "1.0.0", |
||||
"description": "anxincloud-4.0", |
"description": "anxincloud-4.0", |
||||
"main": "server.js", |
"main": "server.js", |
||||
"scripts": { |
"scripts": { |
||||
"test": "mocha", |
"test": "mocha", |
||||
"start": "cross-env NODE_ENV=development npm run start-params", |
"start": "cross-env NODE_ENV=development npm run start-params", |
||||
"start-params": "node server -p 5900 -u http://127.0.0.1:4900 --qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu --qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5 --qnbkt anxinyun-test --qndmn http://test.resources.anxinyun.cn --aliOssAccessKey LTAI5tNDfn7UhStYQcn3JBtw --aliOssSecretKey rnoXtDWQA1djJ5Xqcdn1OSEol0lVyv --aliOssBucket test-c371 --aliOssRegion oss-cn-hangzhou", |
"start-params": "node server -p 5900 -u http://127.0.0.1:4900 --apiAnxinyunUrl https://openapi.anxinyun.cn/api/v1 --axyProject 1a271f12-52f2-4d16-8dad-ec0c92d3e0cc/03bzzdh/123456", |
||||
"deploy": "export NODE_ENV=production && npm run build && node server", |
"deploy": "export NODE_ENV=production && npm run build && node server", |
||||
"build-dev": "export NODE_ENV=development&&webpack --config webpack.config.js", |
"build-dev": "export NODE_ENV=development&&webpack --config webpack.config.js", |
||||
"build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js" |
"build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js" |
||||
}, |
}, |
||||
"keywords": [ |
"keywords": [ |
||||
"app" |
"app" |
||||
], |
], |
||||
"author": "", |
"author": "", |
||||
"license": "ISC", |
"license": "ISC", |
||||
"devDependencies": { |
"devDependencies": { |
||||
"@babel/core": "^7.14.6", |
"@babel/core": "^7.14.6", |
||||
"@babel/plugin-proposal-class-properties": "^7.14.5", |
"@babel/plugin-proposal-class-properties": "^7.14.5", |
||||
"@babel/plugin-proposal-object-rest-spread": "^7.14.7", |
"@babel/plugin-proposal-object-rest-spread": "^7.14.7", |
||||
"@babel/plugin-transform-runtime": "^7.14.5", |
"@babel/plugin-transform-runtime": "^7.14.5", |
||||
"@babel/polyfill": "^7.12.1", |
"@babel/polyfill": "^7.12.1", |
||||
"@babel/preset-env": "^7.14.7", |
"@babel/preset-env": "^7.14.7", |
||||
"@babel/preset-react": "^7.14.5", |
"@babel/preset-react": "^7.14.5", |
||||
"babel-loader": "^8.2.2", |
"babel-loader": "^8.2.2", |
||||
"babel-polyfill": "^6.26.0", |
"babel-polyfill": "^6.26.0", |
||||
"babel-plugin-import": "^1.13.3", |
"babel-plugin-import": "^1.13.3", |
||||
"connected-react-router": "^6.8.0", |
"connected-react-router": "^6.8.0", |
||||
"css-loader": "^3.5.0", |
"css-loader": "^3.5.0", |
||||
"express": "^4.17.1", |
"express": "^4.17.1", |
||||
"file-loader": "^6.0.0", |
"file-loader": "^6.0.0", |
||||
"html-webpack-plugin": "^4.5.0", |
"html-webpack-plugin": "^4.5.0", |
||||
"immutable": "^4.0.0-rc.12", |
"immutable": "^4.0.0-rc.12", |
||||
"less": "^3.12.2", |
"less": "^3.12.2", |
||||
"less-loader": "^7.0.2", |
"less-loader": "^7.0.2", |
||||
"natty-fetch": "^2.5.3", |
"natty-fetch": "^2.5.3", |
||||
"nprogress": "^0.2.0", |
"nprogress": "^0.2.0", |
||||
"path": "^0.12.7", |
"path": "^0.12.7", |
||||
"path-to-regexp": "^2.4.0", |
"path-to-regexp": "^2.4.0", |
||||
"perfect-scrollbar": "^1.5.0", |
"perfect-scrollbar": "^1.5.0", |
||||
"react": "^17.0.0", |
"react": "^17.0.0", |
||||
"react-copy-to-clipboard": "^5.0.1", |
"react-copy-to-clipboard": "^5.0.1", |
||||
"react-dnd": "^10.0.2", |
"react-dnd": "^10.0.2", |
||||
"react-dnd-html5-backend": "^10.0.2", |
"react-dnd-html5-backend": "^10.0.2", |
||||
"react-dom": "^17.0.0", |
"react-dom": "^17.0.0", |
||||
"react-if": "^2.2.1", |
"react-if": "^2.2.1", |
||||
"react-jsonschema-form": "^1.8.1", |
"react-jsonschema-form": "^1.8.1", |
||||
"react-quill": "^1.3.5", |
"react-quill": "^1.3.5", |
||||
"react-redux": "^7.2.1", |
"react-redux": "^7.2.1", |
||||
"react-router-dom": "^5.2.0", |
"react-router-dom": "^5.2.0", |
||||
"react-router-redux": "^4.0.8", |
"react-router-redux": "^4.0.8", |
||||
"redux": "^4.0.5", |
"redux": "^4.0.5", |
||||
"redux-thunk": "^2.3.0", |
"redux-thunk": "^2.3.0", |
||||
"redux-undo": "^1.0.1", |
"redux-undo": "^1.0.1", |
||||
"style-loader": "^2.0.0", |
"style-loader": "^2.0.0", |
||||
"webpack": "^5.3.2", |
"webpack": "^5.3.2", |
||||
"webpack-bundle-analyzer": "^4.1.0", |
"webpack-bundle-analyzer": "^4.1.0", |
||||
"webpack-cli": "^4.2.0", |
"webpack-cli": "^4.2.0", |
||||
"webpack-dev-middleware": "^4.0.2", |
"webpack-dev-middleware": "^4.0.2", |
||||
"webpack-hot-middleware": "^2.25.0" |
"webpack-hot-middleware": "^2.25.0" |
||||
}, |
}, |
||||
"dependencies": { |
"dependencies": { |
||||
"@ant-design/icons": "^4.6.2", |
"@ant-design/icons": "^4.6.2", |
||||
"@ant-design/pro-form": "^1.34.0", |
"@ant-design/pro-form": "^1.34.0", |
||||
"@ant-design/pro-table": "^2.48.0", |
"@ant-design/pro-table": "^2.48.0", |
||||
"@antv/g6": "^4.2.5", |
"@antv/g6": "^4.2.5", |
||||
"@fs/attachment": "^1.0.0", |
"@fs/attachment": "^1.0.0", |
||||
"@peace/components": "0.0.35", |
"@peace/components": "0.0.35", |
||||
"@peace/utils": "0.0.37", |
"@peace/utils": "0.0.66", |
||||
"ahooks": "^3.7.4", |
"ahooks": "^3.7.4", |
||||
"ali-oss": "^6.17.1", |
"ali-oss": "^6.17.1", |
||||
"antd": "^4.24.5", |
"antd": "^4.24.5", |
||||
"antd-theme-generator": "^1.2.8", |
"antd-theme-generator": "^1.2.8", |
||||
"args": "^5.0.1", |
"args": "^5.0.1", |
||||
"array-move": "^3.0.1", |
"array-move": "^3.0.1", |
||||
"bpmn-js": "^6.5.1", |
"bpmn-js": "^6.5.1", |
||||
"camunda-bpmn-moddle": "^4.4.0", |
"camunda-bpmn-moddle": "^4.4.0", |
||||
"canvas": "^2.11.0", |
"canvas": "^2.11.0", |
||||
"co-busboy": "^1.4.1", |
"co-busboy": "^1.4.1", |
||||
"cross-env": "^7.0.3", |
"cross-env": "^7.0.3", |
||||
"crypto-js": "^4.1.1", |
"crypto-js": "^4.1.1", |
||||
"echarts": "^5.4.1", |
"echarts": "^5.4.1", |
||||
"file-saver": "^2.0.5", |
"echarts-for-react": "^3.0.2", |
||||
"form-data": "^3.0.0", |
"file-saver": "^2.0.5", |
||||
"fs-attachment": "^1.0.0", |
"form-data": "^3.0.0", |
||||
"fs-web-server-scaffold": "^1.0.6", |
"fs-attachment": "^1.0.0", |
||||
"i": "^0.3.6", |
"fs-web-server-scaffold": "^1.0.6", |
||||
"koa-better-http-proxy": "^0.2.5", |
"i": "^0.3.6", |
||||
"koa-proxy": "^1.0.0-alpha.3", |
"koa-better-http-proxy": "^0.2.5", |
||||
"koa-view": "^2.1.4", |
"koa-proxy": "^1.0.0-alpha.3", |
||||
"mini-dynamic-antd-theme": "^0.5.3", |
"koa-view": "^2.1.4", |
||||
"moment": "^2.22.0", |
"mini-dynamic-antd-theme": "^0.5.3", |
||||
"npm": "^7.20.6", |
"moment": "^2.22.0", |
||||
"qrcode": "^1.5.1", |
"npm": "^7.20.6", |
||||
"qs": "^6.10.1", |
"qrcode": "^1.5.1", |
||||
"react-color": "^2.19.3", |
"qs": "^6.10.1", |
||||
"react-router-breadcrumbs-hoc": "^4.0.1", |
"react-color": "^2.19.3", |
||||
"react-sortable-hoc": "^2.0.0", |
"react-router-breadcrumbs-hoc": "^4.0.1", |
||||
"shortid": "^2.2.16", |
"react-sortable-hoc": "^2.0.0", |
||||
"superagent": "^6.1.0", |
"shortid": "^2.2.16", |
||||
"uuid": "^8.3.1", |
"superagent": "^6.1.0", |
||||
"webpack-dev-server": "^3.11.2", |
"uuid": "^8.3.1", |
||||
"xlsx": "^0.16.9" |
"webpack-dev-server": "^3.11.2", |
||||
} |
"xlsx": "^0.16.9" |
||||
|
} |
||||
} |
} |
||||
|