parent
ac9f9eb6b8
commit
b1abda97d6
@ -0,0 +1,81 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.orm.dao |
||||
|
||||
import androidx.room.Dao |
||||
import androidx.room.Delete |
||||
import androidx.room.Insert |
||||
import androidx.room.Query |
||||
import androidx.room.Transaction |
||||
import androidx.room.Update |
||||
import com.arialyy.aria.orm.entity.DEntity |
||||
import com.arialyy.aria.orm.entity.DGEntity |
||||
import com.arialyy.aria.orm.entity.DGSubRelation |
||||
|
||||
/** |
||||
* @Author laoyuyu |
||||
* @Description |
||||
* @Date 8:55 AM 2023/1/19 |
||||
**/ |
||||
@Dao |
||||
interface DGEntityDao { |
||||
|
||||
@Transaction |
||||
@Query("SELECT * FROM DGEntity") |
||||
suspend fun getDGEntityList(): List<DGSubRelation> |
||||
|
||||
@Transaction |
||||
@Query("SELECT * FROM DGEntity WHERE :gid=gid") |
||||
suspend fun getDGEntityByGid(gid: Int): DGSubRelation |
||||
|
||||
@Transaction |
||||
@Query("SELECT * FROM DGEntity WHERE :gid=gid") |
||||
suspend fun getDGList(): List<DGSubRelation> |
||||
|
||||
@Insert |
||||
suspend fun insertSubList(subList: List<DEntity>) |
||||
|
||||
@Update |
||||
suspend fun update(dgEntity: DGEntity) |
||||
|
||||
@Delete |
||||
suspend fun deleteSubList(subList: List<DEntity>) |
||||
|
||||
@Delete |
||||
@Deprecated( |
||||
"please use ", |
||||
ReplaceWith("delete(dgEntity)", "com.arialyy.aria.orm.dao.DGEntityDao.delete") |
||||
) |
||||
suspend fun deleteDg(dgEntity: DGEntity) |
||||
|
||||
@Insert |
||||
@Deprecated( |
||||
"please use ", |
||||
ReplaceWith("insert(dgEntity)", "com.arialyy.aria.orm.dao.DGEntityDao.insert") |
||||
) |
||||
suspend fun insertDg(dgEntity: DGEntity) |
||||
|
||||
@Transaction |
||||
suspend fun delete(dgEntity: DGEntity) { |
||||
deleteSubList(dgEntity.subList) |
||||
deleteDg(dgEntity) |
||||
} |
||||
|
||||
suspend fun insert(dgEntity: DGEntity) { |
||||
insertDg(dgEntity) |
||||
insertSubList(dgEntity.subList) |
||||
} |
||||
} |
@ -0,0 +1,67 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.orm.dao |
||||
|
||||
import androidx.room.Dao |
||||
import androidx.room.Delete |
||||
import androidx.room.Insert |
||||
import androidx.room.Query |
||||
import androidx.room.Transaction |
||||
import androidx.room.Update |
||||
import com.arialyy.aria.orm.entity.BlockRecord |
||||
import com.arialyy.aria.orm.entity.RecordRelation |
||||
import com.arialyy.aria.orm.entity.TaskRecord |
||||
|
||||
/** |
||||
* @Author laoyuyu |
||||
* @Description |
||||
* @Date 10:34 AM 2023/1/19 |
||||
**/ |
||||
@Dao |
||||
interface RecordDao { |
||||
|
||||
@Transaction |
||||
@Query("SELECT * FROM TaskRecord WHERE :key=taskKey") |
||||
suspend fun getTaskRecordByKey(key: String): RecordRelation |
||||
|
||||
@Insert |
||||
@Deprecated( |
||||
"please use ", |
||||
ReplaceWith( |
||||
"deleteTaskRecord(taskRecord)", |
||||
"com.arialyy.aria.orm.dao.RecordDao.insert" |
||||
) |
||||
) |
||||
suspend fun insertTaskRecord(taskRecord: TaskRecord) |
||||
|
||||
@Insert |
||||
suspend fun insertSubList(blockList: List<BlockRecord>) |
||||
|
||||
@Update |
||||
suspend fun update(record: TaskRecord) |
||||
|
||||
@Delete |
||||
suspend fun deleteTaskRecord(record: TaskRecord) |
||||
|
||||
@Delete |
||||
suspend fun deleteBlockRecord(blockRecord: List<BlockRecord>) |
||||
|
||||
@Transaction |
||||
suspend fun insert(taskRecord: TaskRecord) { |
||||
insertTaskRecord(taskRecord) |
||||
insertSubList(taskRecord.blockList) |
||||
} |
||||
} |
@ -0,0 +1,54 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.orm.entity |
||||
|
||||
import androidx.room.Entity |
||||
import androidx.room.ForeignKey |
||||
import androidx.room.ForeignKey.Companion.CASCADE |
||||
import androidx.room.PrimaryKey |
||||
|
||||
/** |
||||
* @Author laoyuyu |
||||
* @Description |
||||
* @Date 10:16 AM 2023/1/19 |
||||
**/ |
||||
@Entity( |
||||
foreignKeys = [ForeignKey( |
||||
entity = TaskRecord::class, |
||||
parentColumns = ["tId"], |
||||
childColumns = ["tId"], |
||||
onDelete = CASCADE |
||||
)] |
||||
) |
||||
data class BlockRecord( |
||||
@PrimaryKey(autoGenerate = true) val bId: Int = 0, |
||||
|
||||
val tId: Int, |
||||
|
||||
/** |
||||
* 开始位置 |
||||
*/ |
||||
val startLocation: Long = 0, |
||||
|
||||
/** |
||||
* 结束位置 |
||||
*/ |
||||
val endLocation: Long = 0, |
||||
|
||||
val blockSize: Long = 0, |
||||
|
||||
val isComplete: Boolean = false |
||||
) |
@ -0,0 +1,61 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.orm.entity |
||||
|
||||
import androidx.room.Entity |
||||
import androidx.room.Index |
||||
import androidx.room.PrimaryKey |
||||
|
||||
@Entity(indices = [Index(value = ["sourceUrl", "savePath"])]) |
||||
data class MEntity( |
||||
@PrimaryKey(autoGenerate = true) val mId: Int = 0, |
||||
|
||||
val keyId: Int = -1, |
||||
|
||||
/** |
||||
* file source url |
||||
*/ |
||||
val sourceUrl: String, |
||||
/** |
||||
* file save path |
||||
*/ |
||||
val savePath: String, |
||||
/** |
||||
* extended Information |
||||
*/ |
||||
var ext: String? = null, |
||||
|
||||
/** |
||||
* 当前peer的位置 |
||||
*/ |
||||
val peerIndex: Int = 0, |
||||
|
||||
/** |
||||
* peer总数 |
||||
*/ |
||||
private var peerNum: Int = 0, |
||||
|
||||
/** |
||||
* 是否是直播,true 直播 |
||||
*/ |
||||
val isLive: Boolean = false, |
||||
|
||||
/** |
||||
* 缓存目录 |
||||
*/ |
||||
val cacheDir: String? = null |
||||
|
||||
) |
@ -0,0 +1,40 @@ |
||||
package com.arialyy.aria.orm.entity |
||||
|
||||
import androidx.room.Entity |
||||
import androidx.room.PrimaryKey |
||||
|
||||
@Entity |
||||
data class MKeyInfo( |
||||
|
||||
@PrimaryKey(autoGenerate = true) val kId: Int, |
||||
|
||||
/** |
||||
* 加密key保存地址 |
||||
*/ |
||||
val keyPath: String, |
||||
|
||||
/** |
||||
* 加密key的下载地址 |
||||
*/ |
||||
val keyUrl: String, |
||||
|
||||
/** |
||||
* 加密算法 |
||||
*/ |
||||
val method: String, |
||||
|
||||
/** |
||||
* key的iv值 |
||||
*/ |
||||
val iv: String, |
||||
|
||||
/** |
||||
* key的格式,可能为空 |
||||
*/ |
||||
val keyFormat: String? = null, |
||||
|
||||
/** |
||||
* key的格式版本,默认为1,如果是多个版本,使用"/"分隔,如:"1", "1/2", or "1/2/5" |
||||
*/ |
||||
val keyFormatVersion: String = "1", |
||||
) |
@ -0,0 +1,42 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.orm.entity |
||||
|
||||
import androidx.room.Embedded |
||||
import androidx.room.Relation |
||||
|
||||
/** |
||||
* @Author laoyuyu |
||||
* @Description |
||||
* @Date 10:27 AM 2023/1/19 |
||||
**/ |
||||
data class RecordRelation( |
||||
@Embedded |
||||
val taskRecord: TaskRecord |
||||
) { |
||||
@Relation( |
||||
parentColumn = "tId", |
||||
entityColumn = "tId" |
||||
) |
||||
var blockRecordList: List<BlockRecord> = emptyList() |
||||
set(value) { |
||||
taskRecord.blockList.apply { |
||||
clear() |
||||
addAll(value) |
||||
} |
||||
field = value |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.orm.entity |
||||
|
||||
import androidx.room.Entity |
||||
import androidx.room.Ignore |
||||
import androidx.room.Index |
||||
import androidx.room.PrimaryKey |
||||
|
||||
@Entity(indices = [Index(value = ["taskKey"])]) |
||||
data class TaskRecord( |
||||
@PrimaryKey(autoGenerate = true) val tId: Int = 0, |
||||
val taskKey: String, |
||||
val filePath: String, |
||||
val taskType: Int, |
||||
val fileLen: Long, |
||||
val blockNum: Int, |
||||
val blockSize: Long |
||||
) { |
||||
@Ignore |
||||
internal var blockList: MutableList<BlockRecord> = mutableListOf() |
||||
} |
Loading…
Reference in new issue