Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification #45

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0
github.com/jackc/pgx/v5 v5.7.1
github.com/mailru/easyjson v0.9.0
github.com/microcosm-cc/bluemonday v1.0.27
github.com/pborman/uuid v1.2.1
github.com/prometheus/client_golang v1.20.5
Expand All @@ -44,6 +45,7 @@ require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand All @@ -71,6 +73,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
Expand Down
3 changes: 1 addition & 2 deletions internal/account/controller/get_account.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package controller

import (
"encoding/json"
"net/http"

cModels "github.com/go-park-mail-ru/2024_2_TeamOn_Patreon/internal/account/controller/models"
Expand Down Expand Up @@ -64,7 +63,7 @@ func (handler *Handler) GetAccount(w http.ResponseWriter, r *http.Request) {
}

accountData := cModels.MapUserToAccount(user, subscriptions)
json.NewEncoder(w).Encode(accountData)
utils.SendModel(accountData, w, op, ctx)
// Status 200
w.WriteHeader(http.StatusOK)
}
6 changes: 1 addition & 5 deletions internal/account/controller/get_new_notifications.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package controller

import (
"encoding/json"
"net/http"

"github.com/go-park-mail-ru/2024_2_TeamOn_Patreon/internal/account/controller/models"
Expand Down Expand Up @@ -61,8 +60,5 @@ func (handler *Handler) GetNewNotifications(w http.ResponseWriter, r *http.Reque
notifications := models.MapNotificationsCommonToController(sNotifications)

w.WriteHeader(http.StatusOK)
if err = json.NewEncoder(w).Encode(notifications); err != nil {
logger.StandardResponse(ctx, err.Error(), global.GetCodeError(err), r.Host, op)
w.WriteHeader(global.GetCodeError(err))
}
utils.SendModel(notifications, w, op, ctx)
}
6 changes: 1 addition & 5 deletions internal/account/controller/get_notifications.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package controller

import (
"encoding/json"
"net/http"

"github.com/go-park-mail-ru/2024_2_TeamOn_Patreon/internal/account/controller/models"
Expand Down Expand Up @@ -64,8 +63,5 @@ func (handler *Handler) GetNotifications(w http.ResponseWriter, r *http.Request)
notifications := models.MapNotificationsCommonToController(sNotifications)

w.WriteHeader(http.StatusOK)
if err = json.NewEncoder(w).Encode(notifications); err != nil {
logger.StandardResponse(ctx, err.Error(), global.GetCodeError(err), r.Host, op)
w.WriteHeader(global.GetCodeError(err))
}
utils.SendModel(notifications, w, op, ctx)
}
4 changes: 4 additions & 0 deletions internal/account/controller/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import (
valid "github.com/go-park-mail-ru/2024_2_TeamOn_Patreon/internal/pkg/validate"
)

//go:generate easyjson

// Service модель аккаунта пользователя
//
//easyjson:json
type Account struct {
// Имя пользователя
Username string `json:"username"`
Expand Down
188 changes: 188 additions & 0 deletions internal/account/controller/models/account_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/account/controller/models/model_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package models

import "fmt"

//go:generate easyjson

//easyjson:json
type ModelError struct {
// Описание ошибки
Message string `json:"message,omitempty"`
Expand Down
86 changes: 86 additions & 0 deletions internal/account/controller/models/model_error_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading