13 changed files with 171 additions and 65 deletions
@ -1,18 +1,36 @@ |
|||||
package com.ccsens.ptos_tall.service; |
package com.ccsens.ptos_tall.service; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollectionUtil; |
||||
import com.ccsens.ptos_tall.bean.dto.BusinessDto; |
import com.ccsens.ptos_tall.bean.dto.BusinessDto; |
||||
|
import com.ccsens.util.JwtUtil; |
||||
|
import com.ccsens.util.RedisKeyManager; |
||||
|
import com.ccsens.util.RedisUtil; |
||||
|
import com.ccsens.util.WebConstant; |
||||
import lombok.extern.slf4j.Slf4j; |
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Propagation; |
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Map; |
||||
|
|
||||
@Slf4j |
@Slf4j |
||||
@Service |
@Service |
||||
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) |
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) |
||||
public class BusinessService implements IBusinessService { |
public class BusinessService implements IBusinessService { |
||||
|
@Resource |
||||
|
private RedisUtil redisUtil; |
||||
|
|
||||
@Override |
@Override |
||||
public String getAccessTokenByAppId(BusinessDto.BusinessToken params) { |
public String getAccessTokenByAppId(BusinessDto.BusinessToken params) { |
||||
|
//生成accessToken
|
||||
return null; |
Map<String, Object> payLoads = CollectionUtil.newHashMap(); |
||||
|
payLoads.put("secret", params.getSecret()); |
||||
|
//生成过期时间
|
||||
|
long tokenExpired = 3600 * 1000L * 2; |
||||
|
//生成token并缓存
|
||||
|
String accessToken = JwtUtil.createJWT(params.getAppId() + "",payLoads, tokenExpired,WebConstant.JWT_ACCESS_TOKEN_SECERT); |
||||
|
redisUtil.set(RedisKeyManager.getTokenCachedKey(params.getAppId()), accessToken, tokenExpired / 1000); |
||||
|
return accessToken; |
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue