管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-10 86698147b0dc4a518bea2cad42e11e4601f7e970
src/main/java/com/lf/server/service/sys/TokenService.java
@@ -2,7 +2,7 @@
import com.lf.server.entity.sys.LoginEntity;
import com.lf.server.entity.sys.TokenEntity;
import com.lf.server.entity.sys.UsersEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.entity.all.RedisCacheKey;
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.WebHelper;
@@ -32,7 +32,7 @@
    TokenMapper tokenMapper;
    @Autowired
    UsersService usersService;
    UserService usersService;
    @Autowired
    LoginService loginService;
@@ -160,7 +160,7 @@
        WebHelper.deleteAll(req, res);
        // 获取当前用户
        UsersEntity ue = getCurrentUser(req);
        UserEntity ue = getCurrentUser(req);
        if (ue == null) {
            return false;
        }
@@ -220,7 +220,7 @@
     * @param req
     * @param res
     */
    public void saveToken(UsersEntity ue, TokenEntity te, HttpServletRequest req, HttpServletResponse res) {
    public void saveToken(UserEntity ue, TokenEntity te, HttpServletRequest req, HttpServletResponse res) {
        // 保存至Cookie
        WebHelper.saveToken2Cookie(te.getToken(), req, res);
@@ -239,7 +239,7 @@
     * @param req
     * @return
     */
    public UsersEntity getCurrentUser(HttpServletRequest req) {
    public UserEntity getCurrentUser(HttpServletRequest req) {
        String token = WebHelper.getToken(req);
        if (StringHelper.isNull(token)) {
            return null;
@@ -249,12 +249,12 @@
        // redis
        Object obj = redisService.get(userKey);
        if (obj != null && obj instanceof UsersEntity) {
            return (UsersEntity) obj;
        if (obj != null && obj instanceof UserEntity) {
            return (UserEntity) obj;
        }
        // db
        UsersEntity ue = usersService.selectByToken(token);
        UserEntity ue = usersService.selectByToken(token);
        if (ue != null) {
            TokenEntity te = getEntityByToken(token);
            if (te != null) {