Merge branch 'master' of ssh://85.143.175.152:222/bro-students/multy-stub

This commit is contained in:
RustamRu 2025-03-03 20:14:06 +03:00
commit 4f9434163e

View File

@ -156,17 +156,21 @@ router.post('/create', async (req, res, next) => {
router.get('/:id', async (req, res, next) => {
const { id } = req.params
if (!mongoose.Types.ObjectId.isValid(id)) {
throw new Error(VALIDATION_MESSAGES.orderId.invalid)
}
try {
const order = await OrderModel.findById(id)
if (!order) {
throw new Error(VALIDATION_MESSAGES.order.notFound)
}
res.status(200).send({ success: true, body: order })
const data = await OrderCarImgModel.findOne({ orderId: order.id }) || {}
res.status(200).send({ success: true, body: {...order,...data} })
} catch (error) {
next(error)
}
@ -277,7 +281,6 @@ const upload = multer({
const { v4: uuidv4 } = require("uuid")
const axios = require('axios')
const GIGA_CHAT_ACCESS_TOKEN = 'MTQwMmNmZjgtZjA5OC00OGMxLWI0OTUtNWU3ZTU4YzMzZjdjOmU5OGFiYmNiLThmMDItNGVmOC1hNjhhLTA4Y2QxYjVmOGRmMA=='
const GIGA_CHAT_OAUTH = 'https://ngw.devices.sberbank.ru:9443/api/v2/oauth'
const GIGA_CHAT_API = 'https://gigachat.devices.sberbank.ru/api/v1'
@ -416,7 +419,7 @@ router.post('/:id/upload-car-img', upload.single('file'), async (req, res) => {
image: convertFileToBase64(req.file),
imageRating: value,
imageDescription: description,
orderId,
orderId: order.id,
created: new Date().toISOString(),
})
@ -439,4 +442,4 @@ router.use((err, req, res, next) => {
throw new Error(err.message)
})
module.exports = router
module.exports = router