package dto

import (
	"go-admin/app/operate/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
	"go-admin/common/utils"
	"time"
)

type OrgAdGetPageReq struct {
	dto.Pagination `search:"-"`
	AdName         string `form:"adName"  search:"type:contains;column:ad_name;table:org_ad"`                 //广告名称
	StartTime      string `form:"startTime"  search:"type:gte;column:created_at;table:org_ad" comment:"开始时间"` //开始时间
	EndTime        string `form:"endTime"  search:"type:lte;column:created_at;table:org_ad" comment:"结束时间"`   //结束时间
	Status         string `form:"status"  search:"type:exact;column:status;table:org_ad"`                     //广告类型
}

type OrgAdOrder struct {
	Id        int       `form:"idOrder"  search:"type:order;column:id;table:org_ad"`
	UserId    string    `form:"userIdOrder"  search:"type:order;column:user_id;table:org_ad"`
	AdName    string    `form:"adNameOrder"  search:"type:order;column:ad_name;table:org_ad"`
	AdType    string    `form:"adTypeOrder"  search:"type:order;column:ad_type;table:org_ad"`
	AdImg     string    `form:"adImgOrder"  search:"type:order;column:ad_img;table:org_ad"`
	AdUrl     string    `form:"adUrlOrder"  search:"type:order;column:ad_url;table:org_ad"`
	Status    string    `form:"statusOrder"  search:"type:order;column:status;table:org_ad"`
	StartTime time.Time `form:"startTimeOrder"  search:"type:order;column:start_time;table:org_ad"`
	EndTime   time.Time `form:"endTimeOrder"  search:"type:order;column:end_time;table:org_ad"`
	CreateBy  string    `form:"createByOrder"  search:"type:order;column:create_by;table:org_ad"`
	UpdateBy  string    `form:"updateByOrder"  search:"type:order;column:update_by;table:org_ad"`
	CreatedAt time.Time `form:"createdAtOrder"  search:"type:order;column:created_at;table:org_ad"`
	UpdatedAt time.Time `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:org_ad"`
	DeletedAt time.Time `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:org_ad"`
}

func (m *OrgAdGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type OrgAdInsertReq struct {
	Id        int    `json:"-" comment:""` //
	UserId    string `json:"userId" comment:"sys_user表id"`
	AdName    string `json:"adName" comment:"广告名称"`
	AdType    string `json:"adType" comment:"类型"`
	AdImg     string `json:"adImg" comment:"广告图"`
	AdUrl     string `json:"adUrl" comment:"链接地址"`
	Status    string `json:"status" comment:"广告状态 1 开启 0关闭"`
	StartTime string `json:"startTime" comment:"广告有效期 开始时间"`
	EndTime   string `json:"endTime" comment:"广告有效期 结束时间"`
	common.ControlBy
}

func (s *OrgAdInsertReq) Generate(model *models.OrgAd) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.UserId = s.UserId
	model.AdName = s.AdName
	model.AdType = s.AdType
	model.AdImg = s.AdImg
	model.AdUrl = s.AdUrl
	model.Status = s.Status
	model.StartTime = utils.StringToTime(s.StartTime)
	model.EndTime = utils.StringToTime(s.EndTime)
}

func (s *OrgAdInsertReq) GetId() interface{} {
	return s.Id
}

type OrgAdUpdateReq struct {
	Id        int    `uri:"id" comment:""` //
	UserId    string `json:"userId" comment:"sys_user表id"`
	AdName    string `json:"adName" comment:"广告名称"`
	AdType    string `json:"adType" comment:"类型"`
	AdImg     string `json:"adImg" comment:"广告图"`
	AdUrl     string `json:"adUrl" comment:"链接地址"`
	Status    string `json:"status" comment:"广告状态 1 开启 0关闭"`
	StartTime string `json:"startTime" comment:"广告有效期 开始时间"`
	EndTime   string `json:"endTime" comment:"广告有效期 结束时间"`
	common.ControlBy
}

func (s *OrgAdUpdateReq) Generate(model *models.OrgAd) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.UserId = s.UserId
	model.AdName = s.AdName
	model.AdType = s.AdType
	model.AdImg = s.AdImg
	model.AdUrl = s.AdUrl
	model.Status = s.Status
	model.StartTime = utils.StringToTime(s.StartTime)
	model.EndTime = utils.StringToTime(s.EndTime)
}

func (s *OrgAdUpdateReq) GetId() interface{} {
	return s.Id
}

// OrgAdGetReq 功能获取请求参数
type OrgAdGetReq struct {
	Id int `uri:"id"`
}

func (s *OrgAdGetReq) GetId() interface{} {
	return s.Id
}

// OrgAdDeleteReq 功能删除请求参数
type OrgAdDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *OrgAdDeleteReq) GetId() interface{} {
	return s.Ids
}
