|
@@ -7,32 +7,46 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-type ActivityList struct {
|
|
|
- ActivityID int `json:"activityId"`
|
|
|
- ActivityName string `json:"activityName"`
|
|
|
- ActivityTypeName string `json:"activityTypeName"`
|
|
|
- StartTime time.Time `json:"startTime"`
|
|
|
- EndTime time.Time `json:"endTime"`
|
|
|
- Speaker string `json:"speaker"`
|
|
|
- HasRemind int `json:"hasRemind"`
|
|
|
- HasPlayBack int `json:"hasPlayBack"`
|
|
|
- Registered int `json:"registered"`
|
|
|
+type ActivityItem struct {
|
|
|
+ ActivityID int `json:"activityId"`
|
|
|
+ ActivityName string `json:"activityName"` // 活动名称
|
|
|
+ ActivityTypeName string `json:"activityTypeName"` // 活动类型名称
|
|
|
+ StartTime time.Time `json:"startTime"` // 活动开始时间
|
|
|
+ EndTime time.Time `json:"endTime"` // 活动结束时间
|
|
|
+ WeekString string `json:"weekString"` // 周几
|
|
|
+ Speaker string `json:"speaker"` // 主讲人
|
|
|
+ HasRemind int `json:"hasRemind"` // 是否已提醒
|
|
|
+ HasPlayBack int `json:"hasPlayBack"` // 是否有回放
|
|
|
+ RegisterState int `json:"registerState"` // 报名状态 0-取消报名 1-已报名
|
|
|
+ City string `json:"city"` // 城市
|
|
|
}
|
|
|
|
|
|
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"` // 报告链接
|
|
|
+ Address string `json:"address"` // 活动地址
|
|
|
+ RegisteredNum int `json:"registeredNum"` // 已报名人数
|
|
|
}
|
|
|
|
|
|
// GetPageListByWhereMap 分页获取列表-关联录音、提醒和报名信息
|
|
|
-func GetPageListByWhereMap(where map[string]interface{}, page, limit int, order string, userId int) (activities []*ActivityList, err error) {
|
|
|
+func GetPageListByWhereMap(where map[string]interface{}, page, limit int, order string, userId int) (activities []*ActivityItem, err error) {
|
|
|
condition, values, buildErr := utils.WhereBuild(where)
|
|
|
if buildErr != nil {
|
|
|
err = errors.New("系统异常,生成查询语句失败")
|
|
|
return
|
|
|
}
|
|
|
fields := []string{
|
|
|
- "a.activity_id", "a.activity_name", "a.activity_type_name", "a.start_time", "a.end_time", "a.speaker",
|
|
|
- "b.activity_voice_id AS has_play_back", "c.id AS has_remind", "d.id AS registered",
|
|
|
+ "a.activity_id", "a.activity_name", "a.activity_type_name", "a.start_time", "a.end_time", "a.speaker", "a.city",
|
|
|
+ "b.activity_voice_id AS has_play_back", "c.id AS has_remind", "d.register_state",
|
|
|
}
|
|
|
queryOrder := "start_time asc"
|
|
|
if order != "" {
|
|
@@ -42,7 +56,7 @@ func GetPageListByWhereMap(where map[string]interface{}, page, limit int, order
|
|
|
Select(fields).
|
|
|
Joins("LEFT JOIN yb_activity_voice AS b ON a.activity_id = b.activity_id").
|
|
|
Joins("LEFT JOIN yb_activity_remind AS c ON a.activity_id = c.activity_id AND c.user_id = ?", userId).
|
|
|
- Joins("LEFT JOIN yb_activity_register AS d ON a.activity_id = d.activity_id AND d.user_id = ?", userId).
|
|
|
+ Joins("LEFT JOIN yb_activity_register AS d ON a.activity_id = d.activity_id AND d.user_id = ? AND d.register_state = ?", userId, 1).
|
|
|
Where(condition, values...).
|
|
|
Order(queryOrder).
|
|
|
Group("activity_id").
|
|
@@ -57,6 +71,20 @@ func GetOneById(activityId int) (activity *YbActivity, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetDetailById() {
|
|
|
-
|
|
|
+// GetDetailByIdWithUserId 根据主键获取活动详情-userId关联信息
|
|
|
+func GetDetailByIdWithUserId(activityId, userId int) (detail *ActivityDetail, err error) {
|
|
|
+ fields := []string{
|
|
|
+ "a.activity_id", "a.activity_name", "a.activity_type_name", "a.start_time", "a.end_time", "a.speaker", "a.city",
|
|
|
+ "a.mainland_tel", "a.hong_kong_tel", "a.taiwan_tel", "a.america_tel", "a.singapore_tel", "a.participation_code",
|
|
|
+ "a.link_participants", "a.is_limit_people", "a.limit_people_num", "a.report_link", "a.address",
|
|
|
+ "b.id AS has_remind", "c.register_state",
|
|
|
+ }
|
|
|
+ err = global.DEFAULT_MYSQL.Table("yb_activity AS a").
|
|
|
+ Select(fields).
|
|
|
+ Joins("LEFT JOIN yb_activity_remind AS b ON a.activity_id = b.activity_id AND b.user_id = ?", userId).
|
|
|
+ Joins("LEFT JOIN yb_activity_register AS c ON a.activity_id = c.activity_id AND c.user_id = ? AND c.register_state = ?", userId, 1).
|
|
|
+ Where("a.activity_id", activityId).
|
|
|
+ Group("activity_id").
|
|
|
+ Scan(&detail).Error
|
|
|
+ return
|
|
|
}
|