cooperation_contract_undertaker.go 1.8 KB
package domain

import "time"

// CooperationContractUndertaker 共创合约承接人
type CooperationContractUndertaker struct {
	// 共创合约承接人id
	CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId,string"`
	// 共创合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 共创合约承接人
	Undertaker *Undertaker `json:"undertaker"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
}

type CooperationContractUndertakerRepository interface {
	Save(cooperationContractUndertaker *CooperationContractUndertaker) (*CooperationContractUndertaker, error)
	Remove(cooperationContractUndertaker *CooperationContractUndertaker) (*CooperationContractUndertaker, error)
	FindOne(queryOptions map[string]interface{}) (*CooperationContractUndertaker, error)
	Find(queryOptions map[string]interface{}) (int64, []*CooperationContractUndertaker, error)
}

func (cooperationContractUndertaker *CooperationContractUndertaker) Identify() interface{} {
	if cooperationContractUndertaker.CooperationContractUndertakerId == 0 {
		return nil
	}
	return cooperationContractUndertaker.CooperationContractUndertakerId
}

func (cooperationContractUndertaker *CooperationContractUndertaker) Update(data map[string]interface{}) error {
	if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
		cooperationContractUndertaker.CooperationContractNumber = cooperationContractNumber.(string)
	}
	if userId, ok := data["userId"]; ok {
		cooperationContractUndertaker.Undertaker.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		cooperationContractUndertaker.Undertaker.UserBaseId = userBaseId.(int64)
	}
	return nil
}