1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

较多改动,暂存

This commit is contained in:
2023-04-04 01:06:22 +08:00
parent ac885fb06b
commit a68307b9f9
44 changed files with 2467 additions and 649 deletions

View File

@@ -37,5 +37,11 @@
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>
<!-- 腾讯云临时密钥 -->
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos-sts_api</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -3,7 +3,9 @@ package com.cxyxiaomo.epp.PageTable.enums;
public enum AddType {
CAN_NOT_ADD("plainText"),
INPUT("input"),
SELECT("select");
TEXTAREA("textarea"),
SELECT("select"),
IMAGE("image");
private final String value;

View File

@@ -3,7 +3,9 @@ package com.cxyxiaomo.epp.PageTable.enums;
public enum EditType {
CAN_NOT_EDIT("plainText"),
INPUT("input"),
SELECT("select");
TEXTAREA("textarea"),
SELECT("select"),
IMAGE("image");
private final String value;

View File

@@ -0,0 +1,18 @@
package com.cxyxiaomo.epp.PageTable.enums;
public enum FieldType {
HIDDEN("null"),
TEXT("plaintext"),
LONG_TEXT("longtext"),
IMAGE("image");
private final String value;
private FieldType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.cxyxiaomo.epp.PageTable.enums.AddType;
import com.cxyxiaomo.epp.PageTable.enums.EditType;
import com.cxyxiaomo.epp.PageTable.enums.FieldType;
import com.cxyxiaomo.epp.PageTable.enums.SearchType;
public class FieldBuilder {
@@ -26,11 +27,11 @@ public class FieldBuilder {
* 用于渲染表格时指定显示列 <br>
* @param fieldName 列的显示名称 <br>
* @param defaultValue 新增弹窗中的默认值 <br>
* @param showInTable <br>
* @param fieldType 表格中该列的展示形式(以及是否展示该列) <br>
* @param searchPlaceholder 搜索的placeholder <br>
* 如果为 null 则使用 fieldName <br>
* @param addPlaceholder <br>
* @param editPlaceholder <br>
* @param addPlaceholder 新增弹窗中该字段 Placeholder <br>
* @param editPlaceholder 修改弹窗中该字段 Placeholder <br>
* @param searchType 该筛选字段显示为什么类型 <br>
* @param addType 新增弹窗中该字段显示为什么类型 <br>
* @param editType 修改弹窗中该字段显示为什么类型 <br>
@@ -39,7 +40,7 @@ public class FieldBuilder {
* @return FieldBuilder
*/
public FieldBuilder add(String field, String prop, String fieldName, Object defaultValue,
Boolean showInTable, SearchType searchType, AddType addType, EditType editType,
FieldType fieldType, SearchType searchType, AddType addType, EditType editType,
String searchPlaceholder, String addPlaceholder, String editPlaceholder,
FieldRuleListBuilder fieldRuleListBuilder, String mockDataPattern) {
JSONObject jsonObject = new JSONObject(2);
@@ -54,7 +55,7 @@ public class FieldBuilder {
// 表格列显示名称
jsonObject.put("label", fieldName);
// 表格是否展示该字段
jsonObject.put("showInTable", showInTable);
jsonObject.put("fieldType", fieldType.getValue());
/* 筛选 */
// 上方筛选条件

View File

@@ -0,0 +1,65 @@
package com.cxyxiaomo.epp.TencentCloud;
import com.tencent.cloud.CosStsClient;
import com.tencent.cloud.Response;
import java.util.TreeMap;
public class QCloudCosStsClient {
private QCloudCosStsClient() {
}
public static TmpCredential getCredential(String cosObjectKey) {
// 用户的 SecretId
String secretId = "AKIDSkmeXTHsTqzwe8ZDiGcomW4OYXcZIerp";
// 用户的 SecretKey
String secretKey = "22sVt494mGZeV7sQkqwxnNjneHesqXxA";
// bucket
String bucket = "epp-1302260381";
// bucket 所在地区
String region = "ap-shanghai";
// 临时密钥有效时长,单位是秒
Integer durationSeconds = 1800;
try {
TreeMap<String, Object> config = new TreeMap<String, Object>();
config.put("secretId", secretId);
config.put("secretKey", secretKey);
config.put("durationSeconds", durationSeconds);
config.put("bucket", bucket);
config.put("region", region);
// 可以通过 allowPrefixes 指定前缀数组, 例子: a.jpg 或者 a/* 或者 * (使用通配符*存在重大安全风险, 请谨慎评估使用)
config.put("allowPrefixes", new String[]{
cosObjectKey
// "good",
// "avatar"
});
// 密钥的权限列表。简单上传和分片需要以下的权限,其他权限列表请看 https://cloud.tencent.com/document/product/436/31923
String[] allowActions = new String[]{
// 简单上传
"name/cos:PutObject",
"name/cos:PostObject",
// 分片上传
"name/cos:InitiateMultipartUpload",
"name/cos:ListMultipartUploads",
"name/cos:ListParts",
"name/cos:UploadPart",
"name/cos:CompleteMultipartUpload"
};
config.put("allowActions", allowActions);
Response response = CosStsClient.getCredential(config);
long startTimestamp = System.currentTimeMillis();
long expiredTimestamp = startTimestamp + (durationSeconds * 1000);
return new TmpCredential(response, cosObjectKey, startTimestamp, expiredTimestamp, bucket, region);
} catch (Exception e) {
e.printStackTrace();
throw new IllegalArgumentException("no valid secret !");
}
}
}

View File

@@ -0,0 +1,27 @@
package com.cxyxiaomo.epp.TencentCloud;
import com.tencent.cloud.Response;
import lombok.Data;
@Data
public class TmpCredential {
String tmpSecretId;
String tmpSecretKey;
String sessionToken;
String objectKey;
Long startTimestamp;
Long expiredTimestamp;
String bucket;
String region;
public TmpCredential(Response response, String objectKey, Long startTimestamp, Long expiredTimestamp, String bucket, String region) {
this.tmpSecretId = response.credentials.tmpSecretId;
this.tmpSecretKey = response.credentials.tmpSecretKey;
this.sessionToken = response.credentials.sessionToken;
this.objectKey = objectKey;
this.startTimestamp = startTimestamp;
this.expiredTimestamp = expiredTimestamp;
this.bucket = bucket;
this.region = region;
}
}

View File

@@ -8,6 +8,7 @@ import org.springframework.beans.BeanUtils;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
// 数据库关系映射
@@ -49,4 +50,23 @@ public class GoodVO implements Serializable {
List<GoodVO> goodVOList = goodList.stream().map(GoodVO::convertFrom).collect(Collectors.toList());
return goodVOList;
}
public static Good convertTo(GoodVO goodVO) {
if (goodVO == null) {
return null;
}
Good good = new Good();
BeanUtils.copyProperties(goodVO, good);
try {
if (!Objects.isNull(goodVO.getId())) {
Long goodId = Long.valueOf(goodVO.getId());
good.setId(goodId);
} else {
good.setId(null);
}
} catch (Exception e) {
good.setId(null);
}
return good;
}
}