소스 검색

Complete record field

tags/v0.5
patrick 5 년 전
부모
커밋
8447ea87e4
1개의 변경된 파일39개의 추가작업 그리고 0개의 파일을 삭제
  1. +39
    -0
      leanwork_request.go

+ 39
- 0
leanwork_request.go 파일 보기

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…
취소
저장