- Implemented Invite management with creation, searching, and disabling functionalities. - Added Ledger overview for financial transactions with filtering options. - Developed Order Detail view for individual order insights and refund capabilities. - Created Orders management page with search, reset, and pagination features. - Enhanced user experience with toast notifications for actions and error handling.
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package web
|
|
|
|
import (
|
|
"quyun/v2/app/errorx"
|
|
"quyun/v2/app/http/web/dto"
|
|
"quyun/v2/app/services"
|
|
"quyun/v2/pkg/consts"
|
|
"quyun/v2/providers/jwt"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
// @provider
|
|
type me struct{}
|
|
|
|
// Me 获取当前登录用户信息(脱敏)。
|
|
//
|
|
// @Summary 当前用户信息
|
|
// @Tags Web
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} dto.MeResponse "成功"
|
|
// @Router /v1/me [get]
|
|
func (ctl *me) me(ctx fiber.Ctx) (*dto.MeResponse, error) {
|
|
claims, ok := ctx.Locals(consts.CtxKeyClaims).(*jwt.Claims)
|
|
if !ok || claims == nil || claims.UserID <= 0 {
|
|
return nil, errorx.ErrTokenInvalid
|
|
}
|
|
|
|
m, err := services.User.FindByID(ctx, claims.UserID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &dto.MeResponse{
|
|
ID: m.ID,
|
|
Username: m.Username,
|
|
Roles: m.Roles,
|
|
Status: m.Status,
|
|
StatusDescription: m.Status.Description(),
|
|
CreatedAt: m.CreatedAt,
|
|
UpdatedAt: m.UpdatedAt,
|
|
}, nil
|
|
}
|
|
|
|
// MyTenants 获取当前用户可进入的租户列表。
|
|
//
|
|
// @Summary 我的租户列表
|
|
// @Tags Web
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {array} dto.MyTenantItem "成功"
|
|
// @Router /v1/me/tenants [get]
|
|
func (ctl *me) myTenants(ctx fiber.Ctx) ([]*dto.MyTenantItem, error) {
|
|
claims, ok := ctx.Locals(consts.CtxKeyClaims).(*jwt.Claims)
|
|
if !ok || claims == nil || claims.UserID <= 0 {
|
|
return nil, errorx.ErrTokenInvalid
|
|
}
|
|
|
|
return services.Tenant.UserTenants(ctx, claims.UserID)
|
|
}
|