package com.starry.admin.modules.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.modules.order.module.vo.PlayOrderContinueQueryVo;
import com.starry.admin.modules.order.module.vo.PlayOrderContinueReturnVo;
import com.starry.admin.modules.order.module.vo.PlayOrderReviewStateEditVo;
import com.starry.admin.modules.order.service.IPlayOrderContinueInfoService;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单续单信息Controller
 *
 * @author admin
 * @since 2024-05-10
 */
@Api(tags = "订单续单管理", description = "订单续单信息管理相关接口，包括查询和审核等操作")
@RestController
@RequestMapping("/order/continue")
public class PlayOrderContinueInfoController {
    @Resource
    private IPlayOrderContinueInfoService playOrderContinueInfoService;

    /**
     * 查询订单续单信息列表
     */
    @ApiOperation(value = "分页查询续单列表", notes = "分页查询订单续单信息列表")
    @ApiResponses({
            @ApiResponse(code = 200, message = "操作成功", response = PlayOrderContinueReturnVo.class, responseContainer = "Page")})
    @PostMapping("/listByPage")
    public R list(@ApiParam(value = "查询条件", required = true) @Validated @RequestBody PlayOrderContinueQueryVo vo) {
        IPage<PlayOrderContinueReturnVo> list = playOrderContinueInfoService.selectPlayByPage(vo);
        return R.ok(list);
    }

    /**
     * 审批续单申申请
     */
    @ApiOperation(value = "审批续单申请", notes = "审核店员的续单申请")
    @ApiResponses({@ApiResponse(code = 200, message = "审批成功"), @ApiResponse(code = 500, message = "审批失败")})
    // @PreAuthorize("@customSs.hasPermission('order:continue:update')")
    @PostMapping("/updateReviewState")
    public R updateReviewState(
            @ApiParam(value = "审批信息", required = true) @Validated @RequestBody PlayOrderReviewStateEditVo vo) {
        playOrderContinueInfoService.updateReviewState(vo);
        return R.ok("成功");
    }
}
