package com.jianshui.web.controller.invoice;

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

import com.jianshui.invoice.domain.BillInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianshui.common.annotation.Log;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.enums.BusinessType;
import com.jianshui.invoice.service.IBillInfoService;
import com.jianshui.common.utils.poi.ExcelUtil;
import com.jianshui.common.core.page.TableDataInfo;

/**
 * 开票信息Controller
 * 
 * @author Gong Quanlin
 * @date 2022-03-06
 */
//@Api(tags = "测试接口文档",value = "ceceshi")
@RestController
@RequestMapping("/invoice/billinfo")
public class BillInfoController extends BaseController
{
    @Autowired
    private IBillInfoService billInfoService;

    /**
     * 查询开票信息列表
     */
    @ApiOperation("查询开票信息列表")
    @PreAuthorize("@ss.hasPermi('invoice:billinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BillInfo billInfo)
    {
        startPage();
        List<BillInfo> list = billInfoService.selectBillInfoList(billInfo);
        return getDataTable(list);
    }

    /**
     * 导出开票信息列表
     */
    @PreAuthorize("@ss.hasPermi('invoice:billinfo:export')")
    @Log(title = "开票信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BillInfo billInfo)
    {
        List<BillInfo> list = billInfoService.selectBillInfoList(billInfo);
        ExcelUtil<BillInfo> util = new ExcelUtil<BillInfo>(BillInfo.class);
        util.exportExcel(response, list, "开票信息数据");
    }

    /**
     * 获取开票信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('invoice:billinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(billInfoService.selectBillInfoById(id));
    }

    /**
     * 新增开票信息
     */
    @PreAuthorize("@ss.hasPermi('invoice:billinfo:add')")
    @Log(title = "开票信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BillInfo billInfo)
    {
        return toAjax(billInfoService.insertBillInfo(billInfo));
    }

    /**
     * 修改开票信息
     */
    @PreAuthorize("@ss.hasPermi('invoice:billinfo:edit')")
    @Log(title = "开票信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BillInfo billInfo)
    {
        return toAjax(billInfoService.updateBillInfo(billInfo));
    }

    /**
     * 删除开票信息
     */
    @PreAuthorize("@ss.hasPermi('invoice:billinfo:remove')")
    @Log(title = "开票信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(billInfoService.deleteBillInfoByIds(ids));
    }

    /**
     * 重新推送单据
     */
    @PreAuthorize("@ss.hasPermi('invoice:billinfo:edit')")
    @GetMapping(value = "/push/{id}")
    public AjaxResult pushInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(billInfoService.pushBillInfo(id));
    }

}
