package com.ruoyi.web.controller.houseManage;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.houseManage.HouseManage;
import com.ruoyi.system.service.IHouseManageService;
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 boman
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/wuYe/houseManage")
public class HouseManageController extends BaseController
{
    @Autowired
    private IHouseManageService houseManageService;

/**
 * 查询房屋管理列表
 */
@PreAuthorize("@ss.hasPermi('wuYe:houseManage:list')")
@GetMapping("/list")
    public TableDataInfo list(HouseManage houseManage)
    {
        startPage();
        List<HouseManage> list = houseManageService.selectHouseManageList(houseManage);
        return getDataTable(list);
    }

    /**
     * 导出房屋管理列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:houseManage:export')")
    @Log(title = "房屋管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseManage houseManage)
    {
        List<HouseManage> list = houseManageService.selectHouseManageList(houseManage);
        ExcelUtil<HouseManage> util = new ExcelUtil<HouseManage>(HouseManage.class);
        util.exportExcel(response, list, "房屋管理数据");
    }

    /**
     * 获取房屋管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuYe:houseManage:query')")
    @GetMapping(value = "/{portalId}")
    public AjaxResult getInfo(@PathVariable("portalId") Long portalId)
    {
        return success(houseManageService.selectHouseManageByPortalId(portalId));
    }

    /**
     * 新增房屋管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:houseManage:add')")
    @Log(title = "房屋管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseManage houseManage)
    {
        return toAjax(houseManageService.insertHouseManage(houseManage));
    }

    /**
     * 修改房屋管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:houseManage:edit')")
    @Log(title = "房屋管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody HouseManage houseManage)
    {
        return toAjax(houseManageService.updateHouseManage(houseManage));
    }

    /**
     * 删除房屋管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:houseManage:remove')")
    @Log(title = "房屋管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{portalIds}")
    public AjaxResult remove(@PathVariable Long[] portalIds)
    {
        return toAjax(houseManageService.deleteHouseManageByPortalIds(portalIds));
    }
}
