|
@ -147,6 +147,11 @@ async function getResourceFileList(ctx, next) { |
|
|
findObj.where = where; |
|
|
findObj.where = where; |
|
|
} |
|
|
} |
|
|
if ("公司培训资料" == type) { |
|
|
if ("公司培训资料" == type) { |
|
|
|
|
|
if (findObj.where) { |
|
|
|
|
|
findObj.where.fileName = { $not: null }; |
|
|
|
|
|
} else { |
|
|
|
|
|
findObj.where = { fileName: { $not: null } }; |
|
|
|
|
|
} |
|
|
rlst = await models.TrainingInformation.findAndCountAll(findObj); |
|
|
rlst = await models.TrainingInformation.findAndCountAll(findObj); |
|
|
} else { |
|
|
} else { |
|
|
rlst = await models.DeptTraining.findAndCountAll(findObj); |
|
|
rlst = await models.DeptTraining.findAndCountAll(findObj); |
|
@ -163,6 +168,7 @@ async function getResourceFileList(ctx, next) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
async function postResourceClassify(ctx) { |
|
|
async function postResourceClassify(ctx) { |
|
|
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
const { departmentName, trainDate } = ctx.request.body; |
|
|
const { departmentName, trainDate } = ctx.request.body; |
|
@ -180,17 +186,19 @@ async function postResourceClassify(ctx) { |
|
|
await models.TrainingInformation.create({ |
|
|
await models.TrainingInformation.create({ |
|
|
departmentName: departmentName, |
|
|
departmentName: departmentName, |
|
|
trainDate: trainDate |
|
|
trainDate: trainDate |
|
|
}) |
|
|
}, { transaction }) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
await transaction.commit(); |
|
|
ctx.status = 204; |
|
|
ctx.status = 204; |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
|
|
|
await transaction.rollback(); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |
|
|
ctx.body = { message: err.message || '新增培训资源储备库文件夹失败' } |
|
|
ctx.body = { message: err.message || '新增培训资源储备库文件夹失败' } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
async function putResourceClassify(ctx) { |
|
|
async function putResourceClassify(ctx) { |
|
|
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
const { oldDepName, oldTrainDate, departmentName, trainDate } = ctx.request.body; |
|
|
const { oldDepName, oldTrainDate, departmentName, trainDate } = ctx.request.body; |
|
@ -199,24 +207,50 @@ async function putResourceClassify(ctx) { |
|
|
|
|
|
|
|
|
if (trainDate && '' != trainDate && oldTrainDate && '' != oldTrainDate) { |
|
|
if (trainDate && '' != trainDate && oldTrainDate && '' != oldTrainDate) { |
|
|
where.trainDate = oldTrainDate; |
|
|
where.trainDate = oldTrainDate; |
|
|
await models.TrainingInformation.update({ trainDate: trainDate }, { where }); |
|
|
await models.TrainingInformation.update({ trainDate: trainDate }, { where, transaction }); |
|
|
//三级目录
|
|
|
//三级目录
|
|
|
} else { |
|
|
} else { |
|
|
//二级目录
|
|
|
//二级目录
|
|
|
await models.TrainingInformation.update({ departmentName: departmentName }, { where }); |
|
|
await models.TrainingInformation.update({ departmentName: departmentName }, { where, transaction }); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await transaction.commit(); |
|
|
ctx.status = 204; |
|
|
ctx.status = 204; |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
|
|
|
await transaction.rollback(); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |
|
|
ctx.body = { message: err.message || '编辑培训资源储备库文件夹失败' }; |
|
|
ctx.body = { message: err.message || '编辑培训资源储备库文件夹失败' }; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function delResourceClassify(ctx) { |
|
|
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
|
|
|
try { |
|
|
|
|
|
const { departmentName, trainDate } = ctx.query; |
|
|
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
|
|
|
|
|
|
|
|
if (departmentName && '' != departmentName) { |
|
|
|
|
|
const where = { departmentName }; |
|
|
|
|
|
if (trainDate && '' != trainDate) { |
|
|
|
|
|
where.trainDate = trainDate; |
|
|
|
|
|
} |
|
|
|
|
|
await models.TrainingInformation.destroy({ where, transaction }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await transaction.commit(); |
|
|
|
|
|
ctx.status = 204; |
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
await transaction.rollback(); |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = { message: err.message || '新增培训资源储备库文件夹失败' } |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
getResourceClassify, |
|
|
getResourceClassify, |
|
|
getResourceFileList, |
|
|
getResourceFileList, |
|
|
postResourceClassify, |
|
|
postResourceClassify, |
|
|
putResourceClassify |
|
|
putResourceClassify, |
|
|
|
|
|
delResourceClassify |
|
|
} |
|
|
} |