package com.sqx.modules.activity.controller.app;

import com.sqx.common.utils.Constant;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.activity.dto.ActivityQueryDTO;
import com.sqx.modules.activity.service.ActivityService;
import com.sqx.modules.activity.vo.OrderSuitActivityVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 活动
 * @author : codingliang
 * @date : 2024-6-17
 */
@Api(tags = "活动-app活动信息")
@RestController
@RequestMapping("app/activity")
@RequiredArgsConstructor
public class AppActivityController {

    private final ActivityService activityService;

    @GetMapping("page")
    @ApiOperation(value = "获取活动信息分页", response = PageUtils.class, notes="enableFlag、allowShop搜索条件无效")
    public Result page(@Valid ActivityQueryDTO queryDTO) {
        queryDTO.setAllowShop(null);
        queryDTO.setEnableFlag(Constant.YES);
        PageUtils page = activityService.pageActivity(queryDTO);
        return Result.success().put("data", page);
    }

    @GetMapping("suit-activity/{orderId}")
    @ApiOperation(value = "获取适用的活动列表")
    public Result getOrderSuitActivity(@PathVariable @ApiParam("订单id") Long orderId) {
        List<OrderSuitActivityVO> suitActivityVOList = activityService.getOrderSuitActivity(orderId);
        return Result.success().put("data", suitActivityVOList);
    }
}
