package com.ruoyi.web.controller.system;

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.ss.clean.domain.Clean;
import com.ruoyi.ss.clean.domain.CleanVO;
import com.ruoyi.ss.clean.domain.CleanQuery;
import com.ruoyi.ss.clean.service.ICleanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 保洁记录Controller
 *
 * @author qzz
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/system/clean")
public class CleanController extends BaseController
{
    @Autowired
    private ICleanService eCleanService;

    /**
     * 查询保洁记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:clean:list')")
    @GetMapping("/list")
    public TableDataInfo list(CleanQuery query)
    {
        startPage();
        startOrderBy();
        List<CleanVO> list = eCleanService.selectECleanList(query);
        return getDataTable(list);
    }

    /**
     * 导出保洁记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:clean:export')")
    @Log(title = "保洁记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CleanQuery query)
    {
        List<CleanVO> list = eCleanService.selectECleanList(query);
        ExcelUtil<CleanVO> util = new ExcelUtil<CleanVO>(CleanVO.class);
        util.exportExcel(response, list, "保洁记录数据");
    }

    /**
     * 获取保洁记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:clean:query')")
    @GetMapping(value = "/{cleanId}")
    public AjaxResult getInfo(@PathVariable("cleanId") Long cleanId)
    {
        return success(eCleanService.selectECleanByCleanId(cleanId));
    }

    /**
     * 新增保洁记录
     */
    @PreAuthorize("@ss.hasPermi('system:clean:add')")
    @Log(title = "保洁记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Clean eClean)
    {
        return toAjax(eCleanService.insertEClean(eClean));
    }

    /**
     * 修改保洁记录
     */
    @PreAuthorize("@ss.hasPermi('system:clean:edit')")
    @Log(title = "保洁记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Clean eClean)
    {
        return toAjax(eCleanService.updateEClean(eClean));
    }

    /**
     * 删除保洁记录
     */
    @PreAuthorize("@ss.hasPermi('system:clean:remove')")
    @Log(title = "保洁记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cleanIds}")
    public AjaxResult remove(@PathVariable Long[] cleanIds)
    {
        return toAjax(eCleanService.deleteECleanByCleanIds(cleanIds));
    }
}
