File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ package session
2+
3+ import (
4+ "github.com/google/uuid"
5+ "github.com/jackc/pgx/v5/pgtype"
6+
7+ "github.com/PythonHacker24/linux-acl-management-backend/internal/postgresql"
8+ )
9+
10+ /* converts project session struct into PostgreSQL supported format */
11+ func ConvertSessionToStoreParams (session * Session ) (* postgresql.StoreSessionPQParams , error ) {
12+ createdAt := pgtype.Timestamp {}
13+ if err := createdAt .Scan (session .CreatedAt ); err != nil {
14+ return nil , err
15+ }
16+
17+ lastActiveAt := pgtype.Timestamp {}
18+ if err := lastActiveAt .Scan (session .LastActiveAt ); err != nil {
19+ return nil , err
20+ }
21+
22+ expiry := pgtype.Timestamp {}
23+ if err := expiry .Scan (session .Expiry ); err != nil {
24+ return nil , err
25+ }
26+
27+ return & postgresql.StoreSessionPQParams {
28+ ID : uuid .MustParse (session .ID ),
29+ Username : session .Username ,
30+ Ip : pgtype.Text {String : session .IP , Valid : true },
31+ UserAgent : pgtype.Text {String : session .UserAgent , Valid : true },
32+ Status : string (session .Status ),
33+ CreatedAt : createdAt ,
34+ LastActiveAt : lastActiveAt ,
35+ Expiry : expiry ,
36+ }, nil
37+ }
You can’t perform that action at this time.
0 commit comments