Refactor code

pull/141/head
wenxu12345 3 years ago
parent 4c3474a9f7
commit 99a8eaea91

@ -76,6 +76,14 @@ func InsertFriendApplication(friendRequest *db.FriendRequest) error {
if err != nil {
return err
}
friendRequest.CreateTime = time.Now()
u := dbConn.Table("friend_requests").Where("from_user_id=? and to_user_id=?",
friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest)
if u.RowsAffected != 0 {
return nil
}
if friendRequest.CreateTime.Unix() < 0 {
friendRequest.CreateTime = time.Now()
}

@ -36,6 +36,14 @@ func InsertIntoGroupRequest(toInsertInfo db.GroupRequest) error {
return err
}
if toInsertInfo.HandledTime.Unix() < 0 {
toInsertInfo.HandledTime = utils.UnixSecondToTime(0)
}
u := dbConn.Table("group_requests").Where("group_id=? and user_id=?", toInsertInfo.GroupID, toInsertInfo.UserID).Update(&toInsertInfo)
if u.RowsAffected != 0 {
return nil
}
toInsertInfo.ReqTime = time.Now()
if toInsertInfo.HandledTime.Unix() < 0 {
toInsertInfo.HandledTime = utils.UnixSecondToTime(0)

Loading…
Cancel
Save