feat: 重构认证控制器,统一类型命名为auth
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// @provider
|
||||
type authController struct {
|
||||
type auth struct {
|
||||
app *app.Config
|
||||
jwt *jwt.JWT
|
||||
}
|
||||
@@ -27,7 +27,7 @@ type authController struct {
|
||||
//
|
||||
// @Router /super/v1/auth/login [post]
|
||||
// @Bind form body
|
||||
func (ctl *authController) login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
func (ctl *auth) login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
m, err := services.User.FindByUsername(ctx, form.Username)
|
||||
if err != nil {
|
||||
return nil, errorx.Wrap(err).WithMsg("用户名或密码错误")
|
||||
|
||||
@@ -14,8 +14,8 @@ func Provide(opts ...opt.Option) error {
|
||||
if err := container.Container.Provide(func(
|
||||
app *app.Config,
|
||||
jwt *jwt.JWT,
|
||||
) (*authController, error) {
|
||||
obj := &authController{
|
||||
) (*auth, error) {
|
||||
obj := &auth{
|
||||
app: app,
|
||||
jwt: jwt,
|
||||
}
|
||||
@@ -25,14 +25,14 @@ func Provide(opts ...opt.Option) error {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func(
|
||||
authController *authController,
|
||||
auth *auth,
|
||||
tenant *tenant,
|
||||
user *user,
|
||||
) (contracts.HttpRoute, error) {
|
||||
obj := &Routes{
|
||||
authController: authController,
|
||||
tenant: tenant,
|
||||
user: user,
|
||||
auth: auth,
|
||||
tenant: tenant,
|
||||
user: user,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -20,9 +20,9 @@ import (
|
||||
type Routes struct {
|
||||
log *log.Entry `inject:"false"`
|
||||
// Controller instances
|
||||
authController *authController
|
||||
tenant *tenant
|
||||
user *user
|
||||
auth *auth
|
||||
tenant *tenant
|
||||
user *user
|
||||
}
|
||||
|
||||
// Prepare initializes the routes provider with logging configuration.
|
||||
@@ -40,10 +40,10 @@ func (r *Routes) Name() string {
|
||||
// Register registers all HTTP routes with the provided fiber router.
|
||||
// Each route is registered with its corresponding controller action and parameter bindings.
|
||||
func (r *Routes) Register(router fiber.Router) {
|
||||
// Register routes for controller: authController
|
||||
r.log.Debugf("Registering route: Post /super/v1/auth/login -> authController.login")
|
||||
// Register routes for controller: auth
|
||||
r.log.Debugf("Registering route: Post /super/v1/auth/login -> auth.login")
|
||||
router.Post("/super/v1/auth/login", DataFunc1(
|
||||
r.authController.login,
|
||||
r.auth.login,
|
||||
Body[dto.LoginForm]("form"),
|
||||
))
|
||||
// Register routes for controller: tenant
|
||||
|
||||
Reference in New Issue
Block a user