package dto

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

//CooperationProjectItem 返回共创项目列表项
type CooperationProjectItem struct {
	CooperationMode struct {
		CooperationModeId     int    `json:"cooperationModeId,string"`
		CooperationModeName   string `json:"cooperationModeName"`
		CooperationModeNumber string `json:"cooperationModeNumber"`
	} `json:"cooperationMode"` //项目模式
	CooperationProjectID             int    `json:"cooperationProjectId,string,"`     //id
	CooperationProjectName           string `json:"cooperationProjectName"`           //共创项目名称
	CooperationProjectNumber         string `json:"cooperationProjectNumber"`         //项目编号
	CooperationProjectUndertakerType []int  `json:"cooperationProjectUndertakerType"` //承接对象
	Department                       struct {
		DepartmentNumber string `json:"departmentNumber"`
		DepartmentId     int    `json:"departmentId,string,"`
		DepartmentName   string `json:"departmentName"`
	} `json:"department"` //项目发起部门
	Status                        int `json:"status"` //项目状态
	CooperationProjectPublishTime int `json:"cooperationProjectPublishTime"`
	CooperationProjectSponsor     struct {
		UsersId  int `json:"usersId"`
		UserInfo struct {
			UsersName string `json:"usersName"`
			Phone     string `json:"phone"`
			UsersId   int    `json:"userId,string"`
		} `json:"UserInfo"`
	} `json:"cooperationProjectSponsor"` //共创发起人
}

func ToCooperationProjectItem(projecetParam *allied_creation_cooperation.CooperationProject) *CooperationProjectItem {
	data := CooperationProjectItem{
		CooperationMode:                  projecetParam.CooperationMode,
		CooperationProjectID:             projecetParam.CooperationProjectId,
		CooperationProjectName:           projecetParam.CooperationProjectName,
		CooperationProjectNumber:         projecetParam.CooperationProjectNumber,
		CooperationProjectUndertakerType: projecetParam.CooperationProjectUndertakerType,
		Department:                       projecetParam.Department,
		Status:                           projecetParam.Status,
		CooperationProjectPublishTime:    int(projecetParam.CooperationProjectPublishTime.Unix()),
	}
	data.CooperationProjectSponsor.UsersId = projecetParam.CooperationProjectSponsor.UsersId
	data.CooperationProjectSponsor.UserInfo.UsersId = projecetParam.CooperationProjectSponsor.UsersId
	data.CooperationProjectSponsor.UserInfo.Phone = projecetParam.CooperationProjectSponsor.UserInfo.Phone
	data.CooperationProjectSponsor.UserInfo.UsersName = projecetParam.CooperationProjectSponsor.UserInfo.UsersName
	return &data
}

//CooperationProjectInfo 返回共创项目详情
type CooperationProjectInfo struct {
	CooperationMode struct {
		CooperationModeId     int    `json:"cooperationModeId,string"`
		CooperationModeName   string `json:"cooperationModeName"`
		CooperationModeNumber string `json:"cooperationModeNumber"`
	} `json:"cooperationMode"` //共创模式
	CooperationProjectID             int    `json:"cooperationProjectId,string,"`     //id
	CooperationProjectName           string `json:"cooperationProjectName"`           //共创项目名称
	CooperationProjectNumber         string `json:"cooperationProjectNumber"`         //项目编号
	CooperationProjectPublishTime    int    `json:"cooperationProjectPublishTime"`    //共创项目发布时间
	CooperationProjectUndertakerType []int  `json:"cooperationProjectUndertakerType"` //承接对象
	CooperationProjectDescription    string `json:"cooperationProjectDescription"`    //共创描述
	Department                       struct {
		DepartmentNumber string `json:"departmentNumber"`
		DepartmentId     int    `json:"departmentId,string,"`
		DepartmentName   string `json:"departmentName"`
	} `json:"department"` //项目发起部门
	Status                    int `json:"status"` //项目状态
	CooperationProjectSponsor struct {
		UsersId  int `json:"usersId"`
		UserInfo struct {
			UsersName string `json:"usersName"`
			Phone     string `json:"phone"`
			UsersId   int    `json:"userId,string"`
		} `json:"UserInfo"`
	} `json:"cooperationProjectSponsor"` //共创发起人
	Attachment []allied_creation_cooperation.ProjectAttachment `json:"attachment"` //图片附件
}

func ToCooperationProjectInfo(projecetParam *allied_creation_cooperation.CooperationProject) *CooperationProjectInfo {
	data := CooperationProjectInfo{
		CooperationMode:                  projecetParam.CooperationMode,
		CooperationProjectID:             projecetParam.CooperationProjectId,
		CooperationProjectName:           projecetParam.CooperationProjectName,
		CooperationProjectNumber:         projecetParam.CooperationProjectNumber,
		CooperationProjectUndertakerType: projecetParam.CooperationProjectUndertakerType,
		Department:                       projecetParam.Department,
		Status:                           projecetParam.Status,
		CooperationProjectPublishTime:    int(projecetParam.CooperationProjectPublishTime.Unix()),
		Attachment:                       projecetParam.Attachment,
		CooperationProjectDescription:    projecetParam.CooperationProjectDescription,
	}
	data.CooperationProjectSponsor.UsersId = projecetParam.CooperationProjectSponsor.UsersId
	data.CooperationProjectSponsor.UserInfo.UsersId = projecetParam.CooperationProjectSponsor.UsersId
	data.CooperationProjectSponsor.UserInfo.Phone = projecetParam.CooperationProjectSponsor.UserInfo.Phone
	data.CooperationProjectSponsor.UserInfo.UsersName = projecetParam.CooperationProjectSponsor.UserInfo.UsersName

	return &data
}