syh 5 anni fa
parent
commit
44d3f8afcb
45 ha cambiato i file con 1093 aggiunte e 588 eliminazioni
  1. 1 2
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 0 16
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseController.java
  3. 0 10
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseEntity.java
  4. 0 23
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseRepository.java
  5. 0 119
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseService.java
  6. 0 33
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/CorsFilter.java
  7. 0 17
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/PassUrl.java
  8. 0 62
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/UserHandlerAdapter.java
  9. 0 21
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/UserMvcAdapter.java
  10. 116 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/controller/FileCallBackController.java
  11. 44 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/controller/UserCallBackController.java
  12. 118 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/controller/UserImplController.java
  13. 0 14
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsFileMapper.java
  14. 19 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsFile.java
  15. 1 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsFileVersion.java
  16. 17 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsFileWatermark.java
  17. 4 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsUser.java
  18. 12 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsUserAcl.java
  19. 51 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/mapper/WpsFileMapper.java
  20. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsFileVersionMapper.java
  21. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsFileWatermarkMapper.java
  22. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsUserAclMapper.java
  23. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsUserMapper.java
  24. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsFileMapper.xml
  25. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsFileVersionMapper.xml
  26. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsFileWatermarkMapper.xml
  27. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsUserAclMapper.xml
  28. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsUserMapper.xml
  29. 1 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/propertie/WpsProperties.java
  30. 32 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsFileService.java
  31. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsFileVersionService.java
  32. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsFileWatermarkService.java
  33. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsUserAclService.java
  34. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsUserService.java
  35. 377 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileServiceImpl.java
  36. 26 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileVersionServiceImpl.java
  37. 16 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileWatermarkServiceImpl.java
  38. 18 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsUserAclServiceImpl.java
  39. 47 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsUserServiceImpl.java
  40. 8 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/SignatureUtil.java
  41. 19 21
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/WpsUtil.java
  42. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/file/FileTypeJudge.java
  43. 119 52
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/upload/oss/OSSUtil.java
  44. 0 120
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/upload/qn/QNUtil.java
  45. 14 9
      jeecg-boot-module-system/src/main/resources/application.yml

+ 1 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -81,7 +81,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/byteDance/homePage/report/*", "anon");
         filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
 
-        filterChainDefinitionMap.put("/pangolin/**", "anon");
+        filterChainDefinitionMap.put("/v1/**", "anon");
 
         filterChainDefinitionMap.put("/generic/**", "anon");
         filterChainDefinitionMap.put("/", "anon");
@@ -144,7 +144,6 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ks/web/test", "anon");
         filterChainDefinitionMap.put("/ureport/**", "anon");
         filterChainDefinitionMap.put("/ctop/advertiser/**", "anon");
-        filterChainDefinitionMap.put("/pangolin/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 0 - 16
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseController.java

@@ -1,16 +0,0 @@
-package org.jeecg.modules.wps.base;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- *
- * @author zm
- * @see abstract
- */
-public abstract class BaseController {
-
-	protected Logger logger = LoggerFactory.getLogger(getClass());
-
-}

+ 0 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseEntity.java

@@ -1,10 +0,0 @@
-package org.jeecg.modules.wps.base;
-
-import java.io.Serializable;
-
-/**
- *
- * @author zm
- * @see abstract
- */
-public abstract class BaseEntity implements Serializable {}

+ 0 - 23
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseRepository.java

@@ -1,23 +0,0 @@
-/*
- * www.takead.cn
- * Copyright (c) 2012-2013 All Rights Reserved.
- */
-package org.jeecg.modules.wps.base;
-
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.repository.NoRepositoryBean;
-import org.springframework.data.repository.PagingAndSortingRepository;
-
-import java.io.Serializable;
-
-/**
- *
- * @author zm
- * @see abstract
- */
-@NoRepositoryBean
-public interface BaseRepository<M extends BaseEntity, ID extends Serializable>
-		extends PagingAndSortingRepository<M, ID>,JpaSpecificationExecutor<M> {
-
-
-}

+ 0 - 119
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/base/BaseService.java

@@ -1,119 +0,0 @@
-package org.jeecg.modules.wps.base;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-
-import java.io.Serializable;
-import java.util.Optional;
-
-/**
- *
- * @author zm
- * @see abstract
- */
-public abstract class BaseService<M extends BaseEntity, ID extends Serializable> {
-
-	protected BaseRepository<M, ID> baseRepository;
-
-	protected abstract void setDao(BaseRepository baseRepository);
-
-	protected Logger logger = LoggerFactory.getLogger(getClass());
-
-	/**
-	 * 保存单个实体
-	 *
-	 * @param m
-	 *            实体
-	 * @return 返回保存的实体
-	 */
-	public M save(M m) {
-		return baseRepository.save(m);
-	}
-
-	/**
-	 * 更新单个实体
-	 *
-	 * @param m
-	 *            实体
-	 * @return 返回更新的实体
-	 */
-	public M update(M m) {
-		return baseRepository.save(m);
-	}
-
-	/**
-	 * 根据主键删除相应实体
-	 *
-	 * @param id
-	 *            主键
-	 */
-	public void delete(ID id) {
-		baseRepository.deleteById(id);
-	}
-
-	/**
-	 * 删除实体
-	 *
-	 * @param m
-	 *            实体
-	 */
-	public void delete(M m) {
-		baseRepository.delete(m);
-	}
-
-	/**
-	 * 按照主键查询
-	 *
-	 * @param id
-	 *            主键
-	 * @return 返回id对应的实体
-	 */
-	public M findOne(ID id) {
-		Optional<M> om = baseRepository.findById(id);
-		return om.orElse(null);
-	}
-
-	/**
-	 * 实体是否存在
-	 *
-	 * @param id
-	 *            主键
-	 * @return 存在 返回true,否则false
-	 */
-	public boolean exists(ID id) {
-		return baseRepository.existsById(id);
-	}
-
-	/**
-	 * 统计实体总数
-	 *
-	 * @return 实体总数
-	 */
-	public long count() {
-		return baseRepository.count();
-	}
-
-	/**
-	 * 分页及排序查询实体
-	 *
-	 * @param pageable
-	 *            分页及排序数据
-	 * @return
-	 */
-	public Page<M> findAll(Pageable pageable) {
-		return baseRepository.findAll(pageable);
-	}
-
-	/**
-	 * 获取全部
-	 *
-	 *            获取全部
-	 * @return
-	 */
-	public Iterable<M> findAll(){
-		return baseRepository.findAll();
-	}
-
-}

+ 0 - 33
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/CorsFilter.java

@@ -1,33 +0,0 @@
-package org.jeecg.modules.wps.config;
-
-import org.springframework.stereotype.Component;
-
-import javax.servlet.*;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- *  跨域
- * @author zm
- * @version  1.0.0
- * @since 2019年10月12日
- */
-@Component
-public class CorsFilter implements Filter {
-
-    @Override
-    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
-        HttpServletResponse response = (HttpServletResponse) res;
-        response.setHeader("Access-Control-Allow-Origin", "*");
-        response.setHeader("Access-Control-Allow-Methods", "POST,PUT,GET");
-        response.setHeader("Access-Control-Max-Age", "3600");
-        response.setHeader("Access-Control-Allow-Headers", "*");
-        chain.doFilter(req, res);
-    }
-
-    @Override
-    public void init(FilterConfig filterConfig) {}
-
-    @Override
-    public void destroy() {}
-}

+ 0 - 17
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/PassUrl.java

@@ -1,17 +0,0 @@
-package org.jeecg.modules.wps.config;
-
-public enum PassUrl {
-
-    v1_3rd_user,v1_3rd_file,v1_api_file;
-
-    public static boolean checkCode(String code){
-        for (PassUrl mode : PassUrl.values()){
-            if (code.contains(mode.toString())){
-                return true;
-            }
-        }
-        return false;
-    }
-
-
-}

+ 0 - 62
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/UserHandlerAdapter.java

@@ -1,62 +0,0 @@
-package org.jeecg.modules.wps.config;
-
-import org.jeecg.modules.wps.base.Request;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Component;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * 拦截器
- */
-
-@Component
-public class UserHandlerAdapter extends HandlerInterceptorAdapter {
-
-    private final Logger logger = LoggerFactory.getLogger(UserHandlerAdapter.class);
-
-    @Override
-    public boolean preHandle(HttpServletRequest request,
-                             HttpServletResponse response, Object handler){
-
-        String token = Request.getHeaderParam(request, Context.TOKEN_KEY);
-        String fileId = Request.getHeaderParam(request,Context.FILE_ID_KEY);
-        String agent = Request.getHeaderParam(request,Context.USER_AGENT);
-
-        String appId = Request.getQueryParam(request,Context.APP_ID);
-        String signature = Request.getQueryParam(request,Context.SIGNATURE);
-
-        logger.info("_w_agent:{}",agent);
-
-        String uri = request.getRequestURI();
-        logger.info("request whole uri:{}", uri);
-
-        Context.setToken(token);
-        Context.setFileId(fileId);
-        Context.setAgent(agent);
-        Context.setAppId(appId);
-        Context.setSignature(signature);
-
-        // 当是用户自定义接口,直接通过(有点废话,举个例子而已)
-        if (checkUri(request,response)){
-            return true;
-        }else {
-            response.setStatus(HttpStatus.BAD_REQUEST.value());
-            return false;
-        }
-
-        // 如果是三方回调接口,则需校验
-        // 这里可以增加 处理token的校验,如果开启强制token,通过传递的signature以及相应的参数,再次生成该token数值,然后进行对比即可
-//        return true;
-    }
-
-    private boolean checkUri(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){
-        String uri = httpServletRequest.getRequestURI();
-        return PassUrl.checkCode(uri.replace("/", "_"));
-    }
-
-}

