From 21354ef97bc41ef7df0d2484a25782ca0594d933 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sat, 11 May 2019 13:41:05 +0800 Subject: [PATCH] test --- def.go | 2 +- sql.go | 23 +++++++++++++++++++++-- workers.go | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/def.go b/def.go index 31577ed..99ebce0 100644 --- a/def.go +++ b/def.go @@ -16,7 +16,7 @@ type ChatWarsMessage struct { } type ChatWarsMessageAuctionAnnounce struct { - MsgID64 int64 `json:"msg_id"` + ObjID64 int64 `json:"obj_id"` LotID int32 `json:"lot_id"` Item string `json:"item"` Cond string `json:"cond"` diff --git a/sql.go b/sql.go index 5e6aa5b..ab69211 100644 --- a/sql.go +++ b/sql.go @@ -1278,6 +1278,21 @@ func getObjSubTypeId(objId int64) (int64, error) { return objSubTypeId, nil } +func setObjSubTypeId(objId int64, objSubTypeID64 int64) error { + var objSubTypeId int64 + + stmt, err := db.Prepare(`UPDATE obj o SET o.obj_sub_type_id = ? WHERE o.id = ?l`) + logOnError(err, "setObjSubTypeId : prepare update") + if err != nil { + return err + } + defer stmt.Close() + + err = stmt.Exec(objSubTypeID64, objId) + logOnError(err, "setObjSubTypeId : exec update") + return err +} + func insertMsgReport(objId int64, war_date int32, atk int32, def int32, exp int32, gold int32, stock int32, crit bool, stamina bool) error { objSubTypeId, err := getObjSubTypeId(objId) if err != nil { @@ -1328,10 +1343,14 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error { } defer stmt.Close() - _, err = stmt.Exec(m.MsgID64, m.LotID, m.Item, m.Cond, m.Quality, m.Seller, m.Buyer, m.Price, m.Status, m.End) + _, err = stmt.Exec(m.ObjID64, m.LotID, m.Item, m.Cond, m.Quality, m.Seller, m.Buyer, m.Price, m.Status, m.End) if err != nil { return err } + + err = setObjSubTypeId(m.ObjID64, objSubTypeMessageAuctionAnnounce) + logOnError(err, "insertMsgAuctionAnnounce : setObjSubTypeId") + return nil } @@ -1392,7 +1411,7 @@ func setJobDone(jobId int64) error { } func setJobStart(jobId int64) error { - stmt, err := db.Prepare(`UPDATE obj_job j SET j.ended = ? WHERE j.obj_id = ?;`) + stmt, err := db.Prepare(`UPDATE obj_job j SET j.started = ? WHERE j.obj_id = ?;`) logOnError(err, "setJobStart : prepare update obj_job") if err != nil { return err diff --git a/workers.go b/workers.go index 51b8de9..416b304 100644 --- a/workers.go +++ b/workers.go @@ -101,7 +101,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) { log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId) case objSubTypeMessageAuctionAnnounce: cwm := ChatWarsMessageAuctionAnnounce{ - MsgID64: objId, + ObjID64: objId, } l, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${Lot}"), 10, 32) cwm.LotID = int32(l)