Skip to content

Commit 38375da

Browse files
committed
Updating NCs with input validation.
1 parent 1e1ff93 commit 38375da

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package org.graphqlncs
2+
3+
class Exep(message: String?) : RuntimeException(message)

jdk_8_maven/cs/graphql/graphql-ncs/src/main/kotlin/org/graphqlncs/resolver/QueryResolver.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.graphqlncs.resolver
22

33
import graphql.kickstart.tools.GraphQLQueryResolver
4+
import org.graphqlncs.Exep
45
import org.graphqlncs.type.*
6+
import org.springframework.http.ResponseEntity
57
import org.springframework.stereotype.Component
68

79
@Component
@@ -32,10 +34,18 @@ open class QueryResolver(
3234
}
3335

3436
fun remainder(a: Int, b:Int ): Int {
35-
return remainder.exe(a, b)
37+
val lim = 10000
38+
return if (a > lim || a < -lim || b > lim || b < -lim) {
39+
throw Exep("400")
40+
} else remainder.exe(a, b)
3641
}
3742

3843
fun bessj(n:Int, x:Double ): Double {
39-
return bessj.bessj(n, x)
44+
45+
return if (n <= 2 || n > 1000) {
46+
throw Exep("400")
47+
48+
} else
49+
bessj.bessj(n, x)
4050
}
4151
}

0 commit comments

Comments
 (0)