package com.cool.store.controller.webc;

import com.cool.store.request.close.file.CloseStoreFileSubmitRequest;
import com.cool.store.request.close.file.CloseStoreMailInfoRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.close.CloseStoreFileService;
import com.cool.store.vo.close.file.CloseStoreFileDetailMiniVO;
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 = "mini闭店材料")
@RestController
@RequestMapping("/mini/close/file")
@RequiredArgsConstructor
@Validated
public class MiniCloseStoreFileController {
    private final CloseStoreFileService closeStoreFileService;

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