|
@@ -9,7 +9,6 @@ import com.diagbot.entity.OpenedProducts;
|
|
|
import com.diagbot.entity.ProductService;
|
|
|
import com.diagbot.entity.ServiceInfo;
|
|
|
import com.diagbot.entity.ServiceToken;
|
|
|
-import com.diagbot.entity.ServiceTokenWithUser;
|
|
|
import com.diagbot.entity.wrapper.ServiceTokenWrapper;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.enums.StatusEnum;
|
|
@@ -61,35 +60,32 @@ public class ServiceTokenFacade extends ServiceTokenServiceImpl {
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
paramMap.put("appkey", appkey);
|
|
|
paramMap.put("secret", secret);
|
|
|
- //ServiceToken st = this.getServiceToken(paramMap);
|
|
|
+ paramMap.put("productId", serviceTokenVo.getProductId());
|
|
|
|
|
|
//获取用户的id
|
|
|
- List<ServiceTokenWithUser> serviceTokenWithUserList = this.getByAppkeyAndSecret(paramMap);
|
|
|
- if(ListUtil.isEmpty(serviceTokenWithUserList)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "appkey和secret错误或已失效,appkey=【" + appkey + "】," + "secret=【" + secret + "】");
|
|
|
+ List<ServiceTokenWrapper> serviceTokenWrapperList = this.getByAppkeyAndSecretAndProductId(paramMap);
|
|
|
+
|
|
|
+ if(ListUtil.isEmpty(serviceTokenWrapperList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "appkey或secret错误,appkey=【" + appkey + "】," + "secret=【" + secret + "】");
|
|
|
+ }
|
|
|
+ ServiceTokenWrapper st = serviceTokenWrapperList.get(0);
|
|
|
+ if(StatusEnum.Disable.getKey() == st.getServiceStatus()) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品已停用");
|
|
|
}
|
|
|
- ServiceTokenWithUser st = serviceTokenWithUserList.get(0);
|
|
|
if (TokenTypeEnum.Trial.getKey() == st.getType()) {
|
|
|
- ProductService ps = productServiceFacade.getById(st.getProductServiceId());
|
|
|
- if (ps == null) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问");
|
|
|
- }
|
|
|
- if (!ps.getProductId().equals(serviceTokenVo.getProductId())) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问");
|
|
|
- }
|
|
|
Date date = new Date();
|
|
|
if (st.getExpiringDate().getTime() < date.getTime()) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "访问权限已过期");
|
|
|
}
|
|
|
} else {
|
|
|
- List<OpenedProducts> opList = openedProductsFacade.getByAppkeyAndSecret(paramMap);
|
|
|
- if (ListUtil.isEmpty(opList)) {
|
|
|
+ QueryWrapper<OpenedProducts> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ queryWrapper.eq("user_id", st.getUserId());
|
|
|
+ queryWrapper.eq("product_id", st.getProductId());
|
|
|
+ OpenedProducts op = openedProductsFacade.getOne(queryWrapper);
|
|
|
+ if(op == null) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问");
|
|
|
}
|
|
|
- if (opList.size() != 1) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "当前appkey和secret对应多条数据");
|
|
|
- }
|
|
|
- OpenedProducts op = opList.get(0);// 正常只有一条数据
|
|
|
Date date = new Date();
|
|
|
if (!(StatusEnum.Enable.getKey() == op.getServiceStatus())) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "当前服务已停用");
|