Просмотр исходного кода

Merge branch 'master' of http://git.izouma.com/xiongzhu/9th

xuqiang 4 лет назад
Родитель
Сommit
809babb0d9

+ 6 - 0
pom.xml

@@ -374,6 +374,12 @@
             <groupId>com.fasterxml.jackson.datatype</groupId>
             <groupId>com.fasterxml.jackson.datatype</groupId>
             <artifactId>jackson-datatype-jsr310</artifactId>
             <artifactId>jackson-datatype-jsr310</artifactId>
         </dependency>
         </dependency>
+
+        <dependency>
+            <groupId>net.coobird</groupId>
+            <artifactId>thumbnailator</artifactId>
+            <version>0.4.14</version>
+        </dependency>
     </dependencies>
     </dependencies>
 
 
 </project>
 </project>

+ 29 - 1
src/main/java/com/izouma/nineth/web/FileUploadController.java

@@ -29,6 +29,7 @@ import java.util.Base64;
 import java.util.Date;
 import java.util.Date;
 import java.util.Objects;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Optional;
+import java.util.regex.Pattern;
 
 
 
 
 @RestController
 @RestController
@@ -41,7 +42,34 @@ public class FileUploadController {
 
 
     @PostMapping("/file")
     @PostMapping("/file")
     public String uploadFile(@RequestParam("file") MultipartFile file,
     public String uploadFile(@RequestParam("file") MultipartFile file,
-                             @RequestParam(value = "path", required = false) String path) {
+                             @RequestParam(value = "path", required = false) String path,
+                             @RequestParam(value = "compress", defaultValue = "false") boolean compress,
+                             @RequestParam(value = "width", required = false) Integer width,
+                             @RequestParam(value = "height", required = false) Integer height) throws IOException {
+
+        if (width != null && height == null) {
+            height = Integer.MAX_VALUE;
+        }
+        if (height != null && width == null) {
+            width = Integer.MAX_VALUE;
+        }
+
+        String ext = Optional.ofNullable(FilenameUtils.getExtension(file.getOriginalFilename())).orElse("")
+                .toLowerCase().replace("jpeg", "jpg");
+        if (Pattern.matches("(jpg|png)", ext)) {
+            File tmpFile = null;
+            try {
+                tmpFile = File.createTempFile("upload", "." + ext);
+                FileUtils.copyToFile(file.getInputStream(), tmpFile);
+            } catch (IOException e) {
+                e.printStackTrace();
+                throw new BusinessException("上传失败");
+            }
+            PngQuant pngQuant = new PngQuant();
+            ImageIO.write(pngQuant.getRemapped(ImageIO.read(file.getInputStream())),
+                    "png", new File("/Users/drew/Downloads/111.png"));
+        }
+
         if (path == null) {
         if (path == null) {
             String basePath = "application";
             String basePath = "application";
             try {
             try {

+ 2 - 0
src/main/pc-space/package.json

@@ -12,7 +12,9 @@
         "core-js": "^3.6.5",
         "core-js": "^3.6.5",
         "element-ui": "^2.15.6",
         "element-ui": "^2.15.6",
         "qs": "^6.10.1",
         "qs": "^6.10.1",
+        "swiper": "5.x",
         "vue": "^2.6.11",
         "vue": "^2.6.11",
+        "vue-awesome-swiper": "^4.1.1",
         "vue-clipboard2": "^0.3.3",
         "vue-clipboard2": "^0.3.3",
         "vue-router": "^3.2.0",
         "vue-router": "^3.2.0",
         "vue-social-share": "0.0.3",
         "vue-social-share": "0.0.3",

+ 1 - 1
src/main/pc-space/src/components/CollectionInfo.vue

@@ -1,7 +1,7 @@
 <template>
 <template>
     <router-link
     <router-link
         :to="{
         :to="{
-            path: '/storeDetail',
+            path: '/collectionDetail',
             query: {
             query: {
                 id: info.id
                 id: info.id
             }
             }

+ 3 - 3
src/main/pc-space/src/router/index.js

@@ -57,9 +57,9 @@ const routes = [
                 }
                 }
             },
             },
             {
             {
-                path: '/storeDetail',
-                name: 'storeDetail',
-                component: () => import('../views/StoreDetail.vue'),
+                path: '/collectionDetail',
+                name: 'collectionDetail',
+                component: () => import('../views/CollectionDetail.vue'),
                 meta: {
                 meta: {
                     title: '数字盲盒详情'
                     title: '数字盲盒详情'
                 }
                 }

+ 1 - 1
src/main/pc-space/src/styles/list.less

@@ -34,7 +34,7 @@
     }
     }
 
 
     .content {
     .content {
-        // height: 416px;
+        width: 276px;
         .line(@radius:8px);
         .line(@radius:8px);
         display: inline-block;
         display: inline-block;
         margin: 16px;
         margin: 16px;

+ 66 - 3
src/main/pc-space/src/views/StoreDetail.vue → src/main/pc-space/src/views/CollectionDetail.vue

@@ -3,6 +3,13 @@
         <div class="top">
         <div class="top">
             <div>
             <div>
                 <img class="imgBox" src="../assets/img/888.jpg" alt="" />
                 <img class="imgBox" src="../assets/img/888.jpg" alt="" />
+                <swiper ref="mySwiper" :options="swiperOptions">
+                    <swiper-slide>Slide 1</swiper-slide>
+                    <swiper-slide>Slide 2</swiper-slide>
+                    <swiper-slide>Slide 3</swiper-slide>
+                    <swiper-slide>Slide 4</swiper-slide>
+                    <swiper-slide>Slide 5</swiper-slide>
+                </swiper>
                 <div class="works">
                 <div class="works">
                     <img class="works1" src="../assets/img/icon-quanyibaohu@3x.png" alt="" />
                     <img class="works1" src="../assets/img/icon-quanyibaohu@3x.png" alt="" />
                     <div class="works2">该作品已在保存至区块链并进行权益保护</div>
                     <div class="works2">该作品已在保存至区块链并进行权益保护</div>
@@ -152,17 +159,68 @@
 </template>
 </template>
 <script>
 <script>
 import GoodsInfo from '../components/GoodsInfo.vue';
 import GoodsInfo from '../components/GoodsInfo.vue';
+import { Swiper, SwiperSlide, directive } from 'vue-awesome-swiper';
+import 'swiper/css/swiper.css';
 export default {
 export default {
-    components: { GoodsInfo },
+    components: { GoodsInfo, Swiper, SwiperSlide },
     data() {
     data() {
         return {
         return {
             showMore: false,
             showMore: false,
             showMore1: false,
             showMore1: false,
             showMore2: false,
             showMore2: false,
-            tableData: []
+            tableData: [],
+            info: {},
+            blindBoxItems: [],
+            swiperOptions: {}
         };
         };
     },
     },
-    methods: {}
+    computed: {
+        banners() {
+            return this.info.pics || [];
+        },
+        properties() {
+            return this.info.properties || [];
+        },
+        isBuy() {
+            return this.info.stock && this.info.onShelf && this.info.salable;
+        },
+        boxs() {
+            let list = [...this.blindBoxItems];
+            return list.map(item => {
+                return this.getImg(this.changeImgs(item.pics));
+            });
+        }
+    },
+    mounted() {
+        this.getDetail();
+    },
+    methods: {
+        getDetail() {
+            this.$http
+                .get('/collection/get/' + this.$route.query.id)
+                .then(res => {
+                    this.info = res;
+                    if (res.type === 'BLIND_BOX') {
+                        return this.$http.post(
+                            '/blindBoxItem/all',
+                            {
+                                query: {
+                                    blindBoxId: res.id
+                                }
+                            },
+                            { body: 'json' }
+                        );
+                    } else {
+                        return Promise.resolve();
+                    }
+                })
+                .then(res => {
+                    if (res) {
+                        this.blindBoxItems = res.content;
+                    }
+                });
+        }
+    }
 };
 };
 </script>
 </script>
 <style lang="less" scoped>
 <style lang="less" scoped>
@@ -473,4 +531,9 @@ export default {
         }
         }
     }
     }
 }
 }
+.mySwiper {
+    /deep/.swiper-slide {
+        width: 460px;
+    }
+}
 </style>
 </style>

+ 25 - 0
src/main/pc-space/yarn.lock

@@ -3245,6 +3245,13 @@ dom-serializer@^1.0.1:
     domhandler "^4.2.0"
     domhandler "^4.2.0"
     entities "^2.0.0"
     entities "^2.0.0"
 
 
+dom7@^2.1.5:
+  version "2.1.5"
+  resolved "https://registry.yarnpkg.com/dom7/-/dom7-2.1.5.tgz#a79411017800b31d8400070cdaebbfc92c1f6377"
+  integrity sha512-xnhwVgyOh3eD++/XGtH+5qBwYTgCm0aW91GFgPJ3XG+jlsRLyJivnbP0QmUBFhI+Oaz9FV0s7cxgXHezwOEBYA==
+  dependencies:
+    ssr-window "^2.0.0"
+
 domain-browser@^1.1.1:
 domain-browser@^1.1.1:
   version "1.2.0"
   version "1.2.0"
   resolved "https://registry.nlark.com/domain-browser/download/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda"
   resolved "https://registry.nlark.com/domain-browser/download/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda"
@@ -7637,6 +7644,11 @@ sshpk@^1.7.0:
     safer-buffer "^2.0.2"
     safer-buffer "^2.0.2"
     tweetnacl "~0.14.0"
     tweetnacl "~0.14.0"
 
 
+ssr-window@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/ssr-window/-/ssr-window-2.0.0.tgz#98c301aef99523317f8d69618f0010791096efc4"
+  integrity sha512-NXzN+/HPObKAx191H3zKlYomE5WrVIkoCB5IaSdvKokxTpjBdWfr0RaP+1Z5KOfDT0ZVz+2tdtiBkhsEQ9p+0A==
+
 ssri@^6.0.1:
 ssri@^6.0.1:
   version "6.0.2"
   version "6.0.2"
   resolved "https://registry.nlark.com/ssri/download/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5"
   resolved "https://registry.nlark.com/ssri/download/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5"
@@ -7878,6 +7890,14 @@ svgo@^1.0.0:
     unquote "~1.1.1"
     unquote "~1.1.1"
     util.promisify "~1.0.0"
     util.promisify "~1.0.0"
 
 
+swiper@5.x:
+  version "5.4.5"
+  resolved "https://registry.yarnpkg.com/swiper/-/swiper-5.4.5.tgz#a350f654bf68426dbb651793824925512d223c0f"
+  integrity sha512-7QjA0XpdOmiMoClfaZ2lYN6ICHcMm72LXiY+NF4fQLFidigameaofvpjEEiTQuw3xm5eksG5hzkaRsjQX57vtA==
+  dependencies:
+    dom7 "^2.1.5"
+    ssr-window "^2.0.0"
+
 table@^5.2.3:
 table@^5.2.3:
   version "5.4.6"
   version "5.4.6"
   resolved "https://registry.npmmirror.com/table/download/table-5.4.6.tgz?cache=0&sync_timestamp=1633019371192&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Ftable%2Fdownload%2Ftable-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
   resolved "https://registry.npmmirror.com/table/download/table-5.4.6.tgz?cache=0&sync_timestamp=1633019371192&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Ftable%2Fdownload%2Ftable-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
@@ -8358,6 +8378,11 @@ vm-browserify@^1.0.1:
   resolved "https://registry.npm.taobao.org/vm-browserify/download/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
   resolved "https://registry.npm.taobao.org/vm-browserify/download/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
   integrity sha1-eGQcSIuObKkadfUR56OzKobl3aA=
   integrity sha1-eGQcSIuObKkadfUR56OzKobl3aA=
 
 
+vue-awesome-swiper@^4.1.1:
+  version "4.1.1"
+  resolved "https://registry.yarnpkg.com/vue-awesome-swiper/-/vue-awesome-swiper-4.1.1.tgz#8f7ab221ad003021d756b86aa618f429924900fe"
+  integrity sha512-50um10t6N+lJaORkpwSi1wWuMmBI1sgFc9Znsi5oUykw2cO5DzLaBHcO2JNX21R+Ue4TGoIJDhhxjBHtkFrTEQ==
+
 vue-cli-plugin-style-resources-loader@^0.1.5:
 vue-cli-plugin-style-resources-loader@^0.1.5:
   version "0.1.5"
   version "0.1.5"
   resolved "https://registry.yarnpkg.com/vue-cli-plugin-style-resources-loader/-/vue-cli-plugin-style-resources-loader-0.1.5.tgz#3e95f4df41f5408e1255664690698c0533648109"
   resolved "https://registry.yarnpkg.com/vue-cli-plugin-style-resources-loader/-/vue-cli-plugin-style-resources-loader-0.1.5.tgz#3e95f4df41f5408e1255664690698c0533648109"

+ 5 - 5
src/main/resources/application.yaml

@@ -78,11 +78,11 @@ storage:
   provider: aliyun
   provider: aliyun
   local_path: /var/www/upload/
   local_path: /var/www/upload/
 aliyun:
 aliyun:
-  access-key-id: PXzJyah5rZfWHIIH
-  access-key-secret: e1MS6j0wypXJrw8CM0hObZu8qKbfah
-  oss-end-point: oss-cn-hangzhou.aliyuncs.com
-  oss-bucket-name: 9space
-  oss-domain: https://9space.oss-cn-hangzhou.aliyuncs.com
+  access-key-id: LTAI5tCtRs8DXBLBsn49qRZX
+  access-key-secret: 86uC18LZsfB9JU04BK7ImVXfOytEkG
+  oss-end-point: oss-cn-shenzhen.aliyuncs.com
+  oss-bucket-name: 9space-2021
+  oss-domain: https://9space-2021.oss-cn-shenzhen.aliyuncs.com
 general:
 general:
   host: https://nft.9space.vip
   host: https://nft.9space.vip
 mychain:
 mychain:

+ 23 - 2
src/test/java/com/izouma/nineth/CommonTest.java

@@ -14,6 +14,8 @@ import io.ipfs.api.NamedStreamable;
 import io.ipfs.cid.Cid;
 import io.ipfs.cid.Cid;
 import io.ipfs.multihash.Multihash;
 import io.ipfs.multihash.Multihash;
 import lombok.SneakyThrows;
 import lombok.SneakyThrows;
+import net.coobird.thumbnailator.Thumbnails;
+import net.coobird.thumbnailator.name.Rename;
 import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.net.URLCodec;
 import org.apache.commons.codec.net.URLCodec;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomStringUtils;
@@ -26,6 +28,7 @@ import org.bouncycastle.util.encoders.Base64;
 import org.bouncycastle.util.encoders.UrlBase64Encoder;
 import org.bouncycastle.util.encoders.UrlBase64Encoder;
 import org.junit.Assert;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.Test;
+import org.libjpegturbo.turbojpeg.processor.api.ImageProcessException;
 import org.libjpegturbo.turbojpeg.processor.api.ImageProcessInfo;
 import org.libjpegturbo.turbojpeg.processor.api.ImageProcessInfo;
 import org.libjpegturbo.turbojpeg.processor.api.ImageProcessor;
 import org.libjpegturbo.turbojpeg.processor.api.ImageProcessor;
 import org.libjpegturbo.turbojpeg.processor.impl.ImageProcessorImpl;
 import org.libjpegturbo.turbojpeg.processor.impl.ImageProcessorImpl;
@@ -172,8 +175,8 @@ public class CommonTest {
     public void pngquant() {
     public void pngquant() {
         PngQuant pngQuant = new PngQuant();
         PngQuant pngQuant = new PngQuant();
         ImageIO.write(pngQuant
         ImageIO.write(pngQuant
-                        .getRemapped(ImageIO.read(new File("/Users/drew/Downloads/国内申请-案件新增(客户经理).png"))),
-                "png", new File("/Users/drew/Downloads/111.png"));
+                        .getRemapped(ImageIO.read(new File("/Users/drew/Downloads/2021-11-01-18-07-04JCDfFxKb.HEIC"))),
+                "jpg", new File("/Users/drew/Downloads/111.jpg"));
     }
     }
 
 
     @SneakyThrows
     @SneakyThrows
@@ -188,6 +191,24 @@ public class CommonTest {
         System.out.println(out);
         System.out.println(out);
     }
     }
 
 
+    @Test
+    public void thumbnailator() throws IOException, ImageProcessException {
+        Thumbnails.of(new File("/Users/drew/Downloads/2021-11-01-17-47-55zMwbSlgJ.jpeg"))
+                .size(1000, 1000)
+                .outputFormat("jpg")
+                .toFile("/Users/drew/Desktop/1.jpg");
+
+        PngQuant pngQuant = new PngQuant();
+        ImageIO.write(pngQuant
+                        .getRemapped(ImageIO.read(new File("/Users/drew/Desktop/1.jpg"))),
+                "jpg", new File("/Users/drew/Desktop/2.jpg"));
+
+        ImageProcessor processor = new ImageProcessorImpl();
+        ImageProcessInfo processInfo = ImageProcessInfo.fromMap(ImageProcessorUtils.compressImage(processor,
+                new File("/Users/drew/Desktop/1.jpg"),
+                new File("/Users/drew/Desktop/3.jpg"), 75));
+    }
+
     @Test
     @Test
     public void base64() {
     public void base64() {
         System.out.println(Base64.decode("e6e6vQJYhGmIkcA1pfnsipTovp10wJ"));
         System.out.println(Base64.decode("e6e6vQJYhGmIkcA1pfnsipTovp10wJ"));