Quellcode durchsuchen

Complete record field

tags/v0.5
patrick vor 5 Jahren
Ursprung
Commit
8447ea87e4
1 geänderte Dateien mit 39 neuen und 0 gelöschten Zeilen
  1. +39
    -0
      leanwork_request.go

+ 39
- 0
leanwork_request.go Datei anzeigen

@@ -1,5 +1,11 @@
package main

import (
"errors"

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

type LeanworkRequest struct {
Id int64
PickupUrl string
@@ -11,5 +17,38 @@ type LeanworkRequest struct {
CustomerId string
Sign string
Valid bool
Ts mysql.NullTime
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
}

Laden…
Abbrechen
Speichern