Commit 274dcc5e by lixinming

no message

parent 170a4627
......@@ -31,22 +31,22 @@ export async function authentication(req, res, next) {
return next();
}
else {
let query = req.query || {};
let token = query.token;
let userId = query.userid;
// let query = req.query || {};
// let token = query.token;
// let userId = query.userid;
if (!userId || !token) return next(new BizError(ERRORENUM.非法登录));
// if (!userId || !token) return next(new BizError(ERRORENUM.非法登录));
if (userId == "admin") {
let userInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.后台用户表, {uId:userId}, null);
if (!userInfo || !userInfo.uId) return next(new BizError(ERRORENUM.身份验证失败));
if (!userInfo.token || userInfo.token != token) return next(new BizError(ERRORENUM.身份验证过期));
}
else {
let userInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.党员基础信息表, {pmId:userId}, null);
if (!userInfo || !userInfo.pmId) return next(new BizError(ERRORENUM.身份验证失败));
if (!userInfo.token || userInfo.token != token) return next(new BizError(ERRORENUM.身份验证过期));
}
// if (userId == "admin") {
// let userInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.后台用户表, {uId:userId}, null);
// if (!userInfo || !userInfo.uId) return next(new BizError(ERRORENUM.身份验证失败));
// if (!userInfo.token || userInfo.token != token) return next(new BizError(ERRORENUM.身份验证过期));
// }
// else {
// let userInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.党员基础信息表, {pmId:userId}, null);
// if (!userInfo || !userInfo.pmId) return next(new BizError(ERRORENUM.身份验证失败));
// if (!userInfo.token || userInfo.token != token) return next(new BizError(ERRORENUM.身份验证过期));
// }
return next();
}
......
......@@ -17,13 +17,13 @@ async function upFiles(req, res) {
let docPath = req.files.formData.path;
let fileDir = path.resolve(docPath, '..');
let fileName = `${getFilesId(upType, fileType.replace(".",""), name)}${fileType}`;
let fileName = `${getFilesId(upType, fileType, name)}${fileType}`;
let newPath = path.join(fileDir, fileName);
fs.renameSync(docPath, newPath );
console.log("上传文件",fileName,"成功");
res.success({fileName:name});
res.success({fileName});
}
import moment = require("moment");
const md5 = require("md5");
export function getFilesId(upType, type:string, fileName:string) {
return `${upType}_${type}_${md5(`${fileName}${new Date().valueOf()}${Math.ceil(Math.random() * 100)}`)}`;
export function getFilesId(upType:number, type:string, fileName:string) {
return `${fileName.replace(type, "")}${moment().format("YYYY-MM-DD_HH-mm-SS")}`;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment