18586361686
2025-05-27 60f92fd9afc5eb34998f248c51403129d3313d46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package tech.aiflowy.system.controller;
 
import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.aiflowy.common.constant.Constants;
import tech.aiflowy.common.domain.Result;
import tech.aiflowy.common.entity.LoginAccount;
 
import java.math.BigInteger;
 
@RestController
@RequestMapping("/api/temp-token")
public class SysTempTokenController {
 
    @GetMapping("/create")
    @SaIgnore
    public Result createTempToken() {
 
        StpUtil.login(0);
        String tokenValue = StpUtil.getTokenValue();
        LoginAccount loginAccount = new LoginAccount();
        loginAccount.setId(BigInteger.valueOf(0));
        loginAccount.setLoginName("匿名用户");
        StpUtil.getSession().set(Constants.LOGIN_USER_KEY, loginAccount);
 
        return Result.success(tokenValue);
    }
}