project_module_version.go 1.8 KB
package domain

import "time"

// 项目模块版本
type ProjectModuleVersion struct {
	// 唯一标识
	Id int64 `json:"id"`
	// 项目编号
	ProjectModuleId int64 `json:"projectModuleId"`
	// 唯一标识
	Version int64 `json:"version"`
	// 描述信息
	Description string `json:"description"`
	// 状态 1:正常 2:删除
	Status int `json:"status"`
	// 创建时间
	CreateTime time.Time `json:"createTime"`
	// 更新时间
	UpdateTime time.Time `json:"updateTime"`
}

type ProjectModuleVersionRepository interface {
	Save(projectModuleVersion *ProjectModuleVersion) (*ProjectModuleVersion, error)
	Remove(projectModuleVersion *ProjectModuleVersion) (*ProjectModuleVersion, error)
	FindOne(queryOptions map[string]interface{}) (*ProjectModuleVersion, error)
	Find(queryOptions map[string]interface{}) (int64, []*ProjectModuleVersion, error)
}

func (projectModuleVersion *ProjectModuleVersion) Identify() interface{} {
	if projectModuleVersion.Id == 0 {
		return nil
	}
	return projectModuleVersion.Id
}

func (projectModuleVersion *ProjectModuleVersion) Update(data map[string]interface{}) error {
	if id, ok := data["id"]; ok {
		projectModuleVersion.Id = id.(int64)
	}
	if projectModuleId, ok := data["projectModuleId"]; ok {
		projectModuleVersion.ProjectModuleId = projectModuleId.(int64)
	}
	if version, ok := data["version"]; ok {
		projectModuleVersion.Version = version.(int64)
	}
	if description, ok := data["description"]; ok {
		projectModuleVersion.Description = description.(string)
	}
	if status, ok := data["status"]; ok {
		projectModuleVersion.Status = status.(int)
	}
	if CreateTime, ok := data["CreateTime"]; ok {
		projectModuleVersion.CreateTime = CreateTime.(time.Time)
	}
	if UpdateTime, ok := data["UpdateTime"]; ok {
		projectModuleVersion.UpdateTime = UpdateTime.(time.Time)
	}
	return nil
}