This commit is contained in:
shoopea 2020-01-02 18:35:41 +08:00
parent d8d941a8d2
commit 00a782e1dd
2 changed files with 12 additions and 8 deletions

9
obj.go
View File

@ -47,6 +47,13 @@ func initCache() {
err = loadObjMsg()
logOnError(err, "initCache : caching msgs")
err = loadObjType()
logOnError(err, "initCache : caching obj_type")
err = loadObjSubType()
logOnError(err, "initCache : caching obj_sub_type")
}
func loadObjType() error {
@ -87,7 +94,6 @@ func loadObjType() error {
}
/*
func loadObjSubType() error {
var obj []ObjSubType
@ -126,7 +132,6 @@ func loadObjSubType() error {
}
*/
func codeObjTypeId(intlId string) (int64, error) {
var objTypeId int64

11
sql.go
View File

@ -636,24 +636,23 @@ func insertObjType(intlId string, name string) error {
return nil
}
/*
func insertObjSubType(intlId string, name string, objType string) error {
stmt, err := db.Prepare(`INSERT INTO code_obj_sub_type
SELECT (intl_id, name, obj_type_id)
VALUES (?, ?, ?);`)
stmt, err := db.Prepare(`INSERT INTO code_obj_sub_type
SELECT null id, ? intl_id, ? name, cot.id
FROM code_obj_type cot
WHERE cot.intl_id = ?;`)
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(intlId, name)
_, err = stmt.Exec(intlId, name, objType)
if err != nil {
return err
}
return nil
}
*/
func insertMsgItem(objId int64, itemId int64, quantity int64) error {
stmt, err := db.Prepare(`INSERT INTO obj_msg_item (obj_id, item_id, quantity)