project_module.go 2.5 KB
package domain

import "time"

// 项目模块
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:"projectModuleVersion"`
}

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

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

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