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.TBranchPlanItem;
import com.ruoyi.branch.service.ITBranchPlanItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支部年度工作计划条目Controller
 * 
 * @author ruoyi
 * @date 2023-07-17
 */
@RestController
@RequestMapping("/branch/planitem")
public class TBranchPlanItemController extends BaseController
{
    @Autowired
    private ITBranchPlanItemService tBranchPlanItemService;

    /**
     * 查询支部年度工作计划条目列表
     */
    @PreAuthorize("@ss.hasPermi('branch:planitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBranchPlanItem tBranchPlanItem)
    {
        startPage();
        List<TBranchPlanItem> list = tBranchPlanItemService.selectTBranchPlanItemList(tBranchPlanItem);
        return getDataTable(list);
    }

    /**
     * 导出支部年度工作计划条目列表
     */
    @PreAuthorize("@ss.hasPermi('branch:planitem:export')")
    @Log(title = "支部年度工作计划条目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBranchPlanItem tBranchPlanItem)
    {
        List<TBranchPlanItem> list = tBranchPlanItemService.selectTBranchPlanItemList(tBranchPlanItem);
        ExcelUtil<TBranchPlanItem> util = new ExcelUtil<TBranchPlanItem>(TBranchPlanItem.class);
        util.exportExcel(response, list, "支部年度工作计划条目数据");
    }

    /**
     * 获取支部年度工作计划条目详细信息
     */
    @PreAuthorize("@ss.hasPermi('branch:planitem:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") Long itemId)
    {
        return success(tBranchPlanItemService.selectTBranchPlanItemByItemId(itemId));
    }

    /**
     * 新增支部年度工作计划条目
     */
    @PreAuthorize("@ss.hasPermi('branch:planitem:add')")
    @Log(title = "支部年度工作计划条目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBranchPlanItem tBranchPlanItem)
    {
        return toAjax(tBranchPlanItemService.insertTBranchPlanItem(tBranchPlanItem));
    }

    /**
     * 修改支部年度工作计划条目
     */
    @PreAuthorize("@ss.hasPermi('branch:planitem:edit')")
    @Log(title = "支部年度工作计划条目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBranchPlanItem tBranchPlanItem)
    {
        return toAjax(tBranchPlanItemService.updateTBranchPlanItem(tBranchPlanItem));
    }

    /**
     * 删除支部年度工作计划条目
     */
    @PreAuthorize("@ss.hasPermi('branch:planitem:remove')")
    @Log(title = "支部年度工作计划条目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable Long[] itemIds)
    {
        return toAjax(tBranchPlanItemService.deleteTBranchPlanItemByItemIds(itemIds));
    }
}
