-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathperson.go
37 lines (30 loc) · 1.04 KB
/
person.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// TITLE: user database repository layer
// Author: (Jacky: FafnirZ) (09/21)
// Refactor into database package: Varun
package repositories
import (
"log"
"github.com/google/uuid"
)
// Implements IPersonRepository
type personRepository struct {
frontEndID uuid.UUID
embeddedContext
}
func (rep personRepository) PersonExists(p Person) bool {
var result int
err := rep.ctx.Query("SELECT count(*) from person where email = $1 and frontendid = $2 and password = $3;", []interface{}{p.Email, rep.frontEndID, p.Password}, &result)
if err != nil {
log.Println("credentials match err", err.Error())
}
return result == 1
}
func (rep personRepository) GetPersonWithDetails(p Person) Person {
var result Person
err := rep.ctx.Query("SELECT * from person where email = $1 and frontendid = $2 and password = $3;", []interface{}{p.Email, rep.frontEndID, p.Password},
&result.UID, &result.Email, &result.FirstName, &result.Password, &result.GroupID, &result.FrontEndID)
if err != nil {
log.Print("get permissions error", err.Error())
}
return result
}