feat: 互动处理
This commit is contained in:
@@ -56,6 +56,10 @@ func (a *AuthApi) Login(c *gin.Context) {
|
||||
func (a *AuthApi) Logout(c *gin.Context) {
|
||||
token := auth.GetToken(c)
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
err := jwtService.PutBlacklist(userId, token)
|
||||
if err != nil {
|
||||
global.Logger.Error("登出失败!", zap.Error(err))
|
||||
|
||||
@@ -138,6 +138,10 @@ func (m *MenuApi) GetAllMenuTree(c *gin.Context) {
|
||||
// @Router /menu/getUserMenuTree [get]
|
||||
func (m *MenuApi) GetUserMenuTree(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
routes, err := menuService.GetUserRoutes(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("获取用户菜单失败!", zap.Error(err))
|
||||
@@ -156,6 +160,10 @@ func (m *MenuApi) GetUserMenuTree(c *gin.Context) {
|
||||
// @Router /menu/route [get]
|
||||
func (m *MenuApi) Route(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" || userId == "0" {
|
||||
response.FailWithMsg("用户未登录", c)
|
||||
return
|
||||
}
|
||||
routes, err := menuService.GetUserRoutes(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("获取用户菜单失败!", zap.Error(err))
|
||||
|
||||
@@ -24,6 +24,9 @@ type UserApi struct {
|
||||
// @Router /user/info [get]
|
||||
func (u *UserApi) CurrentUser(c *gin.Context) {
|
||||
userId := auth.GetUserId(c)
|
||||
if userId == "" {
|
||||
|
||||
}
|
||||
user, err := userService.GetUserById(userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("获取用户信息失败!", zap.Error(err))
|
||||
|
||||
Reference in New Issue
Block a user