123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package yb_activity
- import (
- "hongze/hongze_yb/global"
- "time"
- )
- type ActivityItem struct {
- ActivityID int `json:"activityId"`
- FirstActivityTypeID int `json:"firstActivityTypeId"` // 第一级的活动类型ID
- FirstActivityTypeName string `json:"firstActivityTypeName"` // 第一级的活动类型名称
- ActivityName string `json:"activityName"` // 活动名称
- ActivityTypeID int `json:"activityTypeId"` // 活动类型ID
- ActivityTypeName string `json:"activityTypeName"` // 活动类型名称
- StartTime time.Time `json:"startTime"` // 活动开始时间
- EndTime time.Time `json:"endTime"` // 活动结束时间
- Speaker string `json:"speaker"` // 主讲人
- SpeakerHeadPic string `json:"speakerHeadPic"` // 主讲人头像
- SpeakerBackgroundPic string `json:"speakerBackgroundPic"` // 主讲人背景图
- City string `json:"city"` // 城市
- WeekString string `json:"weekString"` // 周几
- HasRemind int `json:"hasRemind"` // 是否已提醒
- HasPlayBack int `json:"hasPlayBack"` // 是否有回放
- RegisterState int `json:"registerState"` // 报名状态 0-取消报名 1-已报名
- ActivityState int `json:"activityState"` // 活动状态 1-本周预告 2-进行中 3-已结束
- }
- type ActivityDetail struct {
- ActivityItem
- MainlandTel string `json:"mainlandTel"` // 大陆拨入
- HongKongTel string `json:"hongKongTel"` // 香港拨入
- TaiwanTel string `json:"taiwanTel"` // 台湾拨入
- AmericaTel string `json:"americaTel"` // 美国拨入
- SingaporeTel string `json:"singaporeTel"` // 新加坡拨入
- ParticipationCode string `json:"participationCode"` // 参会密码
- LinkParticipants string `json:"linkParticipants"` // 参会链接
- IsLimitPeople int8 `json:"isLimitPeople"` // 是否限制人数 1是,0否
- LimitPeopleNum int `json:"limitPeopleNum"` // 限制人数数量
- ReportLink string `json:"reportLink"` // 报告链接
- ReportName string `json:"reportName"` // 报告名称
- Address string `json:"address"` // 活动地址
- RegisteredNum int `json:"registeredNum"` // 已报名人数
- ReportId int `json:"report_id"` // 报告ID
- IsNewReport int `json:"is_new_report"` // 是否关联新报告
- }
- // GetPageListByWhere 分页获取活动列表
- func GetPageListByWhere(condition string, pars []interface{}, page, limit int, order string, userId int) (activities []ActivityItem, err error) {
- fields := []string{
- "activity_id", "activity_name", "activity_type_id", "activity_type_name", "start_time", "end_time", "speaker",
- "city", "speaker_head_pic", "speaker_background_pic", "first_activity_type_id", "first_activity_type_name",
- }
- queryOrder := "start_time asc"
- if order != "" {
- queryOrder = order
- }
- err = global.DEFAULT_MYSQL.Model(YbActivity{}).Select(fields).Where(condition, pars...).Order(queryOrder).Limit(limit).Offset((page - 1) * limit).Scan(&activities).Error
- return
- }
- // GetDetailById 根据主键获取详情
- func GetDetailById(activityId int) (activity *ActivityDetail, err error) {
- fields := []string{
- "activity_id", "activity_name", "activity_type_id", "activity_type_name", "start_time", "end_time", "speaker", "city", "speaker_head_pic", "speaker_background_pic",
- "mainland_tel", "hong_kong_tel", "taiwan_tel", "america_tel", "singapore_tel", "participation_code", "report_id", "is_new_report",
- "link_participants", "is_limit_people", "limit_people_num", "report_link", "report_name", "address", "first_activity_type_id", "first_activity_type_name",
- }
- err = global.DEFAULT_MYSQL.Model(YbActivity{}).Select(fields).Where("activity_id", activityId).Scan(&activity).Error
- return
- }
- // GetOneById 根据主键获取活动
- func GetOneById(activityId int) (activity *YbActivity, err error) {
- err = global.DEFAULT_MYSQL.Where("activity_id = ?", activityId).First(&activity).Error
- return
- }
- // GetActivityByIDsAndDate 根据时间和活动ID筛选出合适的记录
- func GetActivityByIDsAndDate(ids []int, publishTime string) (list []*YbActivity, err error) {
- err = global.DEFAULT_MYSQL.Model(YbActivity{}).
- Select("DISTINCT activity_id").
- Where("activity_id in (?) and publish_status = 1 and create_time > ? and is_delete = 0", ids, publishTime).Scan(&list).Error
- return
- }
- // GetLatestByIds 获取最新的活动
- func GetLatestByIds(activityids []int) (activity *YbActivity, err error) {
- err = global.DEFAULT_MYSQL.Model(YbActivity{}).Where("activity_id in (?) and is_delete = 0 and publish_status = 1", activityids).Order("create_time desc").First(&activity).Error
- return
- }
- // GetListByIds 分页查询活动列表
- func GetListByIds(activityids []int, offset, limit int) (activitys []*YbActivity, err error) {
- err = global.DEFAULT_MYSQL.Model(YbActivity{}).
- Where("activity_id in (?) and is_delete = 0 and publish_status = 1", activityids).
- Order("create_time desc").
- Offset(offset).
- Limit(limit).
- Scan(&activitys).Error
- return
- }
- // GetListCountByIds 查询活动列表总数
- func GetListCountByIds(activityIds []int) (total int64, err error) {
- err = global.DEFAULT_MYSQL.Model(YbActivity{}).
- Where("activity_id in (?) and is_delete = 0 and publish_status = 1", activityIds).
- Count(&total).Error
- return
- }
- // GetLatestActivity 获取最新的活动
- func GetLatestActivity() (activity *YbActivity, err error) {
- err = global.DEFAULT_MYSQL.Model(YbActivity{}).Where("is_delete = 0 and publish_status = 1").Order("create_time desc").First(&activity).Error
- return
- }
|