瀏覽代碼

获取个人信息

master
牧羊人 4 年之前
父節點
當前提交
525b704555
共有 2 個檔案被更改,包括 46 行新增0 行删除
  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 查看文件

@@ -29,4 +29,9 @@ public class FrontBaseController {
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 查看文件

@@ -0,0 +1,41 @@
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…
取消
儲存