package com.prolog.rdc.tms.app.controller.business;

import com.prolog.rdc.tms.app.model.dto.business.ScanQRByLoadingBillDTO;
import com.prolog.rdc.tms.app.model.dto.business.ScanQRDTO;
import com.prolog.rdc.tms.app.model.vo.business.ScanQRByLoadingBillVO;
import com.prolog.rdc.tms.app.model.vo.business.ScanQRVO;
import org.springframework.beans.factory.annotation.Autowired;
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;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.business.FrontPageStatisticalDTO;
import com.prolog.rdc.tms.app.service.business.FrontPageService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.validation.Valid;

/**
 * 业务APP-首页控制层
 * <p>
 * Company: 湖北普罗格科技股份有限公司
 *
 * @author zhangsj
 * @since 2022/7/15 10:56
 */
@RestController
@Api(tags = "业务APP-首页控制层")
@RequestMapping("/frontPage")
public class FrontPageController {

    @Autowired
    private FrontPageService frontPageService;

    @UserLog("统计查询")
    @ApiOperation(value = "统计查询", notes = "统计查询")
    @PostMapping("/statistical")
    public RestMessage<FrontPageStatisticalDTO> statisticalExecute() {
        FrontPageStatisticalDTO dto = frontPageService.statisticalData();
        return RestMessage.newInstance(true, "查询成功！", dto);
    }

    @UserLog("扫描运单二维码跳转预约取号界面")
    @ApiOperation(value = "扫描运单二维码跳转预约取号界面", notes = "扫描运单二维码跳转预约取号界面")
    @PostMapping("/scanQR")
    public RestMessage<ScanQRDTO> scanQR(@RequestBody @Valid ScanQRVO vo) throws Exception{
        ScanQRDTO dto = frontPageService.scanQR(vo.getShipbillNo());
        return RestMessage.newInstance(true, "操作成功！", dto);
    }

    @UserLog("扫描派车单二维码跳转预约取号界面")
    @ApiOperation(value = "扫描派车单二维码跳转预约取号界面", notes = "扫描派车单二维码跳转预约取号界面")
    @PostMapping("/scanQRByLoadingBill")
    public RestMessage<ScanQRByLoadingBillDTO> scanQRByLoadingBill(@RequestBody @Valid ScanQRByLoadingBillVO vo) {
        ScanQRByLoadingBillDTO dto = frontPageService.scanQRByLoadingBill(vo.getLoadingBillNo());
        return RestMessage.newInstance(true, "操作成功！", dto);
    }

}
