cooperation_contract.go 3.1 KB
package domain

import (
	"time"
)

// CooperationContract 共创项目合约实体
type CooperationContract struct {
	// 共创合约ID
	CooperationContractId int64 `json:"cooperationContractId,string"`
	// 共创合约描述
	CooperationContractDescription string `json:"cooperationContractDescription"`
	// 共创合约名称
	CooperationContractName string `json:"cooperationContractName"`
	// 共创合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 共创合约承接对象,1员工,2共创用户,3公开
	CooperationContractUndertakerTypes []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"`
	// 分红激励规则
	DividendsIncentivesRules []*DividendsIncentivesRule `json:"dividendsIncentivesRules"`
	// 金额激励规则
	MoneyIncentivesRules []*MoneyIncentivesRule `json:"moneyIncentivesRules"`
	// 共创承接人列表
	Undertakers []*Undertaker `json:"undertakers"`
	// 共创合约相关人列表
	RelevantPeople []*Relevant `json:"relevantPeople"`
	// 操作时间
	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 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 cooperationContractUndertakerType, ok := data["cooperationContractUndertakerType"]; ok {
		cooperationContract.CooperationContractUndertakerTypes = cooperationContractUndertakerType.([]int32)
	}
	if status, ok := data["status"]; ok {
		cooperationContract.Status = status.(int32)
	}
	if operateTime, ok := data["operateTime"]; ok {
		cooperationContract.OperateTime = operateTime.(time.Time)
	}
	return nil
}