use of com.whoiszxl.cqrs.response.ActivityApiResponse in project shopzz by whoiszxl.
the class ActivityServiceImpl method detail.
@Override
public ActivityApiResponse detail(Long id) {
String redisKey = RedisKeyPrefixConstants.ACTIVITY_DETAIL + id;
String activityJson = redisUtils.get(redisKey);
if (StringUtils.isBlank(activityJson)) {
synchronized (this) {
activityJson = redisUtils.get(redisKey);
if (StringUtils.isBlank(activityJson)) {
// 从数据库拿数据
ActivityApiResponse response = new ActivityApiResponse();
Activity activity = super.getById(id);
dozerUtils.map(activity, response);
List<ActivityCoupon> activityCouponList = activityCouponService.list(Wrappers.<ActivityCoupon>lambdaQuery().eq(ActivityCoupon::getActivityId, id));
List<Long> couponIdList = activityCouponList.stream().map(ActivityCoupon::getCouponId).collect(Collectors.toList());
List<Coupon> couponList = couponService.listByIds(couponIdList);
List<CouponApiVO> couponApiVOList = dozerUtils.mapList(couponList, CouponApiVO.class);
response.setCouponList(couponApiVOList);
activityJson = JsonUtil.toJson(response);
redisUtils.set(redisKey, activityJson);
}
}
}
return JsonUtil.fromJson(activityJson, ActivityApiResponse.class);
}
Aggregations