Add statistics.

This commit is contained in:
2025-05-13 18:59:23 +08:00
parent f1345f9a0c
commit 12c1e0e413
8 changed files with 98 additions and 28 deletions

View File

@@ -379,6 +379,7 @@ func DownloadFile(fid string) (string, string, error) {
if file.StorageID == nil {
if file.RedirectUrl != "" {
_ = dao.AddResourceDownloadCount(file.ResourceID)
return file.RedirectUrl, file.Filename, nil
}
return "", "", model.NewRequestError("file is not available")
@@ -396,5 +397,7 @@ func DownloadFile(fid string) (string, string, error) {
path, err := iStorage.Download(file.StorageKey, file.Filename)
_ = dao.AddResourceDownloadCount(file.ResourceID)
return path, file.Filename, err
}

View File

@@ -56,6 +56,7 @@ func CreateResource(uid uint, params *ResourceCreateParams) (uint, error) {
func GetResource(id uint) (*model.ResourceDetailView, error) {
r, err := dao.GetResourceByID(id)
_ = dao.AddResourceViewCount(id)
if err != nil {
return nil, err
}