yazid138 3 vuotta sitten
vanhempi
commit
64105b8f4e
2 muutettua tiedostoa jossa 15 lisäystä ja 2 poistoa
  1. 7 2
      controller/sanksi.controller.js
  2. 8 0
      utils/cekData.js

+ 7 - 2
controller/sanksi.controller.js

@@ -88,7 +88,7 @@ exports.create = handleError(async (req, res) => {
 
 exports.getAll = handleError(async (req, res) => {
   const user = req.user
-  const { keberatan, jawaban, banding, cabutSanksi, perbaikan, aktif } =
+  const { keberatan, jawaban, banding, cabutSanksi, perbaikan, aktif, delegasi } =
     req.query
   const where = {}
   if (aktif && aktif === 'false') {
@@ -115,6 +115,8 @@ exports.getAll = handleError(async (req, res) => {
     }
   } else if (perbaikan === 'true') {
     where['jawaban.banding'] = { $exists: true, $ne: null }
+  } else if (delegasi === 'true') {
+    w.delegasi = true
   }
   const data = await cekBanyakDataSanksi(user, where)
   return response.success(res, {
@@ -128,13 +130,16 @@ exports.getOne = handleError(async (req, res) => {
   const { sanksi_id } = req.params
 
   const w = {}
-  const { banding, aktif } = req.query
+  const { banding, aktif, delegasi } = req.query
   if (banding === 'true') {
     w.banding = true
     w['pengajuan.keberatan'] = { $exists: true, $ne: null }
     w['jawaban.keberatan'] = { $exists: true, $ne: null }
     w['pengajuan.banding'] = { $exists: true, $ne: null }
   }
+  if (delegasi === 'true') {
+    w.delegasi = true
+  }
   if (aktif && aktif === 'false') {
     w.aktif = false
   }

+ 8 - 0
utils/cekData.js

@@ -117,6 +117,10 @@ exports.cekSatuDataSanksi = async (
     case 2020:
       // if (where.all) w.role_asal = 'dikti'
       if (where.all) break
+      else if (where.delegasi) {
+        w.role_data = 'lldikti'
+        w.role_asal = 'dikti'
+      }
       else if (!where.banding) w.role_data = 'dikti'
       break
     case 2021:
@@ -160,6 +164,10 @@ exports.cekBanyakDataSanksi = async (user, where = {}, q = {}) => {
     case 2020:
       // if (where.all) w.role_asal = 'dikti'
       if (where.all) break
+      else if (where.delegasi) {
+        w.role_data = 'lldikti'
+        w.role_asal = 'dikti'
+      }
       else if (!where.banding) w.role_data = 'dikti'
       break
     case 2021: