v0.0.33 Уведомления о лайках
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
admin 2025-09-18 00:55:57 +03:00
parent 59220f4e43
commit ecf62c7346
2 changed files with 17 additions and 9 deletions

View File

@ -132,7 +132,7 @@ func main() {
userService := service.NewUserService(userRepo)
postService := service.NewPostService(postRepo)
commentService := service.NewCommentService(commentRepo, postRepo)
likeService := service.NewLikeService(likeRepo, postRepo)
likeService := service.NewLikeService(likeRepo, postRepo, userRepo)
auditService := service.NewAuditService(auditRepo)
recoveryService := service.NewRecoveryService(recoveryRepo, userRepo, sessionRepo, deviceRepo, mailService)
sessionService := service.NewSessionService(sessionRepo, deviceRepo, userRepo, mailService)

View File

@ -49,25 +49,33 @@ type Like struct {
}
type LikeNotification struct {
ID int `json:"id"`
LikerID int `json:"-"` // Для внутреннего использования
Liker *User `json:"liker"` // Для GraphQL
PostID int `json:"-"` // Для внутреннего использования
Post *Post `json:"post"` // Для GraphQL
IsRead bool `json:"isRead"`
CreatedAt time.Time `json:"-"`
CreatedAtStr string `json:"createdAt"` // Для GraphQL
ID int `json:"id"`
LikerID int `json:"-"` // Для внутреннего использования
Liker *User `json:"liker"` // Для GraphQL
LikerUsername string `json:"likerUsername"` // Добавьте это поле
LikerAvatar string `json:"likerAvatar"` // Добавьте это поле
PostID int `json:"-"` // Для внутреннего использования
Post *Post `json:"post"` // Для GraphQL
PostTitle string `json:"postTitle"` // Добавьте это поле
PostAuthorID int `json:"postAuthorId"` // Добавьте это поле
IsRead bool `json:"isRead"`
CreatedAt time.Time `json:"-"`
CreatedAtStr string `json:"createdAt"` // Для GraphQL
}
// Вспомогательные методы
func (n *LikeNotification) SetLiker(user *User) {
n.Liker = user
n.LikerID = user.ID
n.LikerUsername = user.Username // Добавьте эту строку
n.LikerAvatar = user.Avatar // Добавьте эту строку
}
func (n *LikeNotification) SetPost(post *Post) {
n.Post = post
n.PostID = post.ID
n.PostTitle = post.Title // Добавьте эту строку
n.PostAuthorID = post.AuthorID // Добавьте эту строку
}
func (n *LikeNotification) SetCreatedAtStr() {