@@ -18,17 +18,17 @@ import (
18
18
)
19
19
20
20
func EnvelopeDeleteAll (cc core.Context ) error {
21
- _ , err := cc .DB .NewDelete ().Model (& envelope.Message {}).Where ("1=1" ).Exec (cc . Context () )
21
+ _ , err := cc .DB .NewDelete ().Model (& envelope.Message {}).Where ("1=1" ).Exec (cc )
22
22
return err
23
23
}
24
24
25
25
func EnvelopeDelete (cc core.Context , id int64 ) error {
26
- _ , err := cc .DB .NewDelete ().Model (& envelope.Message {}).Where ("id = ?" , id ).Exec (cc . Context () )
26
+ _ , err := cc .DB .NewDelete ().Model (& envelope.Message {}).Where ("id = ?" , id ).Exec (cc )
27
27
return err
28
28
}
29
29
30
30
func EnvelopeCreate (cc core.Context , msg * envelope.Message , atts []* envelope.Attachment ) (int64 , []int64 , error ) {
31
- err := cc .DB .RunInTx (cc . Context () , & sql.TxOptions {}, func (ctx context.Context , tx bun.Tx ) error {
31
+ err := cc .DB .RunInTx (cc , & sql.TxOptions {}, func (ctx context.Context , tx bun.Tx ) error {
32
32
_ , err := tx .NewInsert ().Model (msg ).Exec (ctx )
33
33
if err != nil {
34
34
return err
@@ -74,7 +74,7 @@ func EnvelopeMessageList(cc core.Context, page pagination.Page, filter envelope.
74
74
}
75
75
}
76
76
77
- ctx := cc . Context ()
77
+ ctx := cc
78
78
79
79
err := q .Scan (ctx , & msgs )
80
80
if err != nil {
@@ -93,7 +93,7 @@ func EnvelopeMessageList(cc core.Context, page pagination.Page, filter envelope.
93
93
}
94
94
95
95
func EnvelopeGet (cc core.Context , id int64 ) (envelope.Envelope , error ) {
96
- ctx := cc . Context ()
96
+ ctx := cc
97
97
msg := & envelope.Message {}
98
98
err := cc .DB .NewSelect ().Model (msg ).Where ("id = ?" , id ).Scan (ctx , msg )
99
99
if err != nil {
@@ -117,16 +117,16 @@ func EnvelopeMessageHTMLGet(cc core.Context, id int64) (string, error) {
117
117
err := Messages .
118
118
SELECT (Messages .HTML ).
119
119
WHERE (Messages .ID .EQ (Int64 (id ))).
120
- QueryContext (cc . Context () , cc . DB , & res )
120
+ QueryContext (cc , cc , & res )
121
121
return res .HTML , err
122
122
}
123
123
124
124
func EnvelopeCount (cc core.Context ) (int , error ) {
125
- return cc .DB .NewSelect ().Model (& envelope.Message {}).Count (cc . Context () )
125
+ return cc .DB .NewSelect ().Model (& envelope.Message {}).Count (cc )
126
126
}
127
127
128
128
func EnvelopeAttachmentCount (cc core.Context ) (int , error ) {
129
- return cc .DB .NewSelect ().Model (& envelope.Attachment {}).Where ("message_id IS NOT NULL" ).Count (cc . Context () )
129
+ return cc .DB .NewSelect ().Model (& envelope.Attachment {}).Where ("message_id IS NOT NULL" ).Count (cc )
130
130
}
131
131
132
132
func EnvelopeAttachmentList (cc core.Context , page pagination.Page , filter envelope.AttachmentFilter ) (envelope.AttachmentListResult , error ) {
@@ -140,7 +140,7 @@ func EnvelopeAttachmentList(cc core.Context, page pagination.Page, filter envelo
140
140
q = q .Order ("id DESC" )
141
141
}
142
142
143
- ctx := cc . Context ()
143
+ ctx := cc
144
144
145
145
// Scan
146
146
err := q .Scan (ctx , & atts )
@@ -162,7 +162,7 @@ func EnvelopeAttachmentList(cc core.Context, page pagination.Page, filter envelo
162
162
163
163
func EnvelopeAttachmentListOrphan (cc core.Context , limit int ) ([]* envelope.Attachment , error ) {
164
164
var atts []* envelope.Attachment
165
- err := cc .DB .NewSelect ().Model (& atts ).Limit (limit ).Where ("message_id IS NULL" ).Scan (cc . Context () )
165
+ err := cc .DB .NewSelect ().Model (& atts ).Limit (limit ).Where ("message_id IS NULL" ).Scan (cc )
166
166
return atts , err
167
167
}
168
168
@@ -173,7 +173,7 @@ func EnvelopeDeleteUntilCount(cc core.Context, keep int, olderThan time.Time) (i
173
173
DELETE ().
174
174
WHERE (Messages .ID .NOT_IN (Messages .SELECT (Messages .ID ).ORDER_BY (Messages .ID ).LIMIT (int64 (keep ))).
175
175
AND (Messages .CreatedAt .LT (DATETIME (olderThan ))),
176
- ).ExecContext (cc . Context () , cc .DB )
176
+ ).ExecContext (cc , cc .DB )
177
177
if err != nil {
178
178
return 0 , err
179
179
}
@@ -182,7 +182,7 @@ func EnvelopeDeleteUntilCount(cc core.Context, keep int, olderThan time.Time) (i
182
182
}
183
183
184
184
func EnvelopeDeleteOlderThan (cc core.Context , olderThan time.Time ) (int64 , error ) {
185
- res , err := Messages .DELETE ().WHERE (Messages .CreatedAt .LT (DATETIME (olderThan ))).ExecContext (cc . Context () , cc .DB )
185
+ res , err := Messages .DELETE ().WHERE (Messages .CreatedAt .LT (DATETIME (olderThan ))).ExecContext (cc , cc .DB )
186
186
if err != nil {
187
187
return 0 , err
188
188
}
@@ -197,7 +197,7 @@ func EnvelopeAttachmentDelete(cc core.Context, att *envelope.Attachment) error {
197
197
return err
198
198
}
199
199
200
- _ , err = cc .DB .NewDelete ().Model (& envelope.Attachment {}).Where ("id = ?" , att .ID ).Exec (cc . Context () )
200
+ _ , err = cc .DB .NewDelete ().Model (& envelope.Attachment {}).Where ("id = ?" , att .ID ).Exec (cc )
201
201
202
202
return err
203
203
}
0 commit comments