forked from iVMiku/guidance-backend
minio
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.ivmiku.tutorial.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ivmiku.tutorial.response.Result;
|
||||
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 java.util.HashMap;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
public class TestController {
|
||||
@GetMapping("/login1")
|
||||
public Object getToken1() {
|
||||
StpUtil.login("1");
|
||||
String token = StpUtil.getTokenValue();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("token", token);
|
||||
return JSON.toJSON(Result.ok(map));
|
||||
}
|
||||
|
||||
@GetMapping("/login2")
|
||||
public Object getToken2() {
|
||||
StpUtil.login("2");
|
||||
String token = StpUtil.getTokenValue();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("token", token);
|
||||
return JSON.toJSON(Result.ok(map));
|
||||
}
|
||||
|
||||
@PostMapping("test")
|
||||
public Object test() {
|
||||
//添加请求头"satoken",值为上方接口返回的token后可以获取token对应的用户id
|
||||
String userId = (String) StpUtil.getLoginId();
|
||||
//其他业务逻辑
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user