support hide/unhide account

This commit is contained in:
MaysWind
2020-11-14 14:11:36 +08:00
parent c2a7b3d686
commit d8424b8848
8 changed files with 105 additions and 3 deletions
+23
View File
@@ -122,6 +122,29 @@ func (s *AccountService) CreateAccounts(mainAccount *models.Account, childrenAcc
})
}
func (s *AccountService) HideAccount(uid int64, ids []int64, hidden bool) error {
if uid <= 0 {
return errs.ErrUserIdInvalid
}
now := time.Now().Unix()
updateModel := &models.Account{
Hidden: hidden,
UpdatedUnixTime: now,
}
return s.UserDataDB(uid).DoTransaction(func(sess *xorm.Session) error {
deletedRows, err := sess.Cols("hidden", "updated_unix_time").In("account_id", ids).Where("uid=? AND deleted=?", uid, false).Update(updateModel)
if deletedRows < 1 {
return errs.ErrAccountNotFound
}
return err
})
}
func (s *AccountService) ModifyAccountDisplayOrders(uid int64, accounts []*models.Account) error {
if uid <= 0 {
return errs.ErrUserIdInvalid