import { environment } from "src/environments/environment"
import { TagModel } from "./tag.mmodel"
import { GroupModel } from "./group.mmodel"

export interface DocumentContentModel {
    docId: string
    thName: string
    engName: string
    thDesc: string
    engDesc: string
    thumbnail: string
    link1: string
    langSupport: string
    thDocObj: string
    engDocObj: string
    uploadBy: string
    uploadDate: string
    uploadTime: string
    dwTime: number
    downloadDate: string
    downloadTime: string
    remark: string
    referId: string
    approveBy: string
    approveDate: string
    approveTime: string
    tags: TagModel[]
    group: GroupModel
}

export class DocumentContentModel implements DocumentContentModel {
    docId: string
    thName: string
    engName: string
    thDesc: string
    engDesc: string
    thumbnail: string
    link1: string
    langSupport: string
    thDocObj: string
    engDocObj: string
    uploadBy: string
    uploadDate: string
    uploadTime: string
    dwTime: number
    downloadDate: string
    downloadTime: string
    remark: string
    referId: string
    approveBy: string
    approveDate: string
    approveTime: string
    tags: TagModel[]
    group: GroupModel
    constructor(data: Partial<any>) {
        this.docId = data.docId?data.docId:''
        this.thumbnail = data.thumbnail?data.thumbnail:''
        this.link1 = data.link1?data.link1:''
        this.langSupport = data.langSupport?data.langSupport:''
        this.thDocObj = data.thDocObj?data.thDocObj:''
        this.engDocObj = data.engDocObj?data.engDocObj:''
        this.uploadBy = data.uploadBy?data.uploadBy:''
        this.remark = data.remark?data.remark:''
        this.dwTime = data.dwTime?data.dwTime:0
        this.approveBy = data.approveBy?data.approveBy:''
        this.thName = data.thName?data.thName:''
        this.engName = data.engName?data.engName:''
        this.thDesc = data.thDesc?data.thDesc:''
        this.engDesc = data.engDesc?data.engDesc:''
        this.referId = data.referId?data.referId:''
        this.tags = data.tags?data.tags:[]
        this.uploadDate = data.uploadDate?data.uploadDate:''
        this.uploadTime = data.uploadTime?data.uploadTime:''
        this.downloadDate = data.downloadDate?data.downloadDate:''
        this.downloadTime = data.downloadTime?data.downloadTime:''
        this.approveDate = data.approveDate?data.approveDate:''
        this.approveTime = data.approveTime?data.approveTime:''
        this.group = data.group?new GroupModel(data.group):new GroupModel({})
   
    }
    getImage(){
        if(this.thumbnail){
            return environment.url+"files/image/"+this.thumbnail
        }else{
            return 'assets/images/big/auth-bg.jpg'
        }
    }
}