新增了长时间未操作处理
This commit is contained in:
+11
-14
@@ -8,6 +8,7 @@ import (
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Public struct{}
|
||||
@@ -27,20 +28,6 @@ func (b *Public) GetCaptcha(c *gin.Context) {
|
||||
|
||||
// Login 登陆
|
||||
func (b *Public) Login(c *gin.Context) {
|
||||
//orderService := service.OrderService{}
|
||||
//res, err := orderService.PdfToImg()
|
||||
//if err != nil {
|
||||
// responses.FailWithMessage(err.Error(), c)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//if res != true {
|
||||
// responses.FailWithMessage("错误", c)
|
||||
// return
|
||||
//}
|
||||
//responses.Ok(c)
|
||||
//return
|
||||
|
||||
var adminRequest requests.AdminRequest
|
||||
|
||||
if err := c.ShouldBind(&adminRequest.Login); err != nil {
|
||||
@@ -72,5 +59,15 @@ func (b *Public) Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 开始记录api请求时间
|
||||
key := "request_" + token.UserId
|
||||
|
||||
// 增加缓存
|
||||
_, err = global.Redis.Set(c, "request_api"+key, time.Now().Unix(), 30*60*time.Second).Result()
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(token, c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user