...
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) => {
|
exports.getBelongingInventory = catchAsync(async (req, res, next) => {
|
||||||
const result = await transactionService.getBelongingInventory(req.params.belongingId)
|
const result = await transactionService.getBelongingInventory(req.params.belongingId)
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ router.get(
|
|||||||
transactionController.getBelongingInventory
|
transactionController.getBelongingInventory
|
||||||
)
|
)
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
'/admin/belonging/:belongingId',
|
||||||
|
// perm.requires('getallbelongings'),
|
||||||
|
transactionController.getTransactionByBelongingId
|
||||||
|
)
|
||||||
|
|
||||||
router.patch(
|
router.patch(
|
||||||
'/admin/update/:transactionId',
|
'/admin/update/:transactionId',
|
||||||
// perm.requires('getallbelongings'),
|
// perm.requires('getallbelongings'),
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ const getUserTransaction = async (userId) => {
|
|||||||
return Transaction.find({ userId }, null, null)
|
return Transaction.find({ userId }, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getTransactionByBelongingId = async (belongingId) => {
|
||||||
|
return Transaction.find({ belongingId }, null, null)
|
||||||
|
}
|
||||||
|
|
||||||
const getBelongingInventory = async (belongingId) => {
|
const getBelongingInventory = async (belongingId) => {
|
||||||
const belonging = await Belonging.findById(belongingId, null, null)
|
const belonging = await Belonging.findById(belongingId, null, null)
|
||||||
|
|
||||||
@@ -147,4 +151,11 @@ const deleteTransaction = async (transactionId) => {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { createTransaction, getUserTransaction, getBelongingInventory, updateTransaction, deleteTransaction }
|
module.exports = {
|
||||||
|
createTransaction,
|
||||||
|
getUserTransaction,
|
||||||
|
getBelongingInventory,
|
||||||
|
updateTransaction,
|
||||||
|
deleteTransaction,
|
||||||
|
getTransactionByBelongingId,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user