package com.ruoyi.web.controller.houseInfo;

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

import com.ruoyi.system.domain.houseInfo.PropertySettings;
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.IPropertySettingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物业费设置Controller
 *
 * @author boman
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/wuYe/fee/settings")
public class PropertySettingsController extends BaseController
{
    @Autowired
    private IPropertySettingsService propertySettingsService;

/**
 * 查询物业费设置列表
 */
@PreAuthorize("@ss.hasPermi('wuYe:fee:settings:list')")
@GetMapping("/list")
    public TableDataInfo list(PropertySettings propertySettings)
    {
        startPage();
        List<PropertySettings> list = propertySettingsService.selectPropertySettingsList(propertySettings);
        return getDataTable(list);
    }

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

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

    /**
     * 新增物业费设置
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:settings:add')")
    @Log(title = "物业费设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertySettings propertySettings)
    {
        return toAjax(propertySettingsService.insertPropertySettings(propertySettings));
    }

    /**
     * 修改物业费设置
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:settings:edit')")
    @Log(title = "物业费设置", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody PropertySettings propertySettings)
    {
        return toAjax(propertySettingsService.updatePropertySettings(propertySettings));
    }

    /**
     * 删除物业费设置
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:settings:remove')")
    @Log(title = "物业费设置", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{settingsId}")
    public AjaxResult remove(@PathVariable Long settingsId)
    {
        return toAjax(propertySettingsService.deletePropertySettingsBySettingsId(settingsId));
    }
}
