package com.cool.store.controller.webb;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.request.AuditOpenNewShopRequest;
import com.cool.store.request.PartnerOpenNewShopPageRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.OpenNewShopService;
import com.cool.store.vo.PartnerOpenNewShopDetailVO;
import com.cool.store.vo.PartnerOpenNewShopPageVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

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

    @Resource
    private OpenNewShopService openNewShopService;

    @ApiOperation("获取老加盟商开新店列表")
    @PostMapping("/getPartnerOpenNewShopPage")
    public ResponseResult<PageInfo<PartnerOpenNewShopPageVO>> getPartnerOpenNewShopPage(@RequestBody PartnerOpenNewShopPageRequest request) {
        request.setInvestmentManager(CurrentUserHolder.getUserId());
        return ResponseResult.success(openNewShopService.getPartnerOpenNewShopPage(request));
    }

    @ApiOperation("获取详情")
    @GetMapping("/getOpenNewShopRecordDetail")
    public ResponseResult<PartnerOpenNewShopDetailVO> getOpenNewShopRecordDetail(@RequestParam("recordId") Long recordId) {
        return ResponseResult.success(openNewShopService.getOpenNewShopRecordDetail(recordId));
    }

    @ApiOperation("审核")
    @PostMapping("/auditOpenNewShop")
    public ResponseResult<Integer> auditOpenNewShop(@RequestBody @Validated AuditOpenNewShopRequest request) {
        return ResponseResult.success(openNewShopService.auditOpenNewShop(request));
    }

}
