package com.cool.store.controller.webc;

import com.cool.store.request.closeup.CloseUpApplyRequest;
import com.cool.store.request.closeup.CloseUpApplySimpleQueryRequest;
import com.cool.store.request.closeup.CloseUpOpenApplyRequest;
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.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.*;

/**
 * <p>
 * Mini歇业管理
 * </p>
 *
 * @author wangff
 * @since 2026/4/8
 */
@Api(tags = "Mini歇业管理")
@RestController
@RequestMapping("/mini/closeup")
@RequiredArgsConstructor
@Validated
public class MiniCloseUpController {
    private final CloseUpService closeUpService;

    @ApiOperation("歇业申请")
    @PostMapping("/apply")
    public ResponseResult<Boolean> closeUpApply(@RequestBody @Validated CloseUpApplyRequest request) {
        return ResponseResult.success(closeUpService.closeUpApply(request));
    }

    @ApiOperation("恢复营业申请")
    @PostMapping("/openApply")
    public ResponseResult<Boolean> openApply(@RequestBody @Validated CloseUpOpenApplyRequest request) {
        return ResponseResult.success(closeUpService.openApply(request));
    }

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

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