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

import javax.validation.Valid;

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.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.business.PendingReceiptDTO;
import com.prolog.rdc.tms.app.model.vo.business.PendingReceiptConfirmVO;
import com.prolog.rdc.tms.app.model.vo.business.PendingReceiptQueryVO;
import com.prolog.rdc.tms.app.service.business.PendingReceiptService;

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

/**
 * @author hongbo.pan
 * @date 2023/1/12
 */
@RestController
@Api(tags = "待回单控制层")
@RequestMapping("/pendingReceipt")
public class PendingReceiptController {

    @Autowired
    private PendingReceiptService pendingReceiptService;

    @UserLog("回单查询")
    @ApiOperation(value = "回单查询", notes = "回单查询")
    @PostMapping("/findByCondition")
    public RestMessage<Page<PendingReceiptDTO>> findByCondition(@RequestBody @Valid PendingReceiptQueryVO vo) {
        return RestMessage.newInstance(true, "查询成功！", pendingReceiptService.findByCondition(vo));
    }

    @UserLog("回单确认")
    @ApiOperation(value = "回单确认", notes = "回单确认")
    @PostMapping("/confirm")
	public RestMessage<Object> confirm(@RequestBody @Valid PendingReceiptConfirmVO vo) {
        pendingReceiptService.confirm(vo);
        return RestMessage.newInstance(true, "操作成功！", null);
    }
}
