Skip to content

Commit

Permalink
NightMate updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Kannan112 committed Dec 20, 2023
1 parent 087d4af commit 3a8a1a3
Show file tree
Hide file tree
Showing 10 changed files with 1,519 additions and 839 deletions.
867 changes: 551 additions & 316 deletions cmd/api/docs/docs.go

Large diffs are not rendered by default.

864 changes: 551 additions & 313 deletions cmd/api/docs/swagger.json

Large diffs are not rendered by default.

504 changes: 302 additions & 202 deletions cmd/api/docs/swagger.yaml

Large diffs are not rendered by default.

Binary file modified cmd/api/tmp/api.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ help: ## Display this help screen

mockgen:
mockgen -source=pkg/repository/interface/user.go -destination=pkg/repository/mockrepo/mock_user.go
mockgen -source=pkg/repository/interface/refresh_token.go -destination=pkg/repository/mockrepo/refresh_token.go
mockgen -source=pkg/usecase/interface/user.go -destination=pkg/usecase/mockusecase/mock_user.go
mockgen -source=pkg/usecase/interface/cart.go -destination=pkg/usecase/mockusecase/mock_cart.go
mockgen -source=pkg/usecase/interface/wallet.go -destination=pkg/usecase/mockusecase/mock_wallet.go
mockgen -source=pkg/usecase/interface/wallet.go -destination=pkg/usecase/mockusecase/mock_wallet.go
1 change: 1 addition & 0 deletions pkg/db/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func ConnectDatabase(cfg config.Config) (*gorm.DB, error) {
&domain.OfferTable{},
&domain.Images{},
&domain.AdminRefreshToken{},
&domain.UserRefreshToken{},
)

return db, dbErr
Expand Down
6 changes: 3 additions & 3 deletions pkg/di/wire_gen.go

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

93 changes: 93 additions & 0 deletions pkg/repository/mockrepo/refresh_token.go

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

18 changes: 15 additions & 3 deletions pkg/repository/refresh_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,28 @@ func (c *RefreshTokenDataBase) AdminFindRefreshToken(ctx context.Context, adminI
}

func (c *RefreshTokenDataBase) UserRefreshTokenAdd(token string, userID uint) error {
sql := `INSERT INTO user_refresh_tokens (refresh_token,user_id)VALUES($1,$2)`
var check bool
tokenExist := `SELECT EXISTS(select * from user_refresh_tokens where users_id=$1)`
if err := c.DB.Raw(tokenExist, userID).Scan(&check).Error; err != nil {
return err
}
if check {
updateQuery := `update user_refresh_tokens SET refresh_token=$1 where users_id=$2`
if err := c.DB.Exec(updateQuery, token, userID).Error; err != nil {
return err
}
return nil
}
sql := `INSERT INTO user_refresh_tokens (refresh_token,users_id)VALUES($1,$2)`
if err := c.DB.Exec(sql, token, userID).Error; err != nil {
return fmt.Errorf("failed to add refresh token")
return err
}
return nil
}

func (c *RefreshTokenDataBase) UserFindRefreshToken(ctx context.Context, userID uint) (string, error) {
var token string
sql := `SELECT refresh_token FROM user_refresh_tokens where user_id = $1`
sql := `SELECT refresh_token FROM user_refresh_tokens where users_id = $1`
if err := c.DB.Raw(sql, userID).Scan(&token).Error; err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion tmp/build-errors.log

Large diffs are not rendered by default.

0 comments on commit 3a8a1a3

Please sign in to comment.