package com.cool.store.controller.webb;

import com.cool.store.request.closeup.CloseUpAuditRequest;
import com.cool.store.request.closeup.CloseUpPlatformHandleRequest;
import com.cool.store.request.closeup.CloseUpQueryRequest;
import com.cool.store.request.closeup.CloseUpTodoQueryRequest;
import com.cool.store.response.AuditInfoResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.closeup.CloseUpService;
import com.cool.store.vo.closeup.CloseUpApplyFormSimpleVO;
import com.cool.store.vo.closeup.CloseUpApplyFormVO;
import com.cool.store.vo.closeup.CloseUpPlatformVO;
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.*;

import java.util.List;

/**
 * <p>
 * 歇业管理 前端控制器
 * </p>
 *
 * @author wangff
 * @since 2026/4/8
 */
@Api(tags = "歇业管理")
@RestController
@RequestMapping("/pc/closeup")
@RequiredArgsConstructor
@Validated
public class CloseUpController {
    private final CloseUpService closeUpService;

    @ApiOperation("H5歇业开业待办")
    @PostMapping("/todoList")
    public ResponseResult<PageInfo<CloseUpApplyFormSimpleVO>> todoList(@RequestBody @Validated CloseUpTodoQueryRequest request) {
        return ResponseResult.success(closeUpService.todoList(request));
    }

    @ApiOperation("开业歇业申请列表")
    @PostMapping("/applyList")
    public ResponseResult<PageInfo<CloseUpApplyFormSimpleVO>> applyList(@RequestBody @Validated CloseUpQueryRequest request) {
        return ResponseResult.success(closeUpService.applyList(request));
    }

    @ApiOperation("申请单详情")
    @GetMapping("/detail")
    public ResponseResult<CloseUpApplyFormVO> getDetail(@RequestParam("applyId") Long applyId) {
        return ResponseResult.success(closeUpService.getDetail(applyId));
    }

    @ApiOperation("审批通过")
    @PostMapping("/auditPass")
    public ResponseResult<Boolean> auditPass(@RequestBody @Validated CloseUpAuditRequest request) {
        return ResponseResult.success(closeUpService.auditPass(request));
    }

    @ApiOperation("审批拒绝")
    @PostMapping("/auditRejected")
    public ResponseResult<Boolean> auditRefuse(@RequestBody @Validated CloseUpAuditRequest request) {
        return ResponseResult.success(closeUpService.auditRejected(request));
    }

    @ApiOperation("查询平台账号列表")
    @GetMapping("/platformList")
    public ResponseResult<List<CloseUpPlatformVO>> getPlatformList(@RequestParam("applyId") Long applyId) {
        return ResponseResult.success(closeUpService.getPlatformListByApplyId(applyId));
    }

    @ApiOperation("查询审批记录")
    @GetMapping("/auditRecordList")
    public ResponseResult<List<AuditInfoResponse>> getAuditRecordList(@RequestParam("applyId") Long applyId) {
        return ResponseResult.success(closeUpService.getAuditRecordList(applyId));
    }

    @ApiOperation("平台待办记录-工作台")
    @GetMapping("/platformTodoList")
    public ResponseResult<PageInfo<CloseUpApplyFormSimpleVO>> getPlatformTodoList(@Validated CloseUpTodoQueryRequest request) {
        return ResponseResult.success(closeUpService.getPlatformTodoList(request));
    }

    @ApiOperation("平台关闭开启处理")
    @PostMapping("/handlePlatform")
public ResponseResult<Boolean> handlePlatform(@RequestBody @Validated CloseUpPlatformHandleRequest request) {
        return ResponseResult.success(closeUpService.handlePlatform(request));
    }
}
