|
|
@@ -0,0 +1,69 @@
|
|
|
+const sanksiModel = require('../model/sanksi.model')
|
|
|
+const dokumenModel = require('../model/dokumen.model')
|
|
|
+const handleError = require('../utils/handleError')
|
|
|
+const response = require('../utils/responseHandler')
|
|
|
+
|
|
|
+exports.pengajuan = handleError(async (req, res) => {
|
|
|
+ const [keberatan, banding] = await Promise.all([
|
|
|
+ (() =>
|
|
|
+ sanksiModel.find({
|
|
|
+ ['pengajuan.keberatan']: { $ne: null, $exists: true },
|
|
|
+ is_pengajuan_keberatan: { $eq: null, $exists: false },
|
|
|
+ }))(),
|
|
|
+ (() =>
|
|
|
+ sanksiModel.find({
|
|
|
+ ['jawaban.keberatan']: { $ne: null, $exists: true },
|
|
|
+ ['pengajuan.banding']: { $ne: null, $exists: true },
|
|
|
+ is_pengajuan_banding: { $eq: null, $exists: false },
|
|
|
+ }))()
|
|
|
+ ])
|
|
|
+ await Promise.all([
|
|
|
+ ...keberatan.map(async (e) => {
|
|
|
+ await sanksiModel.findOneAndUpdate({ _id: e._id }, { is_pengajuan_keberatan: true })
|
|
|
+ }),
|
|
|
+ ...banding.map(async (e) => {
|
|
|
+ await sanksiModel.findOneAndUpdate({ _id: e._id }, { is_pengajuan_banding: true })
|
|
|
+ })
|
|
|
+ ])
|
|
|
+
|
|
|
+ return response.success(res, {
|
|
|
+ message: 'Berhasil migrasi pengajuan',
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+exports.dokumen = handleError(async (req, res) => {
|
|
|
+ const dokumen = await dokumenModel.find({ path: /api.sidali.sixsenz.net/ })
|
|
|
+
|
|
|
+ if (dokumen?.length) await Promise.all(dokumen.map(async e => {
|
|
|
+ const path = e.path.split('/').slice(3).join('/')
|
|
|
+ await dokumenModel.findOneAndUpdate({
|
|
|
+ _id: e._id
|
|
|
+ }, {
|
|
|
+ path: `${process.env.BASE_URL}/${path}`
|
|
|
+ })
|
|
|
+ }))
|
|
|
+
|
|
|
+ return response.success(res, {
|
|
|
+ message: 'Berhasil migrasi dokumen',
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+exports.pelanggaranSanksi = handleError(async (req, res) => {
|
|
|
+ const sanksi = await sanksiModel.find({sanksi: {
|
|
|
+ $eq: [],
|
|
|
+ }}).populate('pelanggaran')
|
|
|
+
|
|
|
+ if(sanksi?.length) await Promise.all(sanksi.map(async e => {
|
|
|
+ await sanksiModel.findOneAndUpdate({
|
|
|
+ _id: e._id
|
|
|
+ }, {
|
|
|
+ sanksi: e.pelanggaran.map(e2 => ({label: e2.label_sanksi, description: e2.sanksi, level: e2.level_sanksi}))
|
|
|
+ })
|
|
|
+ }))
|
|
|
+
|
|
|
+ return response.success(res, {
|
|
|
+ message: 'Berhasil migrasi pelanggaran sanksi',
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+
|