package com.cool.store.controller.webb;

import com.cool.store.request.IdRequest;
import com.cool.store.request.NewStoreOpeningRequest;
import com.cool.store.request.OpenAcceptanceRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.NewStoreOpeningService;
import com.cool.store.service.OpenAcceptanceInfoService;
import com.cool.store.vo.NewStoreOpeningVO;
import com.cool.store.vo.OpenAcceptanceInfoListVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * @Author byd
 * @Date 2023/6/15 9:49
 * @Version 1.0
 */
@RestController
@RequestMapping("pc/newStoreOpening")
@Api(tags = "PC新店开业")
public class NewStoreOpeningController {

    @Resource
    OpenAcceptanceInfoService openAcceptanceInfoService;

    @Resource
    NewStoreOpeningService newStoreOpeningService;

    @GetMapping(path = "/newStoreOpeningList")
    @ApiOperation("新店开业列表")
    public ResponseResult<PageInfo<OpenAcceptanceInfoListVO>> newStoreOpeningList(OpenAcceptanceRequest openAcceptanceRequest) {
        //已验收
        openAcceptanceRequest.setAcceptanceStatus(1);
        return ResponseResult.success(openAcceptanceInfoService.openAcceptanceList(openAcceptanceRequest));
    }

    @GetMapping(path = "/storeTodoList")
    @ApiOperation("新店开业待办列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "shopId", value = "店铺id", required = true)
    })
    public ResponseResult<List<NewStoreOpeningVO>> storeTodoList(@RequestParam("shopId") Long shopId) {
        return ResponseResult.success(newStoreOpeningService.storeTodoList(shopId));
    }


    @PostMapping(path = "/addStoreTodo")
    @ApiOperation("新店开业-新建待办")
    public ResponseResult<Boolean> addStoreTodo(@RequestBody NewStoreOpeningRequest newStoreOpeningRequest) {
        newStoreOpeningService.addStoreTodo(newStoreOpeningRequest);
        return ResponseResult.success(Boolean.TRUE);
    }

    @PostMapping(path = "/removeStoreTodo")
    @ApiOperation("新店开业-删除待办")
    public ResponseResult<Boolean> removeStoreTodo(@RequestBody IdRequest idRequest) {
        newStoreOpeningService.removeStoreTodo(idRequest.getId());
        return ResponseResult.success(Boolean.TRUE);
    }
}
