mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-09-17 22:09:14 +08:00
由gopath形式改为module
This commit is contained in:
28
legend/controllers/base/baseController.go
Normal file
28
legend/controllers/base/baseController.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"legend/models/fast"
|
||||
)
|
||||
|
||||
/**
|
||||
** 基础controller插件,重写一些公共的方法
|
||||
*/
|
||||
type BasicController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
func (c *BasicController) Prepare() {
|
||||
|
||||
userName, ok := c.GetSession("userName").(string)
|
||||
if ok {
|
||||
logs.Info("该用户已经登录, userName:", userName)
|
||||
userInfo := fast.GetUserInfoByUserName(userName)
|
||||
if userInfo.Mobile != "" {
|
||||
c.Data["nickName"] = userInfo.UserName
|
||||
}
|
||||
} else {
|
||||
c.Data["nickName"] = "史蒂芬-库里"
|
||||
}
|
||||
}
|
15
legend/controllers/default.go
Normal file
15
legend/controllers/default.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type MainController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *MainController) Get() {
|
||||
c.Data["Website"] = "beego.me"
|
||||
c.Data["Email"] = "astaxie@gmail.com"
|
||||
c.TplName = "index.tpl"
|
||||
}
|
19
legend/controllers/expection/expection.go
Normal file
19
legend/controllers/expection/expection.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package expection
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func PageNotFind(rw http.ResponseWriter, r *http.Request) {
|
||||
t, _ := template.New("404.html").ParseFiles(web.BConfig.WebConfig.ViewsPath + "/error/404.html")
|
||||
data := make(map[string]interface{})
|
||||
t.Execute(rw, data)
|
||||
}
|
||||
|
||||
func SystemExpection(rw http.ResponseWriter, r *http.Request) {
|
||||
t, _ := template.New("503.html").ParseFiles(web.BConfig.WebConfig.ViewsPath + "/error/503.html")
|
||||
data := make(map[string]interface{})
|
||||
t.Execute(rw, data)
|
||||
}
|
16
legend/controllers/indexController.go
Normal file
16
legend/controllers/indexController.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"legend/controllers/base"
|
||||
)
|
||||
|
||||
type IndexController struct {
|
||||
base.BasicController
|
||||
}
|
||||
|
||||
/**
|
||||
** 用户登录后跳转的页面,也是后台的整个主题框架
|
||||
*/
|
||||
func (c *IndexController) Index() {
|
||||
c.TplName = "index.html"
|
||||
}
|
62
legend/controllers/loginController.go
Normal file
62
legend/controllers/loginController.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"legend/service"
|
||||
)
|
||||
|
||||
type LoginController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
/**
|
||||
**展示登录页面
|
||||
*/
|
||||
func (c *LoginController) LoginPage() {
|
||||
c.TplName = "login.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 处理登录逻辑
|
||||
*/
|
||||
func (c *LoginController) Login() {
|
||||
|
||||
userName := c.GetString("username")
|
||||
password := c.GetString("password")
|
||||
|
||||
logs.Info("username:"+userName, ";password: "+password)
|
||||
|
||||
loginService := new(service.LoginService)
|
||||
|
||||
loginJsonData := loginService.Login(userName, password)
|
||||
if loginJsonData.Code == 200 {
|
||||
_ = c.SetSession("userName", userName)
|
||||
}
|
||||
|
||||
c.Data["json"] = loginJsonData
|
||||
|
||||
err := c.ServeJSON()
|
||||
if err != nil {
|
||||
logs.Error("错误:", err)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** 更新登录密码
|
||||
*/
|
||||
func (c *LoginController) PersonPassword() {
|
||||
oldPassword := c.GetString("oldpass")
|
||||
newPassword := c.GetString("newpass")
|
||||
repeatPassword := c.GetString("repass")
|
||||
|
||||
logs.Debug("用户跟换密码,旧密码:%s, 新密码:%s,确认密码:%s", oldPassword, newPassword, repeatPassword)
|
||||
|
||||
userNname := c.GetSession("userName").(string)
|
||||
|
||||
loginService := new(service.LoginService)
|
||||
loginJsonData := loginService.PersonPassword(newPassword, oldPassword, repeatPassword, userNname)
|
||||
|
||||
c.Data["json"] = loginJsonData
|
||||
_ = c.ServeJSON()
|
||||
}
|
29
legend/controllers/logoutController.go
Normal file
29
legend/controllers/logoutController.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type LogoutController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
func (c *LogoutController) Logout() {
|
||||
if err := c.DelSession("username"); err != nil {
|
||||
logs.Error("用户退出登录出错,错误信息:", err)
|
||||
}
|
||||
c.Redirect("/login.html", 302)
|
||||
}
|
||||
|
||||
/**
|
||||
** 切换用户登录
|
||||
*/
|
||||
func (c *LogoutController) SwitchLogin() {
|
||||
err := c.DelSession("username")
|
||||
if err != nil {
|
||||
logs.Error("切换账号失败,错误信息:", err)
|
||||
}
|
||||
|
||||
c.Redirect("/login.html", 302)
|
||||
}
|
143
legend/controllers/showPageController.go
Normal file
143
legend/controllers/showPageController.go
Normal file
@@ -0,0 +1,143 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"legend/controllers/base"
|
||||
"legend/service"
|
||||
"legend/utils"
|
||||
)
|
||||
|
||||
type ShowPageController struct {
|
||||
base.BasicController
|
||||
}
|
||||
|
||||
func (c *ShowPageController) FaviconPage() {
|
||||
c.TplName = "favicon.png"
|
||||
}
|
||||
|
||||
/**
|
||||
** 展示后台第一个页面
|
||||
*/
|
||||
func (c *ShowPageController) WelcomePage() {
|
||||
|
||||
userName := c.GetSession("userName").(string)
|
||||
|
||||
accountService := new(service.AccountService)
|
||||
accountInfo := accountService.GetAccountInfo(userName)
|
||||
|
||||
c.Data["balance"] = accountInfo.Balance
|
||||
c.Data["unBalance"] = accountInfo.Unbalance
|
||||
c.Data["settleAmount"] = accountInfo.SettAmount
|
||||
c.Data["todayAmount"] = accountInfo.TodayIncome
|
||||
|
||||
c.TplName = "welcome.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 展示商户密钥
|
||||
*/
|
||||
func (c *ShowPageController) MerchantKeyPage() {
|
||||
userName := c.GetSession("userName").(string)
|
||||
|
||||
merchantService := new(service.MerchantService)
|
||||
userInfo, bankInfo, payConfigInfo := merchantService.GetMerchantBankInfo(userName)
|
||||
|
||||
c.Data["currentTime"] = utils.GetNowTime()
|
||||
c.Data["userName"] = userName
|
||||
c.Data["userInfo"] = userInfo
|
||||
c.Data["bankInfo"] = bankInfo
|
||||
c.Data["payConfigInfo"] = payConfigInfo
|
||||
c.TplName = "merchant-key.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 比例模板
|
||||
*/
|
||||
func (c *ShowPageController) ScaleTempletePage() {
|
||||
c.TplName = "scale-templete.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 增加模板
|
||||
*/
|
||||
func (c *ShowPageController) TempleteAdd() {
|
||||
c.TplName = "templete-add.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 分组列表
|
||||
*/
|
||||
func (c *ShowPageController) GroupListPage() {
|
||||
c.TplName = "group-list.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 分区列表
|
||||
*/
|
||||
func (c *ShowPageController) AreaListPage() {
|
||||
c.TplName = "area-list.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 充值订单
|
||||
*/
|
||||
func (c *ShowPageController) OrderListPage() {
|
||||
c.TplName = "order-list.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 模拟充值
|
||||
*/
|
||||
func (c *ShowPageController) ImitateChargePage() {
|
||||
c.TplName = "imitate-order.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 结算管理
|
||||
*/
|
||||
func (c *ShowPageController) SettleListPage() {
|
||||
c.TplName = "settle-list.html"
|
||||
}
|
||||
|
||||
/**
|
||||
**每日充值统计
|
||||
*/
|
||||
func (c *ShowPageController) EverydayChargeCountPage() {
|
||||
c.TplName = "everyday-charge-count.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 分组充值统计
|
||||
*/
|
||||
func (c *ShowPageController) GroupChargeCountPage() {
|
||||
c.TplName = "group-charge-count.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 分区充值统计
|
||||
*/
|
||||
func (c *ShowPageController) AreaChargePage() {
|
||||
c.TplName = "area-charge-count.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 创建分区和编辑分区
|
||||
*/
|
||||
func (c *ShowPageController) AreaAddOrEdit() {
|
||||
c.TplName = "area-add.html"
|
||||
}
|
||||
|
||||
/**
|
||||
** 个人页面
|
||||
*/
|
||||
func (c *ShowPageController) PersonPage() {
|
||||
userName, ok := c.GetSession("userName").(string)
|
||||
if !ok {
|
||||
c.Abort("404")
|
||||
} else {
|
||||
merchantService := new(service.MerchantService)
|
||||
userInfo := merchantService.MerchantInfo(userName)
|
||||
c.Data["userName"] = userInfo.UserName
|
||||
}
|
||||
|
||||
c.TplName = "person.html"
|
||||
}
|
Reference in New Issue
Block a user