package com.njzscloud.supervisory.biz.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.biz.pojo.entity.BizInvoiceEntity;
import com.njzscloud.supervisory.biz.pojo.param.SearchBizInvoiceParam;
import com.njzscloud.supervisory.biz.service.BizInvoiceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 发票抬头管理
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/biz_invoice")
@RequiredArgsConstructor
public class BizInvoiceController {

    private final BizInvoiceService bizInvoiceService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody BizInvoiceEntity entity) {
        bizInvoiceService.add(entity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody BizInvoiceEntity entity) {
        bizInvoiceService.modify(entity);
        return R.success();
    }

    /**
     * 删除
     */
    @GetMapping("/remove")
    public R<?> remove(@RequestParam Long id) {
        bizInvoiceService.remove(id);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<BizInvoiceEntity> detail(@RequestParam Long id) {
        return R.success(bizInvoiceService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<BizInvoiceEntity>> paging(PageParam pageParam, SearchBizInvoiceParam searchParam) {
        return R.success(bizInvoiceService.paging(pageParam, searchParam));
    }

}
