package com.tofly.feesapi.dzfp.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.feesapi.common.core.ResultRespone;

import com.tofly.feesapi.dzfp.entity.EiSalerConfig;
import com.tofly.feesapi.dzfp.service.EiSalerConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/eisalerconfig")
@Api(tags="电子发票-电子发票销售方配置信息接口")
public class EiSalerConfigController {

    @Autowired
    private  EiSalerConfigService eiSalerConfigService;

    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getEiSalerConfigPage(Page page, @ModelAttribute EiSalerConfig eiSalerConfig) {
      return ResultRespone.success(eiSalerConfigService.page(page, Wrappers.query(eiSalerConfig)));
    }

    @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(eiSalerConfigService.getById(id));
    }

    @ApiOperation(value = "新增电子发票销售方配置信息")
    @PostMapping
    public ResultRespone save(@RequestBody EiSalerConfig eiSalerConfig) {
      return ResultRespone.success(eiSalerConfigService.save(eiSalerConfig));
    }

    @ApiOperation(value = "修改电子发票销售方配置信息")
    @PutMapping
    public ResultRespone updateById(@RequestBody EiSalerConfig eiSalerConfig) {
      return ResultRespone.success(eiSalerConfigService.updateById(eiSalerConfig));
    }

    @ApiOperation(value = "通过ID删除电子发票销售方配置信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable String id) {
      return ResultRespone.success(eiSalerConfigService.removeById(id));
    }

    @ApiOperation(value = "通过ID批量删除电子发票销售方配置信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(eiSalerConfigService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
