37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
// /components/employeeTimings/employeeTimingController.js
|
|
'use strict';
|
|
|
|
const catchAsync = require('../../utils/catchAsync');
|
|
const employeeTimingService = require('./employeeTimingService');
|
|
const { successResponse } = require('../../utils/apiResponse');
|
|
|
|
exports.getAll = catchAsync(async (req, res) => {
|
|
const result = await employeeTimingService.getAll(req.query);
|
|
return successResponse(res, 200, 'Employee timing records retrieved', result.items, result.meta);
|
|
});
|
|
|
|
exports.getSummary = catchAsync(async (req, res) => {
|
|
const summary = await employeeTimingService.getSummary(req.query);
|
|
return successResponse(res, 200, 'Employee timing summary retrieved', summary);
|
|
});
|
|
|
|
exports.getOne = catchAsync(async (req, res) => {
|
|
const record = await employeeTimingService.getOne(req.params.id);
|
|
return successResponse(res, 200, 'Employee timing record retrieved', record);
|
|
});
|
|
|
|
exports.create = catchAsync(async (req, res) => {
|
|
const record = await employeeTimingService.create(req.body, req.user?._id);
|
|
return successResponse(res, 201, 'Employee timing record created', record);
|
|
});
|
|
|
|
exports.update = catchAsync(async (req, res) => {
|
|
const record = await employeeTimingService.update(req.params.id, req.body, req.user?._id);
|
|
return successResponse(res, 200, 'Employee timing record updated', record);
|
|
});
|
|
|
|
exports.delete = catchAsync(async (req, res) => {
|
|
const result = await employeeTimingService.remove(req.params.id);
|
|
return successResponse(res, 200, 'Employee timing record deleted', result);
|
|
});
|