-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 重构图书馆登陆接口, 当前/历史借书记录接口, 将续借接口标记为未上架
refactor: 重构图书馆登陆接口, 当前/历史借书记录接口, 将续借接口标记为未上架 refactor: 重构图书馆登陆接口, 当前/历史借书记录接口, 将续借接口标记为未上架 refactor: 重构图书馆登陆接口, 当前/历史借书记录接口, 将续借接口标记为未上架
- Loading branch information
Showing
17 changed files
with
557 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
package library | ||
|
||
import "funnel/app/apis" | ||
// OAuth | ||
const ( | ||
OAuthChaoXingInit = "https://tyrzfw.chaoxing.com/auth3/zjut/cas/init?isLogout=0&refer=https://opac.lib.zjut.edu.cn:8013/find/sso/login/zjut/0" | ||
OAuthBaseUrl = "https://oauth.zjut.edu.cn/cas" | ||
OAuthPublicKey = OAuthBaseUrl + "/v2/getPubKey" | ||
OAuthLogin = OAuthBaseUrl + "/login" | ||
) | ||
|
||
var LibraryLogin = apis.LIBRARY_URL + "login.aspx" | ||
// Library | ||
const ( | ||
LoginFromOAuth = OAuthLogin + "?service=http://tyrzfw.chaoxing.com/auth3/zjut/cas/index" | ||
|
||
var LibraryBorrowHistory = apis.LIBRARY_URL + "BorrowHistory.aspx" | ||
|
||
var LibraryBorrowing = apis.LIBRARY_URL + "Borrowing.aspx" | ||
BaseUrl = "https://opac.lib.zjut.edu.cn:8013" | ||
CurrentLoanList = BaseUrl + "/find/loanInfo/loanList" | ||
BorrowHistoryList = BaseUrl + "/find/loanInfo/loanHistoryList" | ||
UserInfo = BaseUrl + "/oga/userinfo" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package libraryController | ||
|
||
import ( | ||
"funnel/app/controller" | ||
"funnel/app/service/libraryService" | ||
"funnel/app/utils" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type borrowHistoryData struct { | ||
Username string `json:"username" binding:"required"` | ||
Password string `json:"password" binding:"required"` | ||
Page int `json:"page" default:"1"` | ||
} | ||
|
||
// LibraryBorrowHistory 图书馆历史借书记录 | ||
func LibraryBorrowHistory(c *gin.Context) { | ||
var data borrowHistoryData | ||
if err := c.ShouldBind(&data); err != nil { | ||
controller.ErrorHandle(c, err) | ||
return | ||
} | ||
currentBorrow, err := libraryService.GetBorrowHistory(data.Username, data.Password, data.Page) | ||
if err != nil { | ||
controller.ErrorHandle(c, err) | ||
return | ||
} | ||
utils.ContextDataResponseJson(c, utils.SuccessResponseJson(currentBorrow)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package libraryController | ||
|
||
import ( | ||
"funnel/app/controller" | ||
"funnel/app/service/libraryService" | ||
"funnel/app/utils" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type currentBorrowData struct { | ||
Username string `json:"username" binding:"required"` | ||
Password string `json:"password" binding:"required"` | ||
Page int `json:"page" default:"1"` | ||
} | ||
|
||
// LibraryCurrentBorrow 图书馆当前借书记录 | ||
func LibraryCurrentBorrow(c *gin.Context) { | ||
var data currentBorrowData | ||
if err := c.ShouldBind(&data); err != nil { | ||
controller.ErrorHandle(c, err) | ||
return | ||
} | ||
currentBorrow, err := libraryService.GetCurrentBorrow(data.Username, data.Password, data.Page) | ||
if err != nil { | ||
controller.ErrorHandle(c, err) | ||
return | ||
} | ||
utils.ContextDataResponseJson(c, utils.SuccessResponseJson(currentBorrow)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package libraryController | ||
|
||
import ( | ||
"funnel/app/utils" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func LibraryReBorrow(c *gin.Context) { | ||
utils.ContextDataResponseJson(c, utils.ResponseJsonMessage{ | ||
Code: 500, | ||
Message: "功能仍未上架,敬请期待", | ||
Data: interface{}(nil), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package libraryService | ||
|
||
import ( | ||
"funnel/app/apis/library" | ||
"github.com/go-resty/resty/v2" | ||
) | ||
|
||
// GetBorrowHistory 获取图书馆当前借书记录 | ||
func GetBorrowHistory(username string, password string, page int) (interface{}, error) { | ||
var ret Result | ||
cookies, err := OAuthLogin(username, password) | ||
if err != nil { | ||
return nil, err | ||
} | ||
client := resty.New() | ||
_, err = client.R(). | ||
SetBody(map[string]interface{}{ | ||
"page": page, | ||
"rows": 10, | ||
"searchType": 1, | ||
"searchContent": "", | ||
"sortType": 0, | ||
"startDate": nil, | ||
"endDate": nil}). | ||
SetCookies(cookies). | ||
SetResult(&ret). | ||
Post(library.BorrowHistoryList) | ||
return ret.Data, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package libraryService | ||
|
||
import ( | ||
"funnel/app/apis/library" | ||
"github.com/go-resty/resty/v2" | ||
) | ||
|
||
// GetCurrentBorrow 获取图书馆当前借书记录 | ||
func GetCurrentBorrow(username string, password string, page int) (interface{}, error) { | ||
var ret Result | ||
cookies, err := OAuthLogin(username, password) | ||
if err != nil { | ||
return nil, err | ||
} | ||
client := resty.New() | ||
_, err = client.R(). | ||
SetBody(map[string]interface{}{ | ||
"page": page, | ||
"rows": 10, | ||
"searchType": 1, | ||
"searchContent": "", | ||
"sortType": 0, | ||
"startDate": nil, | ||
"endDate": nil}). | ||
SetCookies(cookies). | ||
SetResult(&ret). | ||
Post(library.CurrentLoanList) | ||
return ret.Data, nil | ||
} |
Oops, something went wrong.