package com.leromro.core.controller;

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

import com.leromro.core.domain.vo.BusinessPriceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.leromro.common.core.domain.R;
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.leromro.common.annotation.Log;
import com.leromro.common.core.controller.BaseController;
import com.leromro.common.core.domain.AjaxResult;
import com.leromro.common.enums.BusinessType;
import com.leromro.core.domain.BusinessPrice;
import com.leromro.core.service.IBusinessPriceService;
import com.leromro.common.utils.poi.ExcelUtil;
import com.leromro.common.core.page.TableDataInfo;

/**
 * 业务价格Controller
 *
 * @author ruoyi
 * @date 2025-04-17
 */
@RestController
@Api(tags = "业务价格")
@RequestMapping("/core/business/price")
public class BusinessPriceController extends BaseController
{
    @Autowired
    private IBusinessPriceService businessPriceService;

    /**
     * 查询业务价格列表
     */
    @ApiOperation("查询业务价格列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "businessManagementId", value = "搜索条件", required = false)
    })
    @GetMapping("/list")
    public TableDataInfo<BusinessPriceVO> list(BusinessPrice businessPrice)
    {
        startPage();
        List<BusinessPriceVO> list = businessPriceService.selectBusinessPriceList(businessPrice);
        return getDataTable(list);
    }

    /**
     * 获取业务价格详细信息
     */
    @ApiOperation("获取业务价格详细信息")
    @GetMapping(value = "/{businessPriceId}")
    public R<BusinessPrice> getInfo(@PathVariable("businessPriceId") Long businessPriceId)
    {
        return R.ok(businessPriceService.selectBusinessPriceByBusinessPriceId(businessPriceId));
    }

    /**
     * 新增业务价格
     */
    @ApiOperation("新增业务价格")
    @Log(title = "业务价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessPrice businessPrice)
    {
        return toAjax(businessPriceService.insertBusinessPrice(businessPrice));
    }

    /**
     * 修改业务价格
     */
    @ApiOperation("修改业务价格")
    @Log(title = "业务价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessPrice businessPrice)
    {
        return toAjax(businessPriceService.updateBusinessPrice(businessPrice));
    }

    /**
     * 删除业务价格
     */
    @ApiOperation("删除业务价格")
    @Log(title = "业务价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{businessPriceIds}")
    public R<Integer> remove(@PathVariable Long[] businessPriceIds)
    {
        return R.ok(businessPriceService.deleteBusinessPriceByBusinessPriceIds(businessPriceIds));
    }
}
