do_project_module_version.go 1.3 KB
package domain

import "time"

// ProjectModuleVersion
type ProjectModuleVersion struct {
	// 唯一标识
	Id int64 `json:"id"`
	// 项目编号
	ProjectModuleId int64 `json:"projectModuleId"`
	// 版本号
	Version string `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(dm *ProjectModuleVersion) (*ProjectModuleVersion, error)
	Remove(dm *ProjectModuleVersion) (*ProjectModuleVersion, error)
	FindOne(queryOptions map[string]interface{}) (*ProjectModuleVersion, error)
	Find(queryOptions map[string]interface{}) (int64, []*ProjectModuleVersion, error)
}

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

func (m *ProjectModuleVersion) Update(data map[string]interface{}) error {
	if version, ok := data["version"]; ok {
		m.Version = version.(string)
	}
	if description, ok := data["description"]; ok {
		m.Description = description.(string)
	}
	if status, ok := data["status"]; ok {
		m.Status = status.(int)
	}
	return nil
}

func (m *ProjectModuleVersion) SetStatusDelete() {
	m.Status = StatusDelete
}