package dto

import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"

type ContractChangeLogItem struct {
	CooperationContractNumber string `json:"cooperationContractNumber"`
	CreatedAt                 string `json:"createdAt"`
	IncentivesRule            string `json:"incentivesRule"`
	IncentivesRuleDetail      string `json:"incentivesRuleDetail"`
	Operation                 string `json:"operation"`
	OperationType             int    `json:"operationType"`
	Undertakers               string `json:"undertakers"`
	UpdatedAt                 string `json:"updatedAt"`
	OperatorTime              string `json:"operationTime"`
}

func ToContractChangeLogList(param *allied_creation_cooperation.DataContractChangeLogsSearch) []ContractChangeLogItem {
	listData := []ContractChangeLogItem{}
	for _, v := range param.Grid.List {
		item := ContractChangeLogItem{
			CooperationContractNumber: v.CooperationContractNumber,
			CreatedAt:                 v.CreatedAt.Format("2006-01-02 15:04:05"),
			IncentivesRule:            v.IncentivesRule,
			IncentivesRuleDetail:      v.IncentivesRuleDetail,
			Operation:                 v.Operator.UserName,
			OperationType:             int(v.OperationType),
			Undertakers:               v.Undertakers,
			UpdatedAt:                 v.UpdatedAt.Format("2006-01-02 15:04:05"),
			OperatorTime:              v.OperatorTime.Format("2006-01-02 15:04:05"),
		}
		listData = append(listData, item)
	}
	return listData
}