feat:完善项目信息
This commit is contained in:
@ -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