|
@@ -1,6 +1,7 @@
|
|
|
const API = require("../../lib/API.js")
|
|
const API = require("../../lib/API.js")
|
|
|
const db = require("../../plugin/DataBase/db.js")
|
|
const db = require("../../plugin/DataBase/db.js")
|
|
|
const axios = require("axios")
|
|
const axios = require("axios")
|
|
|
|
|
+const OSS = require("ali-oss")
|
|
|
const { BaseStdResponse } = require("../../BaseStdResponse.js")
|
|
const { BaseStdResponse } = require("../../BaseStdResponse.js")
|
|
|
|
|
|
|
|
class GetBookList extends API {
|
|
class GetBookList extends API {
|
|
@@ -9,6 +10,7 @@ class GetBookList extends API {
|
|
|
|
|
|
|
|
this.setPath("/QXS/GetBookList")
|
|
this.setPath("/QXS/GetBookList")
|
|
|
this.setMethod("POST")
|
|
this.setMethod("POST")
|
|
|
|
|
+
|
|
|
this.UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) UnifiedPCWindowsWechat(0xf254100e) XWEB/16283'
|
|
this.UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) UnifiedPCWindowsWechat(0xf254100e) XWEB/16283'
|
|
|
this.Refer = 'https://servicewechat.com/wxeadc3e8bceec3d03/177/page-frame.html'
|
|
this.Refer = 'https://servicewechat.com/wxeadc3e8bceec3d03/177/page-frame.html'
|
|
|
}
|
|
}
|
|
@@ -20,7 +22,7 @@ class GetBookList extends API {
|
|
|
password,
|
|
password,
|
|
|
loginMethod: 0,
|
|
loginMethod: 0,
|
|
|
isAutoLogin: "0",
|
|
isAutoLogin: "0",
|
|
|
- multiUserType: "1"
|
|
|
|
|
|
|
+ multiUserType: "0,1,2,3,4,5"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const res = await axios.post(endpoint, reqData, {
|
|
const res = await axios.post(endpoint, reqData, {
|
|
@@ -72,6 +74,53 @@ class GetBookList extends API {
|
|
|
return { bookList: data.data.list ?? [] }
|
|
return { bookList: data.data.list ?? [] }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ async qsxGetBookDetail(accessToken, termCode, title, isbn) {
|
|
|
|
|
+ const endpoint = "https://u.quxuanshu.com/api/teacher/textbook/textbookInfo/search"
|
|
|
|
|
+ const queryData = {
|
|
|
|
|
+ termCode,
|
|
|
|
|
+ searchKey: title,
|
|
|
|
|
+ platType: "3",
|
|
|
|
|
+ curPage: 1,
|
|
|
|
|
+ pageSize: 15,
|
|
|
|
|
+ checkCode: "",
|
|
|
|
|
+ awardTypeList: []
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await axios.post(endpoint, queryData, {
|
|
|
|
|
+ proxy: false,
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "AccessToken": accessToken,
|
|
|
|
|
+ "User-Agent": this.UserAgent,
|
|
|
|
|
+ "Referer": this.Refer
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ let data
|
|
|
|
|
+ if (!res.data || !res.data.data || !res.data.data.list)
|
|
|
|
|
+ return null
|
|
|
|
|
+ else data = res.data.data.list
|
|
|
|
|
+ const book = data.find(b => b.isbn === isbn)
|
|
|
|
|
+ if (!book || !book.imgUrl)
|
|
|
|
|
+ return null
|
|
|
|
|
+ const imgUrl = await this.generateSignatureUrl(book.imgUrl)
|
|
|
|
|
+
|
|
|
|
|
+ return imgUrl
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async generateSignatureUrl(fileName) {
|
|
|
|
|
+ // 获取预签名URL
|
|
|
|
|
+ const client = await new OSS({
|
|
|
|
|
+ accessKeyId: "LTAI5tB1ZicmzHDeS8KRsyRS",
|
|
|
|
|
+ accessKeySecret: "sOtCbyJ3NdaAzizoxieN52VV1JkZYr",
|
|
|
|
|
+ bucket: 'univ-common',
|
|
|
|
|
+ region: 'oss-cn-hangzhou',
|
|
|
|
|
+ secure: true,
|
|
|
|
|
+ authorizationV4: true
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ return await client.signatureUrlV4('GET', 3600, {
|
|
|
|
|
+ headers: {}
|
|
|
|
|
+ }, fileName)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async onRequest(req, res) {
|
|
async onRequest(req, res) {
|
|
|
const { username, password } = req.body
|
|
const { username, password } = req.body
|
|
|
|
|
|
|
@@ -86,7 +135,23 @@ class GetBookList extends API {
|
|
|
const { accessToken } = await this.qxsLogin(username, password)
|
|
const { accessToken } = await this.qxsLogin(username, password)
|
|
|
const { userInfo } = await this.qsxUserInfo(accessToken)
|
|
const { userInfo } = await this.qsxUserInfo(accessToken)
|
|
|
const { termCode, email, termName, userName, mobile } = userInfo
|
|
const { termCode, email, termName, userName, mobile } = userInfo
|
|
|
- const { bookList } = await this.qsxGetList(accessToken, termCode)
|
|
|
|
|
|
|
+ let { bookList } = await this.qsxGetList(accessToken, termCode)
|
|
|
|
|
+
|
|
|
|
|
+ let teacherToken
|
|
|
|
|
+ if (bookList.length > 0) {
|
|
|
|
|
+ let { accessToken } = await this.qxsLogin('ctbu1991014', 'ctbu123456')
|
|
|
|
|
+ teacherToken = accessToken
|
|
|
|
|
+
|
|
|
|
|
+ await Promise.all(
|
|
|
|
|
+ bookList.map(async (book) => {
|
|
|
|
|
+ if (book.imgUrl) {
|
|
|
|
|
+ book.imgUrl = await this.generateSignatureUrl(book.imgUrl)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ book.imgUrl = await this.qsxGetBookDetail(teacherToken, termCode, book.title, book.isbn)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
res.json({
|
|
res.json({
|
|
|
...BaseStdResponse.OK,
|
|
...BaseStdResponse.OK,
|