|
|
@@ -9,7 +9,7 @@ const userModel = require('../model/user.model')
|
|
|
exports.get = handleError(async (req, res) => {
|
|
|
const user = req.user
|
|
|
const { laporan_id } = req.params
|
|
|
-
|
|
|
+ const { delegasi, asc } = req.query
|
|
|
// const pt = await axios.get(
|
|
|
// `https://api.kemdikbud.go.id:8243/pddikti/1.2/pt/${pt_id}`
|
|
|
// )
|
|
|
@@ -23,8 +23,9 @@ exports.get = handleError(async (req, res) => {
|
|
|
// message: 'pt_id tidak ditemukan',
|
|
|
// })
|
|
|
// }
|
|
|
-
|
|
|
- const laporan = await cekSatuDataLaporan(res, user, laporan_id)
|
|
|
+ const where = {}
|
|
|
+ if (delegasi) where.delegasi = true
|
|
|
+ const laporan = await cekSatuDataLaporan(res, user, laporan_id, where)
|
|
|
if (!laporan) return
|
|
|
|
|
|
const data = await pemantauanModel
|
|
|
@@ -34,7 +35,7 @@ exports.get = handleError(async (req, res) => {
|
|
|
.populate({ path: 'laporan', select: 'no_laporan' })
|
|
|
.populate({ path: 'sanksi', select: 'no_sanksi' })
|
|
|
.populate('dokumen')
|
|
|
- .sort({ createdAt: -1 })
|
|
|
+ .sort({ createdAt: asc == 'true' ? 1 : -1 })
|
|
|
|
|
|
return response.success(res, {
|
|
|
message: 'Berhasil ambil data Pemantauan',
|