1 /* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #define MLOG_TAG "Media_Cloud_Controller" 17 18 #include "cloud_media_download_controller_processor.h" 19 20 #include "media_log.h" 21 22 namespace OHOS::Media::CloudSync { ConvertPhotosDtoToPhotosVo(const PhotosDto & photosDto)23PhotosVo CloudMediaDownloadControllerProcessor::ConvertPhotosDtoToPhotosVo(const PhotosDto &photosDto) 24 { 25 MEDIA_DEBUG_LOG("ConvertPhotosDtoToPhotosVo, photosDto: %{public}s.", photosDto.ToString().c_str()); 26 PhotosVo photosVo; 27 photosVo.fileId = photosDto.fileId; 28 photosVo.cloudId = photosDto.cloudId; 29 photosVo.size = photosDto.size; 30 photosVo.path = photosDto.path; 31 photosVo.fileName = photosDto.fileName; 32 photosVo.type = photosDto.mediaType; 33 photosVo.originalCloudId = photosDto.originalCloudId; 34 for (auto &nodePair : photosDto.attachment) { 35 CloudFileDataVo fileDataVo; 36 fileDataVo.fileName = nodePair.second.fileName; 37 fileDataVo.filePath = nodePair.second.path; 38 fileDataVo.size = nodePair.second.size; 39 photosVo.attachment[nodePair.first] = fileDataVo; 40 } 41 return photosVo; 42 } 43 GetDownloadThumbnailQueryDto(const GetDownloadThmReqBody & reqBody)44DownloadThumbnailQueryDto CloudMediaDownloadControllerProcessor::GetDownloadThumbnailQueryDto( 45 const GetDownloadThmReqBody &reqBody) 46 { 47 DownloadThumbnailQueryDto queryDto; 48 queryDto.size = reqBody.size; 49 queryDto.type = reqBody.type; 50 queryDto.offset = reqBody.offset; 51 queryDto.isDownloadDisplayFirst = reqBody.isDownloadDisplayFirst; 52 return queryDto; 53 } 54 GetMediaOperateResult(const std::vector<MediaOperateResultDto> & mediaOperateResultDto)55std::vector<MediaOperateResultRespBodyResultNode> CloudMediaDownloadControllerProcessor::GetMediaOperateResult( 56 const std::vector<MediaOperateResultDto> &mediaOperateResultDto) 57 { 58 std::vector<MediaOperateResultRespBodyResultNode> res; 59 for (auto &node : mediaOperateResultDto) { 60 MediaOperateResultRespBodyResultNode resultNode; 61 resultNode.cloudId = node.cloudId; 62 resultNode.errorCode = node.errorCode; 63 resultNode.errorMsg = node.errorMsg; 64 res.emplace_back(resultNode); 65 } 66 return res; 67 } 68 } // namespace OHOS::Media::CloudSync