|
@@ -2,8 +2,10 @@ package com.fdkankan.tk.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.fdkankan.tk.common.ResultCode;
|
|
|
import com.fdkankan.tk.common.util.RedisKeyUtil;
|
|
|
import com.fdkankan.tk.entity.TencentYun;
|
|
|
+import com.fdkankan.tk.exception.BusinessException;
|
|
|
import com.fdkankan.tk.mapper.ITencentYunMapper;
|
|
|
import com.fdkankan.tk.service.ITencentYunService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -11,6 +13,8 @@ import com.tencentyun.TLSSigAPIv2;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -29,7 +33,14 @@ public class TencentYunServiceImpl extends ServiceImpl<ITencentYunMapper, Tencen
|
|
|
public JSONObject getSign(String userId) {
|
|
|
String redisKey = RedisKeyUtil.TENCENT_YUN_KEY + userId;
|
|
|
if (!redisUtil.hasKey(redisKey)) {
|
|
|
- TencentYun tencentYun = this.getById(1);
|
|
|
+ List<TencentYun> list = this.list();
|
|
|
+ if(list == null || list.size() <=0){
|
|
|
+ throw new BusinessException(ResultCode.TENCENT_YUN_EMPTY);
|
|
|
+ }
|
|
|
+ if(list.size() >1){
|
|
|
+ throw new BusinessException(ResultCode.TENCENT_YUN_ERROR);
|
|
|
+ }
|
|
|
+ TencentYun tencentYun = list.get(0);
|
|
|
|
|
|
TLSSigAPIv2 api = new TLSSigAPIv2(tencentYun.getSdkAppid(), tencentYun.getSecretkey());
|
|
|
String sign = api.genUserSig(userId, tencentYun.getExTime() );
|