package roadshow

import (
	"github.com/beego/beego/v2/client/orm"
	"hongze/hongze_cygx/utils"
	"time"
)

type RsCalendar struct {
	RsCalendarId     int    `orm:"column(rs_calendar_id);pk"`
	SysUserId        int    `description:"创建人id"`
	SysUserRealName  string `description:"创建人名称"`
	ActivityType     string `description:"活动类型"`
	RoadshowType     string `description:"路演形式"`
	RoadshowPlatform string `description:"路演平台"`
	CompanyId        int    `description:"客户id"`
	CompanyName      string `description:"客户名称"`
	Province         string `description:"省"`
	ProvinceCode     string `description:"省编码"`
	City             string `description:"市"`
	CityCode         string `description:"市编码"`
	District         string `description:"区"`
	Theme            string `description:"会议主题"`
	CooperationName  string `description:"合作方名称"`
	Title            string `description:"展示在日历的标题"`
	Source           int8   `description:"来源，0：自系统，1：上海方的"`
	CreateTime       time.Time
	ModifyTime       time.Time
	ActivityCategory string `description:"活动类别"`
	IsSynced         int    `description:"是否与上海同步 0:未同步 1:已同步"`
	UnionCode        string `description:"公开会议联合编码"`
	EnglishCompany   int    `description:"是否为英文客户: 0-否; 1-是"`
	SellerId         int    `description:"销售id"`
	ShareSellerId    int    `description:"共享销售员id"`
}

func GetRsCalendarById(rsCalendarId int) (item *RsCalendar, err error) {
	o := orm.NewOrmUsingDB("weekly_report")
	sql := `SELECT * FROM rs_calendar WHERE rs_calendar_id=? `
	err = o.Raw(sql, rsCalendarId).QueryRow(&item)
	return
}

// 列表
func GetRsCalendarListInit(rsCalendarId []int) (items []*RsCalendar, err error) {
	o := orm.NewOrmUsingDB("weekly_report")
	sql := `SELECT
    		*
	FROM rs_calendar as  art 
         WHERE 1=1  AND  rs_calendar_id IN  (` + utils.GetOrmInReplace(len(rsCalendarId)) + `)  `
	_, err = o.Raw(sql, rsCalendarId).QueryRows(&items)
	return
}
