feat(controller): 完善基础控制器及默认页面渲染

- 新增BaseController,包含Success和Error通用响应方法
- 修改DefaultController Index方法,改为返回HTML页面
- 更新index.html模板,优化模板语法和结构,增加条件判断和循环示例
- UserController嵌入BaseController,Index方法统一调用Success响应
- 修正部分注释及代码格式提升可读性
This commit is contained in:
2026-02-20 14:22:47 +08:00
parent ee2e890c39
commit 37c78d9a4e
4 changed files with 34 additions and 32 deletions

View File

@@ -0,0 +1,13 @@
package admin
import "github.com/gin-gonic/gin"
type BaseController struct {
}
func (con BaseController) Success(c *gin.Context) {
c.String(200, "成功")
}
func (con BaseController) Error(c *gin.Context) {
c.String(200, "失败")
}

View File

@@ -3,10 +3,11 @@ package admin
import "github.com/gin-gonic/gin"
type UserController struct {
BaseController
}
func (con UserController) Index(c *gin.Context) {
c.String(200, "管理员用户列表")
con.Success(c)
}
func (con UserController) Show(c *gin.Context) {