Search in sources :

Example 1 with Activity

use of com.whoiszxl.entity.Activity in project shopzz by whoiszxl.

the class ActivityAdminController method save.

@SaCheckLogin
@PostMapping
@ApiOperation(value = "新增活动", notes = "新增活动", response = ResponseResult.class)
public ResponseResult<Boolean> save(@RequestBody ActivitySaveCommand bannerSaveCommand) {
    Activity banner = dozerUtils.map(bannerSaveCommand, Activity.class);
    boolean saveFlag = activityService.save(banner);
    return ResponseResult.buildByFlag(saveFlag);
}
Also used : Activity(com.whoiszxl.entity.Activity) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with Activity

use of com.whoiszxl.entity.Activity 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);
}
Also used : ActivityCoupon(com.whoiszxl.entity.ActivityCoupon) Coupon(com.whoiszxl.entity.Coupon) ActivityCoupon(com.whoiszxl.entity.ActivityCoupon) CouponApiVO(com.whoiszxl.cqrs.vo.CouponApiVO) Activity(com.whoiszxl.entity.Activity) ActivityApiResponse(com.whoiszxl.cqrs.response.ActivityApiResponse)

Example 3 with Activity

use of com.whoiszxl.entity.Activity in project shopzz by whoiszxl.

the class ActivityAdminController method update.

@SaCheckLogin
@PutMapping
@ApiOperation(value = "更新活动", notes = "更新活动", response = ResponseResult.class)
public ResponseResult<Boolean> update(@RequestBody ActivityUpdateCommand bannerSaveCommand) {
    Activity banner = dozerUtils.map(bannerSaveCommand, Activity.class);
    boolean updateFlag = activityService.updateById(banner);
    return ResponseResult.buildByFlag(updateFlag);
}
Also used : Activity(com.whoiszxl.entity.Activity) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Activity (com.whoiszxl.entity.Activity)3 SaCheckLogin (cn.dev33.satoken.annotation.SaCheckLogin)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ActivityApiResponse (com.whoiszxl.cqrs.response.ActivityApiResponse)1 CouponApiVO (com.whoiszxl.cqrs.vo.CouponApiVO)1 ActivityCoupon (com.whoiszxl.entity.ActivityCoupon)1 Coupon (com.whoiszxl.entity.Coupon)1