123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- package controllers
- import (
- "Cold_Api/conf"
- "Cold_Api/controllers/lib"
- "Cold_Api/models/System"
- beego "github.com/beego/beego/v2/server/web"
- "math"
- "strings"
- )
- type LogsController struct {
- beego.Controller
- }
- // 列表 -
- func (c *LogsController) List() {
- page, _ := c.GetInt("page")
- println(page)
- if page < 1 {
- page = 1
- }
- Class_1 := c.GetString("Class_1")
- c.Data["Class_1"] = Class_1
- c.Data["Class_List"] = System.Read_Logs_Class()
- var cnt int64
- c.Data["List"], cnt = System.Read_Logs_ALL(page, Class_1)
- page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
- c.Data["Page"] = page
- c.Data["Page_size"] = page_size
- c.Data["Pages"] = lib.Func_page(int64(page), int64(page_size))
- c.Data["cnt"] = cnt
- c.TplName = "System/Logs.html"
- }
- // 列表 -
- func (c *LogsController) UserLogs() {
- page, _ := c.GetInt("page")
- println(page)
- if page < 1 {
- page = 1
- }
- Class_1 := c.GetString("Class_1")
- c.Data["Class_1"] = Class_1
- c.Data["Class_List"] = System.Read_UserLogs_Class()
- var cnt int64
- c.Data["List"], cnt = System.Read_UserLogs_ALL(page, Class_1)
- page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
- c.Data["Page"] = page
- c.Data["Page_size"] = page_size
- c.Data["Pages"] = lib.Func_page(int64(page), int64(page_size))
- c.Data["cnt"] = cnt
- c.TplName = "User/UserLogs.html"
- }
- // 列表 -
- func (c *LogsController) V2_UserLogsClass() {
- // 验证登录
- b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !b_ {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: System.Read_UserLogs_Class()}
- c.ServeJSON()
- return
- }
- // 列表 -
- func (c *LogsController) V2_UserLogs() {
- // 验证登录
- b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !b_ {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
- c.ServeJSON()
- return
- }
- type R_JSONS struct {
- //必须的大写开头
- Data []System.UserLogs
- Num int64
- Page int
- Page_size int
- }
- var r_jsons R_JSONS
- page, _ := c.GetInt("page")
- println(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("T_class")
- Class_1 = strings.Replace(Class_1, "\"", "", -1)
- r_jsons.Data, r_jsons.Num = System.Read_V2_UserLogs_ALL(admin_r.Admin_uuid, Class_1, page, page_z)
- r_jsons.Page = page
- r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
- // 列表 -
- func (c *LogsController) LogsClass() {
- // 验证登录
- b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !b_ {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
- c.ServeJSON()
- return
- }
- if admin_r.Admin_power > 6 {
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "没有权限!"}
- c.ServeJSON()
- return
- }
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: System.Read_Logs_Class()}
- c.ServeJSON()
- return
- }
- // 列表 -
- func (c *LogsController) LogsList() {
- // 验证登录
- b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
- if !b_ {
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
- c.ServeJSON()
- return
- }
- if admin_r.Admin_power > 6 {
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "没有权限!"}
- c.ServeJSON()
- return
- }
- type R_JSONS struct {
- //必须的大写开头
- Data []System.Logs
- Num int64
- Page int
- Page_size int
- }
- var r_jsons R_JSONS
- page, _ := c.GetInt("page")
- println(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("T_class")
- Class_1 = strings.Replace(Class_1, "\"", "", -1)
- r_jsons.Data, r_jsons.Num = System.Read_V2_Logs_ALL(Class_1, page, page_z)
- r_jsons.Page = page
- r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
- c.ServeJSON()
- return
- }
|