Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package queries |
||
2 | |||
3 | import ( |
||
4 | "memnixrest/app/database" |
||
5 | "memnixrest/app/models" |
||
6 | ) |
||
7 | |||
8 | func CreateLog(logType models.LogType, message string) *models.Logs { |
||
9 | db := database.DBConn // DB Conn |
||
10 | |||
11 | log := &models.Logs{ |
||
12 | LogType: logType, |
||
13 | Message: message, |
||
14 | } |
||
15 | |||
16 | db.Create(log) |
||
17 | return log |
||
18 | |||
19 | } |
||
20 | |||
21 | func CreateUserLog(userID uint, log models.Logs) models.ResponseHTTP { |
||
22 | db := database.DBConn // DB Conn |
||
23 | |||
24 | userLog := &models.UserLogs{ |
||
25 | UserID: userID, |
||
26 | LogID: log.ID, |
||
27 | } |
||
28 | |||
29 | db.Create(userLog) |
||
30 | return models.ResponseHTTP{ |
||
31 | Success: true, |
||
32 | Message: "Created an user log entry", |
||
33 | Data: *userLog, |
||
34 | Count: 1, |
||
35 | } |
||
36 | } |
||
37 | |||
38 | func CreateDeckLog(deckID uint, log models.Logs) models.ResponseHTTP { |
||
39 | db := database.DBConn // DB Conn |
||
40 | |||
41 | deckLog := &models.DeckLogs{ |
||
42 | DeckID: deckID, |
||
43 | LogID: log.ID, |
||
44 | } |
||
45 | |||
46 | db.Create(deckLog) |
||
47 | return models.ResponseHTTP{ |
||
48 | Success: true, |
||
49 | Message: "Created a deck log entry", |
||
50 | Data: *deckLog, |
||
51 | Count: 1, |
||
52 | } |
||
53 | } |
||
54 | |||
55 | func CreateCardLog(cardID uint, log models.Logs) models.ResponseHTTP { |
||
56 | db := database.DBConn // DB Conn |
||
57 | |||
58 | cardLog := &models.CardLogs{ |
||
59 | CardID: cardID, |
||
60 | LogID: log.ID, |
||
61 | } |
||
62 | |||
63 | db.Create(cardLog) |
||
64 | return models.ResponseHTTP{ |
||
65 | Success: true, |
||
66 | Message: "Created a card log entry", |
||
67 | Data: *cardLog, |
||
68 | Count: 1, |
||
69 | } |
||
71 |