mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
配置文件的一些小调整
This commit is contained in:
@@ -23,6 +23,11 @@
|
||||
cursor: pointer;
|
||||
/* cursor: alias; */
|
||||
}
|
||||
|
||||
/* 在分类下隐藏书籍的分类 */
|
||||
tr>*:nth-child(2) {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -33,6 +38,7 @@
|
||||
<!-- <a href="./book">书本详情页</a> -->
|
||||
</div>
|
||||
<hr style="margin: 30px 0;">
|
||||
<h3>该分类下的书籍</h3>
|
||||
<div id="container-book">
|
||||
<table id="book-table" style="width: 100%;"></table>
|
||||
</div>
|
||||
|
@@ -4,12 +4,10 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import plus.bookshelf.Common.Enum.plus.bookshelf.TencentCloud.COS.CosProperties;
|
||||
import plus.bookshelf.Common.TencentCloud.COS.GeneratePresignatureUrl;
|
||||
import plus.bookshelf.Common.FileManager.QCloudCosUtils;
|
||||
import plus.bookshelf.Config.QCloudCosConfig;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
@@ -33,11 +31,11 @@ public class App {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
CosProperties cosProperties;
|
||||
QCloudCosConfig qCloudCosConfig;
|
||||
|
||||
@RequestMapping("/cos")
|
||||
public String cos() {
|
||||
GeneratePresignatureUrl generatePresignatureUrl = new GeneratePresignatureUrl(cosProperties);
|
||||
return generatePresignatureUrl.getUrl("mydemo.jpg", 1);
|
||||
QCloudCosUtils QCloudCosUtils = new QCloudCosUtils(qCloudCosConfig);
|
||||
return QCloudCosUtils.getUrl("mydemo.jpg", 1);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package plus.bookshelf.Common.TencentCloud.COS;
|
||||
package plus.bookshelf.Common.FileManager;
|
||||
|
||||
import com.qcloud.cos.COSClient;
|
||||
import com.qcloud.cos.ClientConfig;
|
||||
@@ -7,17 +7,21 @@ import com.qcloud.cos.auth.COSCredentials;
|
||||
import com.qcloud.cos.http.HttpMethodName;
|
||||
import com.qcloud.cos.http.HttpProtocol;
|
||||
import com.qcloud.cos.region.Region;
|
||||
import plus.bookshelf.Config.QCloudCosConfig;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GeneratePresignatureUrl {
|
||||
plus.bookshelf.Common.Enum.plus.bookshelf.TencentCloud.COS.CosProperties cosProperties;
|
||||
/**
|
||||
* 生成预签名URL
|
||||
*/
|
||||
public class QCloudCosUtils {
|
||||
QCloudCosConfig qCloudCosConfig;
|
||||
|
||||
public GeneratePresignatureUrl(plus.bookshelf.Common.Enum.plus.bookshelf.TencentCloud.COS.CosProperties cosProperties) {
|
||||
this.cosProperties = cosProperties;
|
||||
public QCloudCosUtils(QCloudCosConfig qCloudCosConfig) {
|
||||
this.qCloudCosConfig = qCloudCosConfig;
|
||||
}
|
||||
|
||||
// refer: https://cloud.tencent.com/document/product/436/35217#.E5.88.9B.E5.BB.BA-cosclient
|
||||
@@ -25,8 +29,8 @@ public class GeneratePresignatureUrl {
|
||||
COSClient createCOSClient() {
|
||||
// 设置用户身份信息。
|
||||
// SECRETID 和 SECRETKEY 请登录访问管理控制台 https://console.cloud.tencent.com/cam/capi 进行查看和管理
|
||||
String secretId = cosProperties.getAccessKey();
|
||||
String secretKey = cosProperties.getSecretKey();
|
||||
String secretId = qCloudCosConfig.getAccessKey();
|
||||
String secretKey = qCloudCosConfig.getSecretKey();
|
||||
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
||||
|
||||
// ClientConfig 中包含了后续请求 COS 的客户端设置:
|
||||
@@ -34,7 +38,7 @@ public class GeneratePresignatureUrl {
|
||||
|
||||
// 设置 bucket 的地域
|
||||
// COS_REGION 请参照 https://cloud.tencent.com/document/product/436/6224
|
||||
clientConfig.setRegion(new Region(cosProperties.getRegionName()));
|
||||
clientConfig.setRegion(new Region(qCloudCosConfig.getRegionName()));
|
||||
|
||||
// 设置请求协议, http 或者 https
|
||||
// 5.6.53 及更低的版本,建议设置使用 https 协议
|
||||
@@ -56,19 +60,22 @@ public class GeneratePresignatureUrl {
|
||||
return new COSClient(cred, clientConfig);
|
||||
}
|
||||
|
||||
public String getUrl(String objectKey) {
|
||||
return getUrl(objectKey, 30);
|
||||
}
|
||||
|
||||
public String getUrl(String objectKey, Integer expireMinute) {
|
||||
// 调用 COS 接口之前必须保证本进程存在一个 COSClient 实例,如果没有则创建
|
||||
// 详细代码参见本页:简单操作 -> 创建 COSClient
|
||||
COSClient cosClient = createCOSClient();
|
||||
|
||||
// 存储桶的命名格式为 BucketName-APPID,此处填写的存储桶名称必须为此格式
|
||||
String bucketName = cosProperties.getBucketName();
|
||||
String bucketName = qCloudCosConfig.getBucketName();
|
||||
// 对象键(Key)是对象在存储桶中的唯一标识。详情请参见 [对象键](https://cloud.tencent.com/document/product/436/13324)
|
||||
String key = objectKey;
|
||||
String key = qCloudCosConfig.getKeyName() + objectKey;
|
||||
|
||||
// 设置签名过期时间(可选), 若未进行设置则默认使用 ClientConfig 中的签名过期时间(1小时)
|
||||
// 这里设置签名在半个小时后过期
|
||||
// Date expirationDate = new Date(System.currentTimeMillis() + 30 * 60 * 1000);
|
||||
// 这里设置签名在 expireMinute 分钟后过期
|
||||
Date expirationDate = new Date(System.currentTimeMillis() + expireMinute * 60 * 1000);
|
||||
|
||||
// 填写本次请求的参数,需与实际请求相同,能够防止用户篡改此签名的 HTTP 请求的参数
|
@@ -1,28 +0,0 @@
|
||||
package plus.bookshelf.Common.Enum.plus.bookshelf.TencentCloud.COS;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "cos")
|
||||
@PropertySource(value = "cos.properties")
|
||||
public class CosProperties {
|
||||
// @Value("${cos.accessKey}")
|
||||
private String accessKey;
|
||||
|
||||
// @Value("${cos.secretKey}")
|
||||
private String secretKey;
|
||||
|
||||
// @Value("${cos.regionName}")
|
||||
private String regionName;
|
||||
|
||||
// @Value("${cos.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
// @Value("${cos.keyName}")
|
||||
private String keyName;
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package plus.bookshelf.Config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
public class QCloudCosConfig {
|
||||
@Value("${qcloud.cos.accessKey}")
|
||||
private String accessKey;
|
||||
|
||||
@Value("${qcloud.cos.secretKey}")
|
||||
private String secretKey;
|
||||
|
||||
@Value("${qcloud.cos.regionName}")
|
||||
private String regionName;
|
||||
|
||||
@Value("${qcloud.cos.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
@Value("${qcloud.cos.keyName}")
|
||||
private String keyName;
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package plus.bookshelf.Common.ThirdParty;
|
||||
package plus.bookshelf.Config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import plus.bookshelf.Common.Error.BusinessErrorCode;
|
||||
import plus.bookshelf.Common.Error.BusinessException;
|
||||
import plus.bookshelf.Common.Response.CommonReturnType;
|
||||
import plus.bookshelf.Common.ThirdParty.ThirdPartyConfig;
|
||||
import plus.bookshelf.Config.ThirdPartyConfig;
|
||||
import plus.bookshelf.Service.Impl.UserServiceImpl;
|
||||
import plus.bookshelf.Service.Model.UserModel;
|
||||
|
||||
|
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import plus.bookshelf.Common.Error.BusinessErrorCode;
|
||||
import plus.bookshelf.Common.Error.BusinessException;
|
||||
import plus.bookshelf.Common.Response.CommonReturnType;
|
||||
import plus.bookshelf.Common.ThirdParty.ThirdPartyConfig;
|
||||
import plus.bookshelf.Config.ThirdPartyConfig;
|
||||
import plus.bookshelf.Controller.VO.UserVO;
|
||||
import plus.bookshelf.Service.Impl.ThirdPartyUserServiceImpl;
|
||||
import plus.bookshelf.Service.Model.ThirdPartyUserModel;
|
||||
@@ -23,7 +23,6 @@ import plus.bookshelf.Service.Model.UserModel;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Api(tags = "第三方登录")
|
||||
@Controller
|
||||
|
@@ -103,8 +103,8 @@ public class UserServiceImpl implements UserService {
|
||||
Integer thirdPartyUserId = thirdPartyUserDO.getId();
|
||||
// 删除第三方账号与用户的关联
|
||||
// 首先在 Auth 表中删除
|
||||
int affectRows = thirdPartyUserAuthDOMapper.deleteByUserIdAndThirdPartyUserId(userId, thirdPartyUserId);
|
||||
if (affectRows == 0) {
|
||||
int affectRows1 = thirdPartyUserAuthDOMapper.deleteByUserIdAndThirdPartyUserId(userId, thirdPartyUserId);
|
||||
if (affectRows1 == 0) {
|
||||
// 删除失败
|
||||
return false;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
#spring.redis.port=6379
|
||||
#spring.redis.database=10
|
||||
##spring.redis.password=
|
||||
#
|
||||
|
||||
## 设置jedis连接池
|
||||
#spring.redis.jedis.pool.max-active=50
|
||||
#spring.redis.jedis.pool.max-idle=20
|
||||
@@ -54,3 +54,15 @@ thirdparty.github.redirecturi=
|
||||
thirdparty.qq.clientid=
|
||||
thirdparty.qq.clientsecret=
|
||||
thirdparty.qq.redirecturi=
|
||||
|
||||
# 腾讯云对象存储
|
||||
# SecretId
|
||||
qcloud.cos.accessKey=AKIDaz80bw0nJYWEgqjLgkY4JHzPYQ2NSGn4
|
||||
# SecretKey
|
||||
qcloud.cos.secretKey=1lEQKxJPFo66q54lCNGsDH4brqYzA5j6
|
||||
# 地域名
|
||||
qcloud.cos.regionName=ap-shanghai
|
||||
# 存储桶名称
|
||||
qcloud.cos.bucketName=bookshelfplus-ebooks-1302260381
|
||||
# 文件夹名称(可自定义)
|
||||
qcloud.cos.keyName=images
|
@@ -1,15 +0,0 @@
|
||||
# bookshelfplus-bookdownloaduser
|
||||
# +XM{e@]t
|
||||
# SecretId: AKIDaz80bw0nJYWEgqjLgkY4JHzPYQ2NSGn4
|
||||
# SecretKey: 1lEQKxJPFo66q54lCNGsDH4brqYzA5j6
|
||||
|
||||
# SecretId
|
||||
cos.accessKey=AKIDaz80bw0nJYWEgqjLgkY4JHzPYQ2NSGn4
|
||||
# SecretKey
|
||||
cos.secretKey=1lEQKxJPFo66q54lCNGsDH4brqYzA5j6
|
||||
# 地域名
|
||||
cos.regionName=ap-shanghai
|
||||
# 存储桶名称
|
||||
cos.bucketName=bookshelfplus-ebooks-1302260381
|
||||
# 文件夹名称(可自定义)
|
||||
cos.keyName=images
|
Reference in New Issue
Block a user