package Sp

import (
	"encoding/json"
	"src/Common/Request"
	"src/Config"
	"unsafe"
)

type MediaListModel struct {
	Config *Config.Config
}

type checkReqJson struct {
	Spid string `json:"spid"`
	Start string `json:"start"`
	End string `json:"end"`
}
type checkRespJson struct {
	Total	int	`json:"total"`
	PageNum	int	`json:"page_num"`
}



type pushReqJson struct {
	Spid string `json:"spid"`
	Start string `json:"start"`
	End string `json:"end"`
	Page int `json:"page"`
	PageNum int `json:"page_num"`
	Url string `json:"url"`
	Key string `json:"key"`

}
type pushRespJson struct {
	Code int `json:"code"`
	Msg string `json:"msg"`
}


//检查
func (this *MediaListModel) check(reqJson *checkReqJson) (*checkRespJson,error) {
	center_api_incrementCheck, ok := this.Config.Sys.Get("center_api_incrementCheck")
	resp:=new(checkRespJson)
	var err error
	if ok {
		jsonBody,_:=json.Marshal(reqJson)
		data, err1 := Request.Post(center_api_incrementCheck.(string),*(*string)(unsafe.Pointer(&jsonBody)))
		if err1 == nil {
			err = json.Unmarshal([]byte(data), resp)
		}else{
			err=err1
		}
	}

	return resp,err
}
//推送
func (this *MediaListModel) push(reqJson *pushReqJson) (*pushRespJson,error) {
	center_api_incrementPush, ok := this.Config.Sys.Get("center_api_incrementPush")
	resp:=new(pushRespJson)
	var err error
	if ok {
		jsonBody,_:=json.Marshal(reqJson)
		data, err1 := Request.Post(center_api_incrementPush.(string),*(*string)(unsafe.Pointer(&jsonBody)))
		if err1 == nil {
			err = json.Unmarshal([]byte(data), resp)
		}else{
			err=err1
		}
	}

	return resp,err
}




//type Media struct {
//	Id 	string 	`json:"id"`
//	Title string `json:"title"`
//	Description string	`json:"description"`
//	PlayUrl	string	`json:"playUrl"`
//	PicUrl	string `json:"picUrl"`
//	Year	string	`json:"year"`
//	Type 	string	`json:"type"`
//	Score	string	`json:"score"`
//	Region 	string	`json:"region"`
//	Actor	string	`json:"actor"`
//	Director	string `json:"director"`
//	HotelId	string 	`json:"hotelId"`
//	Status 	string	`json:"status"`
//	StatusInject string `json:"statusInject"`
//}