package com.ruoyi.model.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.model.domain.AppCleanRequest;
import com.ruoyi.model.service.IAppCleanRequestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 清洁要求Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/model/AppCleanRequest")
public class AppCleanRequestController extends BaseController
{
    @Autowired
    private IAppCleanRequestService appCleanRequestService;

    /**
     * 查询清洁要求列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppCleanRequest:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppCleanRequest appCleanRequest)
    {
        startPage();
        List<AppCleanRequest> list = appCleanRequestService.selectAppCleanRequestList(appCleanRequest);
        return getDataTable(list);
    }

    /**
     * 导出清洁要求列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppCleanRequest:export')")
    @Log(title = "清洁要求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppCleanRequest appCleanRequest) throws IOException {
        List<AppCleanRequest> list = appCleanRequestService.selectAppCleanRequestList(appCleanRequest);
        ExcelUtil<AppCleanRequest> util = new ExcelUtil<AppCleanRequest>(AppCleanRequest.class);
        util.exportExcel(response, list, "清洁要求数据");
    }

    /**
     * 获取清洁要求详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppCleanRequest:query')")
    @GetMapping(value = "/{cleanRequestId}")
    public AjaxResult getInfo(@PathVariable("cleanRequestId") Long cleanRequestId)
    {
        return success(appCleanRequestService.selectAppCleanRequestByCleanRequestId(cleanRequestId));
    }

    /**
     * 新增清洁要求
     */
    @PreAuthorize("@ss.hasPermi('model:AppCleanRequest:add')")
    @Log(title = "清洁要求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppCleanRequest appCleanRequest)
    {
        return toAjax(appCleanRequestService.insertAppCleanRequest(appCleanRequest));
    }

    /**
     * 修改清洁要求
     */
    @PreAuthorize("@ss.hasPermi('model:AppCleanRequest:edit')")
    @Log(title = "清洁要求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppCleanRequest appCleanRequest)
    {
        return toAjax(appCleanRequestService.updateAppCleanRequest(appCleanRequest));
    }

    /**
     * 删除清洁要求
     */
    @PreAuthorize("@ss.hasPermi('model:AppCleanRequest:remove')")
    @Log(title = "清洁要求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cleanRequestIds}")
    public AjaxResult remove(@PathVariable Long[] cleanRequestIds)
    {
        return toAjax(appCleanRequestService.deleteAppCleanRequestByCleanRequestIds(cleanRequestIds));
    }
}
