package com.srs.web.controller.staff;

import com.srs.common.annotation.Log;
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.StaffOneStopRoomOpeningHours;
import com.srs.staff.service.IStaffOneStopRoomOpeningHoursService;
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-08-13
 */
@RestController
@RequestMapping("/staff/roomOpeningHours")
@Api(value = "一站式社区-功能房开放时间管理", tags = "一站式社区-功能房开放时间管理")
public class StaffOneStopRoomOpeningHoursController extends BaseController {
    @Autowired
    private IStaffOneStopRoomOpeningHoursService staffOneStopRoomOpeningHoursService;

    /**
     * 查询一站式社区-功能房开放时间列表
     */
    @PreAuthorize("@ss.hasPermi('staff:roomOpeningHours:list')")
    @GetMapping("/list")
    @ApiOperation("查询一站式社区-功能房开放时间列表")
    public TableDataInfo list(StaffOneStopRoomOpeningHours staffOneStopRoomOpeningHours) {
        startPage();
        List<StaffOneStopRoomOpeningHours> list = staffOneStopRoomOpeningHoursService.selectStaffOneStopRoomOpeningHoursList(staffOneStopRoomOpeningHours);
        return getDataTable(list);
    }

    /**
     * 导出一站式社区-功能房开放时间列表
     */
    @PreAuthorize("@ss.hasPermi('staff:roomOpeningHours:export')")
    @Log(title = "一站式社区-功能房开放时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出一站式社区-功能房开放时间列表")
    public void export(HttpServletResponse response, StaffOneStopRoomOpeningHours staffOneStopRoomOpeningHours) {
        List<StaffOneStopRoomOpeningHours> list = staffOneStopRoomOpeningHoursService.selectStaffOneStopRoomOpeningHoursList(staffOneStopRoomOpeningHours);
        ExcelUtil<StaffOneStopRoomOpeningHours> util = new ExcelUtil<StaffOneStopRoomOpeningHours>(StaffOneStopRoomOpeningHours.class);
        util.exportExcel(response, list, "一站式社区-功能房开放时间数据");
    }

    /**
     * 获取一站式社区-功能房开放时间详细信息
     */
    @PreAuthorize("@ss.hasPermi('staff:roomOpeningHours:query')")
    @GetMapping(value = "/{ohId}")
    @ApiOperation("获取一站式社区-功能房开放时间详细信息")
    public AjaxResult getInfo(@PathVariable("ohId") Long ohId) {
        return success(staffOneStopRoomOpeningHoursService.selectStaffOneStopRoomOpeningHoursByOhId(ohId));
    }

    /**
     * 新增一站式社区-功能房开放时间
     */
    @PreAuthorize("@ss.hasPermi('staff:roomOpeningHours:add')")
    @Log(title = "一站式社区-功能房开放时间", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增一站式社区-功能房开放时间")
    public AjaxResult add(@RequestBody StaffOneStopRoomOpeningHours staffOneStopRoomOpeningHours) {
        return toAjax(staffOneStopRoomOpeningHoursService.insertStaffOneStopRoomOpeningHours(staffOneStopRoomOpeningHours));
    }

    /**
     * 批量新增一站式社区-功能房开放时间
     */
    @PreAuthorize("@ss.hasPermi('staff:roomOpeningHours:add')")
    @Log(title = "一站式社区-功能房开放时间", businessType = BusinessType.INSERT)
    @PostMapping("/addBatch")
    @ApiOperation("批量新增一站式社区-功能房开放时间")
    public AjaxResult addBatch(@RequestBody List<StaffOneStopRoomOpeningHours> staffOneStopRoomOpeningHoursList) {
        return toAjax(staffOneStopRoomOpeningHoursService.insertStaffOneStopRoomOpeningHoursBatch(staffOneStopRoomOpeningHoursList));
    }

    /**
     * 修改一站式社区-功能房开放时间
     */
    @PreAuthorize("@ss.hasPermi('staff:roomOpeningHours:edit')")
    @Log(title = "一站式社区-功能房开放时间", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改一站式社区-功能房开放时间")
    public AjaxResult edit(@RequestBody StaffOneStopRoomOpeningHours staffOneStopRoomOpeningHours) {
        return toAjax(staffOneStopRoomOpeningHoursService.updateStaffOneStopRoomOpeningHours(staffOneStopRoomOpeningHours));
    }

    /**
     * 删除一站式社区-功能房开放时间
     */
    @PreAuthorize("@ss.hasPermi('staff:roomOpeningHours:remove')")
    @Log(title = "一站式社区-功能房开放时间", businessType = BusinessType.DELETE)
    @PostMapping("/{ohIds}")
    @ApiOperation("删除一站式社区-功能房开放时间")
    public AjaxResult remove(@PathVariable Long[] ohIds) {
        return toAjax(staffOneStopRoomOpeningHoursService.deleteStaffOneStopRoomOpeningHoursByOhIds(ohIds));
    }
}
