管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-08-14 c8e3797083c44beaeb909a2c2d7a6095cef7aac3
src/main/java/com/lf/server/service/sys/TokenService.java
@@ -8,7 +8,6 @@
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.WebHelper;
import com.lf.server.mapper.sys.TokenMapper;
import com.lf.server.service.all.PermsService;
import com.lf.server.service.all.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -37,18 +36,19 @@
    LoginService loginService;
    @Autowired
    public RedisService redisService;
    @Autowired
    public  PermsService permsService;
    RedisService redisService;
    @Override
    public Integer selectCount(String name, Integer type) {
        name = StringHelper.getLikeUpperStr(name);
        return tokenMapper.selectCount(name, type);
    }
    @Override
    public List<TokenEntity> selectByPage(String name, Integer type, Integer limit, Integer offset) {
        name = StringHelper.getLikeUpperStr(name);
        return tokenMapper.selectByPage(name, type, limit, offset);
    }
@@ -100,14 +100,15 @@
    /**
     * 获取新的令牌实体类
     */
    public TokenEntity getNewToken(int userid, HttpServletRequest req) {
    public TokenEntity getNewToken(UserEntity ue, HttpServletRequest req) {
        TokenEntity te = new TokenEntity();
        te.setToken(WebHelper.getGuid());
        te.setDuration(SettingData.TOKEN_EXPIRE);
        te.setExpire(WebHelper.getTimestamp(SettingData.TOKEN_EXPIRE));
        te.setType(0);
        te.setIp(WebHelper.getIpAddress(req));
        te.setCreateUser(userid);
        te.setCreateUser(ue.getId());
        te.setUname(ue.getUname());
        return te;
    }
@@ -157,13 +158,9 @@
        // 清除缓存
        String tokenKey = RedisCacheKey.signTokenKey(token);
        if (redisService.hasKey(tokenKey)) {
            redisService.delete(tokenKey);
        }
        redisService.delete(tokenKey);
        String userKey = RedisCacheKey.signUserKey(te.getToken());
        if (redisService.hasKey(userKey)) {
            redisService.delete(userKey);
        }
        redisService.delete(userKey);
        // db,设置令牌过期
        te.setUpdateUser(ue.getId());