修复判断bug
This commit is contained in:
parent
56b1a8617f
commit
ff40cc6a27
@ -10,14 +10,26 @@ export class HotTopController{
|
|||||||
|
|
||||||
let hours = 1
|
let hours = 1
|
||||||
let rawHours = parseInt(request.query.hours as unknown as string)
|
let rawHours = parseInt(request.query.hours as unknown as string)
|
||||||
if(request.query.hours && !isNaN(rawHours) && rawHours <=24 && rawHours > 0)
|
if (request.query.hours !=undefined && !isNaN(rawHours) && rawHours <= 24 && rawHours > 0) {
|
||||||
hours = parseInt(request.query.hours as unknown as string)
|
hours = parseInt(request.query.hours as unknown as string)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
response.status(404)
|
||||||
|
return "error"
|
||||||
|
}
|
||||||
|
|
||||||
yestDay.setHours(nowDate.getHours() - hours)
|
yestDay.setHours(nowDate.getHours() - hours)
|
||||||
// console.log(yestDay.toLocaleString())
|
// console.log(yestDay.toLocaleString())
|
||||||
let limit: number
|
let limit: number
|
||||||
if(request.query.limit) limit = parseInt(request.query.limit as unknown as string)
|
if (request.query.limit == undefined) {
|
||||||
if(isNaN(limit) || limit>50 || limit<1) limit = 10
|
response.status(404)
|
||||||
|
return "error"
|
||||||
|
}
|
||||||
|
limit = Number.parseInt(request.query.limit as string)
|
||||||
|
if (isNaN(limit) || limit > 50 || limit < 1) {
|
||||||
|
response.status(404)
|
||||||
|
return "error"
|
||||||
|
}
|
||||||
|
|
||||||
// console.log(limit,hours)
|
// console.log(limit,hours)
|
||||||
// return "OK"
|
// return "OK"
|
||||||
|
Loading…
Reference in New Issue
Block a user