/* ============================================================================ *\
|| ########################################################################## ||
|| # Auction Software Marketplace Release: 0.6 Build 0.7 # ||
|| # ---------------------------------------------------------------------- # ||
|| # License # 35YAHCNR9344X6O666C123AB # ||
|| # ---------------------------------------------------------------------- # ||
|| # Copyright ©2014–2021 Develop Scripts LLC. All Rights Reserved # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ------------- AUCTION SOFTWARE IS NOT FREE SOFTWARE ------------------ # ||
|| # http://www.auctionsoftwaremarketplace.com|support@auctionsoftware.com # ||
|| # ---------------------------------------------------------------------- # ||
|| ########################################################################## ||
\* ============================================================================ */
/* eslint-disable prefer-destructuring */
/* eslint-disable no-param-reassign */
const jwt = require('jsonwebtoken')
const adminSettingModule = require('../../modules/setting').default
const schemaModule = require('./schema').default
const commonFunction = require('../../../common/function').default
const { jsonResponse } = require('../logger')
module.exports = {
/**
* Get All configuration variable
*
* @memberOf adminside.setting
* @param {adminSettingModule.allConfiguration} modules
*/
configurationVariables: async (req, res) => {
let records = []
let totalRecords = []
try {
;[records, totalRecords] = await Promise.all([
adminSettingModule.allConfiguration(req, 0),
adminSettingModule.allConfiguration(req, 1),
])
} catch (e) {
console.error(e)
jsonResponse(res, 'error', {
responseType: 3,
message: 'Internal Server error!',
})
} finally {
let responseData = { records, totalRecords }
responseData = await commonFunction.getdynamicinnercontents(req, responseData)
jsonResponse(res, 'success', {
responseType: 1,
message: 'Details successfully retrieved!',
responseData,
})
}
},
/**
* Get Single configuration variable
*
* @memberOf adminside.setting
* @param {adminSettingModule.getConfigurationbyId} modules
*/
getSingleConfiguration: async (req, res) => {
let item = {}
try {
const id = typeof req.body.id === 'undefined' ? '' : req.body.id
const [records] = await Promise.all([adminSettingModule.getConfigurationbyId(id)])
item = records[0]
} catch (e) {
console.error(e)
jsonResponse(res, 'error', {
responseType: 3,
message: 'Internal Server error!',
})
} finally {
const responseData = { item }
jsonResponse(res, 'success', {
responseType: 1,
message: 'Details successfully retrieved!',
responseData,
})
}
},
/**
* Configuration Action
*
* @memberOf adminside.setting
* @param {adminSettingModule.configurationOperation} modules
*/
configurationAction: async (req, res) => {
try {
req.body.id =
typeof req.body.id === 'undefined' || req.body.id === 0 || req.body.id === ''
? null
: req.body.id
await Promise.all([adminSettingModule.configurationOperation(req)])
} catch (e) {
console.error(e)
jsonResponse(res, 'error', {
responseType: 3,
message: 'Internal Server error!',
})
} finally {
jsonResponse(res, 'success', {
responseType: 1,
message: req.body.id ? 'Successfully updated!' : 'Successfully added!',
})
}
},
}