添加验证登录接口

This commit is contained in:
zk
2026-03-27 14:58:40 +08:00
parent 273c99f9b5
commit ce22f29b6e
2 changed files with 16 additions and 1 deletions
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import org.jiayunet.pojo.dto.SmsLoginDto;
import org.jiayunet.pojo.vo.LoginVo;
import org.jiayunet.service.LoginService;
import org.jiayunet.tool.UserSecurityTool;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -41,4 +42,18 @@ public class LoginController {
loginService.logout(request, response);
return true;
}
/**
* 检查登录状态
* <p>有Cookie且认证通过返回true,否则返回false</p>
*/
@GetMapping("/checkLogin")
public boolean checkLogin() {
try {
UserSecurityTool.getUserId();
}catch (Exception e) {
return false;
}
return true;
}
}