package mapper

import (
	"go-humas-be/app/database/entity"
	res "go-humas-be/app/module/ppid_data_files/response"
)

func PpidDataFilesResponseMapper(ppidDataFilesReq *entity.PpidDataFiles) (ppidDataFilesRes *res.PpidDataFilesResponse) {
	fileUrl := "/ppid-data-files/viewer/"
	if ppidDataFilesReq.FileName != nil {
		fileUrl += *ppidDataFilesReq.FileName
	}
	if ppidDataFilesReq != nil {
		ppidDataFilesRes = &res.PpidDataFilesResponse{
			ID:            ppidDataFilesReq.ID,
			Title:         ppidDataFilesReq.Title,
			PpidDataId:    ppidDataFilesReq.PpidDataId,
			FileUrl:       fileUrl,
			FileType:      ppidDataFilesReq.FileType,
			DownloadCount: ppidDataFilesReq.DownloadCount,
			CreatedById:   ppidDataFilesReq.CreatedById,
			StatusId:      ppidDataFilesReq.StatusId,
			IsPublish:     ppidDataFilesReq.IsPublish,
			PublishedAt:   ppidDataFilesReq.PublishedAt,
			IsActive:      ppidDataFilesReq.IsActive,
			CreatedAt:     ppidDataFilesReq.CreatedAt,
			UpdatedAt:     ppidDataFilesReq.UpdatedAt,
		}
	}
	return ppidDataFilesRes
}