+ 0 - 21
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/config/UserMvcAdapter.java

@@ -1,21 +0,0 @@
-package org.jeecg.modules.wps.config;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
-
-@Configuration
-public class UserMvcAdapter extends WebMvcConfigurerAdapter {
-
-    private static String[] URL_PATTERNS = new String[] { "/v1/**"};
-
-    /**
-     * 注册拦截器
-     */
-    @Override
-    public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(new UserHandlerAdapter()).addPathPatterns(URL_PATTERNS);
-        super.addInterceptors(registry);
-    }
-
-}

+ 116 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/controller/FileCallBackController.java

@@ -0,0 +1,116 @@
+package org.jeecg.modules.wps.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.wps.base.Response;
+import org.jeecg.modules.wps.dto.FileReqDTO;
+import org.jeecg.modules.wps.service.IWpsFileService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Map;
+
+/**
+ * @author zm
+ * 文件相关回调接口
+ */
+@Slf4j
+@RestController
+@RequestMapping("v1/3rd/file")
+public class FileCallBackController{
+
+    @Autowired
+    public FileCallBackController(IWpsFileService fileService) {
+        this.wpsFileService = fileService;
+    }
+
+    private final IWpsFileService wpsFileService;
+
+    /**
+     * 获取文件元数据
+     */
+    @GetMapping("info")
+    public ResponseEntity<Object> getFileInfo(String _w_userid, String _w_filepath, String _w_filetype){
+        log.info("获取文件元数据userId:{},path:{},type:{}",_w_userid,_w_filepath,_w_filetype);
+        try {
+            Map<String,Object> map = wpsFileService.getFileInfo(_w_userid,_w_filepath,_w_filetype);
+            return Response.success(map);
+        }catch (Exception e){
+            return Response.bad("获取文件元数据异常");
+        }
+    }
+
+    /**
+     * 通知此文件目前有哪些人正在协作
+     */
+    @PostMapping("online")
+    public ResponseEntity<Object> fileOnline(@RequestBody JSONObject obj){
+        log.info("通知此文件目前有哪些人正在协作param:{}", JSON.toJSON(obj));
+        return Response.success();
+    }
+
+    /**
+     * 上传文件新版本
+     */
+    @PostMapping("save")
+    public ResponseEntity<Object> fileSave(@RequestBody MultipartFile file, String _w_userid){
+        log.info("上传文件新版本");
+        Map<String,Object> map = wpsFileService.fileSave(file,_w_userid);
+        return Response.success(map);
+    }
+
+    /**
+     * 获取特定版本的文件信息
+     */
+    @GetMapping("version/{version}")
+    public ResponseEntity<Object> fileVersion(@PathVariable Integer version){
+        log.info("获取特定版本的文件信息version:{}",version);
+        Map<String,Object> res = wpsFileService.fileVersion(version);
+        return Response.success(res);
+    }
+
+    /**
+     * 文件重命名
+     */
+    @PutMapping("rename")
+    public ResponseEntity<Object> fileRename(@RequestBody FileReqDTO req, String _w_userid){
+        log.info("文件重命名param:{},userId:{}", JSON.toJSON(req),_w_userid);
+        wpsFileService.fileRename(req.getName(),_w_userid);
+        return Response.success();
+    }
+
+    /**
+     * 获取所有历史版本文件信息
+     */
+    @PostMapping("history")
+    public ResponseEntity<Object> fileHistory(@RequestBody FileReqDTO req){
+        log.info("获取所有历史版本文件信息param:{}", JSON.toJSON(req));
+        Map<String,Object> result = wpsFileService.fileHistory(req);
+        return Response.success(result);
+    }
+
+    /**
+     * 新建文件
+     */
+    @PostMapping("new")
+    public ResponseEntity<Object> fileNew(@RequestBody MultipartFile file, String _w_userid){
+        log.info("新建文件_w_userid:{}",_w_userid);
+        Map<String,Object> res = wpsFileService.fileNew(file,_w_userid);
+        return Response.success(res);
+    }
+
+    /**
+     * 回调通知
+     */
+    @PostMapping("onnotify")
+    public ResponseEntity<Object> onNotify(@RequestBody JSONObject obj){
+        log.info("回调通知param:{}", JSON.toJSON(obj));
+        // TODO
+        // 返回数据暂不处理
+        return Response.success();
+    }
+
+}

+ 44 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/controller/UserCallBackController.java

@@ -0,0 +1,44 @@
+package org.jeecg.modules.wps.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.wps.base.Response;
+import org.jeecg.modules.wps.service.IWpsUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * @author zm
+ * 用户相关回调接口
+ */
+@Slf4j
+@RestController
+@RequestMapping("v1/3rd/user")
+public class UserCallBackController{
+
+    @Autowired
+    private IWpsUserService wpsUserService;
+
+    /**
+     * 获取用户信息
+     */
+    @PostMapping("info")
+    public ResponseEntity<Object> userInfo(@RequestBody JSONObject reqObj){
+        log.info("获取用户信息param:{}", JSON.toJSON(reqObj));
+        try {
+            Map<String,Object> map =
+                    wpsUserService.userInfo(reqObj);
+            return Response.success(map);
+        }catch (Exception e){
+            return Response.bad("获取用户信息异常");
+        }
+    }
+
+}

+ 118 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/controller/UserImplController.java

@@ -0,0 +1,118 @@
+package org.jeecg.modules.wps.controller;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.wps.base.Response;
+import org.jeecg.modules.wps.dto.FileListDTO;
+import org.jeecg.modules.wps.service.IWpsFileService;
+import org.jeecg.modules.wps.util.Token;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author zm
+ * 用户实现获取wps可预览URL
+ */
+@Slf4j
+@RestController
+@RequestMapping("v1/api/file")
+public class UserImplController{
+    @Autowired
+    private IWpsFileService wpsFileService;
+
+    /**
+     * 获取网络文件预览URL
+     * @param fileUrl fileUrl
+     * @return t
+     */
+    @GetMapping("getViewUrlWebPath")
+    public ResponseEntity<Object> getViewUrlWebPath(String fileUrl){
+        log.info("getViewUrlWebPath:fileUrl={}",fileUrl);
+        Token t = wpsFileService.getViewUrl(fileUrl,true);
+        return Response.success(t);
+    }
+
+    /**
+     * 获取所有文件
+     * @return db下的所有文件
+     */
+    @GetMapping("getFileList")
+    public ResponseEntity<Object> getFileList(){
+        log.info("获取所有文件");
+        List<FileListDTO> result = wpsFileService.getFileList();
+        return Response.success(result);
+    }
+
+    /**
+     * 获取所有文件
+     * @return db下的所有文件
+     */
+    @PostMapping("getFileListByPage")
+    public ResponseEntity<Object> getFileListByPage(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize){
+        Map<String,Object> result = wpsFileService.getFileListByPage(pageNo,pageSize);
+        return Response.success(result);
+    }
+
+    /**
+     * 删除用户文件
+     * @return true Or false
+     */
+    @GetMapping("delFile")
+    public ResponseEntity<Object> delFile(String id){
+        log.info("删除文件:{}",id);
+        int res = wpsFileService.delFile(id);
+        if (res == 1){
+            return Response.success(true,"删除成功");
+        }else if (res == 0){
+            return Response.success(false,"删除失败,该文件不允许被删除");
+        }else {
+            return Response.success(false,"数据异常");
+        }
+    }
+
+    /**
+     * 上传文件
+     */
+    @PostMapping("uploadFile")
+    public ResponseEntity<Object> uploadFile(@RequestParam("file") MultipartFile file){
+        try {
+            wpsFileService.uploadFile(file);
+            return Response.success(true,"上传成功");
+        }catch (Exception e){
+            e.printStackTrace();
+            return Response.success(false,"上传失败");
+        }
+    }
+
+    /**
+     * 通过fileId获取wpsUrl以及token
+     * @param fileId 文件id
+     * @return token(包含url)
+     */
+    @GetMapping("getViewUrlDbPath")
+    public ResponseEntity<Object> getViewUrlDbPath(String fileId, String userId){
+        log.info("getViewUrlDbPath:fileId={},userId={}",fileId,userId);
+        Token t = wpsFileService.getViewUrl(fileId,userId,true);
+        if (t != null){
+            return Response.success(t);
+        }else {
+            return Response.bad("文件不存在或其它异常!");
+        }
+    }
+
+    /**
+     * 通过wps官方模版新建文件
+     * template值 {"word", "excel", "ppt"}
+     */
+    @GetMapping("createTemplateFile")
+    public ResponseEntity<Object> createTemplateFile(String template){
+        String newUrl = wpsFileService.createTemplateFile(template);
+        return Response.success(newUrl);
+    }
+
+}

