package cygx

import (
	"github.com/beego/beego/v2/client/orm"
)

type ActivityType struct {
	ActivityTypeId   int    `description:"活动类型id"`
	ActivityTypeName string `description:"活动类型名称"`
	TemplateP        string `description:"活动模板，带P标签"`
	Template         string `description:"活动模板"`
	ZoomTemplateP    string `description:"Zoom活动模板，带P标签"`
	ZoomTemplate     string `description:"Zoom活动模板"`
	ShowType         string `description:"人数限制类型，1不展示限制，2可选限制，3强制限制"`
}

type ActivityTypeListResp struct {
	List          []*ActivityType
	IsShowAddIcon bool `description:"是否展示加号图标"`
}

// 列表
func GetActivityTypeList() (items []*ActivityType, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT * FROM cygx_activity_type ORDER BY sort DESC`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}

func GetActivityTypeDetailById(activityTypeId int) (item *ActivityType, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT * FROM cygx_activity_type WHERE activity_type_id = ? `
	err = o.Raw(sql, activityTypeId).QueryRow(&item)
	return
}

// 列表
func GetActivityTypeSearchList(condition string) (items []*ActivityType, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT * FROM cygx_activity_type WHERE 1= 1  ` + condition + `  ORDER BY sort DESC`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}
