package com.cool.store.controller.webc;

import com.cool.store.context.PartnerUserHolder;
import com.cool.store.request.SubmitOpenNewShopRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.OpenNewShopService;
import com.cool.store.vo.IsSubmitOpenNewShopVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author zhangchenbiao
 * @FileName: PCOpenNewShopController
 * @Description:
 * @date 2024-05-09 15:08
 */
@RestController
@RequestMapping("/mini/open/new/shop")
@Api(tags = "小程序-老加盟商开新店")
@Slf4j
public class MiniOpenNewShopController {

    @Resource
    private OpenNewShopService openNewShopService;

    @ApiOperation("开新店")
    @PostMapping("/submitOpenNewShop")
    public ResponseResult<Long> submitOpenNewShop(@RequestBody SubmitOpenNewShopRequest request) {
        request.setLineId(PartnerUserHolder.getUser().getLineId());
        return ResponseResult.success(openNewShopService.submitOpenNewShop(request));
    }

    @ApiOperation("获取是否可提交开新店申请")
    @GetMapping("/isSubmitOpenNewShop")
    public ResponseResult<IsSubmitOpenNewShopVO> isSubmitOpenNewShop() {
        return ResponseResult.success(openNewShopService.isSubmitOpenNewShop(PartnerUserHolder.getUser().getLineId()));
    }

}
