feat: 优化代码

pull/141/head
kunfei 5 years ago
parent 18b98307ec
commit 532f130b74
  1. 4
      app/src/main/java/io/legado/app/web/controller/BookshelfController.kt
  2. 6
      app/src/main/java/io/legado/app/web/controller/SourceController.kt

@ -23,7 +23,7 @@ class BookshelfController {
fun getChapterList(parameters: Map<String, List<String>>): ReturnData {
val bookUrl = parameters["url"]?.get(0)
val returnData = ReturnData()
if (bookUrl == null) {
if (bookUrl.isNullOrEmpty()) {
return returnData.setErrorMsg("参数url不能为空,请指定书籍地址")
}
val chapterList = App.db.bookChapterDao().getChapterList(bookUrl)
@ -34,7 +34,7 @@ class BookshelfController {
val bookUrl = parameters["url"]?.get(0)
val index = parameters["index"]?.get(0)?.toInt()
val returnData = ReturnData()
if (bookUrl == null) {
if (bookUrl.isNullOrEmpty()) {
return returnData.setErrorMsg("参数url不能为空,请指定书籍地址")
}
if (index == null) {

@ -58,12 +58,12 @@ class SourceController {
}
fun getSource(parameters: Map<String, List<String>>): ReturnData {
val strings = parameters["url"]
val url = parameters["url"]?.get(0)
val returnData = ReturnData()
if (strings == null) {
if (url.isNullOrEmpty()) {
return returnData.setErrorMsg("参数url不能为空,请指定书源地址")
}
val bookSource = App.db.bookSourceDao().getBookSource(strings[0])
val bookSource = App.db.bookSourceDao().getBookSource(url)
?: return returnData.setErrorMsg("未找到书源,请检查书源地址")
return returnData.setData(bookSource)
}

Loading…
Cancel
Save