lixinwang
2024-06-29 48a6b9c925af40c03d0b7c7cf71910d711c5aace
return obj
1 files modified
1 files added
55 ■■■■ changed files
cxlaike-module-cxlaike/cxlaike-module-cxlaike-biz/src/main/java/net/hzxzkj/cxlaike/module/cxlaike/controller/merchant/material/MaterialController.java 42 ●●●●● patch | view | raw | blame | history
cxlaike-module-cxlaike/cxlaike-module-cxlaike-biz/src/main/java/net/hzxzkj/cxlaike/module/cxlaike/controller/merchant/material/vo/StsTokenVO.java 13 ●●●●● patch | view | raw | blame | history
cxlaike-module-cxlaike/cxlaike-module-cxlaike-biz/src/main/java/net/hzxzkj/cxlaike/module/cxlaike/controller/merchant/material/MaterialController.java
@@ -1,17 +1,8 @@
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;
@@ -27,10 +18,7 @@
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;
@@ -67,7 +55,6 @@
    private static final String REGEX = "^[A-Za-z0-9_\\-+\\s.\\p{IsHan}~`!@#$%^&*()\\-+=|\\\\{}\\[\\]:;\"'<>,.?/]+$";
    @SneakyThrows
    @GetMapping("/uploadCallbackGet")
    @Operation(summary = "前端文件上传后回调")
@@ -90,17 +77,19 @@
    @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;
    }
@@ -163,6 +152,7 @@
//            authStr += "?" + queryString;
//        }
    }
    @PostMapping("/createFolder")
    @Operation(summary = "新建文件夹")
    @PreAuthorize("@mss.hasPermission('cxlaike:material')")
@@ -202,7 +192,7 @@
    @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);
    }
@@ -212,7 +202,7 @@
    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);
    }
@@ -256,8 +246,8 @@
    @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")
@@ -282,7 +272,7 @@
        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")
@@ -294,13 +284,13 @@
        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);
        }
cxlaike-module-cxlaike/cxlaike-module-cxlaike-biz/src/main/java/net/hzxzkj/cxlaike/module/cxlaike/controller/merchant/material/vo/StsTokenVO.java
New file
@@ -0,0 +1,13 @@
package net.hzxzkj.cxlaike.module.cxlaike.controller.merchant.material.vo;
import lombok.Data;
@Data
public class StsTokenVO {
    private String accessKeyId;
    private String accessKeySecret;
    private String securityToken;
}