feat:优化项目信息
This commit is contained in:
@ -33,10 +33,11 @@ func WithShelfSessionEnterprise(session *session.Enterprise) ShelfOption {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Shelf) Handle(iModel model.IModel, id uint64) error {
|
||||
func (c *Shelf) Handle(iModel model.IModel, id uint64, callback func(kind model.ShelfStatusKind) error) error {
|
||||
if c.Admin == nil && c.Enterprise == nil {
|
||||
return errors.New("操作错误,未知的人员操作")
|
||||
}
|
||||
iModel.SetID(id)
|
||||
out := new(IModelInfo)
|
||||
|
||||
err := model.ScanFields(iModel, out, []string{"id", "tenant_id", "uid", "shelf_status"},
|
||||
@ -57,14 +58,22 @@ func (c *Shelf) Handle(iModel model.IModel, id uint64) error {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
}
|
||||
shelfStatus := model.ShelfStatusForUp
|
||||
|
||||
if out.ShelfStatus == model.ShelfStatusForUp {
|
||||
shelfStatus = model.ShelfStatusForDown
|
||||
}
|
||||
values := map[string]interface{}{
|
||||
"shelf_status": model.ShelfStatusForUp,
|
||||
"shelf_status": shelfStatus,
|
||||
"updated_at": time.Now(),
|
||||
}
|
||||
if out.ShelfStatus == model.ShelfStatusForUp {
|
||||
values["shelf_status"] = model.ShelfStatusForDown
|
||||
if err := model.Updates(iModel, values); err != nil {
|
||||
return err
|
||||
}
|
||||
return model.Updates(iModel, values)
|
||||
if callback != nil {
|
||||
return callback(shelfStatus)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewShelf(options ...ShelfOption) *Shelf {
|
||||
|
Reference in New Issue
Block a user