- 增加登录日志

- 增加数据库索引
- 修改原生安装文档
This commit is contained in:
dushixiang
2021-01-20 22:57:26 +08:00
parent 1d4653a561
commit f0157dbaeb
20 changed files with 700 additions and 78 deletions

42
pkg/api/login-log.go Normal file
View File

@ -0,0 +1,42 @@
package api
import (
"github.com/labstack/echo/v4"
"next-terminal/pkg/global"
"next-terminal/pkg/model"
"strconv"
"strings"
)
func LoginLogPagingEndpoint(c echo.Context) error {
pageIndex, _ := strconv.Atoi(c.QueryParam("pageIndex"))
pageSize, _ := strconv.Atoi(c.QueryParam("pageSize"))
userId := c.QueryParam("userId")
clientIp := c.QueryParam("clientIp")
items, total, err := model.FindPageLoginLog(pageIndex, pageSize, userId, clientIp)
if err != nil {
return err
}
return Success(c, H{
"total": total,
"items": items,
})
}
func LoginLogDeleteEndpoint(c echo.Context) error {
ids := c.Param("id")
split := strings.Split(ids, ",")
for i := range split {
token := split[i]
global.Cache.Delete(token)
model.Logout(token)
}
if err := model.DeleteLoginLogByIdIn(split); err != nil {
return err
}
return Success(c, nil)
}