From 0b193caa03f8c93b9f361d907d4e826116fd77b4 Mon Sep 17 00:00:00 2001
From: yc13649764453 <1902434166@qq.com>
Date: Sat, 9 Sep 2023 13:51:35 +0800
Subject: [PATCH] =?UTF-8?q?--=20=E6=96=B0=E7=89=88=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/misc.xml | 3 +
.idea/workspace.xml | 1329 +++++++++--------
peanut_book.iml | 14 +-
pom.xml | 37 +
.../com/peanut/PeanutBookApplication.java | 1 +
.../peanut/common/Interface/KdApiEOrder.java | 1 +
.../peanut/common/utils/BaiduVoicesUtils.java | 22 +-
.../com/peanut/common/utils/MD5Utils.java | 2 +-
.../java/com/peanut/common/utils/Query.java | 4 +
src/main/java/com/peanut/common/utils/R.java | 38 +-
.../java/com/peanut/config/ShiroConfig.java | 6 +
.../BookChapterContentController.java | 277 +++-
.../controller/BookChapterController.java | 178 ++-
.../book/controller/BookController.java | 190 ++-
.../controller/BookReadRateController.java | 11 +-
.../book/controller/BookShelfController.java | 15 +-
.../book/controller/BuyOrderController.java | 472 +++++-
.../controller/BuyOrderDetailController.java | 15 +-
.../book/controller/CouponController.java | 11 +-
.../book/controller/MyUserController.java | 124 +-
.../book/controller/OrderCartController.java | 2 -
.../book/controller/PublisherController.java | 1 +
.../controller/ShopCategoryController.java | 2 -
.../controller/ShopProductController.java | 207 ++-
.../controller/UserEbookBuyController.java | 122 +-
.../peanut/modules/book/dao/MyUserDao.java | 2 +
.../book/entity/BookBrowseRecordsEntity.java | 1 -
.../book/entity/BookChapterEntity.java | 12 +-
.../modules/book/entity/BookEntity.java | 13 +
.../book/entity/BuyOrderDetailEntity.java | 4 +
.../modules/book/entity/BuyOrderEntity.java | 7 +-
.../modules/book/entity/MyUserEntity.java | 6 +-
.../book/entity/PayPaymentOrderEntity.java | 4 +
.../book/entity/PayWechatOrderEntity.java | 6 +
.../book/entity/PayZfbOrderEntity.java | 33 +-
.../modules/book/entity/PublisherEntity.java | 1 +
.../book/entity/ShopProductEntity.java | 43 +-
.../book/entity/TransactionDetailsEntity.java | 6 +
.../book/entity/UserEbookBuyEntity.java | 2 +
.../book/service/BookChapterService.java | 5 +
.../modules/book/service/BookService.java | 9 +
.../book/service/BookShelfService.java | 2 +
.../book/service/BuyOrderDetailService.java | 3 +
.../modules/book/service/BuyOrderService.java | 15 +-
.../modules/book/service/MyUserService.java | 13 +
.../book/service/ShopCategoryService.java | 2 +
.../book/service/ShopProductService.java | 5 +
.../book/service/UserEbookBuyService.java | 11 +
.../service/impl/BookChapterServiceImpl.java | 35 +-
.../book/service/impl/BookServiceImpl.java | 247 ++-
.../service/impl/BookShelfServiceImpl.java | 111 +-
.../impl/BuyOrderDetailServiceImpl.java | 34 +
.../service/impl/BuyOrderServiceImpl.java | 82 +-
.../impl/CouponHistoryServiceImpl.java | 2 +
.../book/service/impl/CouponServiceImpl.java | 5 +-
.../book/service/impl/MyUserServiceImpl.java | 123 +-
.../impl/PayPaymentOrderServiceImpl.java | 7 +-
.../service/impl/PublisherServiceImpl.java | 2 +-
.../service/impl/ShopCategoryServiceImpl.java | 10 +-
.../service/impl/ShopProductServiceImpl.java | 33 +-
.../service/impl/ShopSeckillServiceImpl.java | 14 +
.../impl/TransactionDetailsServiceImpl.java | 25 +-
.../service/impl/UserEbookBuyServiceImpl.java | 37 +
.../constant/VerifyReceiptConstant.java | 4 +-
.../pay/IOSPay/controller/AppController.java | 28 +-
.../model/entities/IosPayOrderEntity.java | 6 +-
.../modules/pay/IOSPay/vo/FailureVo.java | 12 +-
.../pay/alipay/config/AliPayConfig.java | 23 +-
.../alipay/controller/AliPayController.java | 4 +-
.../service/impl/AliPayServiceImpl.java | 19 +-
.../pay/weChatPay/config/WechatPayConfig.java | 60 +-
.../controller/WeChatPayController.java | 169 ++-
.../modules/pay/weChatPay/dto/WechatDto.java | 12 +-
.../pay/weChatPay/service/WxpayService.java | 6 +
.../weChatPay/util/WechatRefundCallback.java | 42 -
.../modules/pay/weChatPay/util/WxPayUtil.java | 9 +-
.../sys/controller/SysRoleController.java | 18 +-
.../sys/controller/SysUserController.java | 6 +-
.../sys/service/impl/SysRoleServiceImpl.java | 3 +-
.../sys/service/impl/SysUserServiceImpl.java | 5 +-
.../wx/controller/WeixinApiController.java | 1 +
src/main/resources/application-dev.yml | 3 +-
src/main/resources/application.yml | 6 +-
.../mapper/book/BookBrowseRecordsDao.xml | 1 +
src/main/resources/mapper/book/BookDao.xml | 3 +
src/main/resources/mapper/book/MyUserDao.xml | 12 +
.../mapper/book/PayPaymentOrderDao.xml | 2 +
.../mapper/book/PayWechatOrderDao.xml | 2 +
.../resources/mapper/book/ShopCategoryDao.xml | 2 +
.../resources/mapper/book/ShopProductDao.xml | 18 +-
.../mapper/book/TransactionDetailsDao.xml | 3 +
src/main/resources/weChatConfig.properties | 36 +-
92 files changed, 3451 insertions(+), 1120 deletions(-)
delete mode 100644 src/main/java/com/peanut/modules/pay/weChatPay/util/WechatRefundCallback.java
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a27f3d8c..7f0f38cf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,8 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -556,22 +599,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -604,19 +631,19 @@
+
-
+
-
@@ -828,7 +855,100 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1663124293206
@@ -1209,9 +1329,9 @@
-
+
-
+
@@ -1222,54 +1342,56 @@
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -1277,48 +1399,49 @@
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -1385,19 +1508,12 @@
-
+
+
-
- file://$PROJECT_DIR$/src/main/java/com/peanut/modules/pay/alipay/controller/AliPayController.java
- 42
-
-
-
-
-
jar://$MAVEN_REPOSITORY$/com/github/wechatpay-apiv3/wechatpay-apache-httpclient/0.4.9/wechatpay-apache-httpclient-0.4.9.jar!/com/wechat/pay/contrib/apache/httpclient/auth/WechatPay2Validator.class
36
@@ -1410,11 +1526,25 @@
+
+ file://$PROJECT_DIR$/src/main/java/com/peanut/common/utils/UEditorUpload.java
+ 22
+
+
+
+
+ file://$PROJECT_DIR$/src/main/java/com/peanut/modules/book/service/impl/ShopProductServiceImpl.java
+ 44
+
+
+
+
+
@@ -1428,336 +1558,31 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1771,40 +1596,328 @@
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1814,10 +1927,12 @@
+ peanut_book:war
+
diff --git a/peanut_book.iml b/peanut_book.iml
index 701bdadd..bc7de4f8 100644
--- a/peanut_book.iml
+++ b/peanut_book.iml
@@ -2,11 +2,13 @@
-
+
-
+
+
+
@@ -19,8 +21,8 @@
-
+
@@ -62,6 +64,8 @@
+
+
@@ -75,7 +79,7 @@
-
+
@@ -260,5 +264,7 @@
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a7a41b4f..3a60f55e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,7 @@
2.6.6
+
UTF-8
UTF-8
@@ -41,6 +42,10 @@
1.2.79
5.7.22
1.18.4
+ 0.5.10
+ 1.9.4
+
+
/work/renren
@@ -56,6 +61,16 @@
spring-boot-starter-test
test
+
+ org.aspectj
+ aspectjweaver
+ ${aspectjweaverversion}
+
+
+ net.jodah
+ expiringmap
+ ${expiringmap.varsion}
+
org.springframework.boot
spring-boot-starter-web
@@ -64,6 +79,11 @@
org.springframework.boot
spring-boot-starter-aop
+
+ mars
+ eh-sdk
+ 1.0.0
+
org.springframework
spring-context-support
@@ -117,6 +137,10 @@
3.12.5
+
+
+
+
com.aliyun
@@ -305,6 +329,7 @@
joda-time
${joda.time.version}
+
com.google.code.gson
gson
@@ -334,6 +359,17 @@
org.springframework.boot
spring-boot-starter-data-jpa
+
+
+ com.github.wechatpay-apiv3
+ wechatpay-apache-httpclient
+ 0.4.9
+
+
+ com.twelvemonkeys.common
+ common-lang
+ 3.5
+
@@ -452,4 +488,5 @@
+
diff --git a/src/main/java/com/peanut/PeanutBookApplication.java b/src/main/java/com/peanut/PeanutBookApplication.java
index afe4aefa..60168c04 100644
--- a/src/main/java/com/peanut/PeanutBookApplication.java
+++ b/src/main/java/com/peanut/PeanutBookApplication.java
@@ -1,5 +1,6 @@
package com.peanut;
+import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/src/main/java/com/peanut/common/Interface/KdApiEOrder.java b/src/main/java/com/peanut/common/Interface/KdApiEOrder.java
index 4cd8fc72..2b968493 100644
--- a/src/main/java/com/peanut/common/Interface/KdApiEOrder.java
+++ b/src/main/java/com/peanut/common/Interface/KdApiEOrder.java
@@ -317,6 +317,7 @@ public class KdApiEOrder {
params.put("RequestData", KdUtils.urlEncoder(RequestData, "UTF-8"));
params.put("EBusinessID", EBusinessID);
params.put("RequestType", "8008");//在途监控订阅接口指令8008/地图版订阅接口指令8005
+// params.put("RequestType", "8005");//在途监控订阅接口指令8008/地图版订阅接口指令8005
String dataSign=KdUtils.encrypt(RequestData, ApiKey, "UTF-8");
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
params.put("DataType", "2");
diff --git a/src/main/java/com/peanut/common/utils/BaiduVoicesUtils.java b/src/main/java/com/peanut/common/utils/BaiduVoicesUtils.java
index bc9c004b..c318388e 100644
--- a/src/main/java/com/peanut/common/utils/BaiduVoicesUtils.java
+++ b/src/main/java/com/peanut/common/utils/BaiduVoicesUtils.java
@@ -10,17 +10,23 @@ import java.util.UUID;
public class BaiduVoicesUtils {
// 填写申请百度语音申请的appkey 申请地址:百度AI开放平台
- private final static String appKey = "aKDun6vXyqPLhWMdoIsv87Ez";
+ //todo private final static String appKey = "aKDun6vXyqPLhWMdoIsv87Ez";
+
// private final static String appKey = "eaPPX40oIazH8R4oWsD9U4IT";
+ private final static String appKey = "xkyZMti9hu6KSQ8PdRDsadqI";
// 填写申请百度语音申请的APP SECRET
- private final static String secretKey = "ew9dMb4yGmwF1g4qutxNvogzjd9eP5tb";
+// todo private final static String secretKey = "ew9dMb4yGmwF1g4qutxNvogzjd9eP5tb";
+
// private final static String secretKey = "DTN0ioQywwM23IoT2ZzEBmvfBe63ATEY";
+ private final static String secretKey = "KQvdrrADpV7hBzptqvakwG56dYuGljeg";
// text 的内容为"欢迎使用百度语音合成"的urlencode,utf-8 编码
private final String text = "百度百科是百度公司推出的一部内容开放、自由的网络百科全书。";
- // 发音人选择, 0为普通女声,1为普通男生,3为情感合成-度逍遥,4为情感合成-度丫丫,默认为普通女声
- private final static int per = 3;
+ // 基础 发音人选择, 0为普通女声,1为普通男生,3为情感合成-度逍遥,4为情感合成-度丫丫,默认为普通女声
+ //度逍遥(精品)=5003,度小鹿=5118,度博文=106,度小童=110,度小萌=111,度米朵=103,度小娇=5
+// private final static int per = 3;
+ private final static int per =3;
// 语速,取值0-9,默认为5中语速
private final static int spd = 5;
// 音调,取值0-9,默认为5中语调
@@ -36,7 +42,13 @@ public class BaiduVoicesUtils {
TokenHolder holder = new TokenHolder(appKey, secretKey, TokenHolder.ASR_SCOPE);
holder.resfresh();
String token = holder.getToken();
-
+ String token1 = holder.getToken();
+ final String s = ConnUtil.urlEncode(content);
+ String url21 = url +"?tex=" + s;
+ url21 +="&per="+ per;
+ url21 +=""+cuid;
+ url21 +=""+vol;
+ long expiresAt = holder.getExpiresAt();
// for (String a:list) {
String url2 = url + "?tex=" + ConnUtil.urlEncode(content);
url2 += "&per=" + per;
diff --git a/src/main/java/com/peanut/common/utils/MD5Utils.java b/src/main/java/com/peanut/common/utils/MD5Utils.java
index 65102850..7c48ca43 100644
--- a/src/main/java/com/peanut/common/utils/MD5Utils.java
+++ b/src/main/java/com/peanut/common/utils/MD5Utils.java
@@ -220,7 +220,7 @@ public class MD5Utils {
}
public static void main(String[] args) {
MD5Utils md = new MD5Utils();
- String strMD5 = new String("12345");
+ String strMD5 = new String("696c23c1e04f330c55a635f571ee949f");
System.out.println("原始:" + strMD5);
System.out.println("东东的:" + md.getStrrMD5(strMD5));
diff --git a/src/main/java/com/peanut/common/utils/Query.java b/src/main/java/com/peanut/common/utils/Query.java
index ff630955..c901afb9 100644
--- a/src/main/java/com/peanut/common/utils/Query.java
+++ b/src/main/java/com/peanut/common/utils/Query.java
@@ -27,6 +27,10 @@ public class Query {
return this.getPage(params, null, false);
}
+
+
+
+
public IPage getPage(Map params, String defaultOrderField, boolean isAsc) {
//分页参数
long curPage = 1;
diff --git a/src/main/java/com/peanut/common/utils/R.java b/src/main/java/com/peanut/common/utils/R.java
index fc020019..fcc2ffde 100644
--- a/src/main/java/com/peanut/common/utils/R.java
+++ b/src/main/java/com/peanut/common/utils/R.java
@@ -8,6 +8,8 @@
package com.peanut.common.utils;
+import lombok.Data;
+import lombok.experimental.Accessors;
import org.apache.http.HttpStatus;
import java.util.HashMap;
@@ -18,6 +20,8 @@ import java.util.Map;
*
* @author Mark sunlightcs@gmail.com
*/
+@Data
+//@Accessors(chain = true)
public class R extends HashMap {
private static final long serialVersionUID = 1L;
@@ -25,14 +29,44 @@ public class R extends HashMap {
put("code", 0);
put("msg", "success");
}
-
+
public static R error() {
- return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
+// return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
+ return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "");
+
}
public static R error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
}
+
+ /**
+ * int SC_NOT_IMPLEMENTED = 501;
+ * int SC_BAD_GATEWAY = 502;
+ * int SC_SERVICE_UNAVAILABLE = 503;
+ * int SC_GATEWAY_TIMEOUT = 504;
+ * @param
+ * @param msg
+ * @return
+ */
+ public static R error1(String msg) {
+ return error(HttpStatus.SC_NOT_IMPLEMENTED, msg);
+ }
+
+ public static R error2() {
+ return error(HttpStatus.SC_BAD_GATEWAY,"");
+ }
+
+ public static R error3(String msg) {
+ return error(HttpStatus.SC_SERVICE_UNAVAILABLE, msg);
+ }
+ public static R error4(String msg) {
+ return error(HttpStatus.SC_GATEWAY_TIMEOUT, msg);
+ }
+
+
+
+
public static R error(int code, String msg) {
R r = new R();
diff --git a/src/main/java/com/peanut/config/ShiroConfig.java b/src/main/java/com/peanut/config/ShiroConfig.java
index fde45fdc..aa3f915b 100644
--- a/src/main/java/com/peanut/config/ShiroConfig.java
+++ b/src/main/java/com/peanut/config/ShiroConfig.java
@@ -54,6 +54,8 @@ public class ShiroConfig {
filterMap.put("/image/**","anon");
filterMap.put("/book/book/listForWebsite","anon"); // 网站接口
filterMap.put("/book/shopproduct/forWebList","anon"); // 网站接口
+ filterMap.put("forum/articles/desccreatelist","anon"); // 网站接口
+ filterMap.put("book/task/list","anon"); // 网站接口
filterMap.put("/pay/aliPay/notify","anon"); // 支付宝回调接口
filterMap.put("/pay/payNotify","anon"); // 微信回调接口
filterMap.put("/weChat/**","anon");
@@ -70,6 +72,10 @@ public class ShiroConfig {
filterMap.put("/captcha.jpg", "anon");
filterMap.put("/aaa.txt", "anon");
filterMap.put("/**", "oauth2");
+ filterMap.put("/cent/**","anon");
+
+ //todo 过滤 用户隐私协议未生效
+// filterMap.put("sys/agreement/list","anon");
shiroFilter.setFilterChainDefinitionMap(filterMap);
diff --git a/src/main/java/com/peanut/modules/book/controller/BookChapterContentController.java b/src/main/java/com/peanut/modules/book/controller/BookChapterContentController.java
index 1df7d500..f54f8e58 100644
--- a/src/main/java/com/peanut/modules/book/controller/BookChapterContentController.java
+++ b/src/main/java/com/peanut/modules/book/controller/BookChapterContentController.java
@@ -10,12 +10,8 @@ import java.util.concurrent.Executors;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.common.utils.BaiduVoicesUtils;
-import com.peanut.modules.book.entity.BookChapterEntity;
-import com.peanut.modules.book.entity.BookEntity;
-import com.peanut.modules.book.entity.MyUserEntity;
-import com.peanut.modules.book.service.BookChapterService;
-import com.peanut.modules.book.service.BookService;
-import com.peanut.modules.book.service.MyUserService;
+import com.peanut.modules.book.entity.*;
+import com.peanut.modules.book.service.*;
import com.peanut.modules.oss.service.OssService;
import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;
@@ -28,8 +24,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import com.peanut.modules.book.entity.BookChapterContentEntity;
-import com.peanut.modules.book.service.BookChapterContentService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import org.springframework.web.multipart.MultipartFile;
@@ -55,6 +49,8 @@ public class BookChapterContentController {
private BookChapterService bookChapterService;
@Autowired
private MyUserService myUserService;
+ @Autowired
+ private UserEbookBuyService userEbookBuyService;
/**
* 列表
@@ -124,14 +120,13 @@ public class BookChapterContentController {
singleThreadExecutor.execute(new Runnable() {
@Override
public void run() {
-// bookChapterContentService.getBookVoices(id);
- bookChapterContentService.getWordChapterParagraph(14);
+ bookChapterContentService.getWordChapterParagraph(id);
}
});
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
- bookEntity.setContentStatus("1");
+ bookEntity.setContentStatus("2");
bookService.updateById(bookEntity);
return R.ok();
@@ -141,9 +136,8 @@ public class BookChapterContentController {
*/
@RequestMapping("/signVoices")
public R signVoices(@RequestParam("content") String content) throws Exception {
-
+ //调用百度语音合成 API
String voices = BaiduVoicesUtils.run(content);
-
File file = new File(voices);
if (!file.exists()) {
return R.error("语音文件未生成");
@@ -173,7 +167,7 @@ public class BookChapterContentController {
public R allVoices(@RequestParam("id") Integer id) throws Exception {
BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
-
+ //创建单线程
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
singleThreadExecutor.execute(new Runnable() {
@SneakyThrows
@@ -185,7 +179,7 @@ public class BookChapterContentController {
for (BookChapterContentEntity bookContent:book_id) {
String content = bookContent.getContent();
-
+ //生成相应的语音文件
String voices = BaiduVoicesUtils.run(content);
File file = new File(voices);
@@ -194,9 +188,12 @@ public class BookChapterContentController {
}
FileInputStream fileInputStream = new FileInputStream(file);
-
+ //把 voices 音频文件读入到内存中并将其转换成MultipartFile格式文件 multipartFile 用于OSS上传
+ // application/x-www-form-urlencoded form表单数据被编码为key/value格式发送到服务器
+ // text/plain 纯文本格式
+// MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
-
+ //上传 multipartFile 文件到阿里云OSS上
String path = ossService.uploadFileAvatar(multipartFile);
bookContent.setVoices(path);
@@ -218,6 +215,232 @@ public class BookChapterContentController {
bookService.updateById(bookEntity);
return R.ok();
}
+
+ //章节2.0转音频
+ @RequestMapping("/AllVOices")
+ public R allVoicess2(@RequestParam("id") Integer id) throws Exception {
+
+ BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
+ //创建单线程
+ ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
+ singleThreadExecutor.execute(new Runnable() {
+ @SneakyThrows
+ @Override
+ public void run() {
+ BookEntity bookEntity = bookService.getBaseMapper().selectById(id);
+
+ List book_id = bookChapterService.getBaseMapper().selectList(new QueryWrapper().eq("book_id", id));
+
+
+ for (BookChapterEntity bookChapter:book_id) {
+ String content = bookChapter.getContent();
+ //生成相应的语音文件
+ String voices = BaiduVoicesUtils.run(content);
+
+ File file = new File(voices);
+ if (!file.exists()) {
+ bookEntity.setVoicesStatus("3");
+ }
+ FileInputStream fileInputStream = new FileInputStream(file);
+ MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(fileInputStream));
+ //上传 multipartFile 文件到阿里云OSS上
+ String path = ossService.uploadFileAvatar(multipartFile);
+
+ bookChapter.setVoices(path);
+
+ fileInputStream.close();
+
+ file.delete();
+
+ bookChapterService.updateById(bookChapter);
+ if (StringUtils.isEmpty(path)){
+ bookEntity.setVoicesStatus("3");
+ }
+ }
+ bookEntity.setVoicesStatus("2");
+ bookService.updateById(bookEntity);
+ }
+ });
+ bookEntity.setVoicesStatus("1");
+ bookService.updateById(bookEntity);
+ return R.ok();
+ }
+
+ /**
+ * 鉴权获取章节
+ * @param bookid
+ * @param userId
+ * @return
+ */
+ @RequestMapping("/getBooksCatal")
+ public R getBooksCatal(@RequestParam("id") Integer id,
+ @RequestParam("bookid") Integer bookid,
+ @RequestParam("userId") Integer userId) {
+ // TODO 验证 当前请求的书 是否存在免费章节数
+ BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid);
+ Integer freeChapterCount = bookEntity.getFreeChapterCount();
+
+ //TODO 0-免费 1-会免(改为电子书听书) 2-付费 // 阅读章节数 大于 免费章节数
+ Integer isVip = bookEntity.getIsVip();
+ if ((bookid > freeChapterCount) || freeChapterCount == 0) {
+ // 书籍为 会免
+
+ if (isVip == 1) {
+ //查询用户身份
+ MyUserEntity user = myUserService.getById(userId);
+ String vip = user.getVip();
+ if (!"1".equals(vip)) {
+
+ return R.error("当前为VIP");
+ }
+
+ }
+
+ }
+ if (isVip == 2) {
+ // 鉴权 查询权限表中 用户是否开通
+ boolean b = myUserService.bookAuthenticate(bookid, userId);
+
+ if (!b) {
+ return R.error(500, "请购买书籍!");
+ }
+ }
+ if(isVip == 3){
+ boolean b = myUserService.bookAuthenticate(bookid,userId);
+ if (!b){
+
+ List book = bookChapterService.getBaseMapper().selectList(new QueryWrapper()
+ .eq("book_id", bookid));
+ ArrayList