...
This commit is contained in:
@@ -21,6 +21,16 @@ exports.getUserTransaction = catchAsync(async (req, res, next) => {
|
||||
})
|
||||
})
|
||||
|
||||
exports.getTransactionByBelongingId = catchAsync(async (req, res, next) => {
|
||||
const transactions = await transactionService.getTransactionByBelongingId(req.params.belongingId)
|
||||
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
results: transactions.length,
|
||||
data: transactions,
|
||||
})
|
||||
})
|
||||
|
||||
exports.getBelongingInventory = catchAsync(async (req, res, next) => {
|
||||
const result = await transactionService.getBelongingInventory(req.params.belongingId)
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ router.get(
|
||||
transactionController.getBelongingInventory
|
||||
)
|
||||
|
||||
router.get(
|
||||
'/admin/belonging/:belongingId',
|
||||
// perm.requires('getallbelongings'),
|
||||
transactionController.getTransactionByBelongingId
|
||||
)
|
||||
|
||||
router.patch(
|
||||
'/admin/update/:transactionId',
|
||||
// perm.requires('getallbelongings'),
|
||||
|
||||
@@ -54,6 +54,10 @@ const getUserTransaction = async (userId) => {
|
||||
return Transaction.find({ userId }, null, null)
|
||||
}
|
||||
|
||||
const getTransactionByBelongingId = async (belongingId) => {
|
||||
return Transaction.find({ belongingId }, null, null)
|
||||
}
|
||||
|
||||
const getBelongingInventory = async (belongingId) => {
|
||||
const belonging = await Belonging.findById(belongingId, null, null)
|
||||
|
||||
@@ -147,4 +151,11 @@ const deleteTransaction = async (transactionId) => {
|
||||
return null
|
||||
}
|
||||
|
||||
module.exports = { createTransaction, getUserTransaction, getBelongingInventory, updateTransaction, deleteTransaction }
|
||||
module.exports = {
|
||||
createTransaction,
|
||||
getUserTransaction,
|
||||
getBelongingInventory,
|
||||
updateTransaction,
|
||||
deleteTransaction,
|
||||
getTransactionByBelongingId,
|
||||
}
|
||||
|
||||
Generated
+594
-594
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user