package com.ruoyi.web.controller.branch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.branch.domain.TBranchActivityBudget;
import com.ruoyi.branch.service.ITBranchActivityBudgetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支部活动预算Controller
 * 
 * @author ruoyi
 * @date 2023-07-20
 */
@RestController
@RequestMapping("/branch/activitybudget")
public class TBranchActivityBudgetController extends BaseController
{
    @Autowired
    private ITBranchActivityBudgetService tBranchActivityBudgetService;

    /**
     * 查询支部活动预算列表
     */
    @PreAuthorize("@ss.hasPermi('branch:activitybudget:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBranchActivityBudget tBranchActivityBudget)
    {
        startPage();
        List<TBranchActivityBudget> list = tBranchActivityBudgetService.selectTBranchActivityBudgetList(tBranchActivityBudget);
        return getDataTable(list);
    }

    /**
     * 导出支部活动预算列表
     */
    @PreAuthorize("@ss.hasPermi('branch:activitybudget:export')")
    @Log(title = "支部活动预算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBranchActivityBudget tBranchActivityBudget)
    {
        List<TBranchActivityBudget> list = tBranchActivityBudgetService.selectTBranchActivityBudgetList(tBranchActivityBudget);
        ExcelUtil<TBranchActivityBudget> util = new ExcelUtil<TBranchActivityBudget>(TBranchActivityBudget.class);
        util.exportExcel(response, list, "支部活动预算数据");
    }

    /**
     * 获取支部活动预算详细信息
     */
    @PreAuthorize("@ss.hasPermi('branch:activitybudget:query')")
    @GetMapping(value = "/{budgetId}")
    public AjaxResult getInfo(@PathVariable("budgetId") Long budgetId)
    {
        return success(tBranchActivityBudgetService.selectTBranchActivityBudgetByBudgetId(budgetId));
    }

    /**
     * 新增支部活动预算
     */
    @PreAuthorize("@ss.hasPermi('branch:activitybudget:add')")
    @Log(title = "支部活动预算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBranchActivityBudget tBranchActivityBudget)
    {
        return toAjax(tBranchActivityBudgetService.insertTBranchActivityBudget(tBranchActivityBudget));
    }

    /**
     * 修改支部活动预算
     */
    @PreAuthorize("@ss.hasPermi('branch:activitybudget:edit')")
    @Log(title = "支部活动预算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBranchActivityBudget tBranchActivityBudget)
    {
        return toAjax(tBranchActivityBudgetService.updateTBranchActivityBudget(tBranchActivityBudget));
    }

    /**
     * 删除支部活动预算
     */
    @PreAuthorize("@ss.hasPermi('branch:activitybudget:remove')")
    @Log(title = "支部活动预算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{budgetIds}")
    public AjaxResult remove(@PathVariable Long[] budgetIds)
    {
        return toAjax(tBranchActivityBudgetService.deleteTBranchActivityBudgetByBudgetIds(budgetIds));
    }
}
