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

/**
 * 支部特色活动Controller
 * 
 * @author ruoyi
 * @date 2023-07-18
 */
@RestController
@RequestMapping("/branch/activity")
public class TBranchActivityController extends BaseController
{
    @Autowired
    private ITBranchActivityService tBranchActivityService;

    /**
     * 查询支部特色活动列表
     */
    @PreAuthorize("@ss.hasPermi('branch:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBranchActivity tBranchActivity)
    {
        startPage();
        List<TBranchActivity> list = tBranchActivityService.selectTBranchActivityList(tBranchActivity);
        return getDataTable(list);
    }

    /**
     * 导出支部特色活动列表
     */
    @PreAuthorize("@ss.hasPermi('branch:activity:export')")
    @Log(title = "支部特色活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBranchActivity tBranchActivity)
    {
        List<TBranchActivity> list = tBranchActivityService.selectTBranchActivityList(tBranchActivity);
        ExcelUtil<TBranchActivity> util = new ExcelUtil<TBranchActivity>(TBranchActivity.class);
        util.exportExcel(response, list, "支部特色活动数据");
    }

    /**
     * 获取支部特色活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('branch:activity:query')")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId)
    {
        return success(tBranchActivityService.selectTBranchActivityByActivityId(activityId));
    }

    /**
     * 新增支部特色活动
     */
    @PreAuthorize("@ss.hasPermi('branch:activity:add')")
    @Log(title = "支部特色活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBranchActivity tBranchActivity)
    {
        return toAjax(tBranchActivityService.insertTBranchActivity(tBranchActivity));
    }

    /**
     * 修改支部特色活动
     */
    @PreAuthorize("@ss.hasPermi('branch:activity:edit')")
    @Log(title = "支部特色活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBranchActivity tBranchActivity)
    {
        return toAjax(tBranchActivityService.updateTBranchActivity(tBranchActivity));
    }

    /**
     * 删除支部特色活动
     */
    @PreAuthorize("@ss.hasPermi('branch:activity:remove')")
    @Log(title = "支部特色活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds)
    {
        return toAjax(tBranchActivityService.deleteTBranchActivityByActivityIds(activityIds));
    }
}
