- api/admin/v1 拆 base/system/admin 三子包,路由前缀 /admin/v1/{base,system,admin}
- system: auth/menu/role;admin: 管理员;base: log
- controller 改 import 子包;006_menu_paths_v2.sql 更新接口路径映射
- 权限码与路由分离,permission 标识不变
- 冒烟测试新路径 8 接口全通过
25 lines
846 B
Go
25 lines
846 B
Go
package admin
|
|
|
|
import (
|
|
"context"
|
|
|
|
systemv1 "service.xpcool.com/api/admin/v1/system"
|
|
"service.xpcool.com/internal/model/dto"
|
|
"service.xpcool.com/internal/service"
|
|
)
|
|
|
|
// AuthController exposes only the public login endpoint.
|
|
type AuthController struct{}
|
|
|
|
// NewAuth creates the public admin auth controller (login only).
|
|
func NewAuth() *AuthController { return &AuthController{} }
|
|
|
|
// Login authenticates an administrator and issues a token pair.
|
|
func (c *AuthController) Login(ctx context.Context, req *systemv1.LoginReq) (res *systemv1.LoginRes, err error) {
|
|
p, id, err := service.AdminAuth().Login(ctx, dto.AdminLoginInput{Username: req.Username, Password: req.Password})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &systemv1.LoginRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, AdminID: id}, nil
|
|
}
|