package com.cool.store.controller.webb;

import com.cool.store.request.AddShopRequest;
import com.cool.store.request.DeleteShopRequest;
import com.cool.store.request.UpdateShopCodeRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.ShopService;
import com.cool.store.vo.shop.MiniShopPageVO;
import com.cool.store.vo.shop.ShopStageInfoVO;
import com.cool.store.vo.shop.StageShopCountVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhangchenbiao
 * @FileName: PCShopController
 * @Description:
 * @date 2024-04-16 14:44
 */
@Api(tags = "pc店铺")
@RestController
@RequestMapping("/pc/shop")
public class PCShopController {

    @Resource
    private ShopService shopService;

    @ApiOperation("获取店铺列表")
    @GetMapping("/getShopList")
    public ResponseResult<List<MiniShopPageVO>> getShopList(@RequestParam("lineId")Long lineId) {
        return ResponseResult.success(shopService.getShopList(lineId));
    }

    @ApiOperation("获取各个阶段店铺数量")
    @GetMapping("/getStageShopCount")
    public ResponseResult<StageShopCountVO> getStageShopCount(@RequestParam("lineId")Long lineId) {
        return ResponseResult.success(shopService.getStageShopCount(lineId));
    }

    @ApiOperation("获取店铺的阶段信息")
    @GetMapping("/getShopStageInfo")
    public ResponseResult<List<ShopStageInfoVO>> getShopStageInfo(@RequestParam("shopId")Long shopId, @RequestParam(value = "shopStage", required = false)Integer shopStage) {
        return ResponseResult.success(shopService.getShopStageInfo(shopId, shopStage));
    }

    @ApiOperation("删除店铺")
    @PostMapping("/deleteShop")
    public ResponseResult<Integer> deleteShop(@RequestBody @Validated DeleteShopRequest request) {
        return ResponseResult.success(shopService.deleteShop(request));
    }

    @ApiOperation("新增店铺")
    @PostMapping("/addShop")
    public ResponseResult<Long> addShop(@RequestBody @Validated AddShopRequest request) {
        return ResponseResult.success(shopService.addShop(request));
    }

    @ApiOperation("修改门店编号")
    @PostMapping("/updateShopCode")
    public ResponseResult<Integer> updateShopCode(@RequestBody @Validated UpdateShopCodeRequest request) {
        return ResponseResult.success(shopService.updateShopCode(request));
    }

}
