清理代码

master
Z 4 years ago
parent feca1a1c3d
commit fb107c7318
  1. 1
      app/src/main/assets/litepal.xml
  2. 7
      app/src/main/java/com/novel/read/data/db/BookDatabase.kt
  3. 16
      app/src/main/java/com/novel/read/data/db/UserDao.kt
  4. 29
      app/src/main/java/com/novel/read/data/db/entity/User.kt
  5. 32
      app/src/main/java/com/novel/read/data/model/UserResp.kt
  6. 4
      app/src/main/java/com/novel/read/help/ReadBookConfig.kt
  7. 9
      app/src/main/java/com/novel/read/network/api/BookService.kt
  8. 12
      app/src/main/java/com/novel/read/network/repository/BookRepository.kt

@ -7,7 +7,6 @@
<mapping class="com.novel.read.data.db.entity.Bookmark" />
<mapping class="com.novel.read.data.db.entity.ReadRecord" />
<mapping class="com.novel.read.data.db.entity.SearchHistory" />
<mapping class="com.novel.read.data.db.entity.User" />
</list>
<storage value="external" />
</litepal>

@ -21,7 +21,6 @@ class BookDatabase private constructor() {
private var readRecordDao: ReadRecordDao? = null
private var bookMarkDao: BookMarkDao? = null
private var searchHistoryDao: SearchHistoryDao? = null
private var userDao: UserDao? = null
fun getChapterDao(): ChapterDao {
if (chapterDao == null) {
@ -58,10 +57,4 @@ class BookDatabase private constructor() {
return searchHistoryDao!!
}
fun getUserDao(): UserDao {
if (userDao == null) {
userDao = UserDao()
}
return userDao!!
}
}

@ -1,16 +0,0 @@
package com.novel.read.data.db
import com.novel.read.data.db.entity.User
import org.litepal.LitePal
import org.litepal.extension.deleteAll
class UserDao {
fun saveUser(user: User) = user.saveOrUpdate("userId=?", user.userId.toString())
fun getUser(): User? =
LitePal.findFirst(User::class.java)
fun deleteUser() = LitePal.deleteAll<User>()
}

@ -1,29 +0,0 @@
package com.novel.read.data.db.entity
import org.litepal.crud.LitePalSupport
import java.io.Serializable
data class User(
val createTime: Long,
val email: String,
val headImageUrl: String,
val idToken: String,
val introduction: String?,
val ip: String,
val isEmailVerified: Int,
val lastLoginTime: Long?,
val nickName: String?,
val oldNickName: String?,
val os: String,
val password: String,
val phone: String,
val provider: String,
val sex: Int,
val updateTime: Long?,
val userId: Long,
val userName: String,
val validFlag: Int,
val vipEndTime: Long?,
val vipStartTime: Long?,
val vipStatus: Int
) : LitePalSupport(), Serializable

@ -1,32 +0,0 @@
package com.novel.read.data.model
import com.novel.read.data.db.entity.User
data class UserResp(
val user: User
)
//
//data class User(
// val createTime: Long,
// val email: String,
// val headImageUrl: String,
// val idToken: String,
// val introduction: Any,
// val ip: String,
// val isEmailVerified: Int,
// val lastLoginTime: Any,
// val nickName: String,
// val oldNickName: Any,
// val os: String,
// val password: String,
// val phone: String,
// val provider: String,
// val sex: Any,
// val updateTime: Any,
// val userId: Long,
// val userName: String,
// val validFlag: Int,
// val vipEndTime: Any,
// val vipStartTime: Any,
// val vipStatus: Int
//)

@ -234,8 +234,8 @@ object ReadBookConfig {
}
var paddingBottom: Int
// get() = config.paddingBottom
get() = 20
get() = config.paddingBottom
// get() = 20
set(value) {
config.paddingBottom = value
}

@ -45,15 +45,6 @@ interface BookService {
@POST("api/edition/editionUpdate")
suspend fun appUpdate(@Body body: RequestBody): ApiResult<AppUpdateResp>
@POST("api/user/googleLogin")
suspend fun googleLogin(@Body loginReq: LoginReq): ApiResult<UserResp>
@POST("api/order/getCommodityList")
suspend fun getGoods(): ApiResult<MutableList<GoodsResp>>
@POST("api/order/addBookOrder")
suspend fun buyVip(): ApiResult<MutableList<GoodsResp>>
@Streaming
@GET()
suspend fun getImage(@Url fileUrl: String): ResponseBody

@ -104,18 +104,6 @@ class BookRepository {
ServiceCreator.apiService.feedback(mapToBody(map)).apiData()
}
suspend fun login(loginReq: LoginReq) = withContext(Dispatchers.IO) {
ServiceCreator.apiService.googleLogin(loginReq).apiData()
}
suspend fun getGoods() = withContext(Dispatchers.IO) {
ServiceCreator.apiService.getGoods().apiData()
}
suspend fun buyVip() = withContext(Dispatchers.IO) {
ServiceCreator.apiService.buyVip().apiData()
}
private fun mapToBody(map: HashMap<String, Any>): RequestBody {
return RequestBody.create(
MediaType.parse("application/json;charset=UTF-8"),

Loading…
Cancel
Save