+ 0 - 14
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsFileMapper.java

@@ -1,14 +0,0 @@
-package org.jeecg.modules.wps.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.jeecg.modules.wps.entity.WpsFile;
-
-/**
- * wps文件
- * @author: jeecg-boot
- * @date:   2020-06-01
- * @cersion: V1.0
- */
-public interface WpsFileMapper extends BaseMapper<WpsFile> {
-
-}

+ 19 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsFile.java

@@ -1,18 +1,13 @@
 package org.jeecg.modules.wps.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 /**
@@ -51,7 +46,7 @@ public class WpsFile {
 	/**createTime*/
 	@Excel(name = "createTime", width = 15)
     @ApiModelProperty(value = "createTime")
-	private Integer createTime;
+	private Long createTime;
 	/**modifier*/
 	@Excel(name = "modifier", width = 15)
     @ApiModelProperty(value = "modifier")
@@ -59,11 +54,11 @@ public class WpsFile {
 	/**modifyTime*/
 	@Excel(name = "modifyTime", width = 15)
     @ApiModelProperty(value = "modifyTime")
-	private Integer modifyTime;
+	private Long modifyTime;
 	/**downloadUrl*/
 	@Excel(name = "downloadUrl", width = 15)
     @ApiModelProperty(value = "downloadUrl")
-	private Object downloadUrl;
+	private String downloadUrl;
 	/**deleted*/
 	@Excel(name = "deleted", width = 15)
     @ApiModelProperty(value = "deleted")
@@ -72,4 +67,20 @@ public class WpsFile {
 	@Excel(name = "canDelete", width = 15)
     @ApiModelProperty(value = "canDelete")
 	private String canDelete;
+
+	public WpsFile(){super();}
+
+	public WpsFile(String name, int version, int size, String creator,
+					  String modifier, long create_time, long modify_time, String download_url) {
+		this.name = name;
+		this.version = version;
+		this.size = size;
+		this.creator = creator;
+		this.modifier = modifier;
+		this.createTime = create_time;
+		this.modifyTime = modify_time;
+		this.downloadUrl = download_url;
+		this.deleted = "N";
+		this.canDelete = "Y";
+	}
 }

+ 1 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsFileVersion.java

@@ -1,18 +1,13 @@
 package org.jeecg.modules.wps.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 /**
@@ -51,7 +46,7 @@ public class WpsFileVersion {
 	/**size*/
 	@Excel(name = "size", width = 15)
     @ApiModelProperty(value = "size")
-	private Double size;
+	private int size;
 	/**creator*/
 	@Excel(name = "creator", width = 15)
     @ApiModelProperty(value = "creator")

+ 17 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsFileWatermark.java

@@ -1,20 +1,17 @@
 package org.jeecg.modules.wps.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
+import java.math.BigDecimal;
+
 /**
  * wps文件水印
  * @author jeecg-boot
@@ -29,9 +26,9 @@ import org.jeecgframework.poi.excel.annotation.Excel;
 public class WpsFileWatermark {
 
 	/**id*/
-	@TableId(type = IdType.UUID)
+	@TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "id")
-	private Integer id;
+	private Long id;
 	/**fileId*/
 	@Excel(name = "fileId", width = 15)
     @ApiModelProperty(value = "fileId")
@@ -64,4 +61,17 @@ public class WpsFileWatermark {
 	@Excel(name = "vertical", width = 15)
     @ApiModelProperty(value = "vertical")
 	private Integer vertical;
+
+	public WpsFileWatermark(){super();}
+
+	public WpsFileWatermark(String fileId) {
+		this.fileId = fileId;
+		this.type = 0;
+		this.value = "";
+		this.fillstyle = "rgba( 192, 192, 192, 0.6 )";
+		this.font = "bold 20px Serif";
+		this.rotate = new BigDecimal("0");
+		this.horizontal = 50;
+		this.vertical = 50;
+	}
 }

+ 4 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsUser.java

@@ -1,18 +1,13 @@
 package org.jeecg.modules.wps.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 /**
@@ -40,4 +35,8 @@ public class WpsUser {
 	@Excel(name = "avatarUrl", width = 15)
     @ApiModelProperty(value = "avatarUrl")
 	private Object avatarUrl;
+
+	public WpsUser(String userId, String fileId) {
+
+	}
 }

+ 12 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/entity/WpsUserAcl.java

@@ -30,7 +30,7 @@ public class WpsUserAcl {
 	/**userId*/
 	@Excel(name = "userId", width = 15)
     @ApiModelProperty(value = "userId")
-	private Integer userId;
+	private String userId;
 	/**fileId*/
 	@Excel(name = "fileId", width = 15)
     @ApiModelProperty(value = "fileId")
@@ -47,4 +47,15 @@ public class WpsUserAcl {
 	@Excel(name = "history", width = 15)
     @ApiModelProperty(value = "history")
 	private Integer history;
+
+	public WpsUserAcl() {
+	}
+
+	public WpsUserAcl(String userId, String fileId) {
+		this.userId = userId;
+		this.fileId = fileId;
+		this.permission = "write";
+		this.reName = 1;
+		this.history = 1;
+	}
 }

+ 51 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/mapper/WpsFileMapper.java

@@ -0,0 +1,51 @@
+package org.jeecg.modules.wps.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.wps.dto.FileListDTO;
+import org.jeecg.modules.wps.entity.WpsFile;
+
+import java.util.List;
+
+/**
+ * wps文件
+ * @author: jeecg-boot
+ * @date:   2020-06-01
+ * @cersion: V1.0
+ */
+public interface WpsFileMapper extends BaseMapper<WpsFile> {
+
+    @Select("select file.id, " +
+            "       file.name, " +
+            "       file.version, " +
+            "       file.size, " +
+            "       user1.name as 'creator', " +
+            "       user2.name as 'modifier', " +
+            "       file.create_time, " +
+            "       file.modify_time, " +
+            "       '_' as 'download_url', " +
+            "       file.modifier as 'user_id' " +
+            " from wps_file file " +
+            "         left join wps_user user1 on file.creator = user1.id " +
+            "         left join wps_user user2 on file.modifier = user2.id " +
+            " where file.deleted = 'N' " +
+            " order by file.create_time desc ")
+    List<FileListDTO> findAllFile();
+
+    @Select("select file.id, " +
+            "       file.name, " +
+            "       file.version, " +
+            "       file.size, " +
+            "       user1.name as 'creator', " +
+            "       user2.name as 'modifier', " +
+            "       file.create_time, " +
+            "       file.modify_time, " +
+            "       '_' as 'download_url', " +
+            "       file.modifier as 'user_id' " +
+            " from wps_file file " +
+            "         left join wps_user user1 on file.creator = user1.id " +
+            "         left join wps_user user2 on file.modifier = user2.id " +
+            " where file.deleted = 'N' " +
+            " order by file.create_time desc ")
+    List<FileListDTO> getAllFileByPage();
+}

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsFileVersionMapper.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.wps.dao;
+package org.jeecg.modules.wps.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.wps.entity.WpsFileVersion;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsFileWatermarkMapper.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.wps.dao;
+package org.jeecg.modules.wps.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.wps.entity.WpsFileWatermark;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsUserAclMapper.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.wps.dao;
+package org.jeecg.modules.wps.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.wps.entity.WpsUserAcl;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/WpsUserMapper.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.wps.dao;
+package org.jeecg.modules.wps.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.wps.entity.WpsUser;

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsFileMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.ctop.mapper.WpsFileMapper">
+<mapper namespace="org.jeecg.modules.wps.mapper.WpsFileMapper">
 
-</mapper>
+</mapper>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsFileVersionMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.ctop.mapper.WpsFileVersionMapper">
+<mapper namespace="org.jeecg.modules.wps.mapper.WpsFileVersionMapper">
 
-</mapper>
+</mapper>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsFileWatermarkMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.ctop.mapper.WpsFileWatermarkMapper">
+<mapper namespace="org.jeecg.modules.wps.mapper.WpsFileWatermarkMapper">
 
-</mapper>
+</mapper>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsUserAclMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.ctop.mapper.WpsUserAclMapper">
+<mapper namespace="org.jeecg.modules.wps.mapper.WpsUserAclMapper">
 
-</mapper>
+</mapper>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/dao/xml/WpsUserMapper.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.com.ctop.ctop.mapper.WpsUserMapper">
+<mapper namespace="org.jeecg.modules.wps.mapper.WpsUserMapper">
 
-</mapper>
+</mapper>

+ 1 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/propertie/WpsProperties.java

@@ -13,10 +13,6 @@ import org.springframework.stereotype.Component;
 @ConfigurationProperties(prefix = "wps")
 public class WpsProperties {
 
-	private String domain;
-	private String appid;
-	private String appsecret;
-	private String downloadHost;
-	private String localDir;
+
 
 }

