|
|
@ -5,7 +5,6 @@ import android.text.TextUtils |
|
|
|
import io.legado.app.api.ReturnData |
|
|
|
import io.legado.app.api.ReturnData |
|
|
|
import io.legado.app.data.appDb |
|
|
|
import io.legado.app.data.appDb |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.help.SourceAnalyzer |
|
|
|
|
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.fromJsonArray |
|
|
|
import io.legado.app.utils.fromJsonArray |
|
|
|
import io.legado.app.utils.msg |
|
|
|
import io.legado.app.utils.msg |
|
|
@ -25,7 +24,7 @@ object BookSourceController { |
|
|
|
val returnData = ReturnData() |
|
|
|
val returnData = ReturnData() |
|
|
|
postData ?: return returnData.setErrorMsg("数据不能为空") |
|
|
|
postData ?: return returnData.setErrorMsg("数据不能为空") |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
val bookSource = SourceAnalyzer.jsonToBookSource(postData) |
|
|
|
val bookSource = BookSource.fromJson(postData) |
|
|
|
if (bookSource != null) { |
|
|
|
if (bookSource != null) { |
|
|
|
if (TextUtils.isEmpty(bookSource.bookSourceName) || TextUtils.isEmpty(bookSource.bookSourceUrl)) { |
|
|
|
if (TextUtils.isEmpty(bookSource.bookSourceName) || TextUtils.isEmpty(bookSource.bookSourceUrl)) { |
|
|
|
returnData.setErrorMsg("源名称和URL不能为空") |
|
|
|
returnData.setErrorMsg("源名称和URL不能为空") |
|
|
@ -45,7 +44,7 @@ object BookSourceController { |
|
|
|
fun saveSources(postData: String?): ReturnData { |
|
|
|
fun saveSources(postData: String?): ReturnData { |
|
|
|
postData ?: return ReturnData().setErrorMsg("数据为空") |
|
|
|
postData ?: return ReturnData().setErrorMsg("数据为空") |
|
|
|
val okSources = arrayListOf<BookSource>() |
|
|
|
val okSources = arrayListOf<BookSource>() |
|
|
|
val bookSources = SourceAnalyzer.jsonToBookSources(postData) |
|
|
|
val bookSources = BookSource.fromJsonArray(postData) |
|
|
|
if (bookSources.isNotEmpty()) { |
|
|
|
if (bookSources.isNotEmpty()) { |
|
|
|
bookSources.forEach { bookSource -> |
|
|
|
bookSources.forEach { bookSource -> |
|
|
|
if (bookSource.bookSourceName.isNotBlank() |
|
|
|
if (bookSource.bookSourceName.isNotBlank() |
|
|
|