fix: swagger
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/pkg/consts"
|
||||
"quyun/v2/providers/app"
|
||||
"quyun/v2/providers/jwt"
|
||||
|
||||
@@ -16,8 +17,16 @@ type authController struct {
|
||||
jwt *jwt.JWT
|
||||
}
|
||||
|
||||
// @Router /super/v1/auth/login [post]
|
||||
// @Bind form body
|
||||
// Login
|
||||
//
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.LoginForm true "form"
|
||||
// @Success 200 {object} dto.LoginResponse "成功"
|
||||
//
|
||||
// @Router /super/v1/auth/login [post]
|
||||
// @Bind form body
|
||||
func (ctl *authController) login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
m, err := services.User.FindByUsername(ctx, form.Username)
|
||||
if err != nil {
|
||||
@@ -28,6 +37,10 @@ func (ctl *authController) login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.Login
|
||||
return nil, errorx.Wrap(err).WithMsg("用户名或密码错误")
|
||||
}
|
||||
|
||||
if !m.Roles.Contains(consts.RoleSuperAdmin) {
|
||||
return nil, errorx.Wrap(err).WithMsg("用户名或密码错误")
|
||||
}
|
||||
|
||||
token, err := ctl.jwt.CreateToken(ctl.jwt.CreateClaims(jwt.BaseClaims{
|
||||
UserID: m.ID,
|
||||
}))
|
||||
|
||||
@@ -12,7 +12,7 @@ type TenantFilter struct {
|
||||
requests.Pagination
|
||||
requests.SortQueryFilter
|
||||
|
||||
Name *string `json:"name,omitempty"`
|
||||
Name *string `json:"name,omitempty" query:"name"`
|
||||
}
|
||||
|
||||
type TenantItem struct {
|
||||
|
||||
@@ -5,18 +5,19 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/super/dto"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
_ "go.ipao.vip/atom"
|
||||
_ "go.ipao.vip/atom/contracts"
|
||||
. "go.ipao.vip/atom/fen"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
)
|
||||
|
||||
// Routes implements the HttpRoute contract and provides route registration
|
||||
// for all controllers in the super module.
|
||||
//
|
||||
// @provider contracts.HttpRoute atom.GroupRoutes
|
||||
// @provider contracts.HttpRoute atom.GroupRoutes
|
||||
type Routes struct {
|
||||
log *log.Entry `inject:"false"`
|
||||
// Controller instances
|
||||
|
||||
@@ -13,16 +13,32 @@ import (
|
||||
type tenant struct{}
|
||||
|
||||
// list
|
||||
// @Router /super/v1/tenants [get]
|
||||
// @Bind filter query
|
||||
//
|
||||
// @Summary 租户列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter query dto.TenantFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.TenantItem}
|
||||
//
|
||||
// @Router /super/v1/tenants [get]
|
||||
// @Bind filter query
|
||||
func (*tenant) list(ctx fiber.Ctx, filter *dto.TenantFilter) (*requests.Pager, error) {
|
||||
return services.Tenant.Pager(ctx, filter)
|
||||
}
|
||||
|
||||
// list
|
||||
// @Router /super/v1/tenants/:tenantID [patch]
|
||||
// @Bind tenantID path
|
||||
// @Bind form body
|
||||
// updateExpire
|
||||
//
|
||||
// @Summary 更新过期时间
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param form body dto.TenantExpireUpdateForm true "Form"
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID [patch]
|
||||
// @Bind tenantID path
|
||||
// @Bind form body
|
||||
func (*tenant) updateExpire(ctx fiber.Ctx, tenantID int64, form *dto.TenantExpireUpdateForm) error {
|
||||
duration, err := form.ParseDuration()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user