const db = require("../models"); const API = require('../helper/API_Response'); const db_helper = require("../helper/db_helper"); const helper = require("../helper/helper"); const { References, Domain, Subdomain, Topic, Books, Certificate, Cohort, Templates, ScheduleTime } = require("../models"); exports.add = async (req, res) => { const input = await helper.decryptRequest(req.body.data); res.status(200).send(API._200(await db_helper.addData('References', input))); }; exports.all = async (req, res) => { const all_data = await References.findAll({ where: { status: 0 }, include: [{ model: Certificate, attributes: ['id', 'certificate_name'] }, { model: Domain, attributes: ['id', 'domin_name'] }, { model: Subdomain, attributes: ['id', 'subdomain_name'] }, { model: Topic, attributes: ['id', 'topic_name'] }, { model: Books, attributes: ['id', 'book_title'] }] }) res.status(200).send(API._200(await all_data)); }; exports.delete = async (req, res) => { const input = await helper.decryptRequest(req.body.data); res.status(200).send(API._200(await db_helper.statusChange('References', input.id))); }; exports.update = async (req, res) => { const input = await helper.decryptRequest(req.body.data); res.status(200).send(API._200(await db_helper.update('References', input))); }; exports.ref_by_book = async (req, res) => { const input = await helper.decryptRequest(req.body.data); res.status(200).send(API._200(await db_helper.selectByWhere('References', { 'book_id': input.book_id }))); }; exports.addScheduleTime = async (req, res) => { const input = await helper.decryptRequest(req.body.data); res.status(200).send(API._200(await db_helper.addData('ScheduleTime', input))); }; exports.allScheduleTime = async (req, res) => { const all_data = await ScheduleTime.findAll({ where: { status: 0 }, include: [{ model: Cohort, attributes: ['id', 'cohort_name'] }, { model: Templates, attributes: ['id', 'name'] } ] }) res.status(200).send(API._200(await all_data)); }; exports.deleteScheduleTime = async (req, res) => { const input = await helper.decryptRequest(req.body.data); res.status(200).send(API._200(await db_helper.statusChange('ScheduleTime', input.id))); }; exports.updateScheduleTime = async (req, res) => { const input = await helper.decryptRequest(req.body.data); res.status(200).send(API._200(await db_helper.update('ScheduleTime', input))); };