//
// Copyright (C) 2024 veypi <i@veypi.com>
// 2025-03-04 16:08:06
// Distributed under terms of the MIT license.
//

package user

import (
	"github.com/veypi/vbase/cfg"
	"github.com/veypi/vigo"
)

var Router = vigo.NewRouter()

func init() {
	// 管理员 管理用户权限 (所有接口需要 user:admin 权限)
	Router.Get("/", "用户列表", cfg.Auth.RequireRead("user:*"), list)
	Router.Post("/", "创建用户", cfg.Auth.RequireCreate("user"), create)
	Router.Get("/{user_id}", "获取用户详情", cfg.Auth.RequireRead("user:*"), get)
	Router.Patch("/{user_id}", "更新用户", cfg.Auth.RequireWrite("user:*"), patch)
	Router.Delete("/{user_id}", "删除用户", cfg.Auth.RequireWrite("user:*"), del)
	Router.Patch("/{user_id}/status", "更新用户状态", cfg.Auth.RequireWrite("user:*"), updateStatus)

	Router.Get("/{user_id}/roles", "Get User Roles", cfg.Auth.RequireRead("user:*"), getRoles)
	Router.Put("/{user_id}/roles", "Update User Roles", cfg.Auth.RequireWrite("user:*"), updateRoles)
	Router.Get("/{user_id}/permissions", "Get User Permissions", cfg.Auth.RequireRead("user:*"), getPermissions)
	Router.Put("/{user_id}/permissions", "Update User Permissions", cfg.Auth.RequireWrite("user:*"), updatePermissions)
}
