package com.srs.web.controller.staff;

import com.srs.common.annotation.Log;
import com.srs.common.annotation.RepeatSubmit;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.core.page.TableDataInfo;
import com.srs.common.enums.BusinessType;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.staff.domain.SrsStaffOneStopCommunityActivities;
import com.srs.staff.service.ISrsStaffOneStopCommunityActivitiesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 一站式社区模块-社区活动Controller
 *
 * @author chc
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/staff/OneStopCommunityActivities")
@Api(value = "一站式社区模块-社区活动管理", tags = "一站式社区模块-社区活动管理")
public class SrsStaffOneStopCommunityActivitiesController extends BaseController {
    @Autowired
    private ISrsStaffOneStopCommunityActivitiesService srsStaffOneStopCommunityActivitiesService;

    /**
     * 查询一站式社区模块-社区活动列表
     */
    @PreAuthorize("@ss.hasPermi('staff:OneStopCommunityActivities:list')")
    @GetMapping("/list")
    @ApiOperation("查询一站式社区模块-社区活动列表")
    public TableDataInfo list(SrsStaffOneStopCommunityActivities srsStaffOneStopCommunityActivities) {
        startPage();
        List<SrsStaffOneStopCommunityActivities> list = srsStaffOneStopCommunityActivitiesService.selectSrsStaffOneStopCommunityActivitiesList(srsStaffOneStopCommunityActivities);
        return getDataTable(list);
    }

    /**
     * 查询一站式社区模块-社区活动列表
     */
    @PreAuthorize("@ss.hasPermi('staff:OneStopCommunityActivities:list')")
    @GetMapping("/listAll")
    @ApiOperation("查询一站式社区模块-社区活动列表(未分页)")
    public AjaxResult listAll(SrsStaffOneStopCommunityActivities srsStaffOneStopCommunityActivities) {
        List<SrsStaffOneStopCommunityActivities> list = srsStaffOneStopCommunityActivitiesService.selectSrsStaffOneStopCommunityActivitiesList(srsStaffOneStopCommunityActivities);
        return success(list);
    }

    /**
     * 导出一站式社区模块-社区活动列表
     */
    @PreAuthorize("@ss.hasPermi('staff:OneStopCommunityActivities:export')")
    @Log(title = "一站式社区模块-社区活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出一站式社区模块-社区活动列表")
    public void export(HttpServletResponse response, SrsStaffOneStopCommunityActivities srsStaffOneStopCommunityActivities) {
        List<SrsStaffOneStopCommunityActivities> list = srsStaffOneStopCommunityActivitiesService.selectSrsStaffOneStopCommunityActivitiesList(srsStaffOneStopCommunityActivities);
        ExcelUtil<SrsStaffOneStopCommunityActivities> util = new ExcelUtil<SrsStaffOneStopCommunityActivities>(SrsStaffOneStopCommunityActivities.class);
        util.exportExcel(response, list, "一站式社区模块-社区活动数据");
    }

    /**
     * 获取一站式社区模块-社区活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('staff:OneStopCommunityActivities:query')")
    @GetMapping(value = "/{activityId}")
    @ApiOperation("获取一站式社区模块-社区活动详细信息")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId) {
        return success(srsStaffOneStopCommunityActivitiesService.selectSrsStaffOneStopCommunityActivitiesByActivityId(activityId));
    }

    /**
     * 新增一站式社区模块-社区活动
     */
    @PreAuthorize("@ss.hasPermi('staff:OneStopCommunityActivities:add')")
    @Log(title = "一站式社区模块-社区活动", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增一站式社区模块-社区活动")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult add(@RequestBody SrsStaffOneStopCommunityActivities srsStaffOneStopCommunityActivities) {
        return toAjax(srsStaffOneStopCommunityActivitiesService.insertSrsStaffOneStopCommunityActivities(srsStaffOneStopCommunityActivities));
    }

    /**
     * 修改一站式社区模块-社区活动
     */
    @PreAuthorize("@ss.hasPermi('staff:OneStopCommunityActivities:edit')")
    @Log(title = "一站式社区模块-社区活动", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改一站式社区模块-社区活动")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult edit(@RequestBody SrsStaffOneStopCommunityActivities srsStaffOneStopCommunityActivities) {
        return toAjax(srsStaffOneStopCommunityActivitiesService.updateSrsStaffOneStopCommunityActivities(srsStaffOneStopCommunityActivities));
    }

    /**
     * 删除一站式社区模块-社区活动
     */
    @PreAuthorize("@ss.hasPermi('staff:OneStopCommunityActivities:remove')")
    @Log(title = "一站式社区模块-社区活动", businessType = BusinessType.DELETE)
    @PostMapping("/{activityIds}")
    @ApiOperation("删除一站式社区模块-社区活动")
    public AjaxResult remove(@PathVariable Long[] activityIds) {
        return toAjax(srsStaffOneStopCommunityActivitiesService.deleteSrsStaffOneStopCommunityActivitiesByActivityIds(activityIds));
    }
}
