admin

package
v1.0.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package admin 提供管理员后台功能

Index

Constants

View Source
const (
	AdminRequired = "未经授权访问"
)

Variables

This section is empty.

Functions

func CreateUserHandler

func CreateUserHandler(c *gin.Context)

CreateUserHandler 创建用户 @Tags admin @Accept json @Produce json @Param request body CreateUserRequest true "创建用户请求" @Success 200 {object} CreateUserResponse @Router /api/v1/admin/users [post]

func DeleteUserHandler

func DeleteUserHandler(c *gin.Context)

DeleteUserHandler 删除用户 @Tags admin @Produce json @Param id path int true "用户ID" @Success 200 {object} DeleteUserResponse @Router /api/v1/admin/users/{id} [delete]

func GetUserHandler

func GetUserHandler(c *gin.Context)

GetUserHandler 获取单个用户 @Tags admin @Produce json @Param id path int true "用户ID" @Success 200 {object} GetUserResponse @Router /api/v1/admin/users/{id} [get]

func ListUsersHandler

func ListUsersHandler(c *gin.Context)

ListUsersHandler 获取用户列表 @Tags admin @Param request query ListUsersRequest true "request query" @Produce json @Success 200 {object} ListUsersResponse @Router /api/v1/admin/users [get]

func LoginAdminRequired

func LoginAdminRequired() gin.HandlerFunc

LoginAdminRequired 管理员权限验证中间件

func UpdateUserHandler

func UpdateUserHandler(c *gin.Context)

UpdateUserHandler 更新用户 @Tags admin @Accept json @Produce json @Param id path int true "用户ID" @Param request body UpdateUserRequest true "更新用户请求" @Success 200 {object} UpdateUserResponse @Router /api/v1/admin/users/{id} [put]

Types

type CreateUserRequest

type CreateUserRequest struct {
	Username string `json:"username" binding:"required,min=3,max=50"`
	Password string `json:"password" binding:"required,min=6,max=100"`
	Nickname string `json:"nickname" binding:"max=100"`
	Email    string `json:"email" binding:"omitempty,max=255,email"`
	IsAdmin  bool   `json:"is_admin"`
}

CreateUserRequest 创建用户请求

type CreateUserResponse

type CreateUserResponse struct {
	ErrorMsg string         `json:"error_msg"`
	Data     *auth.UserInfo `json:"data"`
}

CreateUserResponse 创建用户响应

type DeleteUserResponse

type DeleteUserResponse struct {
	ErrorMsg string `json:"error_msg"`
	Data     any    `json:"data"`
}

DeleteUserResponse 删除用户响应

type GetUserResponse

type GetUserResponse struct {
	ErrorMsg string         `json:"error_msg"`
	Data     *auth.UserInfo `json:"data"`
}

GetUserResponse 获取用户响应

type ListUsersRequest

type ListUsersRequest struct {
	Current  int    `json:"current" form:"current" binding:"min=1"`
	Size     int    `json:"size" form:"size" binding:"min=1,max=100"`
	Username string `json:"username" form:"username"`
	IsActive *bool  `json:"is_active" form:"is_active"`
	IsAdmin  *bool  `json:"is_admin" form:"is_admin"`
}

ListUsersRequest 用户列表请求

type ListUsersResponse

type ListUsersResponse struct {
	ErrorMsg string `json:"error_msg"`
	Data     *struct {
		Total int64            `json:"total"`
		Users []*auth.UserInfo `json:"users"`
	} `json:"data"`
}

ListUsersResponse 用户列表响应

type UpdateUserRequest

type UpdateUserRequest struct {
	Nickname string  `json:"nickname" binding:"max=100"`
	Password string  `json:"password" binding:"omitempty,min=6,max=100"`
	Email    *string `json:"email" binding:"omitempty,max=255,email"`
	IsActive *bool   `json:"is_active"`
	IsAdmin  *bool   `json:"is_admin"`
}

UpdateUserRequest 更新用户请求

type UpdateUserResponse

type UpdateUserResponse struct {
	ErrorMsg string         `json:"error_msg"`
	Data     *auth.UserInfo `json:"data"`
}

UpdateUserResponse 更新用户响应

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL