// Code generated by gtag. DO NOT EDIT.
// See: https://github.com/wolfogre/gtag

//go:generate go run github.com/wolfogre/gtag/cmd/gtag -types Shared -tags bson .
package domain

import (
	"reflect"
	"strings"
)

var (
	valueOfShared = Shared{}
	typeOfShared  = reflect.TypeOf(valueOfShared)

	_                  = valueOfShared.ID
	fieldOfSharedID, _ = typeOfShared.FieldByName("ID")
	tagOfSharedID      = fieldOfSharedID.Tag

	_                    = valueOfShared.Code
	fieldOfSharedCode, _ = typeOfShared.FieldByName("Code")
	tagOfSharedCode      = fieldOfSharedCode.Tag

	_                      = valueOfShared.BookId
	fieldOfSharedBookId, _ = typeOfShared.FieldByName("BookId")
	tagOfSharedBookId      = fieldOfSharedBookId.Tag

	_                          = valueOfShared.ExpireTime
	fieldOfSharedExpireTime, _ = typeOfShared.FieldByName("ExpireTime")
	tagOfSharedExpireTime      = fieldOfSharedExpireTime.Tag
)

// SharedTags indicate tags of type Shared
type SharedTags struct {
	ID         string // `bson:"_id" json:"_id"`
	Code       string // `bson:"code"`
	BookId     string // `bson:"book_id"`
	ExpireTime string // `bson:"expire_time"`
}

// Values return all tags of Shared as slice
func (t *SharedTags) Values() []string {
	return []string{
		t.ID,
		t.Code,
		t.BookId,
		t.ExpireTime,
	}
}

// Tags return specified tags of Shared
func (*Shared) Tags(tag string, convert ...func(string) string) SharedTags {
	conv := func(in string) string { return strings.TrimSpace(strings.Split(in, ",")[0]) }
	if len(convert) > 0 {
		conv = convert[0]
	}
	if conv == nil {
		conv = func(in string) string { return in }
	}
	return SharedTags{
		ID:         conv(tagOfSharedID.Get(tag)),
		Code:       conv(tagOfSharedCode.Get(tag)),
		BookId:     conv(tagOfSharedBookId.Get(tag)),
		ExpireTime: conv(tagOfSharedExpireTime.Get(tag)),
	}
}

// TagsBson is alias of Tags("bson")
func (*Shared) TagsBson() SharedTags {
	var v *Shared
	return v.Tags("bson")
}
