package com.ruoyi.web.controller.butler;

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

import com.ruoyi.system.domain.butler.ButlerSettings;
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.system.service.IButlerSettingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物业管家设置Controller
 *
 * @author boman
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/wuYe/settings")
public class ButlerSettingsController extends BaseController
{
    @Autowired
    private IButlerSettingsService butlerSettingsService;

/**
 * 查询物业管家设置列表
 */
@PreAuthorize("@ss.hasPermi('wuYe:settings:list')")
@GetMapping("/list")
    public TableDataInfo list(ButlerSettings butlerSettings)
    {
        startPage();
        List<ButlerSettings> list = butlerSettingsService.selectButlerSettingsList(butlerSettings);
        return getDataTable(list);
    }

    /**
     * 导出物业管家设置列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:settings:export')")
    @Log(title = "物业管家设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ButlerSettings butlerSettings)
    {
        List<ButlerSettings> list = butlerSettingsService.selectButlerSettingsList(butlerSettings);
        ExcelUtil<ButlerSettings> util = new ExcelUtil<ButlerSettings>(ButlerSettings.class);
        util.exportExcel(response, list, "物业管家设置数据");
    }

    /**
     * 获取物业管家设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuYe:settings:query')")
    @GetMapping(value = "/{settingsId}")
    public AjaxResult getInfo(@PathVariable("settingsId") Long settingsId)
    {
        return success(butlerSettingsService.selectButlerSettingsBySettingsId(settingsId));
    }

    /**
     * 新增物业管家设置
     */
    @PreAuthorize("@ss.hasPermi('wuYe:settings:add')")
    @Log(title = "物业管家设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ButlerSettings butlerSettings)
    {
        return toAjax(butlerSettingsService.insertButlerSettings(butlerSettings));
    }

    /**
     * 修改物业管家设置
     */
    @PreAuthorize("@ss.hasPermi('wuYe:settings:edit')")
    @Log(title = "物业管家设置", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ButlerSettings butlerSettings)
    {
        return toAjax(butlerSettingsService.updateButlerSettings(butlerSettings));
    }

    /**
     * 删除物业管家设置
     */
    @PreAuthorize("@ss.hasPermi('wuYe:settings:remove')")
    @Log(title = "物业管家设置", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{settingsIds}")
    public AjaxResult remove(@PathVariable Long[] settingsIds)
    {
        return toAjax(butlerSettingsService.deleteButlerSettingsBySettingsIds(settingsIds));
    }
}
