-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from SukiEva/dev-compose
Dev compose
- Loading branch information
Showing
56 changed files
with
1,705 additions
and
353 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/github/sukieva/hhu/data/entity/Website.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package github.sukieva.hhu.data.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.Index | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(indices = [Index(value = ["site_name"], unique = true)]) | ||
data class Website( | ||
@ColumnInfo(name = "site_name") | ||
var siteName: String, | ||
@ColumnInfo(name = "site_address") | ||
var siteAddress: String | ||
) { | ||
@PrimaryKey(autoGenerate = true) | ||
var id: Long = 0 | ||
} |
2 changes: 1 addition & 1 deletion
2
...va/github/sukieva/hhu/data/bean/Course.kt → ...ub/sukieva/hhu/data/entity/bean/Course.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package github.sukieva.hhu.data.bean | ||
package github.sukieva.hhu.data.entity.bean | ||
|
||
|
||
data class Course( | ||
|
7 changes: 4 additions & 3 deletions
7
...github/sukieva/hhu/data/bean/LoginData.kt → ...sukieva/hhu/data/entity/bean/LoginData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/github/sukieva/hhu/data/entity/bean/PostData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package github.sukieva.hhu.data.entity.bean | ||
|
||
|
||
data class PostData( | ||
var maccount: String, | ||
var mwid: String, | ||
var mname: String, | ||
var maid: String, | ||
var minstitute: String, | ||
var mgrade: String, | ||
var mclass: String, | ||
var mbuilding: String, | ||
var mroom: String, | ||
var mphone: String | ||
) |
2 changes: 1 addition & 1 deletion
2
...java/github/sukieva/hhu/data/bean/Rank.kt → ...thub/sukieva/hhu/data/entity/bean/Rank.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/github/sukieva/hhu/data/local/AppDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package github.sukieva.hhu.data.local | ||
|
||
import android.content.Context | ||
import androidx.room.Database | ||
import androidx.room.Room | ||
import androidx.room.RoomDatabase | ||
import github.sukieva.hhu.data.entity.Website | ||
import github.sukieva.hhu.data.local.dao.FavDao | ||
|
||
@Database(version = 1, exportSchema = false, entities = [Website::class]) | ||
abstract class AppDatabase : RoomDatabase() { | ||
|
||
abstract fun favDao(): FavDao | ||
|
||
|
||
companion object { // 全局只创建一个数据库实例 | ||
private var instance: AppDatabase? = null | ||
|
||
@Synchronized | ||
fun getDatabase(context: Context): AppDatabase { | ||
instance?.let { | ||
return it | ||
} | ||
return Room.databaseBuilder(context.applicationContext, AppDatabase::class.java, "app_database") | ||
.fallbackToDestructiveMigration() // 数据库升级时销毁,测试用 | ||
.build().apply { | ||
instance = this | ||
} | ||
} | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/github/sukieva/hhu/data/local/dao/FavDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package github.sukieva.hhu.data.local.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import androidx.room.Update | ||
import github.sukieva.hhu.data.entity.Website | ||
|
||
@Dao | ||
interface FavDao { | ||
|
||
@Insert | ||
suspend fun insertWeb(website: Website): Long | ||
|
||
|
||
@Query("select * from Website") | ||
suspend fun loadAllWebs(): List<Website> | ||
|
||
@Query("delete from Website") | ||
suspend fun deleteAllWebs() | ||
|
||
@Query("delete from Website where site_name = :siteName") | ||
suspend fun deleteWebBySiteName(siteName: String): Int | ||
} |
Oops, something went wrong.