package com.sqx.modules.activityManage.controller;


import com.sqx.common.utils.Result;
import com.sqx.modules.activityManage.entity.ActivityManage;
import com.sqx.modules.activityManage.service.ActivityManageService;
import com.sqx.modules.goods.entity.GoodsShop;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 活动管理
 * </p>
 *
 * @author 吴畅
 * @since 2022-11-04
 */
@RestController
@RequestMapping("/admin/activityManage/")
public class AdminActivityManageController {
    @Autowired
    private ActivityManageService activityManageService;

    @PostMapping("addActivity")
    @ApiOperation("添加活动")
    public Result addActivity(ActivityManage activityManage) {
        return activityManageService.addActivity(activityManage);
    }

    @PostMapping("updateActivity")
    @ApiOperation("修改活动")
    public Result updateActivity(ActivityManage activityManage) {
        return activityManageService.updateActivity(activityManage);
    }

    @PostMapping("deleteActivity")
    @ApiOperation("删除活动")
    public Result deleteActivity(Long activityId) {
        return activityManageService.deleteActivity(activityId);
    }

    @GetMapping("getActivityList")
    @ApiOperation("获取活动列表")
    public Result getActivityList(Integer page, Integer limit, ActivityManage activityManage) {
        return Result.success().put("data", activityManageService.getActivityList(page, limit, activityManage));
    }
    @GetMapping("getActivityInfo")
    @ApiOperation("获取活动信息")
    public Result getActivityInfo(Long activityId){
        return Result.success().put("data", activityManageService.getActivityInfo(activityId));

    }
    @GetMapping("getShoActivityShopList")
    @ApiOperation("根据活动查找商家列表")
    public Result getShoActivityShopList(Integer page, Integer limit, GoodsShop goodsShop) {
        return Result.success().put("data", activityManageService.getAdminShoActivityShopList(page, limit, goodsShop));
    }
    @GetMapping("cancelActivityShop")
    @ApiOperation("删除活动中的商家")
    public Result cancelActivityShop(Long activityId,Long shopId){
        return activityManageService.cancelActivityShop(activityId,shopId);
    }
    @GetMapping("shopJoinActivity")
    @ApiOperation("将商家加入活动")
    private Result shopJoinActivity(Long shopId, Long activityId) {
        return activityManageService.shopJoinActivity(shopId, activityId,1);
    }
}

