فهرست منبع

feat: 材料调差-附件 后台增加上传权限判断逻辑

lanjianrong 4 سال پیش
والد
کامیت
73331a8c3b
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      app/controller/material_controller.js

+ 15 - 0
app/controller/material_controller.js

@@ -596,6 +596,20 @@ module.exports = app => {
             }
         }
 
+        _checkMaterialFileCanModify(ctx) {
+            // 检查登录用户,是否可操作
+            const accountId = ctx.session.sessionUser.accountId;
+            if (!ctx.material.curAuditor) {
+                if (ctx.material.status === auditConst.status.uncheck || ctx.material.status === auditConst.status.checkNo && accountId === ctx.material.user_id) {
+                    return;
+                }
+                throw '该调差期当前您无权操作';
+            } else {
+                if (ctx.material.curAuditor.aid === accountId) return;
+                throw '该调差期当前您无权操作';
+            }
+
+        }
         /**
          * 上传附件
          * @param {*} ctx 上下文
@@ -603,6 +617,7 @@ module.exports = app => {
         async upload(ctx) {
             let stream;
             try {
+                this._checkMaterialFileCanModify(ctx);
                 const parts = this.ctx.multipart({
                     autoFields: true,
                 });