package pack

import (
	"youngee_b_api/consts"
	"youngee_b_api/model/gorm_model"
	"youngee_b_api/model/http_model"

	"github.com/issue9/conv"
)

func MGormProjectDraftToHttpProjectDraftPreview(gormProjectInfos []*gorm_model.ProjectInfo) []*http_model.ProjectDraftPreview {
	var httpProjectPreviews []*http_model.ProjectDraftPreview
	for _, gormProjectInfo := range gormProjectInfos {
		httpProjectPreview := GormProjectDraftToHttpProjectDraftPreview(gormProjectInfo)
		httpProjectPreviews = append(httpProjectPreviews, httpProjectPreview)
	}
	return httpProjectPreviews
}
func GormProjectDraftToHttpProjectDraftPreview(gormProjectInfo *gorm_model.ProjectInfo) *http_model.ProjectDraftPreview {
	updatedTime := conv.MustString(gormProjectInfo.UpdatedAt)
	updatedTime = updatedTime[0:19]
	return &http_model.ProjectDraftPreview{
		ProjectId:          conv.MustString(gormProjectInfo.ProjectID),
		ProjectName:        gormProjectInfo.ProjectName,
		ProjectStatus:      consts.GetProjectStatus(gormProjectInfo.ProjectStatus),
		ProjectPlatform:    consts.GetProjectPlatform(gormProjectInfo.ProjectPlatform),
		ProjectForm:        consts.GetProjectForm(gormProjectInfo.ProjectForm),
		ProjectContentType: consts.GetProjectContentType(gormProjectInfo.ContentType),
		ProjectType:        consts.GetProjectType(gormProjectInfo.ProjectType),
		ProjectUpdated:     updatedTime,
	}
}
