package com.wtkj.wrapper; import com.wtkj.entity.InnerFileAndFolder; import com.wtkj.service.IInnerFileAndFolderService; import com.wtkj.vo.InnerFileAndFolderVO; import com.wutong.file.feign.IFileClient; import com.wutong.file.vo.FileVO; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import java.util.Objects; import static com.wtkj.config.MagicValue.ONE; import static com.wtkj.config.MagicValue.TWO; /** * @author Blizzard * @create at 2023-09-26 22:51 * @describe */ public class InnerFileAndFolderWrapper extends BaseEntityWrapper { private static IUserClient userClient; private static IInnerFileAndFolderService innerFileAndFolderService; private static IFileClient fileClient; public static InnerFileAndFolderWrapper build() { userClient = SpringUtil.getBean(IUserClient.class); innerFileAndFolderService = SpringUtil.getBean(IInnerFileAndFolderService.class); fileClient = SpringUtil.getBean(IFileClient.class); return new InnerFileAndFolderWrapper(); } @Override public InnerFileAndFolderVO entityVO(InnerFileAndFolder entity) { InnerFileAndFolderVO vo = Objects.requireNonNull(BeanUtil.copy(entity, InnerFileAndFolderVO.class)); Long createUser = entity.getCreateUser(); R userR = userClient.userInfoById(createUser); if (userR.isSuccess()) { vo.setCreateUserName(userR.getData().getName()); } //如果是文件夹 展示文件夹下文件数量 如果是文件 展示大小和url if (vo.getType() != null && vo.getType().equals(TWO)) { Integer fileAmount = innerFileAndFolderService.getFileAmountByFolderId(null, vo.getId()); vo.setFileAmount(fileAmount); } else if (vo.getType() != null && vo.getType().equals(ONE)) { R rpc = fileClient.findById(vo.getBladeFileId()); if (rpc.isSuccess()) { vo.setVolume(rpc.getData().getVolume()); vo.setUrl(rpc.getData().getFilePath()); vo.setSuffix(rpc.getData().getSuffix()); } } return vo; } }