package com.yzx.ebrand.model

import com.yzx.ebrand.utils.getImgUrl
import java.net.URLDecoder

data class CBClassInfo(
    val brushed_face_num: Int = 0,
    val class_student_num: Int = 0,
    val class_teacher: ClassTeacher = ClassTeacher(),
    val leave_num: Int = 0,
    val unbrushed_face_num: Int = 0,
    val user_photo: UserPhoto = UserPhoto()
)

data class ClassTeacher(
    val user_id: Int = 0,
    val user_name: String = ""
)

data class UserPhoto(
    val head_portrait: String = "",
    val identity: String = ""
)

data class ClassTeaInfo(
    val subject_name: String = "",
    val subject_id: String = "",
    val user_name: String = "",
    val user_id: String = "",
    val type: Int = 0,
)

data class TimeTable(
    val lesson_no: Int = 0,
    val lesson_name: String = "",
    val subject_id: String = "",
    val subject_name: String = "",
)

data class ClassActiveInfo(
    val add_time: Int = 0,
    val user_name: String = "",
    val content: String = "",
    val attachments: MutableList<ActiveAttachment> = mutableListOf(),
){
    fun getNewContent():String{
        return URLDecoder.decode(content,"UTF-8")
    }

    fun getImgUrls():MutableList<String>{
        val list = mutableListOf<String>()
        attachments.forEach {
            if (it.file_id?.isNotEmpty())
            list.add(it.file_identity.getImgUrl(it.file_id))
        }
        return  list
    }
}

data class ActiveAttachment(
    val file_id: String = "",
    val file_identity: String = "",
)

data class ClassStylePic(
    val identity: String = "",
    val picture_id: String = "",
)

data class HeadClassInfo(
    val class_id: Int = 0,
    val class_name: String = "",
    val grade_id: Int = 0,
    val grade_name: String = "",
)