cooperation_application.go 3.8 KB
package domain

import "time"

// CooperationApplication 共创申请实体
type CooperationApplication struct {
	// 共创申请ID
	CooperationApplicationId int64 `json:"cooperationApplicationId,string"`
	// 共创申请人
	CooperationApplicationApplicant *User `json:"cooperationApplicationApplicant"`
	// 共创申请描述附件
	CooperationApplicationAttachment []*Attachment `json:"cooperationApplicationAttachment"`
	// 共创申请描述
	CooperationApplicationDescription string `json:"cooperationApplicationDescription"`
	// 共创申请审核状态,1待审核,2已同意,3已拒绝
	CooperationApplicationStatus int32 `json:"cooperationApplicationStatus"`
	// 共创申请审核人
	CooperationApplicationVerifier *User `json:"cooperationApplicationVerifier"`
	// 共创申请审核描述
	CooperationApplicationVerifyDescription string `json:"cooperationApplicationVerifyDescription"`
	// 共创申请审核时间
	CooperationApplicationVerifyTime time.Time `json:"cooperationApplicationVerifyTime"`
	// 共创申请时间
	CooperationApplyTime time.Time `json:"cooperationApplyTime"`
	// 共创项目
	CooperationProject *CooperationProject `json:"cooperationProject"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 是否被取消标志位
	IsCanceled bool `json:"isCanceled"`
	// 公司
	Company *Company `json:"company"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
}

type CooperationApplicationRepository interface {
	Save(cooperationApplication *CooperationApplication) (*CooperationApplication, error)
	Remove(cooperationApplication *CooperationApplication) (*CooperationApplication, error)
	FindOne(queryOptions map[string]interface{}) (*CooperationApplication, error)
	Find(queryOptions map[string]interface{}) (int64, []*CooperationApplication, error)
}

func (cooperationApplication *CooperationApplication) Identify() interface{} {
	if cooperationApplication.CooperationApplicationId == 0 {
		return nil
	}
	return cooperationApplication.CooperationApplicationId
}

func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error {
	if userId, ok := data["userId"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserBaseId = userBaseId.(int64)
	}
	if orgs, ok := data["orgs"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Orgs = orgs.([]*Org)
	}
	if status, ok := data["status"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Status = status.(int32)
	}
	if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok {
		cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment)
	}
	if cooperationApplicationDescription, ok := data["cooperationApplicationDescription"]; ok {
		cooperationApplication.CooperationApplicationDescription = cooperationApplicationDescription.(string)
	}
	if cooperationApplicationStatus, ok := data["cooperationApplicationStatus"]; ok {
		cooperationApplication.CooperationApplicationStatus = cooperationApplicationStatus.(int32)
	}
	if cooperationApplicationVerifyDescription, ok := data["cooperationApplicationVerifyDescription"]; ok {
		cooperationApplication.CooperationApplicationVerifyDescription = cooperationApplicationVerifyDescription.(string)
	}
	if cooperationApplicationVerifyTime, ok := data["cooperationApplicationVerifyTime"]; ok {
		cooperationApplication.CooperationApplicationVerifyTime = cooperationApplicationVerifyTime.(time.Time)
	}
	if cooperationApplyTime, ok := data["cooperationApplyTime"]; ok {
		cooperationApplication.CooperationApplyTime = cooperationApplyTime.(time.Time)
	}
	return nil
}