cooperation_application.go 7.3 KB
package domain

import "time"

// 共创申请实体
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"`
	// 公司
	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 orgId, ok := data["orgId"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Org.Company.CompanyName = companyName.(string)
	}
	if orgs, ok := data["orgs"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Orgs = orgs.([]*Org)
	}
	if departmentId, ok := data["departmentId"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Department.DepartmentId = departmentId.(int64)
	}
	if departmentName, ok := data["departmentName"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Department.DepartmentName = departmentName.(string)
	}
	if departmentNumber, ok := data["departmentNumber"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Department.DepartmentNumber = departmentNumber.(string)
	}
	if isOrganization, ok := data["isOrganization"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Department.IsOrganization = isOrganization.(bool)
	}
	if roleId, ok := data["roleId"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Role.RoleId = roleId.(int64)
	}
	if roleName, ok := data["roleName"]; ok {
		cooperationApplication.CooperationApplicationApplicant.Role.RoleName = roleName.(string)
	}
	if userAvatar, ok := data["userAvatar"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserInfo.UserAvatar = userAvatar.(string)
	}
	if userEmail, ok := data["userEmail"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserInfo.UserEmail = userEmail.(string)
	}
	if userName, ok := data["userName"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserInfo.UserName = userName.(string)
	}
	if userPhone, ok := data["userPhone"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserInfo.UserPhone = userPhone.(string)
	}
	if userAccount, ok := data["userAccount"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserInfo.UserAccount = userAccount.(string)
	}
	if userType, ok := data["userType"]; ok {
		cooperationApplication.CooperationApplicationApplicant.UserType = userType.(int32)
	}
	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)
	}
	if cooperationProjectId, ok := data["cooperationProjectId"]; ok {
		cooperationApplication.CooperationProject.CooperationProjectId = cooperationProjectId.(int64)
	}
	if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok {
		cooperationApplication.CooperationProject.CooperationProjectNumber = cooperationProjectNumber.(string)
	}
	if cooperationProjectDescription, ok := data["cooperationProjectDescription"]; ok {
		cooperationApplication.CooperationProject.CooperationProjectDescription = cooperationProjectDescription.(string)
	}
	if cooperationProjectName, ok := data["cooperationProjectName"]; ok {
		cooperationApplication.CooperationProject.CooperationProjectName = cooperationProjectName.(string)
	}
	if cooperationProjectPublishTime, ok := data["cooperationProjectPublishTime"]; ok {
		cooperationApplication.CooperationProject.CooperationProjectPublishTime = cooperationProjectPublishTime.(time.Time)
	}
	if operateTime, ok := data["operateTime"]; ok {
		cooperationApplication.CooperationProject.OperateTime = operateTime.(time.Time)
	}
	if status, ok := data["status"]; ok {
		cooperationApplication.CooperationProject.Status = status.(int32)
	}
	return nil
}