| | |
| | | package net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.material; |
| | | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.server.HttpServerRequest; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.druid.util.Base64; |
| | | import com.aliyuncs.DefaultAcsClient; |
| | | import com.aliyuncs.auth.sts.AssumeRoleRequest; |
| | | import com.aliyuncs.auth.sts.AssumeRoleResponse; |
| | | import com.aliyuncs.exceptions.ClientException; |
| | | import com.aliyuncs.http.MethodType; |
| | | import com.aliyuncs.profile.DefaultProfile; |
| | | import com.aliyuncs.profile.IClientProfile; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.common.collect.Maps; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | import net.hzxzkj.cxlaike.framework.security.core.util.SecurityFrameworkUtils; |
| | | import net.hzxzkj.cxlaike.framework.tenant.core.aop.TenantIgnore; |
| | | import net.hzxzkj.cxlaike.framework.tenant.core.context.TenantContextHolder; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.material.vo.CreateFolderVO; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.material.vo.FileUploadReqVO; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.material.vo.FileUploadTemporarilyReqVO; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.material.vo.UpdateFileVO; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.material.vo.*; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.matrixtask.vo.MatrixTaskPushVideoRespVO; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.service.aliyun.AliyunStsCallbackService; |
| | | import net.hzxzkj.cxlaike.module.cxlaike.service.material.MaterialService; |
| | |
| | | private static final String REGEX = "^[A-Za-z0-9_\\-+\\s.\\p{IsHan}~`!@#$%^&*()\\-+=|\\\\{}\\[\\]:;\"'<>,.?/]+$"; |
| | | |
| | | |
| | | |
| | | @SneakyThrows |
| | | @GetMapping("/uploadCallbackGet") |
| | | @Operation(summary = "前端文件上传后回调") |
| | |
| | | |
| | | @GetMapping("/getStsToken") |
| | | @Operation(summary = "前端文件上传后回调") |
| | | public String uploadCallbackPost() { |
| | | public StsTokenVO uploadCallbackPost() { |
| | | // log.error("前端文件上传后回调Get requestBody:{}", ServletUtils.getBody(request)); |
| | | // log.error("前端文件上传后回调Get request:{}, response:{}", JSONUtil.toJsonStr(request), JSONUtil.toJsonStr(response)); |
| | | String s = ""; |
| | | StsTokenVO stsTokenVO = null; |
| | | try { |
| | | s = Http2Utils.doGet01("http://matrix.tbt.ink/cxlaike-sub/file/getStsToken", Maps.newHashMap()); |
| | | stsTokenVO = JSONObject.parseObject(s, StsTokenVO.class); |
| | | //s = Http2Utils.doGet01("http://oss.cxlaike.com:8080/cxlaike-sub/file/getStsToken", Maps.newHashMap()); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return s; |
| | | return stsTokenVO; |
| | | |
| | | } |
| | | |
| | |
| | | // authStr += "?" + queryString; |
| | | // } |
| | | } |
| | | |
| | | @PostMapping("/createFolder") |
| | | @Operation(summary = "新建文件夹") |
| | | @PreAuthorize("@mss.hasPermission('cxlaike:material')") |
| | |
| | | @PreAuthorize("@mss.hasPermission('cxlaike:material')") |
| | | public CommonResult<Boolean> transfer(@Valid @RequestBody UpdateFileVO transferFileVO) throws Exception { |
| | | materialService.transfer(transferFileVO.getId(), transferFileVO.getPath() |
| | | ,TenantContextHolder.getTenantId()); |
| | | , TenantContextHolder.getTenantId()); |
| | | return success(true); |
| | | } |
| | | |
| | |
| | | public CommonResult<Boolean> rename(@Valid @RequestBody UpdateFileVO transferFileVO) throws Exception { |
| | | String fileName = this.checkName(transferFileVO.getName()); |
| | | materialService.rename(transferFileVO.getId(), transferFileVO.getPath(), fileName |
| | | ,TenantContextHolder.getTenantId()); |
| | | , TenantContextHolder.getTenantId()); |
| | | return success(true); |
| | | } |
| | | |
| | |
| | | @Operation(summary = "获得当前目录下的文件夹列表") |
| | | @PreAuthorize("@mss.hasPermission('cxlaike:material')") |
| | | public CommonResult<List<FolderRespVO>> getFolderList(@RequestParam("path") String path, |
| | | @RequestParam("materialType")Integer materialType) { |
| | | return success(materialService.getFolderList(TenantContextHolder.getTenantId(),path,materialType)); |
| | | @RequestParam("materialType") Integer materialType) { |
| | | return success(materialService.getFolderList(TenantContextHolder.getTenantId(), path, materialType)); |
| | | } |
| | | |
| | | @GetMapping("/sys_page") |
| | |
| | | String fileName = this.checkName(file.getOriginalFilename()); |
| | | return success(materialService.createTemporarilyFile(fileName, |
| | | IoUtil.readBytes(file.getInputStream()), |
| | | TenantContextHolder.getTenantId(),uploadReqVO.getMaterialType())); |
| | | TenantContextHolder.getTenantId(), uploadReqVO.getMaterialType())); |
| | | } |
| | | |
| | | @PostMapping("/createSysMaterialFile") |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | private String checkName(String name){ |
| | | private String checkName(String name) { |
| | | String pattern = REGEX; |
| | | boolean matches = name.matches(pattern); |
| | | if (!matches) { |
| | | throw exception(new ErrorCode(400,"文件夹名或文件名不能包含特殊字符")); |
| | | throw exception(new ErrorCode(400, "文件夹名或文件名不能包含特殊字符")); |
| | | } |
| | | if(name.length() > 64){ |
| | | if (name.length() > 64) { |
| | | return name.substring(0, 64); |
| | | } |
| | | |