Skip to content

Commit

Permalink
!234 修复查询满减活动和优惠券活动报错问题
Browse files Browse the repository at this point in the history
Merge pull request !234 from OceansDeep/feature/pg
  • Loading branch information
OceansDeep authored and gitee-org committed Sep 14, 2022
2 parents 74cc5af + cbdcb6f commit 178e0d1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,20 @@ public void setLimitScript(DefaultRedisScript<Long> limitScript) {
@Before("@annotation(limitPointAnnotation)")
public void interceptor(LimitPoint limitPointAnnotation) {
LimitTypeEnums limitTypeEnums = limitPointAnnotation.limitType();
String name = limitPointAnnotation.name();

String key;
int limitPeriod = limitPointAnnotation.period();
int limitCount = limitPointAnnotation.limit();
switch (limitTypeEnums) {
case CUSTOMER:
key = limitPointAnnotation.key();
break;
default:
key = limitPointAnnotation.key() + IpUtils
.getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
if (limitTypeEnums == LimitTypeEnums.CUSTOMER) {
key = limitPointAnnotation.key();
} else {
key = limitPointAnnotation.key() + IpUtils
.getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
}
ImmutableList<String> keys = ImmutableList.of(StringUtils.join(limitPointAnnotation.prefix(), key));
try {
Number count = redisTemplate.execute(limitScript, keys, limitCount, limitPeriod);
assert count != null;
log.info("限制请求{}, 当前请求{},缓存key{}", limitCount, count.intValue(), key);
//如果缓存里没有值,或者他的值小于限制频率
if (count.intValue() >= limitCount) {
Expand All @@ -72,6 +71,7 @@ public void interceptor(LimitPoint limitPointAnnotation) {
} catch (ServiceException e) {
throw e;
} catch (Exception e) {
log.error("限流异常", e);
throw new ServiceException(ResultCode.ERROR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void interceptor(PreventDuplicateSubmissions preventDuplicateSubmissions)
} catch (ServiceException e) {
throw e;
} catch (Exception e) {
log.error("防重复提交拦截器异常", e);
throw new ServiceException(ResultCode.ERROR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public Map<String, Object> createVerification(VerificationEnums verificationEnum
} catch (ServiceException e) {
throw e;
} catch (Exception e) {
log.error("生成验证码失败", e);
throw new ServiceException(ResultCode.ERROR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class FullDiscountManagerController {
@ApiOperation(value = "获取满优惠列表")
@GetMapping
public ResultMessage<IPage<FullDiscount>> getCouponList(FullDiscountSearchParams searchParams, PageVO page) {
page.setNotConvert(true);
return ResultUtil.data(fullDiscountService.pageFindAll(searchParams, page));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class CouponStoreController {
@GetMapping
@ApiOperation(value = "获取优惠券列表")
public ResultMessage<IPage<CouponVO>> getCouponList(CouponSearchParams queryParam, PageVO page) {
page.setNotConvert(true);
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
queryParam.setStoreId(storeId);
IPage<CouponVO> coupons = couponService.pageVOFindAll(queryParam, page);
Expand Down

0 comments on commit 178e0d1

Please sign in to comment.