管理后台新增用户总数卡片,点击进入用户管理,移除header用户管理按钮

This commit is contained in:
2026-07-03 10:24:52 +08:00
parent e65b31abb0
commit fe91a8ffb2
4 changed files with 37 additions and 14 deletions
+6
View File
@@ -44,6 +44,12 @@ func formatUser(u *model.User) userResponse {
}
}
func GetUserCount(c *gin.Context) {
var count int64
db.DB.Model(&model.User{}).Count(&count)
c.JSON(http.StatusOK, gin.H{"count": count})
}
func ListUsers(c *gin.Context) {
var users []model.User
db.DB.Order("id asc").Find(&users)
+1
View File
@@ -26,6 +26,7 @@ func Setup(r *gin.Engine) {
admin := r.Group("/api/admin")
admin.Use(middleware.AuthMiddleware(), middleware.AdminMiddleware())
{
admin.GET("/users/count", handler.GetUserCount)
admin.GET("/users", handler.ListUsers)
admin.POST("/users", handler.CreateUser)
admin.PUT("/users/:id", handler.UpdateUser)