package com.zcloud.modules.invoicing.controller;

import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.utils.*;
import com.zcloud.modules.invoicing.entity.BusInvoicingEntity;
import com.zcloud.modules.invoicing.service.BusInvoicingService;
import com.zcloud.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;
import java.util.Map;

/**
 * @Author lizenan
 * @Desc 开票管理表(BusInvoicing)表控制层
 * @Date 2024-04-03 15:15:37
 */
@Api(tags = "发票抬头管理表")
@RestController
@RequestMapping("busInvoicing")
public class BusInvoicingController extends AbstractController {

    @Autowired
    private BusInvoicingService busInvoicingService;

    @ApiOperation("开票管理表-新增数据")
    @SysLog("开票管理表-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusInvoicingEntity param) throws Exception {
        param.setCreator(getUserId());
		param.setOperator(getUserId());
        param.setApplyTime(new Date());
        param.setStatus(0);
//        busInvoicingService.insert(param);

        return R.ok();
    }


    @ApiOperation("开票管理表-编辑数据")
    @SysLog("开票管理表-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusInvoicingEntity param) throws Exception {
        param.setOperator(getUserId());
        param.setApplyTime(new Date());
        busInvoicingService.update(param);

        return R.ok();
    }


    @ApiOperation("开票管理表-删除数据")
    @SysLog("开票管理表-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusInvoicingEntity param) {
        busInvoicingService.delete(param.getInvoicingId(),getUserId());
        return R.ok();
    }

    @ApiOperation("开票管理表-分页查询")
    @SysLog("开票管理表-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = busInvoicingService.listPage(params);

		return R.ok().put("page", page);
    }


    @ApiOperation("开票管理表-根据ID查详情")
    @SysLog("开票管理表-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusInvoicingEntity params) {
        BusInvoicingEntity busInvoicing = busInvoicingService.info(params);
        return R.ok().put("data", busInvoicing);
    }

    @ApiOperation("开票管理表-重开发票")
    @SysLog("开票管理表-重开发票")
    @PostMapping("/setRebilling")
    public R setRebilling(@RequestBody BusInvoicingEntity param)  throws Exception {
        param.setOperator(getUserId());
        param.setStatus(1);
//        busInvoicingService.setRebilling(param);
        return R.ok();
    }

}
