feat:完善项目信息

This commit is contained in:
henry
2022-01-13 17:48:41 +08:00
parent 4637a5fb4b
commit 27cb063a6c
11 changed files with 85 additions and 79 deletions

View File

@ -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}
}
}