Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin
This commit is contained in:
commit
3bf5996bee
@ -24,6 +24,9 @@ public class MinioClientConfig {
|
|||||||
@Value("${minio.bucket}")
|
@Value("${minio.bucket}")
|
||||||
private String bucket;
|
private String bucket;
|
||||||
|
|
||||||
|
@Value("${minio.replaceHttps}")
|
||||||
|
private Boolean replaceHttps;
|
||||||
|
|
||||||
private MinioClient minioClient;
|
private MinioClient minioClient;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
|
@ -105,7 +105,14 @@ public class OrgProjectService implements IOrgProjectService {
|
|||||||
if (CollectionUtils.isEmpty(orgUserList)) {
|
if (CollectionUtils.isEmpty(orgUserList)) {
|
||||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||||
}
|
}
|
||||||
loginInfo.setOrgProjectVO(new OrgProjectVO(topOrg));
|
// 是否是顶级组织的管理员
|
||||||
|
OrgUser orgUser = orgUserList.stream().filter(o -> loginInfo.getAccountVO().getId().longValue() == o.getUserId().longValue()
|
||||||
|
&& o.getOrgId().longValue() == orgId.longValue()).findFirst().orElse(null);
|
||||||
|
OrgProjectVO orgProjectVO = new OrgProjectVO(topOrg);
|
||||||
|
if (orgUser != null) {
|
||||||
|
orgProjectVO.setRole(orgUser.getRole());
|
||||||
|
}
|
||||||
|
loginInfo.setOrgProjectVO(orgProjectVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,12 +20,22 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
public class MinioClientUtil {
|
public class MinioClientUtil {
|
||||||
private final static String PATH_SEPARATOR = "/";
|
private final static String PATH_SEPARATOR = "/";
|
||||||
|
|
||||||
|
private final static String HTTP_PROTOCOL = "http:";
|
||||||
|
|
||||||
|
private final static String HTTPS_PROTOCOL = "https:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用来判断生成链接是 http|https:// + IP + : + 端口
|
||||||
|
*/
|
||||||
|
private final static Pattern IP_PORT_PATTERN = Pattern.compile("(\\w+):\\/\\/([^/:]+)(:\\d*)");
|
||||||
|
|
||||||
private MinioClientConfig config;
|
private MinioClientConfig config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,9 +225,10 @@ public class MinioClientUtil {
|
|||||||
|
|
||||||
public String getDownLoadPathByPath(String path) {
|
public String getDownLoadPathByPath(String path) {
|
||||||
try {
|
try {
|
||||||
return config.getMinioClient().getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
String downLoadPath = config.getMinioClient().getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
||||||
.bucket(config.getBucket())
|
.bucket(config.getBucket())
|
||||||
.object(path).method(Method.GET).build());
|
.object(path).method(Method.GET).build());
|
||||||
|
return pathProtocolReplace(downLoadPath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SimulationException(SimulationExceptionType.System_Fault, e);
|
throw new SimulationException(SimulationExceptionType.System_Fault, e);
|
||||||
}
|
}
|
||||||
@ -230,13 +241,14 @@ public class MinioClientUtil {
|
|||||||
try {
|
try {
|
||||||
Map<String, String> reqParams = new HashMap<String, String>();
|
Map<String, String> reqParams = new HashMap<String, String>();
|
||||||
reqParams.put("response-content-type", "application/json");
|
reqParams.put("response-content-type", "application/json");
|
||||||
return config.getMinioClient().getPresignedObjectUrl(
|
String uploadPath = config.getMinioClient().getPresignedObjectUrl(
|
||||||
GetPresignedObjectUrlArgs.builder().method(method)
|
GetPresignedObjectUrlArgs.builder().method(method)
|
||||||
.bucket(config.getBucket()).object(getSavePath(fileName))
|
.bucket(config.getBucket()).object(getSavePath(fileName))
|
||||||
.expiry(60 * 60 * 24)
|
.expiry(60 * 60 * 24)
|
||||||
.extraQueryParams(reqParams)
|
.extraQueryParams(reqParams)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
return pathProtocolReplace(uploadPath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new SimulationException(SimulationExceptionType.System_Fault, e);
|
throw new SimulationException(SimulationExceptionType.System_Fault, e);
|
||||||
}
|
}
|
||||||
@ -246,6 +258,21 @@ public class MinioClientUtil {
|
|||||||
return FileInfo.getStoragePath(directory, fileName);
|
return FileInfo.getStoragePath(directory, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 替换访问协议
|
||||||
|
*/
|
||||||
|
private String pathProtocolReplace(String path) {
|
||||||
|
String resultPath = path;
|
||||||
|
// 判断是否是IP加端口模式,替换后会引起问题则不做处理
|
||||||
|
if (IP_PORT_PATTERN.matcher(path).find()) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
if (config.getReplaceHttps() != null && config.getReplaceHttps() && path.startsWith(HTTP_PROTOCOL)) {
|
||||||
|
resultPath = path.replace(HTTP_PROTOCOL, HTTPS_PROTOCOL);
|
||||||
|
}
|
||||||
|
return resultPath;
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class FileInfo {
|
public static class FileInfo {
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
@ -13,6 +13,8 @@ public class OrgProjectVO {
|
|||||||
|
|
||||||
private Long topOrgId;
|
private Long topOrgId;
|
||||||
|
|
||||||
|
private String role;
|
||||||
|
|
||||||
public OrgProjectVO(Org org) {
|
public OrgProjectVO(Org org) {
|
||||||
this.orgId = org.getId();
|
this.orgId = org.getId();
|
||||||
this.name = org.getName();
|
this.name = org.getName();
|
||||||
|
@ -99,10 +99,11 @@ logging:
|
|||||||
club.joylink.rtss: DEBUG
|
club.joylink.rtss: DEBUG
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
endpoint: https://192.168.3.233
|
endpoint: http://192.168.3.233
|
||||||
accessKey: jladmin
|
accessKey: jladmin
|
||||||
secretKey: Joylink@0503
|
secretKey: Joylink@0503
|
||||||
bucket: oss-rtss
|
bucket: oss-rtss
|
||||||
|
replaceHttps: true
|
||||||
|
|
||||||
common:
|
common:
|
||||||
env: dev
|
env: dev
|
||||||
@ -126,10 +127,11 @@ logging:
|
|||||||
club.joylink.rtss: INFO
|
club.joylink.rtss: INFO
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
endpoint: https://192.168.3.233
|
endpoint: http://192.168.3.233
|
||||||
accessKey: jladmin
|
accessKey: jladmin
|
||||||
secretKey: Joylink@0503
|
secretKey: Joylink@0503
|
||||||
bucket: oss-rtss
|
bucket: oss-rtss
|
||||||
|
replaceHttps: true
|
||||||
|
|
||||||
common:
|
common:
|
||||||
env: test
|
env: test
|
||||||
@ -153,10 +155,12 @@ logging:
|
|||||||
club.joylink.rtss: INFO
|
club.joylink.rtss: INFO
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
endpoint: https://192.168.3.233
|
endpoint: http://192.168.3.233
|
||||||
accessKey: jladmin
|
accessKey: jladmin
|
||||||
secretKey: Joylink@0503
|
secretKey: Joylink@0503
|
||||||
bucket: oss-rtss
|
bucket: oss-rtss
|
||||||
|
replaceHttps: true
|
||||||
|
|
||||||
|
|
||||||
common:
|
common:
|
||||||
env: local
|
env: local
|
||||||
@ -184,6 +188,7 @@ minio:
|
|||||||
accessKey: jladmin
|
accessKey: jladmin
|
||||||
secretKey: Joylink@0503
|
secretKey: Joylink@0503
|
||||||
bucket: oss-rtss
|
bucket: oss-rtss
|
||||||
|
replaceHttps: false
|
||||||
|
|
||||||
common:
|
common:
|
||||||
env: test
|
env: test
|
||||||
@ -210,6 +215,7 @@ minio:
|
|||||||
accessKey: jladmin
|
accessKey: jladmin
|
||||||
secretKey: Joylink@0503
|
secretKey: Joylink@0503
|
||||||
bucket: oss-rtss
|
bucket: oss-rtss
|
||||||
|
replaceHttps: false
|
||||||
|
|
||||||
common:
|
common:
|
||||||
env: prd
|
env: prd
|
||||||
|
Loading…
Reference in New Issue
Block a user