package com.fs.app.controller;

import com.fs.common.core.domain.R;
import com.fs.store.domain.*;
import com.fs.store.service.*;
import com.fs.store.vo.FsStoreProductActivityListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api("活动接口")
@RestController
@RequestMapping(value="/app/activity")
public class StoreActivityController extends AppBaseController {

    @Autowired
    private IFsStoreActivityService activityService;

    @Autowired
    private IFsStoreProductService productService;

    @ApiOperation("获取活动")
    @GetMapping("/getStoreActivity")
    public R getStoreActivity(){
        FsStoreActivity activity=activityService.selectFsStoreActivityByTop();
        return R.ok().put("activity",activity);
    }

    @ApiOperation("获取活动详情")
    @GetMapping("/getStoreActivityDetails")
    public R getStoreActivityDetails(@RequestParam(value = "activityId")Long activityId){
        FsStoreActivity activity=activityService.selectFsStoreActivityById(activityId);
        List<FsStoreProductActivityListVO> products=productService.selectFsStoreProductByIds(activity.getProductIds());
        return R.ok().put("activity",activity).put("products",products);
    }

    @ApiOperation("分享")
    @PostMapping("/share")
    public R share(@RequestParam(value = "activityId")Long activityId){
        activityService.addShare(activityId);
        return R.ok();
    }

}
