inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 /*
I 2 Copyright [2020] [https://www.xiaonuo.vip]
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
17
18 1.请不要删除和修改根目录下的LICENSE文件。
19 2.请不要删除和修改Snowy源码头部的版权声明。
20 3.请保留源码和相关描述文件的项目出处,作者声明等。
21 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy
22 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy
23 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
24  */
25 package vip.xiaonuo.sys.modular.file.controller;
26
27 import cn.hutool.core.lang.Dict;
28 import cn.hutool.core.util.ObjectUtil;
29 import cn.hutool.json.JSONUtil;
30 import org.springframework.ui.Model;
31 import org.springframework.validation.annotation.Validated;
32 import org.springframework.web.bind.annotation.*;
33 import org.springframework.web.multipart.MultipartFile;
34 import vip.xiaonuo.core.annotion.BusinessLog;
35 import vip.xiaonuo.core.annotion.Permission;
36 import vip.xiaonuo.core.context.constant.ConstantContextHolder;
37 import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
38 import vip.xiaonuo.core.pojo.response.ResponseData;
39 import vip.xiaonuo.core.pojo.response.SuccessResponseData;
40 import vip.xiaonuo.sys.modular.file.param.SysFileInfoParam;
41 import vip.xiaonuo.sys.modular.file.result.SysOnlineFileInfoResult;
42 import vip.xiaonuo.sys.modular.file.service.SysFileInfoService;
43
44 import javax.annotation.Resource;
45 import javax.servlet.http.HttpServletResponse;
46
47 /**
48  * 文件信息表 控制器
49  *
50  * @author yubaoshan
51  * @date 2020/6/7 22:15
52  */
53 @RestController
54 public class SysFileInfoController {
55
56     @Resource
57     private SysFileInfoService sysFileInfoService;
58
59     /**
60      * onlyoffice资源文件路径
61      */
62     public static final String ONLY_OFFICE_APP_JS_SUFFIX = "/web-apps/apps/api/documents/api.js";
63
64     /**
65      * 在线文档配置
66      *
67      * @author xuyuxiang
68      * @date 2020/11/17 16:40
69      */
70     @GetMapping("/sysFileInfo/getOnlineFileConfig")
71     public ResponseData getOnlineFileConfig(SysFileInfoParam sysFileInfoParam) {
72         //生成在线文档的model
73         SysOnlineFileInfoResult sysOnlineFileInfoResult = sysFileInfoService.onlineAddOrUpdate(sysFileInfoParam);
74         Dict dict = Dict.create();
75         dict.put("docServiceApiUrl",  ConstantContextHolder.getOnlyOfficeUrl() + ONLY_OFFICE_APP_JS_SUFFIX);
76         dict.put("sysOnlineFileInfoResult", sysOnlineFileInfoResult);
77         return new SuccessResponseData(dict);
78     }
79
80     /**
81      * 上传文件
82      *
83      * @author yubaoshan
84      * @date 2020/6/7 22:15
85      */
86     @PostMapping("/sysFileInfo/upload")
87     @BusinessLog(title = "文件信息表_上传文件", opType = LogAnnotionOpTypeEnum.OTHER)
88     public ResponseData upload(@RequestPart("file") MultipartFile file) {
89         Long fileId = sysFileInfoService.uploadFile(file);
90         return new SuccessResponseData(fileId);
91     }
92
93     /**
94      * 下载文件
95      *
96      * @author yubaoshan, xuyuxiang
97      * @date 2020/6/9 21:53
98      */
99     @GetMapping("/sysFileInfo/download")
100     @BusinessLog(title = "文件信息表_下载文件", opType = LogAnnotionOpTypeEnum.OTHER)
101     public void download(@Validated(SysFileInfoParam.detail.class) SysFileInfoParam sysFileInfoParam, HttpServletResponse response) {
102         sysFileInfoService.download(sysFileInfoParam, response);
103     }
104
105     /**
106      * 文件预览
107      *
108      * @author yubaoshan, xuyuxiang
109      * @date 2020/6/9 22:07
110      */
111     @GetMapping("/sysFileInfo/preview")
112     public void preview(@Validated(SysFileInfoParam.detail.class) SysFileInfoParam sysFileInfoParam, HttpServletResponse response) {
113         sysFileInfoService.preview(sysFileInfoParam, response);
114     }
115
116     /**
117      * 分页查询文件信息表
118      *
119      * @author yubaoshan
120      * @date 2020/6/7 22:15
121      */
122     @Permission
123     @GetMapping("/sysFileInfo/page")
124     @BusinessLog(title = "文件信息表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
125     public ResponseData page(SysFileInfoParam sysFileInfoParam) {
126         return new SuccessResponseData(sysFileInfoService.page(sysFileInfoParam));
127     }
128
129     /**
130      * 获取全部文件信息表
131      *
132      * @author yubaoshan
133      * @date 2020/6/7 22:15
134      */
135     @Permission
136     @GetMapping("/sysFileInfo/list")
137     @BusinessLog(title = "文件信息表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
138     public ResponseData list(SysFileInfoParam sysFileInfoParam) {
139         return new SuccessResponseData(sysFileInfoService.list(sysFileInfoParam));
140     }
141
142     /**
143      * 查看详情文件信息表
144      *
145      * @author yubaoshan
146      * @date 2020/6/7 22:15
147      */
148     @Permission
149     @GetMapping("/sysFileInfo/detail")
150     @BusinessLog(title = "文件信息表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
151     public ResponseData detail(@Validated(SysFileInfoParam.detail.class) SysFileInfoParam sysFileInfoParam) {
152         return new SuccessResponseData(sysFileInfoService.detail(sysFileInfoParam));
153     }
154
155     /**
156      * 删除文件信息表
157      *
158      * @author yubaoshan
159      * @date 2020/6/7 22:15
160      */
161     @Permission
162     @PostMapping("/sysFileInfo/delete")
163     @BusinessLog(title = "文件信息表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
164     public ResponseData delete(@RequestBody @Validated(SysFileInfoParam.delete.class) SysFileInfoParam sysFileInfoParam) {
165         sysFileInfoService.delete(sysFileInfoParam);
166         return new SuccessResponseData();
167     }
168
169     /**
170      * 在线文档编辑回调
171      *
172      * @author xuyuxiang
173      * @date 2021/3/25 16:06
174      */
175     @ResponseBody
176     @PostMapping("/sysFileInfo/track")
177     public void track() {
178         sysFileInfoService.track();
179     }
180 }