chore: update response check status
This commit is contained in:
@@ -13,7 +13,7 @@ export default abstract class CommandService {
|
|||||||
const topicData = `${body.merchantName}/${body.floorName}_${unitNumber}-${body.deviceName}-${body.roomName}-${body.deviceType}-${body.commandType}-${body.towerNumber}`
|
const topicData = `${body.merchantName}/${body.floorName}_${unitNumber}-${body.deviceName}-${body.roomName}-${body.deviceType}-${body.commandType}-${body.towerNumber}`
|
||||||
const cmd = dataMapping.find((device) => device.deviceName == body.deviceName)
|
const cmd = dataMapping.find((device) => device.deviceName == body.deviceName)
|
||||||
const request = await sendCommandToThirdParty(topicData, `${cmd?.command}${body.payload.action}`)
|
const request = await sendCommandToThirdParty(topicData, `${cmd?.command}${body.payload.action}`)
|
||||||
if (request.status !== 200) {
|
if (request.status !== 200 || request.data.status == 400) {
|
||||||
return {
|
return {
|
||||||
status: 'error' as const,
|
status: 'error' as const,
|
||||||
message: request.status == 404 ? 'Device not found' : 'Command failed' as const,
|
message: request.status == 404 ? 'Device not found' : 'Command failed' as const,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default abstract class QueryService {
|
|||||||
deviceType: request.data.data.devType,
|
deviceType: request.data.data.devType,
|
||||||
code: request.data.data.code,
|
code: request.data.data.code,
|
||||||
towerNumber: request.data.data.tower,
|
towerNumber: request.data.data.tower,
|
||||||
payload: request.data.data.payload,
|
payload: request.data.data.payload?.split('=')[1],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user