mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-07 14:17:49 +08:00
增加审计日志的导出功能
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/bjdgyc/anylink/dbdata"
|
||||
"github.com/gocarina/gocsv"
|
||||
)
|
||||
|
||||
func SetAuditList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -29,3 +30,24 @@ func SetAuditList(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
RespSucess(w, data)
|
||||
}
|
||||
|
||||
func SetAuditExport(w http.ResponseWriter, r *http.Request) {
|
||||
var datas []dbdata.AccessAudit
|
||||
maxNum := 1000000
|
||||
session := dbdata.GetAuditSession(r.FormValue("search"))
|
||||
count, err := dbdata.FindAndCount(session, &datas, maxNum, 0)
|
||||
if err != nil && !dbdata.CheckErrNotFound(err) {
|
||||
RespError(w, RespInternalErr, err)
|
||||
return
|
||||
}
|
||||
if count == 0 {
|
||||
RespError(w, RespParamErr, "你导出的总数量为0条,请调整搜索条件,再导出")
|
||||
return
|
||||
}
|
||||
if count > int64(maxNum) {
|
||||
RespError(w, RespParamErr, "你导出的数据量超过100万条,请调整搜索条件,再导出")
|
||||
return
|
||||
}
|
||||
gocsv.Marshal(datas, w)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user