Parcourir la source

文物表增加了字段

wuweihao il y a 4 ans
Parent
commit
ceb26d8054

+ 6 - 1
README.md

@@ -1,3 +1,8 @@
 # museum_zhuhai
 
-珠海博物馆-万物墙
+珠海博物馆-万物墙
+
+# sit 
+    部署:win servcie 2016 , 192.168.0.245
+    web: http://192.168.0.245:8001/backstage/index.html admin 1234abcd
+    doc: http://192.168.0.245:8001/doc.html

+ 50 - 30
zhoushan-system-api/src/main/java/com/fdage/controller/CollectionController.java

@@ -1,6 +1,7 @@
 package com.fdage.controller;
 
 import com.fdage.aop.WebControllerLog;
+import com.fdage.constant.ConfigConstant;
 import com.fdage.constant.ConstantUrl;
 import com.fdage.enums.ResponEnum;
 import com.fdage.pojo.TbCollection;
@@ -40,6 +41,9 @@ public class CollectionController {
     @Value("${upload.collection}")
     private String uploadPath;
 
+    @Autowired
+    ConfigConstant configConstant;
+
     @PostMapping("timeList")
     @ResponseBody
     @ApiOperation("获取年代列表")
@@ -58,19 +62,19 @@ public class CollectionController {
     @ResponseBody
     @WebControllerLog(description = "文物库-新增文物")
     @ApiOperation("新增文物")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "name", value = "文物名称", dataType = "String"),
-            @ApiImplicitParam(name = "description", value = "文物描述", dataType = "String"),
-            @ApiImplicitParam(name = "timeId", value = "年代id", dataType = "String"),
-            @ApiImplicitParam(name = "typeId", value = "类型id", dataType = "String"),
-            @ApiImplicitParam(name = "modelUrl", value = "文物模型url", dataType = "String"),
-            @ApiImplicitParam(name = "discoveryTime", value = "文物发现时间", dataType = "String"),
-            @ApiImplicitParam(name = "repairTime", value = "文物维修时间", dataType = "String"),
-            @ApiImplicitParam(name = "venue", value = "文物所在场馆", dataType = "String"),
-            @ApiImplicitParam(name = "contentUrl", value = "多媒体内容Url", dataType = "String"),
-            @ApiImplicitParam(name = "pic", value = "4dmodel文物的封面图", dataType = "String"),
-            @ApiImplicitParam(name = "num", value = "藏品编号", dataType = "String"),
-            @ApiImplicitParam(name = "state", value = "状态,0:展示,1:隐藏", dataType = "String")})
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name = "name", value = "文物名称", dataType = "String"),
+//            @ApiImplicitParam(name = "description", value = "文物描述", dataType = "String"),
+//            @ApiImplicitParam(name = "timeId", value = "年代id", dataType = "String"),
+//            @ApiImplicitParam(name = "typeId", value = "类型id", dataType = "String"),
+//            @ApiImplicitParam(name = "modelUrl", value = "文物模型url", dataType = "String"),
+//            @ApiImplicitParam(name = "discoveryTime", value = "文物发现时间", dataType = "String"),
+//            @ApiImplicitParam(name = "repairTime", value = "文物维修时间", dataType = "String"),
+//            @ApiImplicitParam(name = "venue", value = "文物所在场馆", dataType = "String"),
+//            @ApiImplicitParam(name = "contentUrl", value = "多媒体内容Url", dataType = "String"),
+//            @ApiImplicitParam(name = "pic", value = "4dmodel文物的封面图", dataType = "String"),
+//            @ApiImplicitParam(name = "num", value = "藏品编号", dataType = "String"),
+//            @ApiImplicitParam(name = "state", value = "状态,0:展示,1:隐藏", dataType = "String")})
     public AjaxJson addCollection(@RequestBody RequestCollection bo){
         if(bo == null || StringUtils.isEmpty(bo.getName())  ||
                 bo.getTimeId() == null  || bo.getTypeId() == null){
@@ -79,8 +83,8 @@ public class CollectionController {
 
         TbCollection collection = new TbCollection();
         BeanUtils.copyProperties(bo, collection);
-//        collection.setPic(ConstantUrl.FDMODEL_PIC + bo.getModelUrl().substring(
-//                bo.getModelUrl().indexOf("m=") + 2) + "/thumbnail.jpg");
+        collection.setUnityUrl("/collection/unity/" + bo.getDirCode());
+//        collection.setUnityUrl(configConstant.serverBasePath + "/collection/unity/" + bo.getDirCode());
         service.insert(collection);
         return AjaxJson.success();
     }
@@ -89,20 +93,20 @@ public class CollectionController {
     @ResponseBody
     @WebControllerLog(description = "文物库-修改文物")
     @ApiOperation("修改文物")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "文物id", dataType = "String"),
-            @ApiImplicitParam(name = "name", value = "文物名称", dataType = "String"),
-            @ApiImplicitParam(name = "description", value = "文物描述", dataType = "String"),
-            @ApiImplicitParam(name = "timeId", value = "年代id", dataType = "String"),
-            @ApiImplicitParam(name = "typeId", value = "类型id", dataType = "String"),
-            @ApiImplicitParam(name = "modelUrl", value = "文物模型url", dataType = "String"),
-            @ApiImplicitParam(name = "discoveryTime", value = "文物发现时间", dataType = "String"),
-            @ApiImplicitParam(name = "repairTime", value = "文物维修时间", dataType = "String"),
-            @ApiImplicitParam(name = "venue", value = "文物所在场馆", dataType = "String"),
-            @ApiImplicitParam(name = "contentUrl", value = "多媒体内容Url", dataType = "String"),
-            @ApiImplicitParam(name = "pic", value = "4dmodel文物的封面图", dataType = "String"),
-            @ApiImplicitParam(name = "num", value = "藏品编号", dataType = "String"),
-            @ApiImplicitParam(name = "state", value = "状态,0:展示,1:隐藏", dataType = "String")})
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name = "id", value = "文物id", dataType = "String"),
+//            @ApiImplicitParam(name = "name", value = "文物名称", dataType = "String"),
+//            @ApiImplicitParam(name = "description", value = "文物描述", dataType = "String"),
+//            @ApiImplicitParam(name = "timeId", value = "年代id", dataType = "String"),
+//            @ApiImplicitParam(name = "typeId", value = "类型id", dataType = "String"),
+//            @ApiImplicitParam(name = "modelUrl", value = "文物模型url", dataType = "String"),
+//            @ApiImplicitParam(name = "discoveryTime", value = "文物发现时间", dataType = "String"),
+//            @ApiImplicitParam(name = "repairTime", value = "文物维修时间", dataType = "String"),
+//            @ApiImplicitParam(name = "venue", value = "文物所在场馆", dataType = "String"),
+//            @ApiImplicitParam(name = "contentUrl", value = "多媒体内容Url", dataType = "String"),
+//            @ApiImplicitParam(name = "pic", value = "4dmodel文物的封面图", dataType = "String"),
+//            @ApiImplicitParam(name = "num", value = "藏品编号", dataType = "String"),
+//            @ApiImplicitParam(name = "state", value = "状态,0:展示,1:隐藏", dataType = "String")})
     public AjaxJson updateCollection(@RequestBody RequestCollection bo){
         if(bo == null || StringUtils.isEmpty(bo.getName()) ||
                 bo.getTimeId() == null  || bo.getTypeId() == null ){
@@ -159,7 +163,7 @@ public class CollectionController {
         return AjaxJson.success(pageInfo);
     }
 
-    @RequestMapping("/upload")
+    @PostMapping("/upload")
     @ResponseBody
     @ApiOperation("上传文物图片")
     @ApiImplicitParams({
@@ -188,6 +192,22 @@ public class CollectionController {
         return AjaxJson.success((Object) ("/collection/" + fileName));
     }
 
+
+    /**
+     * 2021-08-09
+     * @param file
+     * @param code
+     * @return
+     */
+    @PostMapping("/uploadCode")
+    @ApiOperation("上传Unity")
+    @ResponseBody
+    public AjaxJson uploadCode(MultipartFile file, String code){
+
+        return service.uploadCode(file, code);
+    }
+
+
     @RequestMapping("/importCollection")
     @ResponseBody
     @ApiOperation("导入文物数据")

+ 19 - 3
zhoushan-system-api/src/main/java/com/fdage/controller/DataStatisticsController.java

@@ -114,11 +114,27 @@ public class DataStatisticsController {
         Map<String, String> map = new HashMap<>();
         map.put("order", "desc");
         map.put("sidx", "a.search_num");
-        result.setCollectionSearchList(collectionService.findListOrderBy(map).subList(0, 5));
+//        result.setCollectionSearchList(collectionService.findListOrderBy(map).subList(0, 5));
+
+        List<ResponCollection> listOrderBy = collectionService.findListOrderBy(map);
+        int max = listOrderBy.size() > 5 ? 5 : listOrderBy.size();
+        result.setCollectionSearchList(listOrderBy.subList(0, max));
+
+
+
+
         map.put("sidx", "a.like_num");
-        result.setCollectionLikeList(collectionService.findListOrderBy(map).subList(0, 10));
+//        result.setCollectionLikeList(collectionService.findListOrderBy(map).subList(0, 10));
+
+        List<ResponCollection> listOrderBy2 = collectionService.findListOrderBy(map);
+        int max2 = listOrderBy2.size() > 10 ? 10 : listOrderBy2.size();
+        result.setCollectionLikeList(listOrderBy2.subList(0, max2));
         map.put("sidx", "a.open_num");
-        result.setCollectionOpenList(collectionService.findListOrderBy(map).subList(0, 3));
+//        result.setCollectionOpenList(collectionService.findListOrderBy(map).subList(0, 3));
+        List<ResponCollection> list3 = collectionService.findListOrderBy(map);
+        int max3 = listOrderBy2.size() > 3 ? 3 : listOrderBy2.size();
+
+        result.setCollectionOpenList(list3.subList(0, max3));
 
         result.setCollectionTypeTotal(collectionService.typeTotal());
 

+ 23 - 6
zhoushan-system-api/src/main/resources/application-dev.yml

@@ -38,13 +38,18 @@ spring:
         max-active: 8
 # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException
         max-wait: -1ms
-
+# 配置静态资源跟目录
+  mvc:
+    static-path-pattern: /**
+  resources:
+    static-locations: file:${my.file.path}
 
 upload:
-  head: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\head
-  information: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\information
-  collection: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\collection
-  exhibition: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\exhibition
+  head: ${my.file.path}\head
+  information: ${my.file.path}\information
+  collection: ${my.file.path}\collection
+  exhibition: ${my.file.path}\exhibition
+
 
 
 swagger:
@@ -54,10 +59,22 @@ swagger:
   version: 1.0
 
 
+# 服务器存放地址
+my:
+  file:
+    path: F:/test/ngin/${project.en}_data
+
+
+
+
+
+
+
+
 logging:
+  path: E:/javaProject/${project.en}_log
   config: classpath:logback-spring.xml
   level:
     com:
       fdage: debug
 
-  path: E:/javaProject/${project.en}_log

+ 26 - 8
zhoushan-system-api/src/main/resources/application-sit.yml

@@ -16,7 +16,7 @@ spring:
 #    username: root
 #    password: 4dagecui2019
     # db 项目测试服务器
-    url: jdbc:mysql://127.0.0.1:3306/${project.en}?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true
+    url: jdbc:mysql://8.135.106.227:3306/${project.en}?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true
     username: root
     password: 4dkk2021testproject%
     driver-class-name: com.mysql.jdbc.Driver
@@ -38,13 +38,18 @@ spring:
         max-active: 8
 # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException
         max-wait: -1ms
-
+# 配置静态资源跟目录
+  mvc:
+    static-path-pattern: /**
+  resources:
+    static-locations: file:${my.file.path}
 
 upload:
-  head: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\head
-  information: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\information
-  collection: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\collection
-  exhibition: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\exhibition
+  head: ${my.file.path}\head
+  information: ${my.file.path}\information
+  collection: ${my.file.path}\collection
+  exhibition: ${my.file.path}\exhibition
+
 
 
 swagger:
@@ -53,7 +58,20 @@ swagger:
   description: ${swagger.title}
   version: 1.0
 
+
+# 服务器存放地址
+my:
+  file:
+    path: D:/data/${project.en}_data
+
+
 logging:
+  path: D:/log/${project.en}_log
   config: classpath:logback-spring.xml
-  level: debug
-  path: /root/log/${project.en}_log
+  level:
+    com:
+      fdage: debug
+
+
+
+

+ 1 - 14
zhoushan-system-api/src/main/resources/application.yml

@@ -1,20 +1,14 @@
-
 spring:
   profiles:
     active: dev
 
 server:
-  port: 8010
+  port: 8001
 
 mybatis:
   mapperLocations: classpath*:mapper/*/*.xml
   typeAliasesPackage: com.fdage.pojo
 
-logging:
-  level:
-    com:
-      fdage:
-        dao: debug
 
 pagehelper:
   helperDialect: mysql
@@ -23,13 +17,6 @@ pagehelper:
   params: count=countSql
 
 
-#upload:
-#  head: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\head
-#  information: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\information
-#  collection: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\collection
-#  exhibition: G:\javaProject\zhoushan-system\zhoushan-system-api\src\main\resources\static\exhibition
-
-
 project:
   sc: 珠海博物馆
   en: museum_zhuhai

+ 2 - 3
zhoushan-system-api/src/main/resources/sh/startup.sh

@@ -1,12 +1,11 @@
 #!/bin/sh
 RESOURCE_NAME=museum_zhuhai.jar
 rm -f tpid
-nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=sit &
-echo $! > tpid
+nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=sit --server.port=8001 & echo $! > tpid
 echo Start Success!
 echo
 
-#tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
+
 
 
 

+ 8 - 0
zhoushan-system-common/pom.xml

@@ -146,6 +146,14 @@
             <version>3.8</version>
         </dependency>
 
+
+        <!-- 工具类 -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.3.3</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 2 - 2
zhoushan-system-common/src/main/java/com/fdage/constant/ConfigConstant.java

@@ -12,8 +12,8 @@ import org.springframework.stereotype.Component;
 public class ConfigConstant {
 
     /** 服务器文件地址*/
-//    @Value("${server.file.path}")
-//    public  String serverBasePath;
+    @Value("${my.file.path}")
+    public  String serverBasePath;
 
 //    @Value("${server.file.allow}")
 //    public String serverFileFallow;

+ 6 - 0
zhoushan-system-common/src/main/java/com/fdage/request/RequestCollection.java

@@ -1,5 +1,7 @@
 package com.fdage.request;
 
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
 import lombok.Data;
 
 import java.util.Date;
@@ -41,5 +43,9 @@ public class RequestCollection extends RequestBase{
     private String unityUrl;
 
     // 图片 2021-08-02
+    @ApiModelProperty(value = "图片")
     private String icon;
+
+    @ApiModelProperty(value = "目录code", notes = "上传文件使用")
+    private String dirCode;
 }

+ 8 - 0
zhoushan-system-common/src/main/java/com/fdage/respon/ResponCollection.java

@@ -1,5 +1,6 @@
 package com.fdage.respon;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.util.Date;
@@ -51,4 +52,11 @@ public class ResponCollection {
     private String unityPic;
 
     private String unityUrl;
+
+    // 图片 2021-08-02
+    @ApiModelProperty(value = "图片")
+    private String icon;
+
+    @ApiModelProperty(value = "目录code", notes = "上传文件使用")
+    private String dirCode;
 }

+ 26 - 0
zhoushan-system-dao/src/main/java/com/fdage/pojo/TbCollection.java

@@ -1,5 +1,7 @@
 package com.fdage.pojo;
 
+import io.swagger.annotations.ApiModelProperty;
+
 import java.util.Date;
 
 public class TbCollection {
@@ -43,6 +45,30 @@ public class TbCollection {
 
     private Integer downloadNum;
 
+
+    @ApiModelProperty(value = "图片")
+    private String icon;
+
+    @ApiModelProperty(value = "目录code", notes = "上传文件使用")
+    private String dirCode;
+
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public String getDirCode() {
+        return dirCode;
+    }
+
+    public void setDirCode(String dirCode) {
+        this.dirCode = dirCode;
+    }
+
     public Integer getDownloadNum() {
         return downloadNum;
     }

+ 26 - 2
zhoushan-system-dao/src/main/resources/mapper/base/TbCollectionMapper.xml

@@ -21,6 +21,8 @@
     <result column="open_num" jdbcType="BIGINT" property="openNum" />
     <result column="search_num" jdbcType="BIGINT" property="searchNum" />
     <result column="download_num" jdbcType="BIGINT" property="downloadNum" />
+    <result column="icon" jdbcType="VARCHAR" property="icon" />
+    <result column="dir_code" jdbcType="VARCHAR" property="dirCode" />
   </resultMap>
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.fdage.pojo.TbCollection">
     <result column="description" jdbcType="LONGVARCHAR" property="description" />
@@ -48,13 +50,13 @@
     insert into tb_collection (id, name, type_id, 
       time_id, num, discovery_time, repair_time,
       venue, pic, model_url, unity_pic, unity_url,
-      content_url, state, create_time, 
+      content_url, state, create_time, icon, dir_code,
       description)
     values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{typeId,jdbcType=BIGINT},
       #{timeId,jdbcType=BIGINT}, #{num,jdbcType=VARCHAR}, #{discoveryTime,jdbcType=TIMESTAMP}, #{repairTime,jdbcType=TIMESTAMP},
       #{venue,jdbcType=VARCHAR}, #{pic,jdbcType=VARCHAR}, #{modelUrl,jdbcType=VARCHAR},
       #{unityPic,jdbcType=VARCHAR}, #{unityUrl,jdbcType=VARCHAR},
-      #{contentUrl,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{contentUrl,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{icon,jdbcType=VARCHAR}, #{dirCode,jdbcType=VARCHAR},
       #{description,jdbcType=LONGVARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.fdage.pojo.TbCollection">
@@ -108,6 +110,12 @@
       <if test="description != null">
         description,
       </if>
+      <if test="icon != null">
+        icon,
+      </if>
+      <if test="dirCode != null">
+        dir_code,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -158,6 +166,12 @@
       <if test="description != null">
         #{description,jdbcType=LONGVARCHAR},
       </if>
+      <if test="icon != null">
+        #{icon,jdbcType=VARCHAR},
+      </if>
+      <if test="dirCode != null">
+        #{dirCode,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.fdage.pojo.TbCollection">
@@ -208,6 +222,12 @@
       <if test="description != null">
         description = #{description,jdbcType=LONGVARCHAR},
       </if>
+      <if test="icon != null">
+        icon = #{icon,jdbcType=VARCHAR},
+      </if>
+      <if test="dirCode != null">
+        dir_code = #{dirCode,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -227,6 +247,8 @@
       content_url = #{contentUrl,jdbcType=VARCHAR},
       state = #{state,jdbcType=INTEGER},
       create_time = #{createTime,jdbcType=TIMESTAMP},
+      icon = #{icon,jdbcType=VARCHAR},
+      dir_code = #{dirCode,jdbcType=VARCHAR},
       description = #{description,jdbcType=LONGVARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -245,6 +267,8 @@
       model_url = #{modelUrl,jdbcType=VARCHAR},
       content_url = #{contentUrl,jdbcType=VARCHAR},
       state = #{state,jdbcType=INTEGER},
+       icon = #{icon,jdbcType=VARCHAR},
+      dir_code = #{dirCode,jdbcType=VARCHAR},
       create_time = #{createTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
   </update>

+ 1 - 1
zhoushan-system-dao/src/main/resources/mapper/cust/TbCollectionMapperCust.xml

@@ -21,7 +21,7 @@
     a.repair_time as repairTime, a.venue, a.model_url as modelUrl, a.content_url as contentUrl, a.state,
     a.create_time as createTime, a.description, b.name as timeName, c.name as typeName, a.pic, a.num,
     a.like_num as likeNum, a.open_num as openNum, a.search_num as searchNum, download_num as downloadNum,
-    a.unity_pic as unityPic, a.unity_url as unityUrl
+    a.unity_pic as unityPic, a.unity_url as unityUrl, a.icon, a.dir_code as dirCode
     from tb_collection a LEFT JOIN tb_collection_time b on a.time_id = b.id
     LEFT JOIN tb_collection_type c ON a.type_id = c.id
     WHERE 1 = 1

+ 3 - 0
zhoushan-system-service/src/main/java/com/fdage/service/ICollectionService.java

@@ -7,6 +7,7 @@ import com.fdage.request.RequestCollection;
 import com.fdage.respon.ResponCollection;
 import com.fdage.respon.ResponStatistics;
 import com.fdage.util.AjaxJson;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 import java.util.Map;
@@ -45,4 +46,6 @@ public interface ICollectionService {
     List<Map<String, Object>> typeTotal();
 
     int deleteById(Long id);
+
+    AjaxJson uploadCode(MultipartFile file, String code);
 }

+ 39 - 3
zhoushan-system-service/src/main/java/com/fdage/service/impl/CollectionServiceImpl.java

@@ -1,5 +1,7 @@
 package com.fdage.service.impl;
 
+import cn.hutool.core.io.FileUtil;
+import com.fdage.constant.ConfigConstant;
 import com.fdage.dao.base.TbCollectionMapper;
 import com.fdage.dao.base.TbCollectionTimeMapper;
 import com.fdage.dao.base.TbCollectionTypeMapper;
@@ -19,18 +21,21 @@ import com.fdage.util.DateUtil;
 import com.fdage.util.ImportExeclUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.util.StringUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.io.IOException;
+import java.util.*;
 
 /**
  * Created by Hb_zzZ on 2019/9/11.
  */
+@Slf4j
 @Service
 public class CollectionServiceImpl implements ICollectionService {
 
@@ -55,6 +60,9 @@ public class CollectionServiceImpl implements ICollectionService {
     @Autowired
     private TbExhibitionCollectionMapperCust exhibitionCollectionMapperCust;
 
+    @Autowired
+    ConfigConstant configConstant;
+
     @Override
     public List<TbCollectionType> typeList(RequestCollection bo) {
         return mapperCust.typeList(bo);
@@ -222,6 +230,34 @@ public class CollectionServiceImpl implements ICollectionService {
         return mapper.deleteByPrimaryKey(id);
     }
 
+    @Override
+    public AjaxJson uploadCode(MultipartFile file, String code) {
+
+        if(file == null){
+            return AjaxJson.failure("参数不能为空");
+        }
+
+        // 拦截非法文件
+        List<String> legalSuffix = Arrays.asList("obj","png");
+        String originalFilename = file.getOriginalFilename();
+        String suffix = StringUtils.substringAfterLast(originalFilename, ".");
+        suffix = StringUtils.lowerCase(suffix);
+
+        if (!legalSuffix.contains(suffix)){
+            return AjaxJson.failure(3001, "非法文件");
+        }
+
+        String filePath = "/collection/unity/" + code +"/" +  originalFilename;
+        String savePath = configConstant.serverBasePath + filePath;
+        try {
+            FileUtil.writeFromStream(file.getInputStream(), savePath);
+            log.info("图片地址:" + savePath);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return AjaxJson.success((Object)filePath);
+    }
+
     public static void main(String[] args) {
         CollectionServiceImpl service = new CollectionServiceImpl();