ad_event.go
628 Bytes
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
package models
import (
"database/sql"
db "client/icesimba.ad/database"
)
type Event struct {
Id int64
Code string
Name string
}
type event struct {
Id sql.NullInt64
Code sql.NullString
Name sql.NullString
}
func QueryEventByCode(code string) (out Event, err error) {
sqlQu := "select event_id,event_name from ice_ad_event where event_code=?"
eventNull := event{}
err = db.SqlDB.QueryRow(sqlQu, code).Scan(
&eventNull.Id,
&eventNull.Name,
)
if err != nil {
return
}
if eventNull.Id.Valid {
out.Id = eventNull.Id.Int64
}
if eventNull.Name.Valid {
out.Name = eventNull.Name.String
}
return
}