package com.cool.store.controller.webb;

import com.cool.store.request.visit.*;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.visit.StoreVisitReservationService;
import com.cool.store.vo.visit.StoreVisitReservationVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "预约到店管理")
@RestController
@RequestMapping("/pc/storeVisitReservation")
@RequiredArgsConstructor
public class StoreVisitReservationController {

    private final StoreVisitReservationService storeVisitReservationService;

    @ApiOperation("列表查询")
    @PostMapping("/page")
    public ResponseResult<PageInfo<StoreVisitReservationVO>> page(@RequestBody StoreVisitReservationAdminQueryRequest request) {
        return ResponseResult.success(storeVisitReservationService.adminPage(request));
    }

    @ApiOperation("标记已到店")
    @PostMapping("/arrived")
    public ResponseResult<Boolean> arrived(@RequestBody @Validated StoreVisitReservationIdRequest request) {
        return ResponseResult.success(storeVisitReservationService.arrived(request));
    }

    @ApiOperation("分配服务人员")
    @PostMapping("/assignServiceUser")
    public ResponseResult<Boolean> assignServiceUser(@RequestBody @Validated StoreVisitReservationAssignServiceRequest request) {
        return ResponseResult.success(storeVisitReservationService.assignServiceUser(request));
    }

    @ApiOperation("取消预约")
    @PostMapping("/cancel")
    public ResponseResult<Boolean> cancel(@RequestBody @Validated StoreVisitReservationCancelRequest request) {
        return ResponseResult.success(storeVisitReservationService.cancel(request));
    }
}
