cooperation_project.go 3.4 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"`
	// 共创模式
	CooperationMode *CooperationMode `json:"cooperationMode"`
	// 共创项目发起部门
	Department *Department `json:"department"`
	// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
	CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 图片附件
	Attachment []*Attachment `json:"attachment"`
	// 公司
	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"`
	//	共创申请人计数
	ApplicantCount int32 `json:"applicantCount"`
}

type CooperationProjectRepository interface {
	Save(cooperationProject *CooperationProject) (*CooperationProject, error)
	UpdateMany(cooperationProjects []*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 cooperationProjectUndertakerTypes, ok := data["cooperationProjectUndertakerTypes"]; ok {
		cooperationProject.CooperationProjectUndertakerTypes = cooperationProjectUndertakerTypes.([]int32)
	}
	if operateTime, ok := data["operateTime"]; ok {
		cooperationProject.OperateTime = operateTime.(time.Time)
	}
	if status, ok := data["status"]; ok {
		cooperationProject.Status = status.(int32)
	}
	return nil
}