prop.go 1.07 KB
package models

import (
	"errors"

	db "client/icesimba.mail/database"
)

type Prop struct {
	Id         string
	Code       string
	Name       string
	Icon       string
	Desc       string
	CreateTime string
	GameId     string
}

func (in *Prop) QueryProp() (out Prop, err error) {
	if in.Id == "" {
		err = errors.New("参数错误")
		return
	}
	sqlQue := "select * from ice_prop where id=?"
	row := db.SqlDB.QueryRow(sqlQue, in.Id)
	err = row.Scan(
		&out.Id,
		&out.Name,
		&out.GameId,
		&out.Icon,
		&out.Desc,
		&out.CreateTime,
		&out.GameId,
	)
	if err != nil {
		err = errors.New("查询数据失败")
		return
	}
	return
}

func (in *Prop) InsertGift() (code int, out Prop, err error) {
	//	sqlIn := "insert into ice_gift(gname,gid,gico,description,discount,price,createtime) VALUES (?, ?, ?, ?, ?, ?, ?)"
	//	_, err = db.SqlDB.Exec(
	//		sqlIn,
	//		in.Name,
	//		in.GameId,
	//		in.Icon,
	//		in.Desc,
	//		in.Discount,
	//		in.Price,
	//		in.CreateTime,
	//	)
	//	if err != nil {
	//		err = errors.New("插入数据失败")
	//		code = 400
	//		return
	//	}
	//	code = 200
	return
}