package shop.alien.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.LifeBrandedCard;
import shop.alien.entity.store.StoreInfo;
import shop.alien.entity.store.vo.LifeBrandedCardVo;
import shop.alien.entity.store.vo.LifeCouponVo;
import shop.alien.store.service.PlatformBrandedCardService;

import java.util.List;

@Api(tags = {"平台-联名卡管理"})
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/platformBrandedCard")
@RequiredArgsConstructor
public class PlatformBrandedCardController {

    private final PlatformBrandedCardService platformBrandedCardService;

    @ApiOperation("联名卡列表")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "name", value = "联名卡名称", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", dataType = "String", paramType = "query")})
    @GetMapping("/getBrandedCardList")
    public R<IPage<LifeBrandedCard>> getBrandedCardList(Integer page, Integer size, String name, String status) {
        return R.data(platformBrandedCardService.getBrandedCardList(page, size, name, status));
    }

    @ApiOperation("下架联名卡")
    @ApiOperationSupport(order = 2)
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query", required = true)})
    @GetMapping("/removeShelf")
    public R<Integer> removeShelf(Integer id) {
        return R.data(platformBrandedCardService.removeShelf(id));
    }

    @ApiOperation("上架联名卡")
    @ApiOperationSupport(order = 2)
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query", required = true)})
    @GetMapping("/putawayShelf")
    public R<Integer> putawayShelf(Integer id) {
        return R.data(platformBrandedCardService.putawayShelf(id));
    }

    @ApiOperation("删除联名卡")
    @ApiOperationSupport(order = 3)
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query", required = true)})
    @GetMapping("/deleteById")
    public R<Integer> deleteById(Integer id) {
        return R.data(platformBrandedCardService.deleteById(id));
    }

    @ApiOperation("商家列表")
    @ApiOperationSupport(order = 4)
    @ApiImplicitParams({@ApiImplicitParam(name = "storeName", value = "商家名称", dataType = "String", paramType = "query")})
    @GetMapping("/getStoreList")
    public R<List<StoreInfo>> getStoreList(String storeName) {
        return R.data(platformBrandedCardService.getStoreList(storeName));
    }

    @ApiOperation("套餐列表")
    @ApiOperationSupport(order = 5)
    @ApiImplicitParams({@ApiImplicitParam(name = "storeIds", value = "商家ids", dataType = "List<String>", paramType = "query", required = true)})
    @GetMapping("/getQuanListByStoreId")
    public R<List<LifeCouponVo>> getQuanListByStoreId(String storeIds) {
        return R.data(platformBrandedCardService.getQuanListByStoreId(storeIds));
    }

    @ApiOperation("新增联名卡")
    @ApiOperationSupport(order = 6)
    @ApiImplicitParams({@ApiImplicitParam(name = "multipartRequest", value = "图片", dataType = "MultipartRequest", paramType = "query")})
    @PostMapping("/saveBrandedCard")
    public R<Boolean> saveBrandedCard(@RequestBody LifeBrandedCardVo brandedCard) {
        return R.data(platformBrandedCardService.saveBrandedCard(brandedCard));
    }

    @ApiOperation("联名卡详情")
    @ApiOperationSupport(order = 7)
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "Integer", paramType = "query", required = true)})
    @GetMapping("/getBrandedCardDetail")
    public R<LifeBrandedCardVo> getBrandedCardDetail(Integer id) {
        return R.data(platformBrandedCardService.getBrandedCardDetail(id));
    }
}
