client_version.go 1.8 KB
package domain

import "time"

// 客户端版本信息
type ClientVersion struct {
	// dcc
	Id int64 `json:"id"`
	// 提交人
	Commiter string `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(clientVersion *ClientVersion) (*ClientVersion, error)
	Remove(clientVersion *ClientVersion) (*ClientVersion, error)
	FindOne(queryOptions map[string]interface{}) (*ClientVersion, error)
	Find(queryOptions map[string]interface{}) (int64, []*ClientVersion, error)
}

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

func (clientVersion *ClientVersion) Update(data map[string]interface{}) error {
	if Id, ok := data["Id"]; ok {
		clientVersion.Id = Id.(int64)
	}
	if commiter, ok := data["commiter"]; ok {
		clientVersion.Commiter = commiter.(string)
	}
	if projectName, ok := data["projectName"]; ok {
		clientVersion.ProjectName = projectName.(string)
	}
	if version, ok := data["version"]; ok {
		clientVersion.Version = version.(string)
	}
	if title, ok := data["title"]; ok {
		clientVersion.Title = title.(string)
	}
	if remark, ok := data["remark"]; ok {
		clientVersion.Remark = remark.(string)
	}
	if clientPackageInfo, ok := data["clientPackageInfo"]; ok {
		clientVersion.ClientPackageInfo = clientPackageInfo.([]*ClientPackageInfo)
	}
	if createTime, ok := data["createTime"]; ok {
		clientVersion.CreateTime = createTime.(time.Time)
	}
	return nil
}