yazid138 hace 3 años
padre
commit
baf33b301c
Se han modificado 1 ficheros con 23 adiciones y 6 borrados
  1. 23 6
      utils/cekData.js

+ 23 - 6
utils/cekData.js

@@ -12,9 +12,20 @@ exports.cekSatuDataLaporan = async (
   const w = { _id: laporan_id, aktif: where.aktif || true, ...where }
   switch (user.role.id) {
     case 2020:
-      if (where.all) break
-      else if (!where.delegasi) w.role_data = 'dikti'
-      else {
+      if (where.all) {
+        w.role_asal = 'dikti'
+        // w['$or'] = [
+        //   { role_asal : 'dikti' },
+        //   { role_asal: 'lldikti', role_data: 'dikti' },
+        // ]
+      } else if (!where.delegasi) {
+        w.role_data = 'dikti'
+      } else if (!where.delegasi) {
+        w['$or'] = [
+          { role_asal: 'dikti' },
+          { role_asal: 'lldikti', role_data: 'dikti' },
+        ]
+      } else {
         w.role_data = 'lldikti'
         w.role_asal = 'dikti'
       }
@@ -54,9 +65,15 @@ exports.cekBanyakDataLaporan = async (user, where = { delegasi: false }) => {
   const w = { aktif: where.aktif || true, ...where }
   switch (user.role.id) {
     case 2020:
-      if (where.all) break
-      else if (!where.delegasi) w.role_data = 'dikti'
-      else {
+      if (where.all) {
+        w.role_asal = 'dikti'
+        // w['$or'] = [
+        //   { role_asal : 'dikti' },
+        //   { role_asal: 'lldikti', role_data: 'dikti' },
+        // ]
+      } else if (!where.delegasi) {
+        w.role_data = 'dikti'
+      } else {
         w.role_data = 'lldikti'
         w.role_asal = 'dikti'
       }