-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
29 lines (25 loc) · 816 Bytes
/
user.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
package methods
import (
"context"
"github.com/gaydin/journey/date"
"github.com/gaydin/journey/store"
"github.com/gaydin/journey/structure"
)
func SaveUser(ctx context.Context, db store.Database, u *structure.User, hashedPassword string, createdBy int64) error {
userId, err := db.InsertUser(ctx, u.Name, u.Slug, hashedPassword, u.Email, u.Image, u.Cover, date.GetCurrentTime(), createdBy)
if err != nil {
return err
}
err = db.InsertRoleUser(ctx, u.Role, userId)
if err != nil {
return err
}
return nil
}
func UpdateUser(ctx context.Context, db store.Database, u *structure.User, updatedById int64) error {
err := db.UpdateUser(ctx, u.Id, u.Name, u.Slug, u.Email, u.Image, u.Cover, u.Bio, u.Website, u.Location, date.GetCurrentTime(), updatedById)
if err != nil {
return err
}
return nil
}