Finish the delete feature.

This commit is contained in:
lishuang
2020-06-21 00:04:11 +08:00
parent 601c60fca7
commit 3fb1d874d5
14 changed files with 212 additions and 4 deletions

View File

@ -2,8 +2,10 @@ package rest
import (
"github.com/eyebluecn/tank/code/core"
"github.com/eyebluecn/tank/code/tool/builder"
"github.com/eyebluecn/tank/code/tool/i18n"
"github.com/eyebluecn/tank/code/tool/result"
"math"
"net/http"
"strings"
"time"
@ -108,3 +110,25 @@ func (this *ShareService) ValidateMatter(request *http.Request, shareUuid string
}
}
//delete user's shares and corresponding bridges.
func (this *ShareService) DeleteSharesByUser(request *http.Request, currentUser *User) {
//delete share and bridges.
pageSize := 100
var sortArray []builder.OrderPair
count, _ := this.shareDao.PlainPage(0, pageSize, currentUser.Uuid, sortArray)
var totalPages = int(math.Ceil(float64(count) / float64(pageSize)))
var page int
for page = 0; page < totalPages; page++ {
_, shares := this.shareDao.PlainPage(0, pageSize, currentUser.Uuid, sortArray)
for _, share := range shares {
this.bridgeDao.DeleteByShareUuid(share.Uuid)
//delete this share
this.shareDao.Delete(share)
}
}
}