-
Notifications
You must be signed in to change notification settings - Fork 0
/
getgroupsettings.xo.go
44 lines (40 loc) · 1.19 KB
/
getgroupsettings.xo.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
38
39
40
41
42
43
44
package xo_wxstat
// Code generated by xo. DO NOT EDIT.
import (
"context"
)
// Custom defined search query GetGroupSettings
type GetGroupSettings struct {
ActivePeriod int `json:"active_period"` // active_period
QuietPeriod int `json:"quiet_period"` // quiet_period
ActiveNum int `json:"active_num"` // active_num
QuietNum int `json:"quiet_num"` // quiet_num
}
// GetGroupSettingsByGroupID runs a custom query, returning results as GetGroupSettings.
func GetGroupSettingsByGroupID(ctx context.Context, db DB, GroupID string) ([]*GetGroupSettings, error) {
// query
const sqlstr = `SELECT active_period, quiet_period, active_num, quiet_num ` +
`FROM wx_group ` +
`WHERE group_id == $1;`
// run
logf(sqlstr, GroupID)
rows, err := db.QueryContext(ctx, sqlstr, GroupID)
if err != nil {
return nil, logerror(err)
}
defer rows.Close()
// load results
var res []*GetGroupSettings
for rows.Next() {
var ggs GetGroupSettings
// scan
if err := rows.Scan(&ggs.ActivePeriod, &ggs.QuietPeriod, &ggs.ActiveNum, &ggs.QuietNum); err != nil {
return nil, logerror(err)
}
res = append(res, &ggs)
}
if err := rows.Err(); err != nil {
return nil, logerror(err)
}
return res, nil
}