added query logger

This commit is contained in:
Fran Jurmanović
2022-06-15 18:46:16 +02:00
parent ed2f5d47c8
commit e43a005192
6 changed files with 71 additions and 3 deletions

View File

@@ -18,7 +18,6 @@ type UsersService struct {
Db *pg.DB
}
/*
Create
@@ -82,7 +81,11 @@ func (us *UsersService) Login(ctx context.Context, loginBody *models.Login) (*mo
exceptionReturn := new(models.Exception)
tokenPayload := new(models.Token)
db.Model(check).Where("? = ?", pg.Ident("email"), loginBody.Email).Select()
tx, _ := db.Begin()
defer tx.Rollback()
tx.Model(check).Where("? = ?", pg.Ident("email"), loginBody.Email).Select()
if check.Email == "" {
exceptionReturn.Message = "Email not found"
exceptionReturn.ErrorCode = "400103"
@@ -109,6 +112,8 @@ func (us *UsersService) Login(ctx context.Context, loginBody *models.Login) (*mo
tokenPayload.Token = token
tx.Commit()
return tokenPayload, exceptionReturn
}