Selaa lähdekoodia

Complete record field

tags/v0.5
patrick 6 vuotta sitten
vanhempi
commit
8447ea87e4
1 muutettua tiedostoa jossa 39 lisäystä ja 0 poistoa
  1. +39
    -0
      leanwork_request.go

+ 39
- 0
leanwork_request.go Näytä tiedosto

package main package main


import (
"errors"

"github.com/go-sql-driver/mysql"
)

type LeanworkRequest struct { type LeanworkRequest struct {
Id int64 Id int64
PickupUrl string PickupUrl string
CustomerId string CustomerId string
Sign string Sign string
Valid bool Valid bool
Ts mysql.NullTime
Ip4 uint32 Ip4 uint32
Ip4Location string
}

//
func lrIsIdMatchSign(id string, sign string) bool {
_, err := getRequestRowByIdAndSign(id, sign)
return err == nil
}

func getRequestRowByIdAndSign(id string, sign string) (row LeanworkRequest, err error) {
//retrieve form DB
row = LeanworkRequest{}
db.conn(Config)
selDB, err := db.h.Query("SELECT * FROM request WHERE id=? and sign=?", id, sign)
if err != nil {
return
}
count := 0
for selDB.Next() {
err = selDB.Scan(&row.Id, &row.PickupUrl, &row.ReceiveUrl, &row.SignType,
&row.OrderNo, &row.OrderAmount, &row.OrderCurrency, &row.CustomerId,
&row.Sign, &row.Valid, &row.Ts, &row.Ip4, &row.Ip4Location)
if err != nil {
return
}
count++
}

if count <= 0 {
err = errors.New("no record found by the given id (" + id + ") and sign(" + sign + ")")
}
return
} }

Loading…
Peruuta
Tallenna