package dto

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

type OrgNewsGetPageReq struct {
	dto.Pagination `search:"-"`
	NewsName       string `form:"newsName"  search:"type:contains;column:news_name;table:org_news"`             //新闻名称
	StartTime      string `form:"startTime"  search:"type:gte;column:created_at;table:org_news" comment:"开始时间"` //开始时间
	EndTime        string `form:"endTime"  search:"type:lte;column:created_at;table:org_news" comment:"结束时间"`   //结束时间
	Status         string `form:"status"  search:"type:exact;column:status;table:org_news"`                     //新闻状态
}

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

type OrgNewsInsertReq struct {
	Id          int    `json:"-" comment:""` //
	NewsName    string `json:"newsName" comment:""`
	NewsTitle   string `json:"newsTitle" comment:""`
	NewsContent string `json:"newsContent" comment:""`
	NewsImg     string `json:"newsImg" comment:""`
	Status      string `json:"status" comment:""`
	common.ControlBy
}

func (s *OrgNewsInsertReq) Generate(model *models.OrgNews) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.NewsName = s.NewsName
	model.NewsTitle = s.NewsTitle
	model.NewsContent = s.NewsContent
	model.NewsImg = s.NewsImg
	model.Status = s.Status
}

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

type OrgNewsUpdateReq struct {
	Id          int    `uri:"id" comment:""` //
	NewsName    string `json:"newsName" comment:""`
	NewsTitle   string `json:"newsTitle" comment:""`
	NewsContent string `json:"newsContent" comment:""`
	NewsImg     string `json:"newsImg" comment:""`
	Status      string `json:"status" comment:""`
	common.ControlBy
}

func (s *OrgNewsUpdateReq) Generate(model *models.OrgNews) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.NewsName = s.NewsName
	model.NewsTitle = s.NewsTitle
	model.NewsContent = s.NewsContent
	model.NewsImg = s.NewsImg
	model.Status = s.Status
}

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

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

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

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

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