|
|
|
@@ -0,0 +1,50 @@ |
|
|
|
package models |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
|
) |
|
|
|
|
|
|
|
// Follow represents relations of user and his/her followers. |
|
|
|
type Invitation struct { |
|
|
|
ID int64 `xorm:"pk autoincr"` |
|
|
|
SrcUserID int64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
UserID int64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
Phone string `xorm:"NULL"` |
|
|
|
CreatedUnix timeutil.TimeStamp `xorm:"created"` |
|
|
|
} |
|
|
|
|
|
|
|
func QueryInvitaion(start int64, end int64) ([]*Invitation, int) { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
cond := "created_unix >=" + fmt.Sprint(start) + " and created_unix <=" + fmt.Sprint(end) |
|
|
|
|
|
|
|
userList := make([]*Invitation, 0) |
|
|
|
|
|
|
|
if err := statictisSess.Table(new(Invitation)).Where(cond).OrderBy("created_unix desc"). |
|
|
|
Find(&userList); err != nil { |
|
|
|
return nil, 0 |
|
|
|
} |
|
|
|
return userList, len(userList) |
|
|
|
} |
|
|
|
|
|
|
|
func InsertInvitaion(invitationUser *Invitation) { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
statictisSess.Insert(invitationUser) |
|
|
|
} |
|
|
|
|
|
|
|
func QueryInvitaionBySrcUserId(srcUserId int64) ([]*Invitation, int) { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
cond := "src_user_id =" + fmt.Sprint(srcUserId) |
|
|
|
|
|
|
|
userList := make([]*Invitation, 0) |
|
|
|
|
|
|
|
if err := statictisSess.Table(new(Invitation)).Where(cond).OrderBy("created_unix desc"). |
|
|
|
Find(&userList); err != nil { |
|
|
|
return nil, 0 |
|
|
|
} |
|
|
|
return userList, len(userList) |
|
|
|
} |