package com.ruoyi.web.controller.warehouse.feeagreement;

import java.util.List;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.feeagreement.domain.TFeeAgreementType;
import com.ruoyi.feeagreement.service.ITFeeAgreementTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用协议类型Controller
 * 
 * @author dongyongwei
 * @date 2021-07-30
 */
@RestController
@RequestMapping("/feeagreement/feeagreementtype")
public class TFeeAgreementTypeController extends BaseController
{
    @Autowired
    private ITFeeAgreementTypeService tFeeAgreementTypeService;

    /**
     * 查询费用协议类型列表
     */
    @PreAuthorize("@ss.hasPermi('feeagreement:feeagreementtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFeeAgreementType tFeeAgreementType)
    {
        startPage();
        List<TFeeAgreementType> list = tFeeAgreementTypeService.selectTFeeAgreementTypeList(tFeeAgreementType);
        return getDataTable(list);
    }

    /**
     * 导出费用协议类型列表
     */
    @PreAuthorize("@ss.hasPermi('feeagreement:feeagreementtype:export')")
    @Log(title = "费用协议类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TFeeAgreementType tFeeAgreementType)
    {
        List<TFeeAgreementType> list = tFeeAgreementTypeService.selectTFeeAgreementTypeList(tFeeAgreementType);
        ExcelUtil<TFeeAgreementType> util = new ExcelUtil<TFeeAgreementType>(TFeeAgreementType.class);
        return util.exportExcel(list, "feeagreementtype");
    }

    /**
     * 获取费用协议类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('feeagreement:feeagreementtype:query')")
    @GetMapping(value = "/{fId}")
    public AjaxResult getInfo(@PathVariable("fId") Long fId)
    {
        return AjaxResult.success(tFeeAgreementTypeService.selectTFeeAgreementTypeById(fId));
    }

    /**
     * 新增费用协议类型
     */
    @PreAuthorize("@ss.hasPermi('feeagreement:feeagreementtype:add')")
    @Log(title = "费用协议类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFeeAgreementType tFeeAgreementType)
    {
        return toAjax(tFeeAgreementTypeService.insertTFeeAgreementType(tFeeAgreementType));
    }

    /**
     * 修改费用协议类型
     */
    @PreAuthorize("@ss.hasPermi('feeagreement:feeagreementtype:edit')")
    @Log(title = "费用协议类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFeeAgreementType tFeeAgreementType)
    {
        return toAjax(tFeeAgreementTypeService.updateTFeeAgreementType(tFeeAgreementType));
    }

    /**
     * 删除费用协议类型
     */
    @PreAuthorize("@ss.hasPermi('feeagreement:feeagreementtype:remove')")
    @Log(title = "费用协议类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fIds}")
    public AjaxResult remove(@PathVariable Long[] fIds)
    {
        return toAjax(tFeeAgreementTypeService.deleteTFeeAgreementTypeByIds(fIds));
    }
}
