From cce2a179ed75b435ce604c2bf0bf390321862b62 Mon Sep 17 00:00:00 2001 From: qosmio <79136983+qosmioo@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:04:33 +0300 Subject: [PATCH] Revert "Tp easyjson" --- Makefile | 6 - internal/delivery/http/utils/httpJSON.go | 24 -- internal/entity/dto/advert.go | 7 - internal/entity/dto/advert_easyjson.go | 58 --- internal/entity/dto/auth.go | 4 - internal/entity/dto/auth_easyjson.go | 238 ------------ internal/entity/dto/cart.go | 6 - internal/entity/dto/cart_easyjson.go | 470 ----------------------- internal/entity/dto/category.go | 2 - internal/entity/dto/category_easyjson.go | 94 ----- internal/entity/dto/history.go | 2 - internal/entity/dto/history_easyjson.go | 203 ---------- internal/entity/dto/purchase.go | 3 - internal/entity/dto/purchase_easyjson.go | 270 ------------- internal/entity/dto/user.go | 3 - internal/entity/dto/user_easyjson.go | 231 ----------- 16 files changed, 1621 deletions(-) delete mode 100644 internal/delivery/http/utils/httpJSON.go delete mode 100644 internal/entity/dto/advert_easyjson.go delete mode 100644 internal/entity/dto/auth_easyjson.go delete mode 100644 internal/entity/dto/cart_easyjson.go delete mode 100644 internal/entity/dto/category_easyjson.go delete mode 100644 internal/entity/dto/history_easyjson.go delete mode 100644 internal/entity/dto/purchase_easyjson.go delete mode 100644 internal/entity/dto/user_easyjson.go diff --git a/Makefile b/Makefile index b54f3086..ebcbc0e0 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,6 @@ MAIN_PATH=./cmd/app GOTMPDIR=./tmp -EASYJSON=easyjson - build: mkdir -p $(BIN_DIR) GOTMPDIR=$(GOTMPDIR) go build -o $(BIN_DIR)/$(BINARY_NAME) $(MAIN_PATH) @@ -27,8 +25,4 @@ run: build swagger: swag init -g $(MAIN_PATH)/main.go -o ./docs -generate: - @echo "Generating easyjson files..." - @find . -name '*.go' -exec $(EASYJSON) -all {} \; - .PHONY: build test clean run swagger \ No newline at end of file diff --git a/internal/delivery/http/utils/httpJSON.go b/internal/delivery/http/utils/httpJSON.go deleted file mode 100644 index 9cc002c8..00000000 --- a/internal/delivery/http/utils/httpJSON.go +++ /dev/null @@ -1,24 +0,0 @@ -package utils - -import ( - "io" - "net/http" - - "github.com/mailru/easyjson" -) - -func WriteJSON(w http.ResponseWriter, v easyjson.Marshaler, status int) error { - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(status) - - writer := io.Writer(w) - _, err := easyjson.MarshalToWriter(v, writer) - return err -} - -func ReadJSON(r *http.Request, v easyjson.Unmarshaler) error { - if err := easyjson.UnmarshalFromReader(r.Body, v); err != nil { - return err - } - return r.Body.Close() -} diff --git a/internal/entity/dto/advert.go b/internal/entity/dto/advert.go index 891a3619..593eeb30 100644 --- a/internal/entity/dto/advert.go +++ b/internal/entity/dto/advert.go @@ -1,4 +1,3 @@ -//go:generate easyjson -all . package dto import ( @@ -7,7 +6,6 @@ import ( "github.com/google/uuid" ) -//easyjson:json type AdvertRequest struct { CategoryId uuid.UUID `json:"category_id"` Title string `json:"title"` @@ -18,7 +16,6 @@ type AdvertRequest struct { Location string `json:"location"` } -//easyjson:json type PreviewAdvert struct { ID uuid.UUID `json:"id"` SellerId uuid.UUID `json:"seller_id"` @@ -32,21 +29,18 @@ type PreviewAdvert struct { PromotedUntil time.Time `json:"promoted_until"` } -//easyjson:json type PreviewAdvertCard struct { Preview PreviewAdvert `json:"preview"` IsSaved bool `json:"is_saved"` IsViewed bool `json:"is_viewed"` } -//easyjson:json type MyPreviewAdvertCard struct { Preview PreviewAdvert `json:"preview"` ViewsNumber uint `json:"views_number"` SavesNumber uint `json:"saves_number"` } -//easyjson:json type Advert struct { ID uuid.UUID `json:"id"` SellerId uuid.UUID `json:"seller_id"` @@ -65,7 +59,6 @@ type Advert struct { PromotedUntil time.Time `json:"promoted_until"` } -//easyjson:json type AdvertCard struct { Advert Advert `json:"advert"` IsSaved bool `json:"is_saved"` diff --git a/internal/entity/dto/advert_easyjson.go b/internal/entity/dto/advert_easyjson.go deleted file mode 100644 index 74a48d16..00000000 --- a/internal/entity/dto/advert_easyjson.go +++ /dev/null @@ -1,58 +0,0 @@ -// TEMPORARY AUTOGENERATED FILE: easyjson stub code to make the package -// compilable during generation. - -package dto - -import ( - "github.com/mailru/easyjson/jwriter" - "github.com/mailru/easyjson/jlexer" -) - -func ( Advert ) MarshalJSON() ([]byte, error) { return nil, nil } -func (* Advert ) UnmarshalJSON([]byte) error { return nil } -func ( Advert ) MarshalEasyJSON(w *jwriter.Writer) {} -func (* Advert ) UnmarshalEasyJSON(l *jlexer.Lexer) {} - -type EasyJSON_exporter_Advert *Advert - -func ( AdvertCard ) MarshalJSON() ([]byte, error) { return nil, nil } -func (* AdvertCard ) UnmarshalJSON([]byte) error { return nil } -func ( AdvertCard ) MarshalEasyJSON(w *jwriter.Writer) {} -func (* AdvertCard ) UnmarshalEasyJSON(l *jlexer.Lexer) {} - -type EasyJSON_exporter_AdvertCard *AdvertCard - -func ( AdvertRequest ) MarshalJSON() ([]byte, error) { return nil, nil } -func (* AdvertRequest ) UnmarshalJSON([]byte) error { return nil } -func ( AdvertRequest ) MarshalEasyJSON(w *jwriter.Writer) {} -func (* AdvertRequest ) UnmarshalEasyJSON(l *jlexer.Lexer) {} - -type EasyJSON_exporter_AdvertRequest *AdvertRequest - -func ( AdvertStatus ) MarshalJSON() ([]byte, error) { return nil, nil } -func (* AdvertStatus ) UnmarshalJSON([]byte) error { return nil } -func ( AdvertStatus ) MarshalEasyJSON(w *jwriter.Writer) {} -func (* AdvertStatus ) UnmarshalEasyJSON(l *jlexer.Lexer) {} - -type EasyJSON_exporter_AdvertStatus *AdvertStatus - -func ( MyPreviewAdvertCard ) MarshalJSON() ([]byte, error) { return nil, nil } -func (* MyPreviewAdvertCard ) UnmarshalJSON([]byte) error { return nil } -func ( MyPreviewAdvertCard ) MarshalEasyJSON(w *jwriter.Writer) {} -func (* MyPreviewAdvertCard ) UnmarshalEasyJSON(l *jlexer.Lexer) {} - -type EasyJSON_exporter_MyPreviewAdvertCard *MyPreviewAdvertCard - -func ( PreviewAdvert ) MarshalJSON() ([]byte, error) { return nil, nil } -func (* PreviewAdvert ) UnmarshalJSON([]byte) error { return nil } -func ( PreviewAdvert ) MarshalEasyJSON(w *jwriter.Writer) {} -func (* PreviewAdvert ) UnmarshalEasyJSON(l *jlexer.Lexer) {} - -type EasyJSON_exporter_PreviewAdvert *PreviewAdvert - -func ( PreviewAdvertCard ) MarshalJSON() ([]byte, error) { return nil, nil } -func (* PreviewAdvertCard ) UnmarshalJSON([]byte) error { return nil } -func ( PreviewAdvertCard ) MarshalEasyJSON(w *jwriter.Writer) {} -func (* PreviewAdvertCard ) UnmarshalEasyJSON(l *jlexer.Lexer) {} - -type EasyJSON_exporter_PreviewAdvertCard *PreviewAdvertCard diff --git a/internal/entity/dto/auth.go b/internal/entity/dto/auth.go index 4032547a..a15be5be 100644 --- a/internal/entity/dto/auth.go +++ b/internal/entity/dto/auth.go @@ -1,19 +1,15 @@ -//go:generate easyjson -all . package dto -//easyjson:json type Signup struct { Email string `json:"email"` Password string `json:"password"` } -//easyjson:json type Login struct { Email string `json:"email"` Password string `json:"password"` } -//easyjson:json type UpdatePassword struct { OldPassword string `json:"old_password"` NewPassword string `json:"new_password"` diff --git a/internal/entity/dto/auth_easyjson.go b/internal/entity/dto/auth_easyjson.go deleted file mode 100644 index 52d99df5..00000000 --- a/internal/entity/dto/auth_easyjson.go +++ /dev/null @@ -1,238 +0,0 @@ -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. - -package dto - -import ( - json "encoding/json" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" -) - -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(in *jlexer.Lexer, out *UpdatePassword) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "old_password": - out.OldPassword = string(in.String()) - case "new_password": - out.NewPassword = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(out *jwriter.Writer, in UpdatePassword) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"old_password\":" - out.RawString(prefix[1:]) - out.String(string(in.OldPassword)) - } - { - const prefix string = ",\"new_password\":" - out.RawString(prefix) - out.String(string(in.NewPassword)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v UpdatePassword) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v UpdatePassword) MarshalEasyJSON(w *jwriter.Writer) { - easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *UpdatePassword) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *UpdatePassword) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(l, v) -} -func easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(in *jlexer.Lexer, out *Signup) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "email": - out.Email = string(in.String()) - case "password": - out.Password = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(out *jwriter.Writer, in Signup) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"email\":" - out.RawString(prefix[1:]) - out.String(string(in.Email)) - } - { - const prefix string = ",\"password\":" - out.RawString(prefix) - out.String(string(in.Password)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v Signup) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v Signup) MarshalEasyJSON(w *jwriter.Writer) { - easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *Signup) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Signup) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(l, v) -} -func easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(in *jlexer.Lexer, out *Login) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "email": - out.Email = string(in.String()) - case "password": - out.Password = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(out *jwriter.Writer, in Login) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"email\":" - out.RawString(prefix[1:]) - out.String(string(in.Email)) - } - { - const prefix string = ",\"password\":" - out.RawString(prefix) - out.String(string(in.Password)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v Login) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v Login) MarshalEasyJSON(w *jwriter.Writer) { - easyjson4a0f95aaEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *Login) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Login) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson4a0f95aaDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(l, v) -} diff --git a/internal/entity/dto/cart.go b/internal/entity/dto/cart.go index 9d2615e7..213a21fc 100644 --- a/internal/entity/dto/cart.go +++ b/internal/entity/dto/cart.go @@ -1,4 +1,3 @@ -//go:generate easyjson -all . package dto import ( @@ -6,25 +5,21 @@ import ( "github.com/google/uuid" ) -//easyjson:json type AddAdvertToUserCartRequest struct { UserID uuid.UUID `json:"user_id"` AdvertID uuid.UUID `json:"advert_id"` } -//easyjson:json type DeleteAdvertFromUserCartRequest struct { CartID uuid.UUID `json:"cart_id"` AdvertID uuid.UUID `json:"advert_id"` } -//easyjson:json type CartPurchase struct { SellerID uuid.UUID `json:"seller_id"` Adverts []PreviewAdvertCard `json:"adverts"` } -//easyjson:json type Cart struct { ID uuid.UUID `json:"id"` UserID uuid.UUID `json:"user_id"` @@ -32,7 +27,6 @@ type Cart struct { Status entity.CartStatus `json:"status"` } -//easyjson:json type CartResponse struct { Cart Cart `json:"cart"` } diff --git a/internal/entity/dto/cart_easyjson.go b/internal/entity/dto/cart_easyjson.go deleted file mode 100644 index 81e562c7..00000000 --- a/internal/entity/dto/cart_easyjson.go +++ /dev/null @@ -1,470 +0,0 @@ -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. - -package dto - -import ( - json "encoding/json" - entity "github.com/go-park-mail-ru/2024_2_BogoSort/internal/entity" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" -) - -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(in *jlexer.Lexer, out *DeleteAdvertFromUserCartRequest) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "cart_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.CartID).UnmarshalText(data)) - } - case "advert_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.AdvertID).UnmarshalText(data)) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(out *jwriter.Writer, in DeleteAdvertFromUserCartRequest) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"cart_id\":" - out.RawString(prefix[1:]) - out.RawText((in.CartID).MarshalText()) - } - { - const prefix string = ",\"advert_id\":" - out.RawString(prefix) - out.RawText((in.AdvertID).MarshalText()) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v DeleteAdvertFromUserCartRequest) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v DeleteAdvertFromUserCartRequest) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *DeleteAdvertFromUserCartRequest) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *DeleteAdvertFromUserCartRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(l, v) -} -func easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(in *jlexer.Lexer, out *CartResponse) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "cart": - (out.Cart).UnmarshalEasyJSON(in) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(out *jwriter.Writer, in CartResponse) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"cart\":" - out.RawString(prefix[1:]) - (in.Cart).MarshalEasyJSON(out) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v CartResponse) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v CartResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *CartResponse) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *CartResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(l, v) -} -func easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(in *jlexer.Lexer, out *CartPurchase) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "seller_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.SellerID).UnmarshalText(data)) - } - case "adverts": - if in.IsNull() { - in.Skip() - out.Adverts = nil - } else { - in.Delim('[') - if out.Adverts == nil { - if !in.IsDelim(']') { - out.Adverts = make([]PreviewAdvertCard, 0, 0) - } else { - out.Adverts = []PreviewAdvertCard{} - } - } else { - out.Adverts = (out.Adverts)[:0] - } - for !in.IsDelim(']') { - var v1 PreviewAdvertCard - (v1).UnmarshalEasyJSON(in) - out.Adverts = append(out.Adverts, v1) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(out *jwriter.Writer, in CartPurchase) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"seller_id\":" - out.RawString(prefix[1:]) - out.RawText((in.SellerID).MarshalText()) - } - { - const prefix string = ",\"adverts\":" - out.RawString(prefix) - if in.Adverts == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v2, v3 := range in.Adverts { - if v2 > 0 { - out.RawByte(',') - } - (v3).MarshalEasyJSON(out) - } - out.RawByte(']') - } - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v CartPurchase) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v CartPurchase) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *CartPurchase) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *CartPurchase) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto2(l, v) -} -func easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto3(in *jlexer.Lexer, out *Cart) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.ID).UnmarshalText(data)) - } - case "user_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.UserID).UnmarshalText(data)) - } - case "cart_purchases": - if in.IsNull() { - in.Skip() - out.CartPurchases = nil - } else { - in.Delim('[') - if out.CartPurchases == nil { - if !in.IsDelim(']') { - out.CartPurchases = make([]CartPurchase, 0, 1) - } else { - out.CartPurchases = []CartPurchase{} - } - } else { - out.CartPurchases = (out.CartPurchases)[:0] - } - for !in.IsDelim(']') { - var v4 CartPurchase - (v4).UnmarshalEasyJSON(in) - out.CartPurchases = append(out.CartPurchases, v4) - in.WantComma() - } - in.Delim(']') - } - case "status": - out.Status = entity.CartStatus(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto3(out *jwriter.Writer, in Cart) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.RawText((in.ID).MarshalText()) - } - { - const prefix string = ",\"user_id\":" - out.RawString(prefix) - out.RawText((in.UserID).MarshalText()) - } - { - const prefix string = ",\"cart_purchases\":" - out.RawString(prefix) - if in.CartPurchases == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v5, v6 := range in.CartPurchases { - if v5 > 0 { - out.RawByte(',') - } - (v6).MarshalEasyJSON(out) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"status\":" - out.RawString(prefix) - out.String(string(in.Status)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v Cart) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto3(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v Cart) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto3(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *Cart) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto3(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Cart) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto3(l, v) -} -func easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto4(in *jlexer.Lexer, out *AddAdvertToUserCartRequest) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "user_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.UserID).UnmarshalText(data)) - } - case "advert_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.AdvertID).UnmarshalText(data)) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto4(out *jwriter.Writer, in AddAdvertToUserCartRequest) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"user_id\":" - out.RawString(prefix[1:]) - out.RawText((in.UserID).MarshalText()) - } - { - const prefix string = ",\"advert_id\":" - out.RawString(prefix) - out.RawText((in.AdvertID).MarshalText()) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v AddAdvertToUserCartRequest) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto4(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v AddAdvertToUserCartRequest) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonDdb0949aEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto4(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *AddAdvertToUserCartRequest) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto4(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *AddAdvertToUserCartRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonDdb0949aDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto4(l, v) -} diff --git a/internal/entity/dto/category.go b/internal/entity/dto/category.go index f41c8e75..3e39ae5a 100644 --- a/internal/entity/dto/category.go +++ b/internal/entity/dto/category.go @@ -1,9 +1,7 @@ -//go:generate easyjson -all . package dto import "github.com/google/uuid" -//easyjson:json type Category struct { ID uuid.UUID `json:"id"` Title string `json:"title"` diff --git a/internal/entity/dto/category_easyjson.go b/internal/entity/dto/category_easyjson.go deleted file mode 100644 index 5ab8e739..00000000 --- a/internal/entity/dto/category_easyjson.go +++ /dev/null @@ -1,94 +0,0 @@ -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. - -package dto - -import ( - json "encoding/json" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" -) - -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjson6a91a67cDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(in *jlexer.Lexer, out *Category) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.ID).UnmarshalText(data)) - } - case "title": - out.Title = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6a91a67cEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(out *jwriter.Writer, in Category) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.RawText((in.ID).MarshalText()) - } - { - const prefix string = ",\"title\":" - out.RawString(prefix) - out.String(string(in.Title)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v Category) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson6a91a67cEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v Category) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6a91a67cEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *Category) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson6a91a67cDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Category) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6a91a67cDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(l, v) -} diff --git a/internal/entity/dto/history.go b/internal/entity/dto/history.go index c55091ae..04712c22 100644 --- a/internal/entity/dto/history.go +++ b/internal/entity/dto/history.go @@ -1,4 +1,3 @@ -//go:generate easyjson -all . package dto import ( @@ -6,7 +5,6 @@ import ( "github.com/google/uuid" ) -//easyjson:json type PriceHistoryResponse struct { AdvertID uuid.UUID `json:"advert_id"` AdvertHistory []entity.PriceHistory `json:"advert_history"` diff --git a/internal/entity/dto/history_easyjson.go b/internal/entity/dto/history_easyjson.go deleted file mode 100644 index 5dfb28fd..00000000 --- a/internal/entity/dto/history_easyjson.go +++ /dev/null @@ -1,203 +0,0 @@ -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. - -package dto - -import ( - json "encoding/json" - entity "github.com/go-park-mail-ru/2024_2_BogoSort/internal/entity" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" -) - -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjson40eb0d12DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(in *jlexer.Lexer, out *PriceHistoryResponse) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "advert_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.AdvertID).UnmarshalText(data)) - } - case "advert_history": - if in.IsNull() { - in.Skip() - out.AdvertHistory = nil - } else { - in.Delim('[') - if out.AdvertHistory == nil { - if !in.IsDelim(']') { - out.AdvertHistory = make([]entity.PriceHistory, 0, 0) - } else { - out.AdvertHistory = []entity.PriceHistory{} - } - } else { - out.AdvertHistory = (out.AdvertHistory)[:0] - } - for !in.IsDelim(']') { - var v1 entity.PriceHistory - easyjson40eb0d12DecodeGithubComGoParkMailRu20242BogoSortInternalEntity(in, &v1) - out.AdvertHistory = append(out.AdvertHistory, v1) - in.WantComma() - } - in.Delim(']') - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson40eb0d12EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(out *jwriter.Writer, in PriceHistoryResponse) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"advert_id\":" - out.RawString(prefix[1:]) - out.RawText((in.AdvertID).MarshalText()) - } - { - const prefix string = ",\"advert_history\":" - out.RawString(prefix) - if in.AdvertHistory == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v2, v3 := range in.AdvertHistory { - if v2 > 0 { - out.RawByte(',') - } - easyjson40eb0d12EncodeGithubComGoParkMailRu20242BogoSortInternalEntity(out, v3) - } - out.RawByte(']') - } - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v PriceHistoryResponse) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson40eb0d12EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v PriceHistoryResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson40eb0d12EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *PriceHistoryResponse) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson40eb0d12DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *PriceHistoryResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson40eb0d12DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(l, v) -} -func easyjson40eb0d12DecodeGithubComGoParkMailRu20242BogoSortInternalEntity(in *jlexer.Lexer, out *entity.PriceHistory) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "ID": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.ID).UnmarshalText(data)) - } - case "AdvertID": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.AdvertID).UnmarshalText(data)) - } - case "OldPrice": - out.OldPrice = int(in.Int()) - case "NewPrice": - out.NewPrice = int(in.Int()) - case "ChangedAt": - if data := in.Raw(); in.Ok() { - in.AddError((out.ChangedAt).UnmarshalJSON(data)) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson40eb0d12EncodeGithubComGoParkMailRu20242BogoSortInternalEntity(out *jwriter.Writer, in entity.PriceHistory) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"ID\":" - out.RawString(prefix[1:]) - out.RawText((in.ID).MarshalText()) - } - { - const prefix string = ",\"AdvertID\":" - out.RawString(prefix) - out.RawText((in.AdvertID).MarshalText()) - } - { - const prefix string = ",\"OldPrice\":" - out.RawString(prefix) - out.Int(int(in.OldPrice)) - } - { - const prefix string = ",\"NewPrice\":" - out.RawString(prefix) - out.Int(int(in.NewPrice)) - } - { - const prefix string = ",\"ChangedAt\":" - out.RawString(prefix) - out.Raw((in.ChangedAt).MarshalJSON()) - } - out.RawByte('}') -} diff --git a/internal/entity/dto/purchase.go b/internal/entity/dto/purchase.go index 77f483da..a35b1a2a 100644 --- a/internal/entity/dto/purchase.go +++ b/internal/entity/dto/purchase.go @@ -1,11 +1,9 @@ -//go:generate easyjson -all . package dto import ( "github.com/google/uuid" ) -//easyjson:json type PurchaseRequest struct { CartID uuid.UUID `json:"cart_id"` Address string `json:"address"` @@ -37,7 +35,6 @@ const ( DeliveryMethodDelivery DeliveryMethod = "delivery" ) -//easyjson:json type PurchaseResponse struct { ID uuid.UUID `json:"id"` SellerID uuid.UUID `json:"seller_id"` diff --git a/internal/entity/dto/purchase_easyjson.go b/internal/entity/dto/purchase_easyjson.go deleted file mode 100644 index ae1da068..00000000 --- a/internal/entity/dto/purchase_easyjson.go +++ /dev/null @@ -1,270 +0,0 @@ -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. - -package dto - -import ( - json "encoding/json" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" -) - -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjson2ad9a821DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(in *jlexer.Lexer, out *PurchaseResponse) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.ID).UnmarshalText(data)) - } - case "seller_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.SellerID).UnmarshalText(data)) - } - case "customer_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.CustomerID).UnmarshalText(data)) - } - case "adverts": - if in.IsNull() { - in.Skip() - out.Adverts = nil - } else { - in.Delim('[') - if out.Adverts == nil { - if !in.IsDelim(']') { - out.Adverts = make([]PreviewAdvertCard, 0, 0) - } else { - out.Adverts = []PreviewAdvertCard{} - } - } else { - out.Adverts = (out.Adverts)[:0] - } - for !in.IsDelim(']') { - var v1 PreviewAdvertCard - (v1).UnmarshalEasyJSON(in) - out.Adverts = append(out.Adverts, v1) - in.WantComma() - } - in.Delim(']') - } - case "address": - out.Address = string(in.String()) - case "status": - out.Status = PurchaseStatus(in.String()) - case "payment_method": - out.PaymentMethod = PaymentMethod(in.String()) - case "delivery_method": - out.DeliveryMethod = DeliveryMethod(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson2ad9a821EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(out *jwriter.Writer, in PurchaseResponse) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.RawText((in.ID).MarshalText()) - } - { - const prefix string = ",\"seller_id\":" - out.RawString(prefix) - out.RawText((in.SellerID).MarshalText()) - } - { - const prefix string = ",\"customer_id\":" - out.RawString(prefix) - out.RawText((in.CustomerID).MarshalText()) - } - { - const prefix string = ",\"adverts\":" - out.RawString(prefix) - if in.Adverts == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v2, v3 := range in.Adverts { - if v2 > 0 { - out.RawByte(',') - } - (v3).MarshalEasyJSON(out) - } - out.RawByte(']') - } - } - { - const prefix string = ",\"address\":" - out.RawString(prefix) - out.String(string(in.Address)) - } - { - const prefix string = ",\"status\":" - out.RawString(prefix) - out.String(string(in.Status)) - } - { - const prefix string = ",\"payment_method\":" - out.RawString(prefix) - out.String(string(in.PaymentMethod)) - } - { - const prefix string = ",\"delivery_method\":" - out.RawString(prefix) - out.String(string(in.DeliveryMethod)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v PurchaseResponse) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson2ad9a821EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v PurchaseResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson2ad9a821EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *PurchaseResponse) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson2ad9a821DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *PurchaseResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson2ad9a821DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(l, v) -} -func easyjson2ad9a821DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(in *jlexer.Lexer, out *PurchaseRequest) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "cart_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.CartID).UnmarshalText(data)) - } - case "address": - out.Address = string(in.String()) - case "payment_method": - out.PaymentMethod = PaymentMethod(in.String()) - case "delivery_method": - out.DeliveryMethod = DeliveryMethod(in.String()) - case "user_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.UserID).UnmarshalText(data)) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson2ad9a821EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(out *jwriter.Writer, in PurchaseRequest) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"cart_id\":" - out.RawString(prefix[1:]) - out.RawText((in.CartID).MarshalText()) - } - { - const prefix string = ",\"address\":" - out.RawString(prefix) - out.String(string(in.Address)) - } - { - const prefix string = ",\"payment_method\":" - out.RawString(prefix) - out.String(string(in.PaymentMethod)) - } - { - const prefix string = ",\"delivery_method\":" - out.RawString(prefix) - out.String(string(in.DeliveryMethod)) - } - { - const prefix string = ",\"user_id\":" - out.RawString(prefix) - out.RawText((in.UserID).MarshalText()) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v PurchaseRequest) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson2ad9a821EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v PurchaseRequest) MarshalEasyJSON(w *jwriter.Writer) { - easyjson2ad9a821EncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *PurchaseRequest) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson2ad9a821DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *PurchaseRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson2ad9a821DecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(l, v) -} diff --git a/internal/entity/dto/user.go b/internal/entity/dto/user.go index 5ca92395..9b293deb 100644 --- a/internal/entity/dto/user.go +++ b/internal/entity/dto/user.go @@ -1,4 +1,3 @@ -//go:generate easyjson -all . package dto import ( @@ -7,7 +6,6 @@ import ( "github.com/google/uuid" ) -//easyjson:json type User struct { ID uuid.UUID `json:"id"` Email string `json:"email"` @@ -19,7 +17,6 @@ type User struct { UpdatedAt time.Time `json:"updated_at"` } -//easyjson:json type UserUpdate struct { ID uuid.UUID `json:"id"` Email string `json:"email"` diff --git a/internal/entity/dto/user_easyjson.go b/internal/entity/dto/user_easyjson.go deleted file mode 100644 index 34038e60..00000000 --- a/internal/entity/dto/user_easyjson.go +++ /dev/null @@ -1,231 +0,0 @@ -// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. - -package dto - -import ( - json "encoding/json" - easyjson "github.com/mailru/easyjson" - jlexer "github.com/mailru/easyjson/jlexer" - jwriter "github.com/mailru/easyjson/jwriter" -) - -// suppress unused package warning -var ( - _ *json.RawMessage - _ *jlexer.Lexer - _ *jwriter.Writer - _ easyjson.Marshaler -) - -func easyjson9e1087fdDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(in *jlexer.Lexer, out *UserUpdate) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.ID).UnmarshalText(data)) - } - case "email": - out.Email = string(in.String()) - case "username": - out.Username = string(in.String()) - case "phone": - out.Phone = string(in.String()) - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson9e1087fdEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(out *jwriter.Writer, in UserUpdate) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.RawText((in.ID).MarshalText()) - } - { - const prefix string = ",\"email\":" - out.RawString(prefix) - out.String(string(in.Email)) - } - { - const prefix string = ",\"username\":" - out.RawString(prefix) - out.String(string(in.Username)) - } - { - const prefix string = ",\"phone\":" - out.RawString(prefix) - out.String(string(in.Phone)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v UserUpdate) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson9e1087fdEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v UserUpdate) MarshalEasyJSON(w *jwriter.Writer) { - easyjson9e1087fdEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *UserUpdate) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson9e1087fdDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *UserUpdate) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson9e1087fdDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto(l, v) -} -func easyjson9e1087fdDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(in *jlexer.Lexer, out *User) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeFieldName(false) - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.ID).UnmarshalText(data)) - } - case "email": - out.Email = string(in.String()) - case "username": - out.Username = string(in.String()) - case "phone": - out.Phone = string(in.String()) - case "avatar_id": - if data := in.UnsafeBytes(); in.Ok() { - in.AddError((out.AvatarId).UnmarshalText(data)) - } - case "status": - out.Status = string(in.String()) - case "created_at": - if data := in.Raw(); in.Ok() { - in.AddError((out.CreatedAt).UnmarshalJSON(data)) - } - case "updated_at": - if data := in.Raw(); in.Ok() { - in.AddError((out.UpdatedAt).UnmarshalJSON(data)) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson9e1087fdEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(out *jwriter.Writer, in User) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"id\":" - out.RawString(prefix[1:]) - out.RawText((in.ID).MarshalText()) - } - { - const prefix string = ",\"email\":" - out.RawString(prefix) - out.String(string(in.Email)) - } - { - const prefix string = ",\"username\":" - out.RawString(prefix) - out.String(string(in.Username)) - } - { - const prefix string = ",\"phone\":" - out.RawString(prefix) - out.String(string(in.Phone)) - } - { - const prefix string = ",\"avatar_id\":" - out.RawString(prefix) - out.RawText((in.AvatarId).MarshalText()) - } - { - const prefix string = ",\"status\":" - out.RawString(prefix) - out.String(string(in.Status)) - } - { - const prefix string = ",\"created_at\":" - out.RawString(prefix) - out.Raw((in.CreatedAt).MarshalJSON()) - } - { - const prefix string = ",\"updated_at\":" - out.RawString(prefix) - out.Raw((in.UpdatedAt).MarshalJSON()) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v User) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson9e1087fdEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v User) MarshalEasyJSON(w *jwriter.Writer) { - easyjson9e1087fdEncodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *User) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson9e1087fdDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *User) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson9e1087fdDecodeGithubComGoParkMailRu20242BogoSortInternalEntityDto1(l, v) -}