package com.ruoyi.web.controller.illegalParking;

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.illegalParking.IllegalParking;
import com.ruoyi.system.service.IIllegalParkingService;
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/illegalParking")
public class IllegalParkingController extends BaseController {
    @Autowired
    private IIllegalParkingService illegalParkingService;

    /**
     * 查询违章停车登记列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:illegalParking:list')")
    @GetMapping("/list")
    public TableDataInfo list(IllegalParking illegalParking) {
        startPage();
        List<IllegalParking> list = illegalParkingService.selectIllegalParkingList(illegalParking);
        return getDataTable(list);
    }

    /**
     * 导出违章停车登记列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:illegalParking:export')")
    @Log(title = "违章停车登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IllegalParking illegalParking) {
        List<IllegalParking> list = illegalParkingService.selectIllegalParkingList(illegalParking);
        ExcelUtil<IllegalParking> util = new ExcelUtil<IllegalParking>(IllegalParking.class);
        util.exportExcel(response, list, "违章停车登记数据");
    }

    /**
     * 获取违章停车登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuYe:illegalParking:query')")
    @GetMapping(value = "/{illegalParkingId}")
    public AjaxResult getInfo(@PathVariable("illegalParkingId") Long illegalParkingId) {
        return success(illegalParkingService.selectIllegalParkingByIllegalParkingId(illegalParkingId));
    }

    /**
     * 新增违章停车登记
     */
    @PreAuthorize("@ss.hasPermi('wuYe:illegalParking:add')")
    @Log(title = "违章停车登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IllegalParking illegalParking) {
        return toAjax(illegalParkingService.insertIllegalParking(illegalParking));
    }

    /**
     * 修改违章停车登记
     */
    @PreAuthorize("@ss.hasPermi('wuYe:illegalParking:edit')")
    @Log(title = "违章停车登记", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody IllegalParking illegalParking) {
        return toAjax(illegalParkingService.updateIllegalParking(illegalParking));
    }

    /**
     * 删除违章停车登记
     */
    @PreAuthorize("@ss.hasPermi('wuYe:illegalParking:remove')")
    @Log(title = "违章停车登记", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{illegalParkingIds}")
    public AjaxResult remove(@PathVariable Long[] illegalParkingIds) {
        return toAjax(illegalParkingService.deleteIllegalParkingByIllegalParkingIds(illegalParkingIds));
    }
    /**
     * 解除黑名单
     */
    @PreAuthorize("@ss.hasPermi('wuYe:illegalParking:cancel')")
    @PostMapping("/cancel")
    public AjaxResult cancel(@RequestBody IllegalParking illegalParking) {
        return illegalParkingService.cancel(illegalParking);
    }
}
