29 lines
1.4 KiB
Go
29 lines
1.4 KiB
Go
|
|
package xmlres
|
|||
|
|
|
|||
|
|
import "github.com/ECUST-XX/xml"
|
|||
|
|
|
|||
|
|
// GoldProductConfig XML根节点结构体
|
|||
|
|
type GoldProductConfig struct {
|
|||
|
|
XMLName xml.Name `xml:"root"`
|
|||
|
|
Items []GoldProductItem `xml:"item"` // 匹配所有<item>节点
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GoldProductItem 金豆商品配置项结构体
|
|||
|
|
// 注:xml标签为`xml:"属性名,attr"` 表示解析XML属性而非子节点
|
|||
|
|
type GoldProductItem struct {
|
|||
|
|
ItemID string `xml:"itemID,attr"` // 物品ID(字符串先接收,后续转uint)
|
|||
|
|
Name string `xml:"name,attr"` // 物品名称
|
|||
|
|
ProductID string `xml:"productID,attr"` // 商品ID(可选字段)
|
|||
|
|
Price string `xml:"price,attr"` // 金豆价格(可选字段,后续转float64)
|
|||
|
|
Vip string `xml:"vip,attr"` // VIP折扣(可选字段,后续转float64,如0.6=6折)
|
|||
|
|
MoneyType string `xml:"moneyType,attr"` // 货币类型(可选字段)
|
|||
|
|
Gold string `xml:"gold,attr"` // 赠送金豆数(可选字段)
|
|||
|
|
// // 解析后的强类型字段(便于业务使用)
|
|||
|
|
// ItemIDUint uint32 `xml:"-"` // 解析后的物品ID
|
|||
|
|
// ProductIDUint uint32 `xml:"-"` // 解析后的商品ID
|
|||
|
|
// PriceFloat float64 `xml:"-"` // 解析后的金豆价格
|
|||
|
|
// VipFloat float64 `xml:"-"` // 解析后的VIP折扣
|
|||
|
|
// MoneyTypeUint uint16 `xml:"-"` // 解析后的货币类型
|
|||
|
|
// GoldUint uint32 `xml:"-"` // 解析后的赠送金豆数
|
|||
|
|
}
|