feat:完善网站活动报名信息
This commit is contained in:
@ -4,7 +4,9 @@ import (
|
|||||||
"SciencesServer/app/api/website/model"
|
"SciencesServer/app/api/website/model"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/service"
|
||||||
"SciencesServer/app/session"
|
"SciencesServer/app/session"
|
||||||
|
"SciencesServer/config"
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -101,10 +103,23 @@ func (c *Activity) Join(id uint64) error {
|
|||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !mActivityInstance.IsCanJoin() {
|
if !mActivityInstance.IsCanJoin() {
|
||||||
return errors.New("操作错误,当前活动信息不可报名")
|
return errors.New("操作错误,当前活动信息不可报名")
|
||||||
}
|
}
|
||||||
|
// 查看当前活动是否报名
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
if err = model2.Count(model.NewActivityJoin().ActivityJoin, &count, model2.NewWhere("identity_id", c.IdentityUID),
|
||||||
|
model2.NewWhere("activity_id", id), model2.NewWhere("status", model2.ActivityJoinStatusForSuccess)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if count > 0 {
|
||||||
|
return errors.New("操作错误,不可重复报名")
|
||||||
|
}
|
||||||
|
if mActivityInstance.Mode == model2.ActivityInstanceModeForOrdinary {
|
||||||
|
service.Publish(config.EventForActivityJoinProduce, c.IdentityUID, c.UID)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
app/api/website/model/activity_join.go
Normal file
11
app/api/website/model/activity_join.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type ActivityJoin struct {
|
||||||
|
*model.ActivityJoin
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewActivityJoin() *ActivityJoin {
|
||||||
|
return &ActivityJoin{model.NewActivityJoin()}
|
||||||
|
}
|
31
app/common/model/sys_navigation.go
Normal file
31
app/common/model/sys_navigation.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// SysNavigation 自定义导航栏数据模型
|
||||||
|
type SysNavigation struct {
|
||||||
|
Model
|
||||||
|
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"parent_id"`
|
||||||
|
Title string `gorm:"column:title;type:varchar(20);default:'';comment:区域名称" json:"title"`
|
||||||
|
Link string `gorm:"column:link;type:varchar(255);default:'';comment:访问地址" json:"link"`
|
||||||
|
Sort int `gorm:"column:sort;type:tinyint(3);default:0;comment:排序,从大到小" json:"-"`
|
||||||
|
Status SysNavigationStatus `gorm:"column:status;type:tinyint(1);default:1;comment:状态" json:"-"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysNavigationStatus 显示状态
|
||||||
|
type SysNavigationStatus int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// SysNavigationStatusForShow 显示
|
||||||
|
SysNavigationStatusForShow SysNavigationStatus = iota + 1
|
||||||
|
// SysNavigationStatusForHidden 隐藏
|
||||||
|
SysNavigationStatusForHidden
|
||||||
|
)
|
||||||
|
|
||||||
|
func (m *SysNavigation) TableName() string {
|
||||||
|
return "sys_navigation"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSysNavigation() *SysNavigation {
|
||||||
|
return &SysNavigation{}
|
||||||
|
}
|
17
app/event/activity.go
Normal file
17
app/event/activity.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type ActivityJoin struct{}
|
||||||
|
|
||||||
|
func (*ActivityJoin) Handle(arg ...interface{}) {
|
||||||
|
_ = model.Create(&model.ActivityJoin{
|
||||||
|
IdentityUID: arg[0].(uint64),
|
||||||
|
ActivityID: arg[1].(uint64),
|
||||||
|
Status: model.ActivityJoinStatusForSuccess,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewActivityJoin() *ActivityJoin {
|
||||||
|
return &ActivityJoin{}
|
||||||
|
}
|
@ -21,6 +21,8 @@ func Init() {
|
|||||||
service.Subscribe(config.EventForSysLogProduce, event.NewSysLogProduce())
|
service.Subscribe(config.EventForSysLogProduce, event.NewSysLogProduce())
|
||||||
// 消耗录入监听
|
// 消耗录入监听
|
||||||
service.Subscribe(config.EventForConsumeProduce, event.NewConsume())
|
service.Subscribe(config.EventForConsumeProduce, event.NewConsume())
|
||||||
|
// 活动加入监听
|
||||||
|
service.Subscribe(config.EventForActivityJoinProduce, event.NewActivityJoin())
|
||||||
// 开启权限
|
// 开启权限
|
||||||
service.NewAuth().Register()(config.SettingInfo.Engine.DBMode, orm.GetDB(), model.NewSysAuthRule().TableName())
|
service.NewAuth().Register()(config.SettingInfo.Engine.DBMode, orm.GetDB(), model.NewSysAuthRule().TableName())
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ const (
|
|||||||
EventForAccountLoginProduce string = "account_login_produce"
|
EventForAccountLoginProduce string = "account_login_produce"
|
||||||
EventForSysLogProduce string = "sys_log_produce"
|
EventForSysLogProduce string = "sys_log_produce"
|
||||||
EventForConsumeProduce string = "consume_produce"
|
EventForConsumeProduce string = "consume_produce"
|
||||||
|
EventForActivityJoinProduce string = "activity_join_produce"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Reference in New Issue
Block a user