package com.yh.saas.plugin.yiliangyiyun.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.yh.saas.plugin.yiliangyiyun.entity.CollectionWarehousingRecord;
import com.yh.saas.plugin.yiliangyiyun.service.ICollectionWarehousingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 代收入库记录 前端控制器
 * </p>
 *
 * @author Gdc
 * @since 2022-01-12
 */
@RestController
@RequestMapping("/collectionWarehousingRecord")
public class CollectionWarehousingRecordController {

    @Autowired
    private ICollectionWarehousingRecordService collectionWarehousingRecordService;

    /**
     * 新增信息
     * @return
     */
    @PostMapping("/api/insertCollectionWarehousingRecord")
    public String insertCollectionWarehousingRecord(@RequestBody @Valid CollectionWarehousingRecord collectionWarehousingRecord) {
        return collectionWarehousingRecordService.insertCollectionWarehousingRecord(collectionWarehousingRecord);
    }

    /**
     * 编辑合同信息
     */
    @PostMapping("/editCollectionWarehousingRecord")
    public String editCollectionWarehousingRecord(@RequestBody CollectionWarehousingRecord collectionWarehousingRecord) {
        return collectionWarehousingRecordService.editCollectionWarehousingRecord(collectionWarehousingRecord);
    }

    /**
     * 查看信息
     */
    @GetMapping("/getCollectionWarehousingRecord")
    public CollectionWarehousingRecord getCollectionWarehousingRecord(@RequestParam String id) {
        return collectionWarehousingRecordService.getCollectionWarehousingRecord(id);
    }

    /**
     * 信息分页列表查询
     *
     * @param collectionWarehousingRecord
     * @return
     */
    @GetMapping("/selectCollectionWarehousingRecordPage")
    public Page<CollectionWarehousingRecord> selectCollectionWarehousingRecordPage(CollectionWarehousingRecord collectionWarehousingRecord) {
        return collectionWarehousingRecordService.selectCollectionWarehousingRecordPage(collectionWarehousingRecord);
    }




    /**
     * 删除
     *
     * @param example
     * @return
     */
    @PostMapping("/deleteCollectionWarehousingRecord")
    public void deleteCollectionWarehousingRecord(@RequestBody  CollectionWarehousingRecord example) {
        collectionWarehousingRecordService.deleteCollectionWarehousingRecord(example.getId());
    }
    /**
     * 导出
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/export")
    public void export(@RequestBody CollectionWarehousingRecord example, HttpServletResponse response) throws Exception {
        collectionWarehousingRecordService.export(example,response);
    }
    /**
     * 批量开发票
     * @param collectionWarehousingRecord
     * @return
     */
    @PostMapping("/api/openInvoiceList")
    public String openInvoiceList(@RequestBody CollectionWarehousingRecord collectionWarehousingRecord) {
        return collectionWarehousingRecordService.openInvoiceList(collectionWarehousingRecord);
    }
    /**
     * 付款
     * @param collectionWarehousingRecord
     * @return
     */
    @PostMapping("/api/payMoney")
    public String payMoney(@RequestBody CollectionWarehousingRecord collectionWarehousingRecord){
        return collectionWarehousingRecordService.payMoney(collectionWarehousingRecord);
    }
    /**
     * 收款
     * @param collectionWarehousingRecord
     * @return
     */
    @PostMapping("/api/collectMoney")
    public String collectMoney(@RequestBody CollectionWarehousingRecord collectionWarehousingRecord){
        return collectionWarehousingRecordService.collectMoney(collectionWarehousingRecord);
    }
}

