| | |
| | | package com.qianwen.smartman.modules.visual.service.impl; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.mp.base.BaseServiceImpl; |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder; |
| | | import com.qianwen.smartman.modules.resource.service.IOssService; |
| | | import com.qianwen.smartman.modules.visual.dto.VisualDTO; |
| | |
| | | import com.qianwen.smartman.modules.visual.service.IVisualService; |
| | | import com.qianwen.smartman.modules.visual.utils.VisualUtils; |
| | | import com.qianwen.smartman.modules.visual.vo.VisualInfoVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/visual/service/impl/VisualServiceImpl.class */ |
| | |
| | | private final OssBuilder ossBuilder; |
| | | private final IOssService ossService; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -1492779276: |
| | | if (implMethodName.equals("getGroupName")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -621871631: |
| | | if (implMethodName.equals("getVisualId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 98245393: |
| | | if (implMethodName.equals("getId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 964243849: |
| | | if (implMethodName.equals("getGroupIndex")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | case 1283554731: |
| | | if (implMethodName.equals("getBackgroundUrl")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 1966196898: |
| | | if (implMethodName.equals("getTitle")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 2128411252: |
| | | if (implMethodName.equals("getCategory")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | switch (z) { |
| | | case false: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/Visual") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getGroupIndex(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/Visual") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getGroupIndex(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/Visual") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getGroupName(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/Visual") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getGroupName(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/Visual") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getTitle(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/Visual") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getCategory(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getId(); |
| | | }; |
| | | } |
| | | break; |
| | | case RegionCache.VILLAGE_LEVEL /* 5 */: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/Visual") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getBackgroundUrl(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getVisualId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getVisualId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getVisualId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getVisualId(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public VisualServiceImpl(final IVisualConfigService configService, final IVisualGlobalApiService globalApiService, final OssBuilder ossBuilder, final IOssService ossService) { |
| | | this.configService = configService; |
| | |
| | | @Override // org.springblade.modules.visual.service.IVisualService |
| | | public VisualDTO detail(Long id) { |
| | | Visual visual = (Visual) getById(id); |
| | | VisualConfig visualConfig = this.configService.getOne(Wrappers.<VisualConfig>query().lambda().eq(VisualConfig::getVisualId, id)); |
| | | /* |
| | | VisualConfig visualConfig = (VisualConfig) this.configService.getOne((Wrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getVisualId(); |
| | | }, id)); |
| | | }, id));*/ |
| | | VisualDTO dto = new VisualDTO(); |
| | | dto.setVisual(visual); |
| | | dto.setConfig(visualConfig); |
| | |
| | | if (StringUtils.isEmpty(visual.getGroupName())) { |
| | | return null; |
| | | } |
| | | List<Visual> list = list(Lambda.eq(Visual::getGroupName, visual.getGroupName()).orderByAsc(Visual::getGroupIndex)); |
| | | /* |
| | | List<Visual> list = list((Wrapper) Lambda.eq((v0) -> { |
| | | return v0.getGroupName(); |
| | | }, visual.getGroupName()).orderByAsc((v0) -> { |
| | | return v0.getGroupIndex(); |
| | | })); |
| | | }));*/ |
| | | if (list.size() <= 1) { |
| | | return null; |
| | | } |
| | |
| | | if (StringUtils.isEmpty(visual.getGroupName())) { |
| | | return null; |
| | | } |
| | | List<Visual> list = list(Lambda.eq(Visual::getGroupName, visual.getGroupName()).orderByDesc(Visual::getGroupIndex)); |
| | | /* |
| | | List<Visual> list = list((Wrapper) Lambda.eq((v0) -> { |
| | | return v0.getGroupName(); |
| | | }, visual.getGroupName()).orderByDesc((v0) -> { |
| | | return v0.getGroupIndex(); |
| | | })); |
| | | }));*/ |
| | | if (list.size() <= 1) { |
| | | return null; |
| | | } |
| | |
| | | }).findFirst().map(item2 -> { |
| | | return item2.getId(); |
| | | }).orElseGet(() -> { |
| | | return ((Visual) list.get(0)).getId(); |
| | | return list.get(0).getId(); |
| | | }); |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Long copyVisual(Long id) { |
| | | Visual visual = (Visual) getById(id); |
| | | |
| | | VisualConfig visualConfig = (VisualConfig)this.configService.getOne(Wrappers.<VisualConfig>query().lambda().eq(VisualConfig::getVisualId, id)); |
| | | /* |
| | | VisualConfig visualConfig = (VisualConfig) this.configService.getOne((Wrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getVisualId(); |
| | | }, id)); |
| | | }, id));*/ |
| | | if (visual != null && visualConfig != null) { |
| | | visual.setId(null); |
| | | visualConfig.setId(null); |
| | |
| | | |
| | | @Override // org.springblade.modules.visual.service.IVisualService |
| | | public List<VisualInfoVO> detailsByCatalog(Integer catalogId) { |
| | | List<Visual> list = list(Lambda.eq((catalogId != null), Visual::getCategory, catalogId) |
| | | .select(Visual::getId, Visual::getTitle, Visual::getBackgroundUrl )); |
| | | /* |
| | | List<Visual> list = list(Lambda.eq(catalogId != null, (v0) -> { |
| | | return v0.getCategory(); |
| | | }, catalogId).select((v0) -> { |
| | |
| | | return v0.getTitle(); |
| | | }, (v0) -> { |
| | | return v0.getBackgroundUrl(); |
| | | })); |
| | | }));*/ |
| | | if (list == null || list.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<Long> visualIds = (List) list.stream().map((v0) -> { |
| | | List<Long> visualIds = list.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<VisualConfig> config = this.configService.list(Lambda.in((v0) -> { |
| | | return v0.getVisualId(); |
| | | }, visualIds)); |
| | | return (List) config.stream().map(item -> { |
| | | return config.stream().map(item -> { |
| | | Visual match = (Visual) list.stream().filter(visual -> { |
| | | return visual.getId().equals(item.getVisualId()); |
| | | }).findFirst().orElse(null); |
| | |
| | | public void visualZipImport(MultipartFile zipFile, Integer category) { |
| | | String localFileName = IdWorker.get32UUID() + ".zip"; |
| | | File localZipFile = new File("static/visual/" + localFileName); |
| | | FileUtils.copyToFile(zipFile.getInputStream(), localZipFile); |
| | | try { |
| | | FileUtils.copyToFile(zipFile.getInputStream(), localZipFile); |
| | | } catch (IOException e) { |
| | | log.error("可视化导入错误",e); |
| | | throw new ServiceException("可视化导入错误"+e.getMessage()); |
| | | } |
| | | visualZipImport(localZipFile, category); |
| | | } |
| | | |
| | |
| | | public void visualZipImport(File zipFile, Integer category) { |
| | | File distFile = ZipUtil.unzip(zipFile); |
| | | File[] files = distFile.listFiles(); |
| | | File imagesDir = (File) Stream.of((Object[]) files).filter(file -> { |
| | | File imagesDir = (File) Stream.of(files).filter(file -> { |
| | | return file.isDirectory() && "images".equalsIgnoreCase(file.getName()); |
| | | }).findFirst().orElse(null); |
| | | if (imagesDir == null) { |
| | | String[] jsFilesText = (String[]) Stream.of((Object[]) files).filter(file2 -> { |
| | | String[] jsFilesText = (String[]) Stream.of( files).filter(file2 -> { |
| | | return file2.isFile() && file2.getName().endsWith("js"); |
| | | }).map(item -> { |
| | | return FileUtil.readString(item, "utf-8"); |
| | | }).toArray(x$0 -> { |
| | | return new String[x$0]; |
| | | }).toArray(x -> { |
| | | return new String[x]; |
| | | }); |
| | | File distFile2 = VisualUtils.visualDownload(jsFilesText); |
| | | visualZipImport(distFile2, category); |