package com.xxfc.platform.tour.rest;

import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.annotation.BeanValid;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.tour.biz.TourGoodVerificationBiz;
import com.xxfc.platform.tour.entity.TourGoodVerification;
import com.xxfc.platform.tour.vo.TourGoodOrderFindVo;
import com.xxfc.platform.tour.vo.TourGoodOrderVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/tourGood/verfication")
@IgnoreClientToken
public class TourGoodVerificationController extends BaseController<TourGoodVerificationBiz, TourGoodVerification> {
    /**
     * 查询订单列表
     * @param tourGoodOrderFindVo
     * @return
     */
    @ApiOperation("订单列表的查询")
    @GetMapping("/orders")
    public ObjectRestResponse<PageDataVO<TourGoodOrderVo>> findTourGoodOrders(@BeanValid TourGoodOrderFindVo tourGoodOrderFindVo){
        PageDataVO<TourGoodOrderVo> tourGoodOrderPageDataVo = getBaseBiz().findTourGoodOrdersPage(tourGoodOrderFindVo);
        return ObjectRestResponse.succ(tourGoodOrderPageDataVo);
    }


    /**
     * 更新发车状态
     * @param verficationId
     * @return
     */
    @PutMapping("/status")
    @ApiOperation("更新发车状态")
    public ObjectRestResponse<Void> updateTourGoodVerificationStatus(@RequestParam("verficationId") Integer verficationId){
        int effectRows = getBaseBiz().updateTourGoodVerificationStatus(verficationId);
        if (effectRows>0){
            return ObjectRestResponse.succ();
        }
        return ObjectRestResponse.createDefaultFail();
    }


    /**
     * 更新总人数或上车人数
     * @param verficationId
     * @param properties
     * @return
     */
    @PutMapping("/personnums")
    @ApiOperation("更新总人数或上车人数")
    public ObjectRestResponse<Void> updateTourGoodPersonNum(@RequestParam("verficationId") Integer verficationId,@RequestParam("properties") String properties){
        int effectRows = getBaseBiz().updateTourGoodPersonNum(verficationId,properties);
            if (effectRows>0){
            return ObjectRestResponse.succ();
        }
        return ObjectRestResponse.createDefaultFail();
    }
}