package controllers import ( "ColdVerify_server/conf" "ColdVerify_server/lib" "ColdVerify_server/models/Account" "ColdVerify_server/models/System" beego "github.com/beego/beego/v2/server/web" "math" ) type LogsController struct { beego.Controller } // 列表 - func (c *LogsController) List() { _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey")) if !User_is { c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"} c.ServeJSON() return } var log_jsons lib.LOG_JSONS page, _ := c.GetInt("page") if page < 1 { page = 1 } page_z, _ := c.GetInt("page_z") if page_z < 1 { page_z = conf.Page_size } Class_1 := c.GetString("Class_1") var cnt int64 List, cnt := System.Read_Logs_ALL(page, page_z, Class_1) page_size := math.Ceil(float64(cnt) / float64(page_z)) log_jsons.Class_1 = Class_1 log_jsons.Class_List = System.Read_Logs_Class() log_jsons.List = List log_jsons.Page = page log_jsons.Page_size = int(page_size) log_jsons.Pages = lib.Func_page(int64(page), int64(page_size)) log_jsons.Num = int(cnt) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: log_jsons} c.ServeJSON() return } // 列表 - func (c *LogsController) UserLogs() { _, User_is := Account.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey")) if !User_is { c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"} c.ServeJSON() return } var log_jsons lib.LOG_JSONS page, _ := c.GetInt("page") if page < 1 { page = 1 } page_z, _ := c.GetInt("page_z") if page_z < 1 { page_z = conf.Page_size } Class_1 := c.GetString("Class_1") var cnt int64 List, cnt := System.Read_UserLogs_ALL(page, page_z, Class_1) page_size := math.Ceil(float64(cnt) / float64(page_z)) log_jsons.Class_1 = Class_1 log_jsons.Class_List = System.Read_UserLogs_Class() log_jsons.List = List log_jsons.Page = page log_jsons.Page_size = int(page_size) log_jsons.Pages = lib.Func_page(int64(page), int64(page_size)) log_jsons.Num = int(cnt) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: log_jsons} c.ServeJSON() return }