package com.cool.store.controller.webb;

import com.cool.store.request.close.file.*;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.close.CloseStoreFileService;
import com.cool.store.vo.close.file.CloseStoreFileDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 闭店材料 前端控制器
 * </p>
 *
 * @author wangff
 * @since 2025/10/7
 */
@Api(tags = "闭店材料")
@RestController
@RequestMapping("/pc/close/file")
@RequiredArgsConstructor
@Validated
public class CloseStoreFileController {
    private final CloseStoreFileService closeStoreFileService;

    @ApiOperation("更新材料邮寄地址")
    @PostMapping("/updateMailAddress")
    public ResponseResult<Boolean> updateMailAddress(@RequestBody @Valid CloseStoreMailAddressRequest request) {
        return ResponseResult.success(closeStoreFileService.updateMailAddress(request));
    }

    @ApiOperation("查询闭店材料详情")
    @GetMapping("/detail")
    @ApiImplicitParam(name = "closeStoreId", value = "闭店申请id", required = true, dataType = "Long")
    public ResponseResult<CloseStoreFileDetailVO> getFileDetail(@NotNull(message = "闭店申请id不能为空") Long closeStoreId) {
        return ResponseResult.success(closeStoreFileService.getFileDetail(closeStoreId));
    }

    @ApiOperation("提交材料")
    @PostMapping("/submitFile")
    public ResponseResult<Boolean> submitFile(@RequestBody @Valid CloseStoreMailInfoRequest request) {
        return ResponseResult.success(closeStoreFileService.submitFile(request));
    }

    @ApiOperation("修改单个材料")
    @PostMapping("/updateFile")
    public ResponseResult<Boolean> updateFile(@RequestBody @Valid CloseStoreFileSubmitRequest request) {
        return ResponseResult.success(closeStoreFileService.updateFile(request));
    }

    @ApiOperation("单个材料提交审批")
    @PostMapping("/submitFileApproveSingle")
    public ResponseResult<Boolean> submitFileApproveSingle(@RequestBody @Valid CloseStoreFileInfoRequest request) {
        return ResponseResult.success(closeStoreFileService.submitFileApproveSingle(request));
    }

    @ApiOperation("督导审批")
    @PostMapping("/supervisionAudit")
    public ResponseResult<Boolean> supervisionAudit(@RequestBody @Valid CloseStoreFileAuditRequest request) {
        return ResponseResult.success(closeStoreFileService.supervisionAudit(request));
    }
}
