Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
pull/537/head
zouap 3 years ago
parent
commit
c851f55952
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      models/star.go

+ 7
- 5
models/star.go View File

@@ -4,12 +4,14 @@

package models

import "code.gitea.io/gitea/modules/timeutil"

// Star represents a starred repo by an user.
type Star struct {
ID int64 `xorm:"pk autoincr"`
UID int64 `xorm:"UNIQUE(s)"`
RepoID int64 `xorm:"UNIQUE(s)"`
CreatedUnix int64 `xorm:"created"`
ID int64 `xorm:"pk autoincr"`
UID int64 `xorm:"UNIQUE(s)"`
RepoID int64 `xorm:"UNIQUE(s)"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
}

// StarRepo or unstar repository.
@@ -40,7 +42,7 @@ func StarRepo(userID, repoID int64, star bool) error {
return nil
}

if _, err := sess.Delete(&Star{0, userID, repoID}); err != nil {
if _, err := sess.Delete(&Star{0, userID, repoID, 0}); err != nil {
return err
}
if _, err := sess.Exec("UPDATE `repository` SET num_stars = num_stars - 1 WHERE id = ?", repoID); err != nil {


Loading…
Cancel
Save