improve empty notice (#15890)

This commit is contained in:
Lunny Xiao 2021-05-16 19:58:26 +08:00 committed by GitHub
parent 3a04d6f43f
commit 0bf8d34630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,6 +114,11 @@ func DeleteNotice(id int64) error {
// DeleteNotices deletes all notices with ID from start to end (inclusive). // DeleteNotices deletes all notices with ID from start to end (inclusive).
func DeleteNotices(start, end int64) error { func DeleteNotices(start, end int64) error {
if start == 0 && end == 0 {
_, err := x.Exec("DELETE FROM notice")
return err
}
sess := x.Where("id >= ?", start) sess := x.Where("id >= ?", start)
if end > 0 { if end > 0 {
sess.And("id <= ?", end) sess.And("id <= ?", end)