This commit is contained in:
shoopea 2020-01-02 18:22:08 +08:00
parent 3b110ad247
commit ce150266bc
2 changed files with 23 additions and 2 deletions

2
obj.go
View File

@ -86,6 +86,7 @@ func loadObjType() error {
}
/*
func loadObjSubType() error {
var obj []ObjSubType
@ -124,6 +125,7 @@ func loadObjSubType() error {
}
*/
func codeObjTypeId(intlId string) (int64, error) {
var objTypeId int64

23
sql.go
View File

@ -49,7 +49,7 @@ func initDB() {
log.Println("initDB : Database cleaned up")
_, err = db.Exec(`CREATE TABLE code_obj_type (
id SMALLINT UNSIGNED NOT NULL
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
,intl_id VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL
,PRIMARY KEY (id)
@ -59,7 +59,7 @@ func initDB() {
log.Println("initDB : code_obj_type created ...")
_, err = db.Exec(`CREATE TABLE code_obj_sub_type (
id SMALLINT UNSIGNED NOT NULL
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
,intl_id VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL
,obj_type_id SMALLINT UNSIGNED NOT NULL
@ -636,6 +636,25 @@ 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 (?, ?, ?);`)
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(intlId, name)
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)
VALUES (?, ?, ?);`)