cooperation_contract.go 7.3 KB
package domain

import "time"

// 共创项目合约实体
type CooperationContract struct {
	// 共创合约ID
	CooperationContractId int64 `json:"cooperationContractId,string"`
	// 共创合约描述
	CooperationContractDescription string `json:"cooperationContractDescription"`
	// 共创合约名称
	CooperationContractName string `json:"cooperationContractName"`
	// 共创合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 合约推荐人
	CooperationContractReferrer *User `json:"cooperationContractReferrer"`
	// 共创合约业务员
	CooperationContractSalesman *User `json:"cooperationContractSalesman"`
	// 共创合约承接对象,1员工,2共创用户,3公开
	CooperationContractUndertakerType []int32 `json:"cooperationContractUndertakerType"`
	// 共创合约发起人
	CooperationContractSponsor *User `json:"cooperationContractSponsor"`
	// 共创模式或者合伙模式
	CooperationMode *CooperationMode `json:"cooperationMode"`
	// 合约状态,1启用,2禁用
	Status int32 `json:"status"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 公司
	Company *Company `json:"company"`
	// 操作人
	Operator *User `json:"operator"`
	// 操作时间
	OperateTime time.Time `json:"operateTime"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
}

type CooperationContractRepository interface {
	Save(cooperationContract *CooperationContract) (*CooperationContract, error)
	Remove(cooperationContract *CooperationContract) (*CooperationContract, error)
	FindOne(queryOptions map[string]interface{}) (*CooperationContract, error)
	Find(queryOptions map[string]interface{}) (int64, []*CooperationContract, error)
}

func (cooperationContract *CooperationContract) Identify() interface{} {
	if cooperationContract.CooperationContractId == 0 {
		return nil
	}
	return cooperationContract.CooperationContractId
}

func (cooperationContract *CooperationContract) Update(data map[string]interface{}) error {
	if cooperationContractId, ok := data["cooperationContractId"]; ok {
		cooperationContract.CooperationContractId = cooperationContractId.(int64)
	}
	if cooperationContractDescription, ok := data["cooperationContractDescription"]; ok {
		cooperationContract.CooperationContractDescription = cooperationContractDescription.(string)
	}
	if cooperationContractName, ok := data["cooperationContractName"]; ok {
		cooperationContract.CooperationContractName = cooperationContractName.(string)
	}
	if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
		cooperationContract.CooperationContractNumber = cooperationContractNumber.(string)
	}
	if userId, ok := data["userId"]; ok {
		cooperationContract.CooperationContractReferrer.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		cooperationContract.CooperationContractReferrer.UserBaseId = userBaseId.(int64)
	}
	if orgId, ok := data["orgId"]; ok {
		cooperationContract.CooperationContractReferrer.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		cooperationContract.CooperationContractReferrer.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationContract.CooperationContractReferrer.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationContract.CooperationContractReferrer.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationContract.CooperationContractReferrer.Org.Company.CompanyName = companyName.(string)
	}
	if orgs, ok := data["orgs"]; ok {
		cooperationContract.CooperationContractReferrer.Orgs = orgs.([]*Org)
	}
	if departmentId, ok := data["departmentId"]; ok {
		cooperationContract.CooperationContractReferrer.Department.DepartmentId = departmentId.(int64)
	}
	if departmentName, ok := data["departmentName"]; ok {
		cooperationContract.CooperationContractReferrer.Department.DepartmentName = departmentName.(string)
	}
	if departmentNumber, ok := data["departmentNumber"]; ok {
		cooperationContract.CooperationContractReferrer.Department.DepartmentNumber = departmentNumber.(string)
	}
	if isOrganization, ok := data["isOrganization"]; ok {
		cooperationContract.CooperationContractReferrer.Department.IsOrganization = isOrganization.(bool)
	}
	if roleId, ok := data["roleId"]; ok {
		cooperationContract.CooperationContractReferrer.Role.RoleId = roleId.(int64)
	}
	if roleName, ok := data["roleName"]; ok {
		cooperationContract.CooperationContractReferrer.Role.RoleName = roleName.(string)
	}
	if userAvatar, ok := data["userAvatar"]; ok {
		cooperationContract.CooperationContractReferrer.UserInfo.UserAvatar = userAvatar.(string)
	}
	if userEmail, ok := data["userEmail"]; ok {
		cooperationContract.CooperationContractReferrer.UserInfo.UserEmail = userEmail.(string)
	}
	if userName, ok := data["userName"]; ok {
		cooperationContract.CooperationContractReferrer.UserInfo.UserName = userName.(string)
	}
	if userPhone, ok := data["userPhone"]; ok {
		cooperationContract.CooperationContractReferrer.UserInfo.UserPhone = userPhone.(string)
	}
	if userAccount, ok := data["userAccount"]; ok {
		cooperationContract.CooperationContractReferrer.UserInfo.UserAccount = userAccount.(string)
	}
	if userType, ok := data["userType"]; ok {
		cooperationContract.CooperationContractReferrer.UserType = userType.(int32)
	}
	if status, ok := data["status"]; ok {
		cooperationContract.CooperationContractReferrer.Status = status.(int32)
	}
	if cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok {
		cooperationContract.CooperationContractUndertakerType = cooperationContractUndertakerType.([]int32)
	}
	if cooperationModeId, ok := data["cooperationModeId"]; ok {
		cooperationContract.CooperationMode.CooperationModeId = cooperationModeId.(int64)
	}
	if cooperationModeNumber, ok := data["cooperationModeNumber"]; ok {
		cooperationContract.CooperationMode.CooperationModeNumber = cooperationModeNumber.(string)
	}
	if cooperationModeName, ok := data["cooperationModeName"]; ok {
		cooperationContract.CooperationMode.CooperationModeName = cooperationModeName.(string)
	}
	if status, ok := data["status"]; ok {
		cooperationContract.CooperationMode.Status = status.(int32)
	}
	if remarks, ok := data["remarks"]; ok {
		cooperationContract.CooperationMode.Remarks = remarks.(string)
	}
	if operateTime, ok := data["operateTime"]; ok {
		cooperationContract.CooperationMode.OperateTime = operateTime.(time.Time)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		cooperationContract.CooperationMode.UpdatedAt = updatedAt.(time.Time)
	}
	if deletedAt, ok := data["deletedAt"]; ok {
		cooperationContract.CooperationMode.DeletedAt = deletedAt.(time.Time)
	}
	if createdAt, ok := data["createdAt"]; ok {
		cooperationContract.CooperationMode.CreatedAt = createdAt.(time.Time)
	}
	if status, ok := data["status"]; ok {
		cooperationContract.Status = status.(int32)
	}
	if operateTime, ok := data["operateTime"]; ok {
		cooperationContract.OperateTime = operateTime.(time.Time)
	}
	if createdAt, ok := data["createdAt"]; ok {
		cooperationContract.CreatedAt = createdAt.(time.Time)
	}
	if deletedAt, ok := data["deletedAt"]; ok {
		cooperationContract.DeletedAt = deletedAt.(time.Time)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		cooperationContract.UpdatedAt = updatedAt.(time.Time)
	}
	return nil
}