/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.feesapi.dzfp.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.feesapi.dzfp.entity.EiKprpz;
import com.tofly.feesapi.dzfp.service.EiKprpzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
/**
 * 开票人配置
 *
 * @author tofly code generator
 * @date Tue Apr 28 00:00:00 CST 2026
 */
@RestController
@AllArgsConstructor
@RequestMapping("/eikprpz")
@Api(tags="开票人配置接口")
public class EiKprpzController {

    private final  EiKprpzService eiKprpzService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param eiKprpz 开票人配置
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getEiKprpzPage(Page page, @ModelAttribute EiKprpz eiKprpz) {
      return ResultRespone.success(eiKprpzService.page(page, Wrappers.query(eiKprpz)));
    }


    /**
     * 通过id查询开票人配置
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("id" ) String id) {
      return ResultRespone.success(eiKprpzService.getById(id));
    }

    /**
     * 新增开票人配置
     * @param eiKprpz 开票人配置
     * @return ResultRespone
     */
    @ApiOperation(value = "新增开票人配置")
    @PostMapping
    public ResultRespone save(@RequestBody EiKprpz eiKprpz) {
      return ResultRespone.success(eiKprpzService.save(eiKprpz));
    }

    /**
     * 修改开票人配置
     * @param eiKprpz 开票人配置
     * @return ResultRespone
     */
    @ApiOperation(value = "修改开票人配置")
    @PutMapping
    public ResultRespone updateById(@RequestBody EiKprpz eiKprpz) {
      return ResultRespone.success(eiKprpzService.updateById(eiKprpz));
    }

    /**
     * 通过id删除开票人配置
     * @param id id
     * @return ResultRespone
     */
    @ApiOperation(value = "通过ID删除开票人配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable String id) {
      return ResultRespone.success(eiKprpzService.removeById(id));
    }

    /**
     * 通过id批量删除开票人配置
     * @param ids id
     * @return ResultRespone
     */
    @ApiOperation(value = "通过ID批量删除开票人配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(eiKprpzService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
