refactor: adjustments to variable namings

This commit is contained in:
2025-09-11 14:26:40 +03:00
parent f81e4eaa47
commit 4b40a05e2d
4 changed files with 42 additions and 8 deletions

View File

@@ -402,7 +402,7 @@ VALUES (
$3::text, $3::text,
$4::text, $4::text,
$5::text, $5::text,
$6::boolean $6::text
) )
RETURNING id, guid, profile_id, hidden, name, icon_name, color, color_grad, deleted RETURNING id, guid, profile_id, hidden, name, icon_name, color, color_grad, deleted
` `
@@ -413,7 +413,7 @@ type CreateWishListParams struct {
Name string Name string
IconName string IconName string
Color string Color string
ColorGrad bool ColorGrad string
} }
func (q *Queries) CreateWishList(ctx context.Context, arg CreateWishListParams) (WishList, error) { func (q *Queries) CreateWishList(ctx context.Context, arg CreateWishListParams) (WishList, error) {

View File

@@ -50,6 +50,6 @@ type NewWishDto struct {
WishListGuid string `json:"wish_list_guid" mapstructure:"wish_list_guid" binding:"required" validate:"guid"` WishListGuid string `json:"wish_list_guid" mapstructure:"wish_list_guid" binding:"required" validate:"guid"`
Name string `json:"name" mapstructure:"name" binding:"required" validate:"max=64"` Name string `json:"name" mapstructure:"name" binding:"required" validate:"max=64"`
Description string `json:"description" mapstructure:"description" validate:"omitempty,max=1000"` Description string `json:"description" mapstructure:"description" validate:"omitempty,max=1000"`
PictureUploadId string `json:"picture_upload_id" mapstructure:"picture_upload_id" validate:"omitempty,upload_id=image"` PictureUploadID string `json:"picture_upload_id" mapstructure:"picture_upload_id" validate:"omitempty,upload_id=image"`
Stars int `json:"stars" mapstructure:"stars" validate:"min=1,max=5"` Stars int `json:"stars" mapstructure:"stars" validate:"min=1,max=5"`
} }

View File

@@ -110,15 +110,15 @@ func (w wishListServiceImpl) CreateWish(cinfo dto.ClientInfo, object dto.NewWish
} }
var avatarUrl *string var avatarUrl *string
if object.PictureUploadId != "" { if object.PictureUploadID != "" {
key, err := w.s3.SaveUpload(object.PictureUploadId, "images"); if err != nil { key, err := w.s3.SaveUpload(object.PictureUploadID, "images"); if err != nil {
if errors.Is(err, errs.ErrFileNotFound) { if errors.Is(err, errs.ErrFileNotFound) {
return nil, err return nil, err
} }
w.log.Error( w.log.Error(
"Failed to save image", "Failed to save image",
zap.String("upload_id", object.PictureUploadId), zap.String("upload_id", object.PictureUploadID),
zap.String("username", cinfo.Username), zap.String("username", cinfo.Username),
zap.Error(err)) zap.Error(err))
return nil, errs.ErrServerError return nil, errs.ErrServerError
@@ -158,7 +158,41 @@ func (w wishListServiceImpl) CreateWish(cinfo dto.ClientInfo, object dto.NewWish
} }
func (w wishListServiceImpl) CreateWishList(cinfo dto.ClientInfo, object dto.NewWishListDto) (*dto.WishListDto, error) { func (w wishListServiceImpl) CreateWishList(cinfo dto.ClientInfo, object dto.NewWishListDto) (*dto.WishListDto, error) {
panic("unimplemented") helper, db, err := database.NewDbHelperTransaction(w.dbctx); if err != nil {
w.log.Error(
"Failed to open transaction",
zap.Error(err))
return nil, errs.ErrServerError
}
defer helper.Rollback()
createdWishList, err := db.TXQueries.CreateWishList(db.CTX, database.CreateWishListParams{
Username: cinfo.Username,
Hidden: object.Hidden,
Name: object.Name,
IconName: object.IconName,
Color: object.Color,
ColorGrad: object.ColorGrad,
}); if err != nil {
w.log.Error(
"Failed to create wish list",
zap.String("username", cinfo.Username),
zap.Error(err))
return nil, errs.ErrServerError
}
err = helper.Commit(); if err != nil {
w.log.Error(
"Failed to commit transaction",
zap.Error(err))
return nil, errs.ErrServerError
}
wishListDto := &dto.WishListDto{}
mapspecial.MapWishListDto(createdWishList, wishListDto)
return wishListDto, nil
} }
func (w wishListServiceImpl) DeleteWishListByGuid(cinfo dto.ClientInfo, guid string) (bool, error) { func (w wishListServiceImpl) DeleteWishListByGuid(cinfo dto.ClientInfo, guid string) (bool, error) {

View File

@@ -374,7 +374,7 @@ VALUES (
@name::text, @name::text,
@icon_name::text, @icon_name::text,
@color::text, @color::text,
@color_grad::boolean @color_grad::text
) )
RETURNING *; RETURNING *;