-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from zjutjh/dev
Dev
- Loading branch information
Showing
20 changed files
with
384 additions
and
432 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,32 @@ | ||
package libraryService | ||
|
||
import ( | ||
"funnel/app/apis/library" | ||
"funnel/app/errors" | ||
"funnel/app/service/libraryService/request" | ||
) | ||
|
||
// GetBorrowHistory 获取图书馆当前借书记录 | ||
func GetBorrowHistory(username string, password string, page int) (interface{}, error) { | ||
var ret Result | ||
cookies, err := OAuthLogin(username, password) | ||
if err != nil { | ||
return nil, errors.ERR_WRONG_PASSWORD | ||
} | ||
|
||
client := request.New() | ||
|
||
_, err = client.Request(). | ||
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,30 @@ | ||
package libraryService | ||
|
||
import ( | ||
"funnel/app/apis/library" | ||
"funnel/app/errors" | ||
"funnel/app/service/libraryService/request" | ||
) | ||
|
||
// GetCurrentBorrow 获取图书馆当前借书记录 | ||
func GetCurrentBorrow(username string, password string, page int) (interface{}, error) { | ||
var ret Result | ||
cookies, err := OAuthLogin(username, password) | ||
if err != nil { | ||
return nil, errors.ERR_WRONG_PASSWORD | ||
} | ||
client := request.New() | ||
_, err = client.Request(). | ||
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.