Skip to content

Commit

Permalink
🐛 关联人课表性别显示异常,统一改成 Ta
Browse files Browse the repository at this point in the history
  • Loading branch information
985892345 committed Jan 7, 2025
1 parent fe6a0b8 commit 8be106f
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ interface ILinkService {
val linkMajor: String, // 关联人的专业
val linkName: String, // 关联人的姓名
val isShowLink: Boolean, // 是否显示
val isBoy: Boolean, // 关联人性别
) : Serializable {

fun isNull(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "5a13098b79b15e882e26a18c07556425",
"entities": [
{
"tableName": "link_stu",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`selfNum` TEXT NOT NULL, `linkNum` TEXT NOT NULL, `linkMajor` TEXT NOT NULL, `linkName` TEXT NOT NULL, `isShowLink` INTEGER NOT NULL, PRIMARY KEY(`selfNum`))",
"fields": [
{
"fieldPath": "selfNum",
"columnName": "selfNum",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "linkNum",
"columnName": "linkNum",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "linkMajor",
"columnName": "linkMajor",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "linkName",
"columnName": "linkName",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isShowLink",
"columnName": "isShowLink",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"selfNum"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5a13098b79b15e882e26a18c07556425')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ data class LinkStudent(
val name: String,
@SerializedName("selfNum")
val selfNum: String, // 自身的学号
@SerializedName("gender")
val gender: String, // 关联人性别
) : Serializable {

fun isEmpty(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object LinkRepository {
}
// 这里说明与远端的关联人不一样,需要修改数据库
// 但注意后端对应没有关联人时会返回空串,所以需要使用 it.isNotEmpty()
val newLinkStu = LinkStuEntity(it, it.isNotEmpty(), it.gender == "")
val newLinkStu = LinkStuEntity(it, it.isNotEmpty())
mLinkStuDB.insertLinkStu(newLinkStu)
newLinkStu
}.doOnError {
Expand Down Expand Up @@ -120,7 +120,7 @@ object LinkRepository {
.changeLinkStudent(linkNum)
.mapOrThrowApiException()
.map {
LinkStuEntity(it, true, it.gender == "")
LinkStuEntity(it, true)
}.doOnSuccess {
mLinkStuDB.insertLinkStu(it)
}.subscribeOn(Schedulers.io())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.io.Serializable
* @email [email protected]
* @date 2022/4/23 14:40
*/
@Database(entities = [LinkStuEntity::class], version = 1)
@Database(entities = [LinkStuEntity::class], version = 2)
abstract class LinkDataBase : RoomDatabase() {
abstract fun getLinkStuDao(): LinkStuDao

Expand All @@ -35,18 +35,16 @@ data class LinkStuEntity(
val linkMajor: String, // 关联人的专业
val linkName: String, // 关联人的姓名
val isShowLink: Boolean, // 是否显示
val isBoy: Boolean // 是否是男生
) : Serializable {
constructor(
linkStu: LinkStudent,
isShowLink: Boolean,
isBoy: Boolean
) : this(linkStu.selfNum, linkStu.linkNum, linkStu.major, linkStu.name, isShowLink, isBoy)
) : this(linkStu.selfNum, linkStu.linkNum, linkStu.major, linkStu.name, isShowLink)

fun isNull(): Boolean = linkNum.isBlank() || selfNum.isBlank()
fun isNotNull(): Boolean = !isNull()
companion object {
val NULL = LinkStuEntity("", "", "", "", isShowLink = false, isBoy = true)
val NULL = LinkStuEntity("", "", "", "", isShowLink = false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ object LinkServiceImpl : ILinkService {
}

private fun LinkStuEntity.toLinkStu(): ILinkService.LinkStu {
return ILinkService.LinkStu(selfNum, linkNum, linkMajor, linkName, isShowLink, isBoy)
return ILinkService.LinkStu(selfNum, linkNum, linkMajor, linkName, isShowLink)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ object CourseHeaderHelper {
nowWeek,
linkData.selfNum,
if (linkData.isShowLink) linkData.linkNum else "",
linkData.isBoy
)
}
}
Expand All @@ -146,7 +145,6 @@ object CourseHeaderHelper {
nowWeek: Int,
selfNum: String,
linkNum: String,
isBoy: Boolean
): Observable<Header> {
// 这里不需要调用 observeSelfLesson(),因为外面的 observeSelfLinkStu() 有观察 self 的作用
val selfSingle = lessonService.getStuLesson(selfNum)
Expand All @@ -172,7 +170,6 @@ object CourseHeaderHelper {
nowWeek,
self + link,
affair,
isBoy
)
}
}
Expand All @@ -183,7 +180,6 @@ object CourseHeaderHelper {
nowWeek: Int,
lessonList: List<ILessonService.Lesson>,
affairList: List<IAffairService.Affair>,
linkIsBoy: Boolean
): Header {
val calendar = Calendar.getInstance()
/*
Expand Down Expand Up @@ -253,15 +249,14 @@ object CourseHeaderHelper {
}.map { AffairItem(it) }
)
val nowTime = calendar.get(Calendar.HOUR_OF_DAY) * 60 + calendar.get(Calendar.MINUTE)
val heOrShe = if (linkIsBoy) "" else ""
val iterator = treeSet.iterator()
while (iterator.hasNext()) {
val item = iterator.next()
if (item.hashDay == todayHashDay) {
if (nowTime < item.startTime) {
return when (item) {
is LessonItem -> ShowHeader(
if (item.isSelf) "下节课" else "${heOrShe}的下节课",
if (item.isSelf) "下节课" else "Ta的下节课",
item.lesson.course,
getShowTimeStr(item.lesson.beginLesson, item.lesson.period),
parseClassRoom(item.lesson.classroom),
Expand All @@ -279,7 +274,7 @@ object CourseHeaderHelper {
} else if (nowTime < item.endTime) {
return when (item) {
is LessonItem -> ShowHeader(
if (item.isSelf) "进行中..." else "${heOrShe}的课进行中...",
if (item.isSelf) "进行中..." else "Ta的课进行中...",
item.lesson.course,
getShowTimeStr(item.lesson.beginLesson, item.lesson.period),
parseClassRoom(item.lesson.classroom),
Expand Down

0 comments on commit 8be106f

Please sign in to comment.