123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- package fetdata
- import (
- "html/template"
- "time"
- "golang-fave/engine/wrapper"
- "golang-fave/utils"
- )
- type ShopProduct struct {
- wrap *wrapper.Wrapper
- object *utils.MySql_shop_product
- user *User
- currency *Currency
- category *ShopCategory
- }
- func (this *ShopProduct) Id() int {
- if this == nil {
- return 0
- }
- return this.object.A_id
- }
- func (this *ShopProduct) User() *User {
- if this == nil {
- return nil
- }
- if this.user != nil {
- return this.user
- }
- this.user = &User{wrap: this.wrap}
- this.user.load(this.object.A_user)
- return this.user
- }
- func (this *ShopProduct) Currency() *Currency {
- if this == nil {
- return nil
- }
- if this.currency != nil {
- return this.currency
- }
- this.currency = &Currency{wrap: this.wrap}
- this.currency.load(this.object.A_currency)
- return this.currency
- }
- func (this *ShopProduct) Price() float64 {
- if this == nil {
- return 0
- }
- return this.object.A_price
- }
- func (this *ShopProduct) PriceFormat(format string) string {
- if this == nil {
- return ""
- }
- return utils.Float64ToStrF(this.object.A_price, format)
- }
- func (this *ShopProduct) Name() string {
- if this == nil {
- return ""
- }
- return this.object.A_name
- }
- func (this *ShopProduct) Alias() string {
- if this == nil {
- return ""
- }
- return this.object.A_alias
- }
- func (this *ShopProduct) Vendor() string {
- if this == nil {
- return ""
- }
- return this.object.A_vendor
- }
- func (this *ShopProduct) Quantity() int {
- if this == nil {
- return 0
- }
- return this.object.A_quantity
- }
- func (this *ShopProduct) Category() *ShopCategory {
- if this == nil {
- return nil
- }
- if this.category != nil {
- return this.category
- }
- this.category = &ShopCategory{wrap: this.wrap}
- this.category.load(this.object.A_category)
- return this.category
- }
- func (this *ShopProduct) Briefly() template.HTML {
- if this == nil {
- return template.HTML("")
- }
- return template.HTML(this.object.A_briefly)
- }
- func (this *ShopProduct) Content() template.HTML {
- if this == nil {
- return template.HTML("")
- }
- return template.HTML(this.object.A_content)
- }
- func (this *ShopProduct) DateTimeUnix() int {
- if this == nil {
- return 0
- }
- return this.object.A_datetime
- }
- func (this *ShopProduct) DateTimeFormat(format string) string {
- if this == nil {
- return ""
- }
- return time.Unix(int64(this.object.A_datetime), 0).Format(format)
- }
- func (this *ShopProduct) Active() bool {
- if this == nil {
- return false
- }
- return this.object.A_active > 0
- }
- func (this *ShopProduct) Permalink() string {
- if this == nil {
- return ""
- }
- return "/shop/" + this.object.A_alias + "/"
- }
|