package cn.superdesk.uniorder.controller.accounting.qchjc;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dto.param.accounting.qchjc.QchjcCustomerAccountingListRequest;
import cn.superdesk.uniorder.dto.param.accounting.qchjc.RemarkParam;
import cn.superdesk.uniorder.dto.vo._function.select.SelectOptionVirt;
import cn.superdesk.uniorder.dto.vo.thirdpart.qchjc.accounting.QchjcCustomerStatementVo;
import cn.superdesk.uniorder.dubbo.consumer.accounting.qchjc.QchjcCustomerAccountingDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author xc
 * @description 企业商城账单-采购单位账单
 * @date 2022/4/14 20:02
 */
@Api(value = "企业商城账单-采购单位账单", tags = "企业商城账单-采购单位账单")
@RestController
@RequestMapping("/accounting/qchjc/customer/statement")
@RequiredArgsConstructor
@Slf4j
public class QchjcCustomerAccountingController {

    private final QchjcCustomerAccountingDubboService qchjcCustomerAccountingDubboService;

    @ApiOperation(value = "企业商城账单-采购单位账单列表", notes = "企业商城账单-采购单位账单列表")
    @PostMapping("/list")
    public R<List<QchjcCustomerStatementVo>> list(@RequestBody @Validated QchjcCustomerAccountingListRequest request) {
        log.info("企业商城账单-采购单位账单列表，request={}", request);

        return qchjcCustomerAccountingDubboService.list(request);
    }

    @ApiOperation(value = "采购单位账单添加备注")
    @PostMapping("/addRemark")
    public R<String> remark(@RequestBody @Validated RemarkParam param, HttpServletRequest request) {
        String token = request.getHeader("token");
        log.info("采购单位账单添加备注，id={},remark={}", param.getId(),param.getRemark());
        return qchjcCustomerAccountingDubboService.remark(param.getId(),param.getRemark(),token);
    }

    @ApiOperation(value = "根据id查询采购单位账单详情")
    @PostMapping("/{id}")
    public R<QchjcCustomerStatementVo> get(@Validated @PathVariable("id") Long id) {
        log.info("根据id查询采购单位账单详情，id={}", id);
        return qchjcCustomerAccountingDubboService.get(id);
    }

    @ApiOperation(value = "查询集采采购单位下拉列表")
    @PostMapping("/getCustomerList")
    public R<List<SelectOptionVirt>> getCustomerList() {
        return qchjcCustomerAccountingDubboService.getCustomerList();
    }
}
