package entity

import (
	"database/sql"
	"time"
)

type NewsChannel struct {
	Id            int64          `json:"id"`
	RssUrl        string         `json:"rss_url"`
	ImageUrl      sql.NullString `json:"image_url"`
	Title         string         `json:"title"`
	Link          sql.NullString `json:"link"`
	Description   sql.NullString `json:"description"`
	Language      sql.NullString `json:"language"`
	Copyright     sql.NullString `json:"copyright"`
	LastBuildDate sql.NullTime   `json:"last_build_date"`
	UpdatedAt     time.Time      `json:"updated_at"`
	CreatedAt     time.Time      `json:"created_at"`
	NewsItems     []*NewsItem
}

func NewNewsChannel(id int64, rssUrl string, imageUrl string,
	title string, link string, description string, language string, copyright string,
	lastBuildDate time.Time, updatedAt time.Time, createdAt time.Time,
) *NewsChannel {
	return &NewsChannel{
		Id:            id,
		RssUrl:        rssUrl,
		ImageUrl:      sql.NullString{String: imageUrl, Valid: true},
		Title:         title,
		Link:          sql.NullString{String: link, Valid: true},
		Description:   sql.NullString{String: description, Valid: true},
		Language:      sql.NullString{String: language, Valid: true},
		Copyright:     sql.NullString{String: copyright, Valid: true},
		LastBuildDate: sql.NullTime{Time: lastBuildDate, Valid: true},
		UpdatedAt:     updatedAt,
		CreatedAt:     createdAt,
	}
}
