dictionary_item.go 927 字节
package domain

// 字典明细项
type DictionaryItem struct {
	// 项编码
	ItemCode string `json:"itemCode"`
	// 项标签
	ItemLabel string `json:"itemLabel"`
	// 值
	ItemValue string `json:"itemValue"`
	// 是否可见【1:不可以】【2:可以】
	IsShow int `json:"isShow"`
	// 显示序号
	Sort int `json:"sort"`
}

type DictionaryItemShow int

const (
	DictionaryItemIsShow  int = 1 //不可见
	DictionaryItemNotShow int = 2 //可见
)

func (show DictionaryItemShow) Valid() bool {
	var ok bool
	switch int(show) {
	case DictionaryItemNotShow:
		ok = true
	case DictionaryItemIsShow:
		ok = true
	default:
		ok = false
	}
	return ok
}

//明细项排序
type DictionaryItems []DictionaryItem

func (a DictionaryItems) Len() int           { return len(a) }
func (a DictionaryItems) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a DictionaryItems) Less(i, j int) bool { return a[i].Sort < a[j].Sort }