feat: SaToken
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.landaiqing.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.base.Preconditions;
|
||||
@@ -143,11 +144,16 @@ public class StudentController {
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(studentDTO.getUsername()), "用户名不能为空!");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(studentDTO.getPassword()), "密码不能为空!");
|
||||
StudentBO studentBO = StudentInfoDtoConvert.INSTANCE.convertDtoToBO(studentDTO);
|
||||
SaTokenInfo saTokenInfo = studentDomainService.login(studentBO);
|
||||
SaTokenInfo saTokenInfo = studentDomainService.login(studentBO);
|
||||
return Result.ok(saTokenInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("StudentController.login.error:{}", e.getMessage(), e);
|
||||
return Result.fail("登录失败!");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("isLogin")
|
||||
public String isLogin() {
|
||||
return "当前会话是否登录:" + StpUtil.isLogin();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user