do_project_module.go 1.4 KB
package domain

import "time"

const (
	StatusNormal = iota + 1
	StatusDelete
)

// ProjectModule
type ProjectModule struct {
	// 唯一标识
	Id int64 `json:"id"`
	// 项目名称
	ProjectName string `json:"projectName"`
	// 项目唯一键值
	ProjectKey string `json:"projectKey"`
	// 项目描述信息
	Description string `json:"description"`
	// 状态 1:正常 2:删除
	Status int `json:"status"`
	// 创建时间
	CreateTime time.Time `json:"createTime"`
	// 更新时间
	UpdateTime           time.Time               `json:"updateTime"`
	ProjectModuleVersion []*ProjectModuleVersion `json:"versions"`
}

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

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

func (m *ProjectModule) Update(data map[string]interface{}) error {
	if projectName, ok := data["projectName"]; ok {
		m.ProjectName = projectName.(string)
	}
	if projectKey, ok := data["projectKey"]; ok {
		m.ProjectKey = projectKey.(string)
	}
	if description, ok := data["description"]; ok {
		m.Description = description.(string)
	}
	if status, ok := data["status"]; ok {
		m.Status = status.(int)
	}
	m.UpdateTime = time.Now()
	return nil
}