- 替换 Beego 框架为 GoFrame v2 - 重构项目结构: controller/service/dao/middleware 分层 - 替换自定义 crons 包为 gcron - 模板从 views/ 迁移到 resource/template/ - 配置从 conf/app.conf 迁移到 config.yml - 数据库从 MySQL 切换为 SQLite (modernc.org/sqlite) - 移除 agent/ 远程执行器(待后续迁移) - 移除 crons/ 自定义定时器包 - 静态资源整理到 resource/static/
40 lines
870 B
Go
40 lines
870 B
Go
package controller
|
|
|
|
import (
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/net/ghttp"
|
|
)
|
|
|
|
// display 渲染页面模板(带 layout 布局)
|
|
func display(r *ghttp.Request, tpl string, data g.Map) {
|
|
// 公共布局数据
|
|
layout := g.Map{
|
|
"MainContent": tpl,
|
|
"flash": g.Map{"error": ""},
|
|
"hideTop": false,
|
|
}
|
|
// 合并页面数据
|
|
for k, v := range data {
|
|
layout[k] = v
|
|
}
|
|
r.Response.WriteTpl("public/layout.html", layout)
|
|
}
|
|
|
|
// ajaxMsg 返回JSON消息
|
|
func ajaxMsg(r *ghttp.Request, msg interface{}, msgno int) {
|
|
r.Response.WriteJson(g.Map{
|
|
"status": msgno,
|
|
"message": msg,
|
|
})
|
|
}
|
|
|
|
// ajaxList 返回JSON列表(LayUI table 格式)
|
|
func ajaxList(r *ghttp.Request, msg interface{}, msgno int, count int, data interface{}) {
|
|
r.Response.WriteJson(g.Map{
|
|
"code": msgno,
|
|
"msg": msg,
|
|
"count": count,
|
|
"data": data,
|
|
})
|
|
}
|