2024-03-06 17:13:29 +08:00
|
|
|
package route
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"wireguard-dashboard/http/api"
|
2024-03-07 11:03:46 +08:00
|
|
|
"wireguard-dashboard/middleware"
|
2024-03-06 17:13:29 +08:00
|
|
|
)
|
|
|
|
|
2024-03-13 17:05:02 +08:00
|
|
|
func UserApi(r *gin.RouterGroup) {
|
2024-03-07 11:03:46 +08:00
|
|
|
// 登陆相关API
|
|
|
|
login := r.Group("/login")
|
|
|
|
{
|
|
|
|
login.POST("", api.UserApi().Login)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 用户登陆后相关的API
|
2024-03-07 15:11:29 +08:00
|
|
|
userApi := r.Group("user", middleware.Authorization())
|
2024-03-06 17:13:29 +08:00
|
|
|
{
|
2024-03-14 15:33:54 +08:00
|
|
|
userApi.DELETE("logout", api.UserApi().Logout) // 用户退出登陆
|
|
|
|
userApi.GET("", api.UserApi().GetUser) // 获取登陆用户信息
|
|
|
|
userApi.POST("save", middleware.Permission(), api.UserApi().Save) // 新增/编辑用户信息
|
|
|
|
userApi.POST("change-password", api.UserApi().ChangePassword) // 更改密码
|
|
|
|
userApi.GET("list", middleware.Permission(), api.UserApi().List) // 用户列表
|
|
|
|
userApi.PUT("change-status", middleware.Permission(), api.UserApi().ChangeUserState) // 变更状态
|
2024-03-06 17:13:29 +08:00
|
|
|
}
|
|
|
|
}
|