do_client_version.go 1.4 KB
package domain

import "time"

// ClientVersion
type ClientVersion struct {
	// 唯一标识
	Id int64 `json:"id"`
	// 提交人
	Commiter int64 `json:"commiter"`
	// 项目名称
	ProjectName string `json:"projectName"`
	// 版本号
	Version string `json:"version"`
	// 标题
	Title string `json:"title"`
	// 其他备注信息
	Remark string `json:"remark"`
	// 客户端安装包信息
	ClientPackageInfo []*ClientPackageInfo `json:"clientPackageInfo"`
	// 创建时间
	CreateTime time.Time `json:"createTime"`
}

type ClientVersionRepository interface {
	Save(dm *ClientVersion) (*ClientVersion, error)
	Remove(dm *ClientVersion) (*ClientVersion, error)
	FindOne(queryOptions map[string]interface{}) (*ClientVersion, error)
	Find(queryOptions map[string]interface{}) (int64, []*ClientVersion, error)
}

func (m *ClientVersion) Identify() interface{} {
	if m.Id == 0 {
		return nil
	}
	return m.Id
}

func (m *ClientVersion) Update(data map[string]interface{}) error {
	if projectName, ok := data["projectName"]; ok {
		m.ProjectName = projectName.(string)
	}
	if version, ok := data["version"]; ok {
		m.Version = version.(string)
	}
	if title, ok := data["title"]; ok {
		m.Title = title.(string)
	}
	if remark, ok := data["remark"]; ok {
		m.Remark = remark.(string)
	}
	if clientPackageInfo, ok := data["clientPackageInfo"]; ok {
		m.ClientPackageInfo = clientPackageInfo.([]*ClientPackageInfo)
	}
	return nil
}