+ 32 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsFileService.java

@@ -1,7 +1,14 @@
 package org.jeecg.modules.wps.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.wps.dto.FileListDTO;
+import org.jeecg.modules.wps.dto.FileReqDTO;
 import org.jeecg.modules.wps.entity.WpsFile;
+import org.jeecg.modules.wps.util.Token;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * wps文件
@@ -11,4 +18,29 @@ import org.jeecg.modules.wps.entity.WpsFile;
  */
 public interface IWpsFileService extends IService<WpsFile> {
 
+    Map<String, Object> getFileInfo(String w_userid, String w_filepath, String w_filetype);
+
+    Map<String, Object> fileSave(MultipartFile file, String w_userid);
+
+    Map<String, Object> fileVersion(Integer version);
+
+    void fileRename(String name, String w_userid);
+
+    Map<String, Object> fileHistory(FileReqDTO req);
+
+    Map<String, Object> fileNew(MultipartFile file, String w_userid);
+
+    Token getViewUrl(String fileUrl, boolean b);
+
+    Token getViewUrl(String fileUrl, String userId,boolean b);
+
+    List<FileListDTO> getFileList();
+
+    Map<String,Object> getFileListByPage(int pageNum,int pageSize);
+
+    int delFile(String id);
+
+    void uploadFile(MultipartFile file);
+
+    String createTemplateFile(String template);
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsFileVersionService.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.wps.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.wps.entity.WpsFileVersion;
 
+import java.util.List;
+
 /**
  * wps文件版本号
  * @author jeecg-boot
@@ -11,4 +13,7 @@ import org.jeecg.modules.wps.entity.WpsFileVersion;
  */
 public interface IWpsFileVersionService extends IService<WpsFileVersion> {
 
+    WpsFileVersion findByFileIdAndVersion(String fileId, Integer version);
+
+    List<WpsFileVersion> findByFileIdOrderByVersionDesc(String id);
 }

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsFileWatermarkService.java

@@ -11,4 +11,7 @@ import org.jeecg.modules.wps.entity.WpsFileWatermark;
  */
 public interface IWpsFileWatermarkService extends IService<WpsFileWatermark> {
 
+    WpsFileWatermark findFirstByFileId(String fileId);
+
+    void saveWatermark(String fileId);
 }

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsUserAclService.java

@@ -11,4 +11,7 @@ import org.jeecg.modules.wps.entity.WpsUserAcl;
  */
 public interface IWpsUserAclService extends IService<WpsUserAcl> {
 
+    WpsUserAcl findFirstByFileIdAndUserId(String fileId, String userId);
+
+    void saveUserFileAcl(String userId, String id);
 }

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/IWpsUserService.java

@@ -1,8 +1,12 @@
 package org.jeecg.modules.wps.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.wps.entity.WpsUser;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * wps用户
  * @author jeecg-boot
@@ -11,4 +15,7 @@ import org.jeecg.modules.wps.entity.WpsUser;
  */
 public interface IWpsUserService extends IService<WpsUser> {
 
+    Map<String, Object> userInfo(JSONObject reqObj);
+
+    List<WpsUser> findByIdIn(List<String> userIdList);
 }

+ 377 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileServiceImpl.java

@@ -1,10 +1,28 @@
 package org.jeecg.modules.wps.service.impl;
 
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.wps.dao.WpsFileMapper;
-import org.jeecg.modules.wps.entity.WpsFile;
-import org.jeecg.modules.wps.service.IWpsFileService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.wps.config.Context;
+import org.jeecg.modules.wps.dto.*;
+import org.jeecg.modules.wps.entity.*;
+import org.jeecg.modules.wps.mapper.WpsFileMapper;
+import org.jeecg.modules.wps.service.*;
+import org.jeecg.modules.wps.util.Token;
+import org.jeecg.modules.wps.util.WpsUtil;
+import org.jeecg.modules.wps.util.file.FileUtil;
+import org.jeecg.modules.wps.util.upload.ResFileDTO;
+import org.jeecg.modules.wps.util.upload.oss.WpsOSSUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.*;
 
 /**
  * wps文件
@@ -12,7 +30,363 @@ import org.springframework.stereotype.Service;
  * @date   2020-06-01
  * @version V1.0
  */
+@Slf4j
 @Service
 public class WpsFileServiceImpl extends ServiceImpl<WpsFileMapper, WpsFile> implements IWpsFileService {
+    @Autowired
+    private IWpsUserAclService wpsUserAclService;
+    @Autowired
+    private IWpsFileWatermarkService wpsFileWatermarkService;
+    @Autowired
+    private IWpsFileVersionService wpsFileVersionService;
+    @Autowired
+    private IWpsUserService wpsUserService;
+    @Autowired
+    private WpsUtil wpsUtil;
+    @Override
+    public Token getViewUrl(String fileUrl, boolean checkToken){
+        Token t = new Token();
+
+        String fileType = FileUtil.getFileTypeByPath(fileUrl);
+        // fileId使用uuid保证出现同样的文件而是最新文件
+        UUID randomUUID = UUID.randomUUID();
+        String uuid = randomUUID.toString().replace("-","");
+
+        Map<String,String> values = new HashMap<String,String>(){
+            {
+                put("_w_appid", appid);
+                if (checkToken){
+                    put("_w_tokentype","1");
+                }
+                put("_w_userid", "-1");
+                put("_w_filepath",fileUrl);
+                put("_w_filetype","web");
+            }
+        };
+
+        String wpsUrl = wpsUtil.getWpsUrl(values,fileType,uuid);
+
+        t.setToken(uuid);
+        t.setExpires_in(600);
+        t.setWpsUrl(wpsUrl);
+
+        return t;
+    }
+    @Value("wps.domain")
+    private String domain;
+    @Value("wps.appid")
+    private String appid;
+    @Value("wps.appsecret")
+    private String appsecret;
+    @Value("wps.download_host")
+    private String downloadHost;
+    @Value("wps.local_Dir")
+    private String localDir;
+
+    @Override
+    public Token getViewUrl(String fileId,String userId,boolean checkToken){
+        WpsFile fileEntity = this.getById(fileId);
+        if (fileEntity != null){
+            Token t = new Token();
+            String fileName = fileEntity.getName();
+            String fileType = FileUtil.getFileTypeByName(fileName);
+
+            UUID randomUuid = UUID.randomUUID();
+            String uuid = randomUuid.toString().replace("-","");
+
+            Map<String,String> values = new HashMap<>();
+            values.put("_w_appid", appid);
+            if (checkToken){
+                values.put("_w_tokentype","1");
+            }
+            values.put("_w_filepath",fileName);
+            values.put("_w_userid", userId);
+            values.put("_w_filetype","db");
+
+            String wpsUrl = wpsUtil.getWpsUrl(values,fileType,fileEntity.getId());
+            t.setToken(uuid);
+            t.setExpires_in(600);
+            t.setWpsUrl(wpsUrl);
+
+            return t;
+        }
+        return null;
+    }
+
+    @Override
+    public Map<String,Object> getFileInfo(String userId, String filePath,String _w_filetype){
+        if ("web".equalsIgnoreCase(_w_filetype)){
+            return getWebFileInfo(filePath);
+        }else if ("db".equalsIgnoreCase(_w_filetype)){
+            return getDbFileInfo(userId);
+        }
+        return null;
+    }
+
+    private Map<String,Object> getWebFileInfo(String filePath){
+        Map<String,Object>result = new HashMap<>();
+        log.info("_w_filepath:{}",filePath);
+        // 构建默认user信息
+        UserDTO wpsUser = new UserDTO(
+                "-1","我","read","https://zmfiletest.oss-cn-hangzhou.aliyuncs.com/user0.png"
+        );
+
+        // 构建文件
+        FileDTO file = new FileDTO(
+                Context.getFileId(), FileUtil.getFileName(filePath),
+                1,2835,"-1",System.currentTimeMillis(), filePath,
+                // 默认设置为无水印,只读权限
+                new UserAclBO(),new WatermarkBO()
+        );
+        result.put("file",file);
+        result.put("user",wpsUser);
+        return result;
+    }
+
+    private Map<String,Object> getDbFileInfo(String userId){
+        String fileId = Context.getFileId();
+        // 获取文件信息
+        WpsFile fileEntity = this.getById(fileId);
+
+        // 初始化文件读写权限为read
+        String permission = "read";
+
+        // 增加用户权限
+        WpsUserAcl userAclEntity = wpsUserAclService.findFirstByFileIdAndUserId(fileId,userId);
+        UserAclBO userAcl = new UserAclBO();
+        if (userAclEntity != null){
+            BeanUtils.copyProperties(userAclEntity,userAcl);
+            permission = userAclEntity.getPermission();
+        }
+
+        // 增加水印
+        WpsFileWatermark watermarkEntity = wpsFileWatermarkService.findFirstByFileId(fileId);
+        WatermarkBO watermark = new WatermarkBO();
+        if (watermarkEntity != null){
+            BeanUtils.copyProperties(watermarkEntity,watermark);
+        }
+
+        //获取user
+        WpsUser wpsUser = wpsUserService.getById(userId);
+        UserDTO user = new UserDTO();
+        if (wpsUser != null){
+            BeanUtils.copyProperties(wpsUser,user);
+            user.setPermission(permission);
+        }
+
+        // 构建fileInfo
+        FileDTO file = new FileDTO();
+        BeanUtils.copyProperties(fileEntity,file);
+        file.setUser_acl(userAcl);
+        file.setWatermark(watermark);
+
+        return new HashMap<String, Object>(){
+            {
+                put("file", file);
+                put("user", user);
+            }
+        };
+    }
+
+    @Override
+    public void fileRename(String fileName, String userId){
+        String fileId = Context.getFileId();
+        WpsFile file = this.getById(fileId);
+        if (file != null){
+            file.setName(fileName);
+            file.setModifier(userId);
+            Date date = new Date();
+            file.setModifyTime(date.getTime());
+            this.updateById(file);
+        }
+    }
+
+    @Override
+    public Map<String,Object> fileNew(MultipartFile file, String userId){
+        ResFileDTO resFileDTO = WpsOSSUtil.uploadMultipartFile(file);
+
+        String fileName = resFileDTO.getFileName();
+        String fileUrl = resFileDTO.getFileUrl();
+        int fileSize = (int) file.getSize();
+        Date date = new Date();
+        long dataTime = date.getTime();
+        // 保存文件
+        WpsFile f = new WpsFile(fileName,1,fileSize,userId,userId,dataTime,dataTime,fileUrl);
+        this.save(f);
+
+        // 处理权限
+        wpsUserAclService.saveUserFileAcl(userId,f.getId());
+
+        // 处理水印
+        wpsFileWatermarkService.saveWatermark(f.getId());
+
+        // 处理返回
+        Map<String,Object> map = new HashMap<>();
+        map.put("redirect_url",this.getViewUrl(f.getId(),userId,false).getWpsUrl());
+        map.put("user_id",userId);
+        return map;
+    }
+
+    @Override
+    public Map<String,Object> fileHistory(FileReqDTO req){
+        Map<String,Object> map = new HashMap<>();
+        List<FileHisDTO> result = new ArrayList<>(12);
+        if (req.getId() == null){
+            map.put("histories",result);
+            return map;
+        }
+        // 目前先实现获取所有的历史记录
+        List<WpsFileVersion> versionList = wpsFileVersionService.findByFileIdOrderByVersionDesc(req.getId());
+        if (versionList == null || versionList.isEmpty()){
+            map.put("histories",result);
+            return map;
+        }
+        Set<String> userIdSet = new HashSet<>();
+        for (WpsFileVersion fileVersion : versionList){
+            userIdSet.add(fileVersion.getModifier());
+            userIdSet.add(fileVersion.getCreator());
+        }
+        List<String> userIdList = new ArrayList<>(userIdSet);
+        // 获取所有关联的人
+        List<WpsUser> userList = wpsUserService.findByIdIn(userIdList);
+        if (userList == null || userList.isEmpty()){
+            map.put("histories",result);
+            return map;
+        }
+        for (WpsFileVersion fileVersion : versionList){
+            FileHisDTO fileHis = new FileHisDTO();
+            BeanUtils.copyProperties(fileVersion,fileHis);
+            fileHis.setId(fileVersion.getFileId());
+            UserDTO creator = new UserDTO();
+            UserDTO modifier = new UserDTO();
+            for (WpsUser user : userList){
+                if (user.getId().equals(fileVersion.getCreator())){
+                    BeanUtils.copyProperties(user,creator);
+                }
+                if (user.getId().equals(fileVersion.getModifier())){
+                    BeanUtils.copyProperties(user,modifier);
+                }
+            }
+            fileHis.setModifier(modifier);
+            fileHis.setCreator(creator);
+            result.add(fileHis);
+        }
+        map.put("histories",result);
+        return map;
+    }
+
+    @Override
+    public Map<String,Object> fileSave(MultipartFile mFile,String userId){
+        Date date = new Date();
+        // 上传
+        ResFileDTO resFileDTO = WpsOSSUtil.uploadMultipartFile(mFile);
+        int size = (int) resFileDTO.getFileSize();
+
+        String fileId = Context.getFileId();
+        WpsFile file = this.getById(fileId);
+        FileDTO fileInfo = new FileDTO();
+
+        String oldFileUrl = file.getDownloadUrl();
+
+        // 更新当前版本
+        file.setVersion(file.getVersion() + 1);
+        file.setDownloadUrl(resFileDTO.getFileUrl());
+        file.setModifier(userId);
+        file.setModifyTime(date.getTime());
+        file.setSize(size);
+        this.updateById(file);
+
+        // 保存历史版本
+        WpsFileVersion fileVersion = new WpsFileVersion();
+        BeanUtils.copyProperties(file,fileVersion);
+        fileVersion.setFileId(fileId);
+        fileVersion.setVersion(file.getVersion() - 1);
+        fileVersion.setDownloadUrl(oldFileUrl);
+        fileVersion.setSize(size);
+        wpsFileVersionService.save(fileVersion);
+
+        // 返回当前版本信息
+        BeanUtils.copyProperties(file,fileInfo);
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("file",fileInfo);
+        return map;
+    }
+
+
+    @Override
+    public Map<String,Object> fileVersion(Integer version){
+        FileDTO fileInfo = new FileDTO();
+        String fileId = Context.getFileId();
+        WpsFileVersion fileVersion =
+                wpsFileVersionService.findByFileIdAndVersion(fileId,version);
+        if (fileVersion != null){
+            BeanUtils.copyProperties(fileVersion,fileInfo);
+            fileInfo.setId(fileVersion.getFileId());
+        }
+        Map<String,Object> map = new HashMap<>();
+        map.put("file",fileInfo);
+        return map;
+    }
+    @Autowired
+    private WpsFileMapper wpsFileMapper;
+
+    @Override
+    public List<FileListDTO> getFileList(){
+        return wpsFileMapper.findAllFile();
+    }
+    @Override
+    public Map<String,Object> getFileListByPage(int pageNum, int pageSize){
+        Map<String,Object>result = new HashMap<>();
+        PageHelper.startPage(pageNum,pageSize);
+        List<FileListDTO> fileListDTOS = wpsFileMapper.getAllFileByPage();
+        PageInfo<FileListDTO> pageInfo = new PageInfo<>(fileListDTOS);
+        result.put("data",pageInfo);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    @Override
+    public int delFile(String id){
+        WpsFile file = this.getById(id);
+        if (file != null){
+            if ("Y".equalsIgnoreCase(file.getCanDelete())){
+                // del
+                this.removeById(id);
+                return 1;
+            }else {
+                return 0;
+            }
+        }else {
+            return -1;
+        }
+    }
+
+    @Override
+    public void uploadFile(MultipartFile file){
+        String uploadUserId = "3";
+        ResFileDTO resFileDTO = WpsOSSUtil.uploadMultipartFile(file);
+        // 上传成功后,处理数据库记录值
+        Date date = new Date();
+        long dataTime = date.getTime();
+        // 保存文件
+        WpsFile f = new WpsFile(resFileDTO.getFileName(),1,((int) resFileDTO.getFileSize()),
+                uploadUserId,uploadUserId,dataTime,dataTime, resFileDTO.getFileUrl());
+        this.save(f);
+
+        // 处理权限
+        wpsUserAclService.saveUserFileAcl(uploadUserId,f.getId());
+
+        // 处理水印
+        wpsFileWatermarkService.saveWatermark(f.getId());
+    }
 
+    @Override
+    public String createTemplateFile(String template){
+        boolean typeTrue = FileUtil.checkCode(template);
+        if (typeTrue){
+            return wpsUtil.getTemplateWpsUrl(template,"3");
+        }
+        return "";
+    }
 }

+ 26 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileVersionServiceImpl.java

@@ -1,11 +1,14 @@
 package org.jeecg.modules.wps.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.wps.dao.WpsFileVersionMapper;
+import org.jeecg.modules.wps.mapper.WpsFileVersionMapper;
 import org.jeecg.modules.wps.entity.WpsFileVersion;
 import org.jeecg.modules.wps.service.IWpsFileVersionService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * wps文件版本号
  * @author jeecg-boot
@@ -15,4 +18,26 @@ import org.springframework.stereotype.Service;
 @Service
 public class WpsFileVersionServiceImpl extends ServiceImpl<WpsFileVersionMapper, WpsFileVersion> implements IWpsFileVersionService {
 
+    @Override
+    public WpsFileVersion findByFileIdAndVersion(String fileId, Integer version) {
+        QueryWrapper<WpsFileVersion>queryWrapper = new QueryWrapper<>();
+        if(null!=fileId&&!fileId.trim().equals("")){
+            queryWrapper.eq("file_id",fileId);
+        }
+        if(null!=version&&version!=0){
+            queryWrapper.eq("version",version);
+        }
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public List<WpsFileVersion> findByFileIdOrderByVersionDesc(String fileId) {
+        QueryWrapper<WpsFileVersion>queryWrapper = new QueryWrapper<>();
+        if(null!=fileId&&fileId.trim().equals("")){
+            queryWrapper.eq("file_id",fileId);
+        }
+        queryWrapper.orderByDesc("version");
+        return this.list(queryWrapper);
+    }
 }

+ 16 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsFileWatermarkServiceImpl.java

@@ -1,7 +1,8 @@
 package org.jeecg.modules.wps.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.wps.dao.WpsFileWatermarkMapper;
+import org.jeecg.modules.wps.mapper.WpsFileWatermarkMapper;
 import org.jeecg.modules.wps.entity.WpsFileWatermark;
 import org.jeecg.modules.wps.service.IWpsFileWatermarkService;
 import org.springframework.stereotype.Service;
@@ -15,4 +16,18 @@ import org.springframework.stereotype.Service;
 @Service
 public class WpsFileWatermarkServiceImpl extends ServiceImpl<WpsFileWatermarkMapper, WpsFileWatermark> implements IWpsFileWatermarkService {
 
+    @Override
+    public WpsFileWatermark findFirstByFileId(String fileId) {
+        QueryWrapper<WpsFileWatermark>queryWrapper = new QueryWrapper<>();
+        if(null!=fileId&&!fileId.trim().equals("")){
+            queryWrapper.eq("file_id",fileId);
+        }
+        queryWrapper.orderByDesc("id").last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public void saveWatermark(String fileId) {
+        this.save(new WpsFileWatermark(fileId));
+    }
 }

+ 18 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsUserAclServiceImpl.java

@@ -1,7 +1,8 @@
 package org.jeecg.modules.wps.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.wps.dao.WpsUserAclMapper;
+import org.jeecg.modules.wps.mapper.WpsUserAclMapper;
 import org.jeecg.modules.wps.entity.WpsUserAcl;
 import org.jeecg.modules.wps.service.IWpsUserAclService;
 import org.springframework.stereotype.Service;
@@ -14,5 +15,21 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class WpsUserAclServiceImpl extends ServiceImpl<WpsUserAclMapper, WpsUserAcl> implements IWpsUserAclService {
+    @Override
+    public WpsUserAcl findFirstByFileIdAndUserId(String fileId, String userId) {
+        QueryWrapper<WpsUserAcl> queryWrapper = new QueryWrapper<>();
+        if(null!=fileId&&!fileId.trim().equals("")){
+            queryWrapper.eq("file_id",fileId);
+        }
+        if(null!=userId&&!userId.trim().equals("")){
+            queryWrapper.eq("user_id",userId);
+        }
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
 
+    @Override
+    public void saveUserFileAcl(String userId, String fileId) {
+        this.save(new WpsUserAcl(userId,fileId));
+    }
 }

+ 47 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/service/impl/WpsUserServiceImpl.java

@@ -1,11 +1,18 @@
 package org.jeecg.modules.wps.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.wps.dao.WpsUserMapper;
+import org.jeecg.modules.wps.mapper.WpsUserMapper;
 import org.jeecg.modules.wps.entity.WpsUser;
 import org.jeecg.modules.wps.service.IWpsUserService;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * wps用户
  * @author jeecg-boot
@@ -15,4 +22,43 @@ import org.springframework.stereotype.Service;
 @Service
 public class WpsUserServiceImpl extends ServiceImpl<WpsUserMapper, WpsUser> implements IWpsUserService {
 
+    @Override
+    public Map<String,Object> userInfo(JSONObject reqObj){
+        List<String> ids = null;
+
+        if(reqObj != null) {
+            if(reqObj.containsKey("ids")) {
+                ids = JSONArray.parseArray(reqObj.getString("ids"), String.class);
+            }
+        }
+
+        Map<String,Object> map = new HashMap<>();
+        List<WpsUser> users = new ArrayList<>();
+        if(ids != null && !ids.isEmpty()) {
+            WpsUser user;
+            for (String id : ids) {
+                user = this.getById(id);
+                if (user != null){
+                    users.add(user);
+                }
+            }
+        }
+        map.put("users", users);
+        return map;
+    }
+
+    @Override
+    public List<WpsUser> findByIdIn(List<String> userIdList) {
+        if(null==userIdList||userIdList.isEmpty()){
+            return null;
+        }
+        List<WpsUser> userList = new ArrayList<>();
+        for (String id :userIdList){
+            WpsUser user = this.getById(id);
+            if(null!=user){
+                userList.add(user);
+            }
+        }
+        return userList;
+    }
 }

+ 8 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/SignatureUtil.java

@@ -15,13 +15,10 @@ import static org.apache.commons.codec.binary.Base64.encodeBase64String;
 public class SignatureUtil {
 
     public static String getKeyValueStr(Map<String, String> params) {
-        List<String> keys = new ArrayList<String>(){
-            {
-                for (Map.Entry<String, String> entry : params.entrySet()) {
-                    add(entry.getKey());
-                }
-            }
-        };
+        List<String> keys = new ArrayList<>();
+        for (Map.Entry<String, String> entry : params.entrySet()) {
+            keys.add(entry.getKey());
+        }
         StringBuilder sb = new StringBuilder();
         for (String key : keys) {
             String value = params.get(key) + "&";
@@ -31,14 +28,10 @@ public class SignatureUtil {
     }
 
     public static String getSignature(Map<String, String> params, String appSecret) {
-        List<String> keys = new ArrayList<String>(){
-            {
-                for (Map.Entry<String, String> entry : params.entrySet()) {
-                    add(entry.getKey());
-                }
-            }
-        };
-
+        List<String> keys = new ArrayList<>();
+        for (Map.Entry<String, String> entry : params.entrySet()) {
+            keys.add(entry.getKey());
+        }
         // 将所有参数按key的升序排序
         keys.sort(String::compareTo);
 

+ 19 - 21
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/WpsUtil.java

@@ -1,8 +1,7 @@
 package org.jeecg.modules.wps.util;
 
-import com.web.wps.propertie.WpsProperties;
-import com.web.wps.util.file.FileUtil;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.jeecg.modules.wps.util.file.FileUtil;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.util.HashMap;
@@ -10,35 +9,34 @@ import java.util.Map;
 
 @Component
 public class WpsUtil {
-
-    private final WpsProperties wpsProperties;
-
-    @Autowired
-    public WpsUtil(WpsProperties wpsProperties) {
-        this.wpsProperties = wpsProperties;
-    }
-
+    @Value("wps.domain")
+    private String domain;
+    @Value("wps.appid")
+    private String appid;
+    @Value("wps.appsecret")
+    private String appsecret;
+    @Value("wps.download_host")
+    private String downloadHost;
+    @Value("wps.local_Dir")
+    private String localDir;
     public String getWpsUrl(Map<String,String> values,String fileType,String fileId){
         String keyValueStr = SignatureUtil.getKeyValueStr(values);
-        String signature = SignatureUtil.getSignature(values, wpsProperties.getAppsecret());
+        String signature = SignatureUtil.getSignature(values, appsecret);
         String fileTypeCode = FileUtil.getFileTypeCode(fileType);
 
-        return wpsProperties.getDomain() + fileTypeCode + "/" + fileId + "?"
+        return domain + fileTypeCode + "/" + fileId + "?"
                 + keyValueStr + "_w_signature=" + signature;
     }
 
     public String getTemplateWpsUrl(String fileType,String userId){
-        Map<String,String> values = new HashMap<String,String>(){
-            {
-                put("_w_appid", wpsProperties.getAppid());
-                put("_w_userid", userId);
-            }
-        };
+        Map<String,String> values = new HashMap<>();
+        values.put("_w_appid", appid);
+        values.put("_w_userid", userId);
         String keyValueStr = SignatureUtil.getKeyValueStr(values);
-        String signature = SignatureUtil.getSignature(values, wpsProperties.getAppsecret());
+        String signature = SignatureUtil.getSignature(values, appsecret);
         String fileTypeCode = FileUtil.getTypeCode(fileType);
 
-        return wpsProperties.getDomain() + fileTypeCode + "/new/0" + "?"
+        return domain + fileTypeCode + "/new/0" + "?"
                 + keyValueStr + "_w_signature=" + signature;
     }
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/file/FileTypeJudge.java

@@ -65,7 +65,7 @@ public class FileTypeJudge {
     * 判断文件类型
     * @return 文件类型
     */
-   public FileType getType(InputStream is) throws IOException {
+   public static FileType getType(InputStream is) throws IOException {
 
        String fileHead = getFileContent(is);
 

+ 119 - 52
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/upload/oss/OSSUtil.java

@@ -5,13 +5,12 @@ import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClient;
 import com.aliyun.oss.model.*;
 import org.apache.commons.lang.StringUtils;
-import org.jeecg.modules.wps.propertie.OSSProperties;
 import org.jeecg.modules.wps.util.file.FileType;
 import org.jeecg.modules.wps.util.file.FileTypeJudge;
 import org.jeecg.modules.wps.util.file.FileUtil;
 import org.jeecg.modules.wps.util.upload.ResFileDTO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
@@ -21,46 +20,93 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.*;
 
-@Service
-public class OSSUtil {
+@Component
+public class WpsOSSUtil {
+    private static String fileUrlPrefix;
+    /**
+     * 阿里云API的bucket名称
+     */
+    private static String bucketName;
+    private static String diskName;
+    private static String regionId;
+
+    /**
+     * 阿里云API的内或外网域名
+     */
+    private static String endpoint;
+    /**
+     * 阿里云API的密钥Access Key ID
+     */
+    private static String accessKey;
+    /**
+     * 阿里云API的密钥Access Key Secret
+     */
+    private static String accessSecret;
+
+    @Value("${wps.oss.file_url_prefix}")
+    public static void setFileUrlPrefix(String fileUrlPrefix) {
+        WpsOSSUtil.fileUrlPrefix = fileUrlPrefix;
+    }
+
+    @Value("${wps.oss.disk_name}")
+    public static void setDiskName(String diskName) {
+        WpsOSSUtil.diskName = diskName;
+    }
+
+    @Value("${wps.oss.region_Id}")
+    public static void setRegionId(String regionId) {
+        WpsOSSUtil.regionId = regionId;
+    }
+
+    @Value("${wps.oss.bucket_name}")
+    public void setBucketName(String bucketName) {
+        WpsOSSUtil.bucketName = bucketName;
+    }
+
+    @Value("${wps.oss.access_key}")
+    public void setAccessKey(String accessKey) {
+        WpsOSSUtil.accessKey = accessKey;
+    }
 
-    @Autowired
-    public OSSUtil(OSSProperties oss, FileTypeJudge fileTypeJudge) {
-        this.oss = oss;
-        this.fileTypeJudge = fileTypeJudge;
+    @Value("${wps.oss.access_secret}")
+    public void setAccessSecret(String accessSecret) {
+        WpsOSSUtil.accessSecret = accessSecret;
+    }
+
+    @Value("${wps.oss.endpoint}")
+    public void setEndpoint(String endpoint) {
+        WpsOSSUtil.endpoint = endpoint;
     }
 
-    private final OSSProperties oss;
-    private final FileTypeJudge fileTypeJudge;
 
-    private OSSClient getOSSClient(){
-        return new OSSClient(oss.getEndpoint(),oss.getAccessKey(), oss.getAccessSecret());
+    private static OSSClient getOSSClient(){
+        return new OSSClient(endpoint,accessKey, accessSecret);
     }
 
-    public String simpleUploadFilePath(String filePath){
+    public static String simpleUploadFilePath(String filePath){
         File file = new File(filePath);
-        return (this.simpleUploadFile(file));
+        return simpleUploadFile(file);
     }
 
-    public String simpleUploadFile(File file){
+    public static String simpleUploadFile(File file){
         String fileName = file.getName();
         String newFileName = FileUtil.makeNewFileName(fileName);
-        this.getOSSClient().putObject(oss.getBucketName(), oss.getDiskName() + newFileName, file);
-        return (oss.getFileUrlPrefix() + oss.getDiskName() + newFileName);
+        getOSSClient().putObject(bucketName, diskName + newFileName, file);
+        return (fileUrlPrefix + diskName + newFileName);
     }
 
     public String simpleUploadMultipartFile(MultipartFile file){
         String fileName = file.getOriginalFilename();
         String newFileName = FileUtil.makeNewFileName(fileName);
         try {
-            this.getOSSClient().putObject(oss.getBucketName(), oss.getDiskName() + newFileName, file.getInputStream());
+            getOSSClient().putObject(bucketName, diskName + newFileName, file.getInputStream());
         } catch (IOException e) {
             e.printStackTrace();
         }
-        return (oss.getFileUrlPrefix() + oss.getDiskName() + newFileName);
+        return (fileUrlPrefix + diskName + newFileName);
     }
 
-    public ResFileDTO uploadMultipartFile(MultipartFile file){
+    public static ResFileDTO uploadMultipartFile(MultipartFile file){
         String fileName = file.getOriginalFilename();
         InputStream inputStream;
         ResFileDTO o = new ResFileDTO();
@@ -68,7 +114,7 @@ public class OSSUtil {
         long fileSize = file.getSize();
         try {
             inputStream = file.getInputStream();
-            FileType type = fileTypeJudge.getType(inputStream);
+            FileType type = FileTypeJudge.getType(inputStream);
 
             if(type == null || "null".equals(type.toString()) ||
                     "XLS_DOC".equals(type.toString())|| "XLSX_DOCX".equals(type.toString()) ||
@@ -85,21 +131,17 @@ public class OSSUtil {
         }
 
         try {
-            o = this.uploadDetailInputStream(file.getInputStream(),fileName,fileType,fileSize);
+            o = uploadDetailInputStream(file.getInputStream(),fileName,fileType,fileSize);
         } catch (IOException e) {
             e.printStackTrace();
         }
         return o;
     }
 
-    public ResFileDTO uploadDetailInputStream (InputStream in, String fileName , String fileType, long fileSize) {
-
+    public static ResFileDTO uploadDetailInputStream (InputStream in, String fileName , String fileType, long fileSize) {
         String uuidFileName = FileUtil.getFileUUIDName(fileName,fileType);
-
-        String fileUrl = oss.getFileUrlPrefix() + oss.getDiskName() + uuidFileName;
-
-        String md5key = this.uploadFile(in, uuidFileName, fileSize, oss.getBucketName(),
-                oss.getDiskName(),fileName);
+        String fileUrl = fileUrlPrefix + diskName + uuidFileName;
+        String md5key = uploadFile(in, uuidFileName, fileSize, bucketName, diskName,fileName);
         ResFileDTO o = new ResFileDTO();
 
         if(md5key != null){
@@ -119,10 +161,10 @@ public class OSSUtil {
      * @param diskName 上传文件的目录  --bucket下文件的路径
      * @return String 唯一MD5数字签名
      * */
-    public String uploadFile(InputStream inputStream, String fileName,long fileSize,String bucketName, String diskName,String localFileName) {
+    public static String uploadFile(InputStream inputStream, String fileName,long fileSize,String bucketName, String diskName,String localFileName) {
         String resultStr = null;
         try {
-            OSSClient client =  this.getOSSClient();
+            OSSClient client =  getOSSClient();
             //创建上传Object的Metadata
             ObjectMetadata metadata = new ObjectMetadata();
             metadata.setContentLength(inputStream.available());
@@ -143,7 +185,6 @@ public class OSSUtil {
         } catch (Exception e) {
             e.printStackTrace();
             System.out.println("上传阿里云OSS服务器异常:"+e.getMessage());
-            //LOG.error("上传阿里云OSS服务器异常." + e.getMessage(), e);
         }
         return resultStr;
     }
@@ -157,7 +198,7 @@ public class OSSUtil {
     public void changeFileMetaInfo(String fileName,String bucketName,String downName){
         try{
             // 创建OSSClient实例。
-            OSS ossClient = this.getOSSClient();
+            OSS ossClient = getOSSClient();
             // 设置源文件与目标文件相同,调用ossClient.copyObject方法修改文件元信息。
             CopyObjectRequest request = new CopyObjectRequest(bucketName, fileName, bucketName, fileName);
             ObjectMetadata meta = new ObjectMetadata();
@@ -191,7 +232,7 @@ public class OSSUtil {
      */
     public URL getDownLoadUrl(String fileName, String bucketName){
         // 创建OSSClient实例。
-        OSS ossClient = this.getOSSClient();
+        OSS ossClient = getOSSClient();
         //设置链接时效60分钟
         Calendar c = Calendar.getInstance();
         c.setTime(new Date());
@@ -240,7 +281,7 @@ public class OSSUtil {
     public String uploadObject(File file, String bucketName, String diskName) {
         String resultStr = null;
         try {
-            OSSClient client =  this.getOSSClient();
+            OSSClient client =  getOSSClient();
             InputStream is = new FileInputStream(file);
             String fileName = file.getName();
             long fileSize = file.length();
@@ -273,7 +314,7 @@ public class OSSUtil {
         String uploadid = null;
         int j=0;
         // 初始化一个OSSClient
-        OSSClient client =  this.getOSSClient();
+        OSSClient client =  getOSSClient();
         ListMultipartUploadsRequest lmur = new ListMultipartUploadsRequest(bucketName);
         // 获取Bucket内所有上传事件
         MultipartUploadListing listing = client.listMultipartUploads(lmur);
@@ -354,7 +395,7 @@ public class OSSUtil {
     public String downloadFile(String bucketName, String diskName,String filePath) {
         String resultStr = null;
         try {
-            OSSClient client =  this.getOSSClient();
+            OSSClient client =  getOSSClient();
             client.getObject(new GetObjectRequest(bucketName, diskName), new File(filePath));
             client.shutdown();
         } catch (Exception e) {
@@ -382,7 +423,7 @@ public class OSSUtil {
      * @param key Bucket下的文件的路径名+文件名
      */
     public void deleteFile( String bucketName, String diskName, String key){
-        OSSClient client =  this.getOSSClient();
+        OSSClient client =  getOSSClient();
         client.deleteObject(bucketName, diskName + key);
         client.shutdown();
         System.out.println("删除" + bucketName + "下的文件" + diskName + key + "成功");
@@ -395,19 +436,45 @@ public class OSSUtil {
      */
     public static String getContentType(String fileName){
         String fileExtension = fileName.substring(fileName.lastIndexOf(".")+1);
-        if("bmp".equalsIgnoreCase(fileExtension)) return "image/bmp";
-        if("gif".equalsIgnoreCase(fileExtension)) return "image/gif";
-        if("jpeg".equalsIgnoreCase(fileExtension) || "jpg".equalsIgnoreCase(fileExtension)  || "png".equalsIgnoreCase(fileExtension) ) return "image/jpeg";
-        if("html".equalsIgnoreCase(fileExtension)) return "text/html";
-        if("txt".equalsIgnoreCase(fileExtension)) return "text/plain";
-        if("vsd".equalsIgnoreCase(fileExtension)) return "application/vnd.visio";
-        if("ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) return "application/x-ppt";
-        if("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension)) return "application/x-xls";
-        if("doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) return "application/x-docx";
-        if("xml".equalsIgnoreCase(fileExtension)) return "text/xml";
-        if("pdf".equalsIgnoreCase(fileExtension)) return "application/pdf";
-        if("mp3".equalsIgnoreCase(fileExtension)) return "audio/mp3";
-        if("mp4".equalsIgnoreCase(fileExtension)) return "video/mpeg4";
+        if("bmp".equalsIgnoreCase(fileExtension)){
+            return "image/bmp";
+        }
+        if("gif".equalsIgnoreCase(fileExtension)){
+            return "image/gif";
+        }
+        if("jpeg".equalsIgnoreCase(fileExtension) || "jpg".equalsIgnoreCase(fileExtension)  || "png".equalsIgnoreCase(fileExtension) ){
+            return "image/jpeg";
+        }
+        if("html".equalsIgnoreCase(fileExtension)){
+            return "text/html";
+        }
+        if("txt".equalsIgnoreCase(fileExtension)){
+            return "text/plain";
+        }
+        if("vsd".equalsIgnoreCase(fileExtension)){
+            return "application/vnd.visio";
+        }
+        if("ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)){
+            return "application/x-ppt";
+        }
+        if("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension)){
+            return "application/x-xls";
+        }
+        if("doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)){
+            return "application/x-docx";
+        }
+        if("xml".equalsIgnoreCase(fileExtension)){
+            return "text/xml";
+        }
+        if("pdf".equalsIgnoreCase(fileExtension)){
+            return "application/pdf";
+        }
+        if("mp3".equalsIgnoreCase(fileExtension)){
+            return "audio/mp3";
+        }
+        if("mp4".equalsIgnoreCase(fileExtension)){
+            return "video/mpeg4";
+        }
         return "text/html";
     }
 

+ 0 - 120
jeecg-boot-module-system/src/main/java/org/jeecg/modules/wps/util/upload/qn/QNUtil.java

@@ -1,120 +0,0 @@
-package org.jeecg.modules.wps.util.upload.qn;
-
-import com.qiniu.common.QiniuException;
-import com.qiniu.http.Response;
-import com.qiniu.storage.Configuration;
-import com.qiniu.storage.Region;
-import com.qiniu.storage.UploadManager;
-import com.qiniu.util.Auth;
-import com.qiniu.util.StringMap;
-import com.web.wps.propertie.QNProperties;
-import com.web.wps.util.file.FileUtil;
-import com.web.wps.util.upload.ResFileDTO;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-@Service
-public class QNUtil {
-
-    private final QNProperties qnConfig;
-
-    public QNUtil(QNProperties qnConfig) {
-        this.qnConfig = qnConfig;
-    }
-
-    private UploadManager uploadManager;
-    private String upToken;
-
-    /**
-     * 同名覆盖,不同名新建
-     * @param key cFilename
-     */
-    private void makeUploadManager(String key){
-        StringMap putPolicy = new StringMap();
-        putPolicy.put("returnBody", "{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"fsize\":$(fsize)}");
-        Configuration cfg = new Configuration(Region.huanan());
-        this.uploadManager = new UploadManager(cfg);
-        Auth auth = Auth.create(qnConfig.getAccessKey(), qnConfig.getSecretKey());
-        this.upToken = auth.uploadToken(qnConfig.getBucket(),key,3600,putPolicy);
-    }
-
-    public ResFileDTO uploadInputStream(InputStream inputStream, String fileName) {
-        try {
-            String fileType = FileUtil.getFileTypeByName(fileName);
-            String uuidFileName = FileUtil.makeNewFileName(fileName,fileType);
-            String key = qnConfig.getDiskName() + uuidFileName;
-            this.makeUploadManager(key);
-            // 默认不指定key的情况下,以文件内容的hash值作为文件名
-//            String key = fileName;
-            Response response = uploadManager.put(inputStream, key, upToken, null, null);
-            MyPutRet myPutRet = response.jsonToObject(MyPutRet.class);
-            String fileUrl = qnConfig.getUrl() + myPutRet.key;
-            return new ResFileDTO(fileUrl,fileName,key,fileType,myPutRet.fsize,myPutRet.hash);
-        } catch (QiniuException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public ResFileDTO uploadFile(File file){
-        try {
-            String fileName = file.getName();
-            String fileType = FileUtil.getFileTypeByName(fileName);
-            String uuidFileName = FileUtil.makeNewFileName(fileName,fileType);
-            String key = qnConfig.getDiskName() + uuidFileName;
-            this.makeUploadManager(key);
-            // 默认不指定key的情况下,以文件内容的hash值作为文件名
-//            String key = file.getName();
-            Response response = uploadManager.put(file, key, upToken);
-            MyPutRet myPutRet = response.jsonToObject(MyPutRet.class);
-            String fileUrl = qnConfig.getUrl() + myPutRet.key;
-            return new ResFileDTO(fileUrl,fileName,key,fileType,myPutRet.fsize,myPutRet.hash);
-        } catch (QiniuException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public ResFileDTO uploadFilePath(String filePath){
-        try {
-            String fileName = FileUtil.getFileName(filePath);
-            String fileType = FileUtil.getFileTypeByPath(filePath);
-            String uuidFileName = FileUtil.makeNewFileName(fileName,fileType);
-            String key = qnConfig.getDiskName() + uuidFileName;
-            this.makeUploadManager(key);
-            // 默认不指定key的情况下,以文件内容的hash值作为文件名
-//            String key = FileUtil.getFileName(filePath);
-            Response response = uploadManager.put(filePath, key, upToken);
-            MyPutRet myPutRet = response.jsonToObject(MyPutRet.class);
-            String fileUrl = qnConfig.getUrl() + myPutRet.key;
-            return new ResFileDTO(fileUrl,fileName,key,fileType,myPutRet.fsize,myPutRet.hash);
-        } catch (QiniuException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public ResFileDTO uploadMultipartFile(MultipartFile file){
-        try {
-            String fileName = file.getOriginalFilename();
-            String fileType = FileUtil.getFileTypeByName(fileName);
-            String uuidFileName = FileUtil.makeNewFileName(fileName,fileType);
-            String key = qnConfig.getDiskName() + uuidFileName;
-            this.makeUploadManager(key);
-            // 默认不指定key的情况下,以文件内容的hash值作为文件名
-//            String key = file.getOriginalFilename();
-            Response response = uploadManager.put(file.getInputStream(), key, upToken,null,null);
-            MyPutRet myPutRet = response.jsonToObject(MyPutRet.class);
-            String fileUrl = qnConfig.getUrl() + myPutRet.key;
-            return new ResFileDTO(fileUrl,fileName,key,fileType,myPutRet.fsize,myPutRet.hash);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-}

+ 14 - 9
jeecg-boot-module-system/src/main/resources/application.yml

@@ -15,12 +15,17 @@ swagger:
     username: jeecg
     password: jeecg1314
 
-oss:
-  file_url_prefix: https://file.xx.com/
-  bucket_name: xxxxxx
-  disk_name:  xxxxxxxxxxxxx/
-  region_id: cn-hangzhou
-  endpoint: https://oss-cn-hangzhou.aliyuncs.com
-  access_key: xxxxxxxxxxxxxx
-  access_secret:  xxxxxxxxxxxxxxxxxxxx
-
+wps:
+  domain: https://wwo.wps.cn/office/
+  appid: AK20200318KOAZAO
+  appsecret: 1114ea897ee04c644e3d886c1578562b
+  download_host:
+  local_dir:
+  oss:
+    file_url_prefix: https://ctop-media.oss-cn-beijing.aliyuncs.com/
+    bucket_name: ctop-media
+    disk_name:  script-lib/wps/
+    region_id: cn-bejing
+    endpoint: http://oss-cn-beijing.aliyuncs.com
+    access_key: LTAIbNbqWzSOklQV
+    access_secret: 1rkPz7JNoXk8sJevPaeYHWqfkQXBGh