Browse Source

获取个人信息

master
牧羊人 4 years ago
parent
commit
525b704555
2 changed files with 46 additions and 0 deletions
  1. +5
    -0
      src/main/java/com/taauav/front/controller/FrontBaseController.java
  2. +41
    -0
      src/main/java/com/taauav/front/controller/LSUserController.java

+ 5
- 0
src/main/java/com/taauav/front/controller/FrontBaseController.java View File

this.userId = Integer.valueOf(data.get("id").toString()); this.userId = Integer.valueOf(data.get("id").toString());
} }


public Integer getUserId(HttpServletRequest request) {
String token = request.getHeader("token");
return 1;
}

} }

+ 41
- 0
src/main/java/com/taauav/front/controller/LSUserController.java View File

package com.taauav.front.controller;

import com.taauav.admin.entity.LsAdmin;
import com.taauav.admin.service.ILsAdminService;
import com.taauav.common.bean.Response;
import com.taauav.common.util.JwtUtil;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/front/user")
public class LSUserController extends FrontBaseController {

@Autowired
private ILsAdminService adminService;

@Autowired
private Response response;

/**
* 获取当前登录人信息
*
* @return
*/
@PostMapping("/info")
public Response info(HttpServletRequest request) {
String token = request.getHeader("token");
Claims data = JwtUtil.parseJWT(token);
this.userId = Integer.valueOf(data.get("id").toString());
LsAdmin adminInfo = adminService.getById(this.userId);
return response.success(adminInfo);
}


}

Loading…
Cancel
Save