column_setting.go 1.9 KB
package domain

import "time"

// 栏目设置
type ColumnSetting struct {
	// 栏目设置id
	Id int64 `json:"id"`
	// 栏目设置关联用户公司id
	CompanyId int32 `json:"companyId"`
	// 栏目设置创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 栏目设置描述
	Description string `json:"description"`
	// 栏目设置模块名称
	Key string `json:"key"`
	// 栏目设置关联用户uid
	Uid int64 `json:"uid"`
	// 栏目设置更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 栏目设置关联用户名称
	UserName string `json:"userName"`
	// 栏目数组
	Value []Column `json:"value"`
}

type ColumnSettingRepository interface {
	Save(columnSetting *ColumnSetting) (*ColumnSetting, error)
	Remove(columnSetting *ColumnSetting) (*ColumnSetting, error)
	FindOne(queryOptions map[string]interface{}) (*ColumnSetting, error)
	Find(queryOptions map[string]interface{}) (int64, []*ColumnSetting, error)
}

func (columnSetting *ColumnSetting) Identify() interface{} {
	if columnSetting.Id == 0 {
		return nil
	}
	return columnSetting.Id
}

func (columnSetting *ColumnSetting) Update(data map[string]interface{}) error {
	if columnSettingId, ok := data["columnSettingId"]; ok {
		columnSetting.Id = columnSettingId.(int64)
	}
	if companyId, ok := data["companyId"]; ok {
		columnSetting.CompanyId = companyId.(int32)
	}
	if createdAt, ok := data["createdAt"]; ok {
		columnSetting.CreatedAt = createdAt.(time.Time)
	}
	if description, ok := data["description"]; ok {
		columnSetting.Description = description.(string)
	}
	if key, ok := data["key"]; ok {
		columnSetting.Key = key.(string)
	}
	if uid, ok := data["uid"]; ok {
		columnSetting.Uid = uid.(int64)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		columnSetting.UpdatedAt = updatedAt.(time.Time)
	}
	if userName, ok := data["userName"]; ok {
		columnSetting.UserName = userName.(string)
	}
	if value, ok := data["value"]; ok {
		columnSetting.Value = value.([]Column)
	}
	return nil
}