package dto

import (
	"time"

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

type CooperationProjectInfo struct {
	Company struct {
		CompanyId   int    `json:"companyId,string,"`
		CompanyLogo string `json:"companyLogo"`
		CompanyName string `json:"companyName"`
	} `json:"company"` //项目归属企业
	Org struct {
		OrgId   int    `json:"orgId,string"`
		OrgName string `json:"orgName"`
	} `json:"org"` //项目创建时的组织
	CooperationMode struct {
		CooperationModeId     int    `json:"cooperationModeId,string"`
		CooperationModeName   string `json:"cooperationModeName"`
		CooperationModeNumber string `json:"cooperationModeNumber"`
	} `json:"cooperationMode"` //项目模式
	CooperationProjectDescription string              `json:"cooperationProjectDescription"`
	Attachment                    []domain.Attachment `json:"attachment"` //图片附件
	CooperationProjectId          int                 `json:"cooperationProjectId,string,"`
	CooperationProjectName        string              `json:"cooperationProjectName"`
	CooperationProjectNumber      string              `json:"cooperationProjectNumber"`
	CooperationProjectPublishTime time.Time           `json:"cooperationProjectPublishTime"`
	CreatedAt                     time.Time           `json:"createdAt"`
	CooperationProjectSponsor     struct {
		UserId    int    `json:"userId,string"`
		UsersName string `json:"userName"`
		UsersCode string `json:"userCode"`
		UserInfo  struct {
			UsersName string `json:"userName"`
			UsersCode string `json:"userCode"`
			Phone     string `json:"phone"`
			UsersId   int    `json:"userId,string"`
		} `json:"userInfo"`
	} `json:"cooperationProjectSponsor"` //项目发起人
	CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerTypes"` //共创合约承接对象,1员工,2共创用户,3公开
	Department                       struct {
		DepartmentNumber string `json:"departmentNumber"`
		DepartmentId     int    `json:"departmentId,string,"`
		DepartmentName   string `json:"departmentName"`
	} `json:"department"` //项目发起部门
	Status int `json:"status"` // 共创项目状态,1招标中,2结束
}

func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProject) *CooperationProjectInfo {
	data := CooperationProjectInfo{
		Company:                          param.Company,
		Org:                              param.Org,
		CooperationMode:                  param.CooperationMode,
		CooperationProjectDescription:    param.CooperationProjectDescription,
		CooperationProjectId:             param.CooperationProjectId,
		CooperationProjectName:           param.CooperationProjectName,
		CooperationProjectNumber:         param.CooperationProjectNumber,
		CooperationProjectPublishTime:    param.CooperationProjectPublishTime,
		CreatedAt:                        param.CreatedAt,
		CooperationProjectUndertakerType: param.CooperationProjectUndertakerType,
		Department:                       param.Department,
		Status:                           param.Status,
		Attachment:                       param.Attachment,
	}

	data.CooperationProjectSponsor.UsersCode = param.CooperationProjectSponsor.UserInfo.UsersCode
	data.CooperationProjectSponsor.UsersName = param.CooperationProjectSponsor.UserInfo.UsersName
	data.CooperationProjectSponsor.UserId = param.CooperationProjectSponsor.UsersId
	data.CooperationProjectSponsor.UserInfo = param.CooperationProjectSponsor.UserInfo
	return &data
}

type CooperationApplicationItem struct {
	CooperationApplicationApplicant struct {
		Company    domain.CompanyData `json:"company"`
		Department domain.Department  `json:"department"`
		Org        domain.Org         `json:"org"`
		UserBaseID int                `json:"userBaseId"`
		UserID     int                `json:"userId"`
		UserInfo   domain.UserInfo    `json:"userInfo"`
		UserType   int                `json:"userType"`
	} `json:"cooperationApplicationApplicant"` //申请人
	CooperationApplicationDescription string              `json:"cooperationApplicationDescription"` //描述
	CooperationApplicationID          int                 `json:"cooperationApplicationId"`          //申请id
	CooperationApplicationStatus      int                 `json:"cooperationApplicationStatus"`      //状态
	CooperationApplyTime              int                 `json:"cooperationApplyTime"`              //申请时间
	CooperationApplicationAttachment  []domain.Attachment `json:"cooperationApplicationAttachment"`  //附件
}

func ToCooperationApplicationItem(param *allied_creation_cooperation.CooperationApplication) *CooperationApplicationItem {
	//data := CooperationApplicationItem{
	//	CooperationApplicationDescription: param.CooperationApplicationDescription,
	//	CooperationApplicationID:          param.CooperationApplicationID,
	//	CooperationApplicationStatus:      param.CooperationApplicationStatus,
	//	CooperationApplyTime:              int(param.CooperationApplyTime.Unix()),
	//	CooperationApplicationAttachment:  param.CooperationApplicationAttachment,
	//}
	//data.CooperationApplicationApplicant.Company.CompanyID = param.CooperationApplicationApplicant.Company.CompanyID
	//data.CooperationApplicationApplicant.Company.CompanyName = param.CooperationApplicationApplicant.Company.CompanyName
	//data.CooperationApplicationApplicant.Department.DepartmentId = param.CooperationApplicationApplicant.Department.DepartmentID
	//data.CooperationApplicationApplicant.Department.DepartmentName = param.CooperationApplicationApplicant.Department.DepartmentName
	//data.CooperationApplicationApplicant.Department.DepartmentNumber = param.CooperationApplicationApplicant.Department.DepartmentNumber
	//data.CooperationApplicationApplicant.Org.OrgID = param.CooperationApplicationApplicant.Org.OrgID
	//data.CooperationApplicationApplicant.Org.OrgName = param.CooperationApplicationApplicant.Org.OrgName
	//data.CooperationApplicationApplicant.UserID = param.CooperationApplicationApplicant.UserID
	//data.CooperationApplicationApplicant.UserType = param.CooperationApplicationApplicant.UserType
	//data.CooperationApplicationApplicant.UserInfo.Phone = param.CooperationApplicationApplicant.UserInfo.UserPhone
	//data.CooperationApplicationApplicant.UserInfo.UsersName = param.CooperationApplicationApplicant.UserInfo.UserName
	//data.CooperationApplicationApplicant.UserInfo.UsersId = param.CooperationApplicationApplicant.UserID
	//return &data
	return nil
}