cooperation_project.go 7.1 KB
package domain

import "time"

// CooperationProject 共创项目实体
type CooperationProject struct {
	// 共创项目ID
	CooperationProjectId int64 `json:"cooperationProjectId,string"`
	// 共创项目编号
	CooperationProjectNumber string `json:"cooperationProjectNumber"`
	// 共创项目描述
	CooperationProjectDescription string `json:"cooperationProjectDescription"`
	// 共创项目名称
	CooperationProjectName string `json:"cooperationProjectName"`
	// 共创项目发布时间
	CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"`
	// 共创项目发布人
	CooperationProjectPublisher *User `json:"cooperationProjectPublisher"`
	// 共创项目发起人
	CooperationProjectSponsor *User `json:"cooperationProjectSponsor"`
	// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
	CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 公司
	Company *Company `json:"company"`
	// 操作人
	Operator *User `json:"operator"`
	// 操作时间
	OperateTime time.Time `json:"operateTime"`
	// 共创项目状态,1招标中,2结束
	Status int32 `json:"status"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
}

type CooperationProjectRepository interface {
	Save(cooperationProject *CooperationProject) (*CooperationProject, error)
	Remove(cooperationProject *CooperationProject) (*CooperationProject, error)
	FindOne(queryOptions map[string]interface{}) (*CooperationProject, error)
	Find(queryOptions map[string]interface{}) (int64, []*CooperationProject, error)
}

func (cooperationProject *CooperationProject) Identify() interface{} {
	if cooperationProject.CooperationProjectId == 0 {
		return nil
	}
	return cooperationProject.CooperationProjectId
}

func (cooperationProject *CooperationProject) Update(data map[string]interface{}) error {
	if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok {
		cooperationProject.CooperationProjectNumber = cooperationProjectNumber.(string)
	}
	if cooperationProjectDescription, ok := data["cooperationProjectDescription"]; ok {
		cooperationProject.CooperationProjectDescription = cooperationProjectDescription.(string)
	}
	if cooperationProjectName, ok := data["cooperationProjectName"]; ok {
		cooperationProject.CooperationProjectName = cooperationProjectName.(string)
	}
	if cooperationProjectPublishTime, ok := data["cooperationProjectPublishTime"]; ok {
		cooperationProject.CooperationProjectPublishTime = cooperationProjectPublishTime.(time.Time)
	}
	if userId, ok := data["userId"]; ok {
		cooperationProject.CooperationProjectPublisher.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		cooperationProject.CooperationProjectPublisher.UserBaseId = userBaseId.(int64)
	}
	if orgId, ok := data["orgId"]; ok {
		cooperationProject.CooperationProjectPublisher.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		cooperationProject.CooperationProjectPublisher.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationProject.CooperationProjectPublisher.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationProject.CooperationProjectPublisher.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationProject.CooperationProjectPublisher.Org.Company.CompanyName = companyName.(string)
	}
	if orgs, ok := data["orgs"]; ok {
		cooperationProject.CooperationProjectPublisher.Orgs = orgs.([]*Org)
	}
	if departmentId, ok := data["departmentId"]; ok {
		cooperationProject.CooperationProjectPublisher.Department.DepartmentId = departmentId.(int64)
	}
	if departmentName, ok := data["departmentName"]; ok {
		cooperationProject.CooperationProjectPublisher.Department.DepartmentName = departmentName.(string)
	}
	if departmentNumber, ok := data["departmentNumber"]; ok {
		cooperationProject.CooperationProjectPublisher.Department.DepartmentNumber = departmentNumber.(string)
	}
	if isOrganization, ok := data["isOrganization"]; ok {
		cooperationProject.CooperationProjectPublisher.Department.IsOrganization = isOrganization.(bool)
	}
	if roleId, ok := data["roleId"]; ok {
		cooperationProject.CooperationProjectPublisher.Role.RoleId = roleId.(int64)
	}
	if roleName, ok := data["roleName"]; ok {
		cooperationProject.CooperationProjectPublisher.Role.RoleName = roleName.(string)
	}
	if userAvatar, ok := data["userAvatar"]; ok {
		cooperationProject.CooperationProjectPublisher.UserInfo.UserAvatar = userAvatar.(string)
	}
	if userEmail, ok := data["userEmail"]; ok {
		cooperationProject.CooperationProjectPublisher.UserInfo.UserEmail = userEmail.(string)
	}
	if userName, ok := data["userName"]; ok {
		cooperationProject.CooperationProjectPublisher.UserInfo.UserName = userName.(string)
	}
	if userPhone, ok := data["userPhone"]; ok {
		cooperationProject.CooperationProjectPublisher.UserInfo.UserPhone = userPhone.(string)
	}
	if userAccount, ok := data["userAccount"]; ok {
		cooperationProject.CooperationProjectPublisher.UserInfo.UserAccount = userAccount.(string)
	}
	if userType, ok := data["userType"]; ok {
		cooperationProject.CooperationProjectPublisher.UserType = userType.(int32)
	}
	if status, ok := data["status"]; ok {
		cooperationProject.CooperationProjectPublisher.Status = status.(int32)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationProject.CooperationProjectPublisher.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationProject.CooperationProjectPublisher.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationProject.CooperationProjectPublisher.Company.CompanyName = companyName.(string)
	}
	if userId, ok := data["userId"]; ok {
		cooperationProject.CooperationProjectSponsor.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		cooperationProject.CooperationProjectSponsor.UserBaseId = userBaseId.(int64)
	}
	if orgId, ok := data["orgId"]; ok {
		cooperationProject.CooperationProjectSponsor.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		cooperationProject.CooperationProjectSponsor.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationProject.CooperationProjectSponsor.Company.CompanyId = companyId.(int64)
	}
	if cooperationProjectUndertakerType, ok := data["cooperationProjectUndertakerType"]; ok {
		cooperationProject.CooperationProjectUndertakerType = cooperationProjectUndertakerType.([]int32)
	}
	if operateTime, ok := data["operateTime"]; ok {
		cooperationProject.OperateTime = operateTime.(time.Time)
	}
	if status, ok := data["status"]; ok {
		cooperationProject.Status = status.(int32)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		cooperationProject.UpdatedAt = updatedAt.(time.Time)
	}
	if deletedAt, ok := data["deletedAt"]; ok {
		cooperationProject.DeletedAt = deletedAt.(time.Time)
	}
	if createdAt, ok := data["createdAt"]; ok {
		cooperationProject.CreatedAt = createdAt.(time.Time)
	}
	return nil
}