cooperation_contract_change_log.go 2.6 KB
package domain

import "time"

const (
	EDIT    = iota + 1 // 编辑
	PAUSE              // 暂停
	RECOVER            // 恢复
)

// CooperationContractChangeLog 共创合约变更日志
type CooperationContractChangeLog struct {
	// 共创合约变更日志
	CooperationContractChangeLogId int64 `json:"cooperationContractChangeLogId,string"`
	// 激励规则
	IncentivesRule string `json:"incentivesRule"`
	// 激励规则明细
	IncentivesRuleDetail string `json:"incentivesRuleDetail"`
	// 合约变更操作类型,1编辑、2暂停、3恢复
	OperationType int32 `json:"operationType"`
	// 共创合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 承接人
	Undertakers string `json:"undertakers"`
	// 公司
	Company *Company `json:"company"`
	// 组织机构
	Org *Org `json:"org"`
	// 操作人
	Operator *User `json:"operator"`
	// 操作时间
	OperatorTime time.Time `json:"operatorTime"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
}

type CooperationContractChangeLogRepository interface {
	Save(cooperationContractChangeLog *CooperationContractChangeLog) (*CooperationContractChangeLog, error)
	Remove(cooperationContractChangeLog *CooperationContractChangeLog) (*CooperationContractChangeLog, error)
	FindOne(queryOptions map[string]interface{}) (*CooperationContractChangeLog, error)
	Find(queryOptions map[string]interface{}) (int64, []*CooperationContractChangeLog, error)
}

func (cooperationContractChangeLog *CooperationContractChangeLog) Identify() interface{} {
	if cooperationContractChangeLog.CooperationContractChangeLogId == 0 {
		return nil
	}
	return cooperationContractChangeLog.CooperationContractChangeLogId
}

func (cooperationContractChangeLog *CooperationContractChangeLog) Update(data map[string]interface{}) error {
	if incentivesRule, ok := data["incentivesRule"]; ok {
		cooperationContractChangeLog.IncentivesRule = incentivesRule.(string)
	}
	if incentivesRuleDetail, ok := data["incentivesRuleDetail"]; ok {
		cooperationContractChangeLog.IncentivesRuleDetail = incentivesRuleDetail.(string)
	}
	if operationType, ok := data["operationType"]; ok {
		cooperationContractChangeLog.OperationType = operationType.(int32)
	}
	if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
		cooperationContractChangeLog.CooperationContractNumber = cooperationContractNumber.(string)
	}
	if undertakers, ok := data["undertakers"]; ok {
		cooperationContractChangeLog.Undertakers = undertakers.(string)
	}
	cooperationContractChangeLog.UpdatedAt = time.Now()
	return nil
}