feat:完善项目信息
This commit is contained in:
@ -18,8 +18,7 @@ func (*Activity) Applys(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).
|
||||
List(form.Title, form.Page, form.PageSize)
|
||||
data, err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise)).Instance(form.Title, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -39,11 +38,10 @@ func (*Activity) ApplyLaunch(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).
|
||||
Launch(&activity.ApplyLaunchParams{
|
||||
Mode: form.Mode, MaxNUmber: form.MaxNumber, Title: form.Title, Amount: form.Amount, Content: form.Content,
|
||||
BeginAt: form.BeginAt, FinishAt: form.FinishAt, JoinDeadline: form.JoinDeadline,
|
||||
})
|
||||
err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise)).Launch(&activity.ApplyLaunchParams{
|
||||
Mode: form.Mode, MaxNUmber: form.MaxNumber, Title: form.Title, Amount: form.Amount, Content: form.Content,
|
||||
BeginAt: form.BeginAt, FinishAt: form.FinishAt, JoinDeadline: form.JoinDeadline,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
@ -54,8 +52,7 @@ func (*Activity) ApplyRevoke(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).
|
||||
Revoke(form.Convert())
|
||||
err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise)).Revoke(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
@ -66,8 +63,7 @@ func (*Activity) ApplyDelete(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).
|
||||
Delete(form.Convert())
|
||||
err := activity.NewApply()(api.GetSession()(c).(*session.Enterprise)).Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
@ -81,8 +77,7 @@ func (*Activity) Joins(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := activity.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).
|
||||
Joins(form.Title, form.Status, form.Page, form.PageSize)
|
||||
data, err := activity.NewInstance()(api.GetSession()(c).(*session.Enterprise)).Joins(form.Title, form.Status, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
@ -93,7 +88,6 @@ func (*Activity) JoinDelete(c *gin.Context) {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := activity.NewInstance()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(string)).
|
||||
JoinDelete(form.Convert())
|
||||
err := activity.NewInstance()(api.GetSession()(c).(*session.Enterprise)).JoinDelete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
@ -12,10 +12,9 @@ import (
|
||||
|
||||
type Apply struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type ApplyHandle func(session *session.Enterprise, local string) *Apply
|
||||
type ApplyHandle func(session *session.Enterprise) *Apply
|
||||
|
||||
type (
|
||||
// ApplyLaunchParams 参数信息
|
||||
@ -28,18 +27,18 @@ type (
|
||||
)
|
||||
|
||||
// List 列表信息
|
||||
func (c *Apply) List(title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
func (c *Apply) Instance(title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
|
||||
out := make([]*model2.ActivityApply, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("local", c.local),
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("identity_uid", c.IdentityUID),
|
||||
Where: model2.NewWhere("identity", c.SelectIdentity),
|
||||
},
|
||||
}
|
||||
if title != "" {
|
||||
@ -79,7 +78,7 @@ func (c *Apply) Revoke(id uint64) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "identity_uid", "status"})
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "uid", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -88,7 +87,7 @@ func (c *Apply) Revoke(id uint64) error {
|
||||
} else if mActivityApply.Status != model2.ActivityApplyStatusForProcessing {
|
||||
return errors.New("操作错误,当前活动状态易发生变化,不可撤销")
|
||||
} else if mActivityApply.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Updates(mActivityApply.ActivityApply, map[string]interface{}{
|
||||
"status": model2.ActivityApplyStatusForRevoke, "updated_at": time.Now(),
|
||||
@ -100,23 +99,20 @@ func (c *Apply) Delete(id uint64) error {
|
||||
mActivityApply := model.NewActivityApply()
|
||||
mActivityApply.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "identity_uid"})
|
||||
isExist, err := model2.FirstField(mActivityApply.ActivityApply, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,活动信息不存在或已被删除")
|
||||
} else if mActivityApply.UID != c.IdentityUID {
|
||||
return errors.New("无权限操作")
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
return model2.Delete(mActivityApply.ActivityApply)
|
||||
}
|
||||
|
||||
func NewApply() ApplyHandle {
|
||||
return func(session *session.Enterprise, local string) *Apply {
|
||||
return &Apply{
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
}
|
||||
return func(session *session.Enterprise) *Apply {
|
||||
return &Apply{session}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,9 @@ import (
|
||||
|
||||
type Instance struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
}
|
||||
|
||||
type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
type InstanceHandle func(session *session.Enterprise) *Instance
|
||||
|
||||
type InstanceForJoin struct {
|
||||
*model.ActivityInstanceJoinInfo
|
||||
@ -25,9 +24,8 @@ func (c *Instance) Joins(title string, status, page, pageSize int) (*controller.
|
||||
mActivityInstance := model.NewActivityInstance()
|
||||
|
||||
where := []*model2.ModelWhere{
|
||||
model2.NewWhere("a.local", c.local),
|
||||
model2.NewWhere("a.identity", c.Identity),
|
||||
model2.NewWhere("j.m_uid", c.UID),
|
||||
model2.NewWhere("j.identity", c.SelectIdentity),
|
||||
model2.NewWhere("j.uid", c.UID),
|
||||
}
|
||||
|
||||
if title != "" {
|
||||
@ -73,7 +71,7 @@ func (c *Instance) JoinDelete(id uint64) error {
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
return func(session *session.Enterprise, local string) *Instance {
|
||||
return &Instance{Enterprise: session, local: local}
|
||||
return func(session *session.Enterprise) *Instance {
|
||||
return &Instance{Enterprise: session}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user