package com.gh.gamecenter.qa.entity

import android.os.Parcelable
import com.gh.gamecenter.common.utils.eliminateDoubleQuote
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.GamesCollectionEntity
import com.gh.gamecenter.entity.MyVideoEntity
import com.gh.gamecenter.feature.entity.AnswerEntity
import com.gh.gamecenter.feature.entity.ArticleEntity
import kotlinx.parcelize.Parcelize

@Parcelize
class EditorInsertEntity(
    var id: String? = "",
    var communityId: String? = "",
    var type: String? = "",
    var title: String? = "",
    var brief: String? = "",
    var icon: String? = "",
    var tags: List<String>? = null
) : Parcelable {
    companion object {

        @JvmStatic
        fun transform(answer: AnswerEntity): EditorInsertEntity {
            val entity = EditorInsertEntity()
            entity.id = answer.id
            entity.type = "answer"
            entity.title = answer.questions.title?.eliminateDoubleQuote()
            entity.brief = answer.brief?.eliminateDoubleQuote()
            entity.icon = "http://static-web.ghzs.com/website-static/images/icon_new_reply.png"
            return entity
        }

        @JvmStatic
        fun transform(article: ArticleEntity): EditorInsertEntity {
            val entity = EditorInsertEntity()
            entity.id = article.id
            entity.communityId = article.bbs.id
            entity.type = "community_article"
            entity.title = article.title.eliminateDoubleQuote()
            entity.brief = article.brief.eliminateDoubleQuote()
            entity.icon = "http://static-web.ghzs.com/website-static/images/icon_new_article.png"
            return entity
        }

        @JvmStatic
        fun transform(game: GameEntity): EditorInsertEntity {
            val entity = EditorInsertEntity()
            entity.id = game.id
            entity.type = "game"
            entity.title = game.name
            entity.tags = game.getTag()
            entity.icon = game.icon
            return entity
        }

        @JvmStatic
        fun transform(game: GamesCollectionEntity): EditorInsertEntity {
            val entity = EditorInsertEntity()
            entity.id = game.id
            entity.type = "game_collection"
            entity.title = game.title
            entity.brief = game.intro
            entity.icon = "https://static-web.ghzs.com/website-static/images/icon_game_collection.png"
            return entity
        }

        @JvmStatic
        fun transform(video: MyVideoEntity): EditorInsertEntity {
            val entity = EditorInsertEntity()
            entity.id = video.id
            entity.type = "video"
            entity.title = video.title
            entity.brief = video.des
            entity.icon = "https://static-web.ghzs.com/website-static/images/icon_video.png"
            return entity
        }
    }
}