package controllers import ( "bzd_server/lib" "bzd_server/models/Account" "bzd_server/models/System" beego "github.com/beego/beego/v2/server/web" "time" ) type AccountController struct { beego.Controller } func (c *AccountController) Login_html() { c.TplName = "login.html" } // 验证登录 func (c *AccountController) Login_verification() { Admin_user := c.GetString("bzd_username") Admin_pass := c.GetString("bzd_password") println("Login_verification", Admin_user, Admin_pass) err, user_r := Account.Read_User_verification(Admin_user, Admin_pass) if err != nil { c.Data["json"] = lib.JSONS{Code: 202, Msg: "E!"} } else { User_tokey := Account.Add_Tokey(user_r.T_uuid) c.Ctx.SetCookie("User_tokey", User_tokey, time.Second*60*60) c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK!", Data: User_tokey} System.Add_UserLogs(user_r.T_uuid,"登陆", "用户登陆", "") } c.ServeJSON() return } // 验证登录 func (c *AccountController) Login_Admin_verification() { Admin_user := c.GetString("bzd_username") Admin_pass := c.GetString("bzd_password") println("Login_Admin_verification", Admin_user, Admin_pass) err, user_r := Account.Read_Admin_verification(Admin_user, Admin_pass) if err != nil { c.Data["json"] = lib.JSONS{Code: 202, Msg: "E!"} } else { User_tokey := Account.Add_Tokey(user_r.T_uuid) c.Ctx.SetCookie("User_tokey", User_tokey, time.Second*60*60) c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK!", Data: User_tokey} System.Add_UserLogs(user_r.T_uuid,"登陆", "管理员登陆", "") } c.ServeJSON() return } // --------------------------------------------------------------------------------------------------------------