package com.jsowell.web.controller.pile;

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.jsowell.common.annotation.Log;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.enums.BusinessType;
import com.jsowell.pile.domain.PileCameraInfo;
import com.jsowell.pile.service.PileCameraInfoService;
import com.jsowell.common.util.poi.ExcelUtil;
import com.jsowell.common.core.page.TableDataInfo;

/**
 * 车位相机信息Controller
 *
 * @author jsowell
 * @date 2023-12-09
 */
@RestController
@RequestMapping("/pile/camera")
public class PileCameraInfoController extends BaseController {
    @Autowired
    private PileCameraInfoService pileCameraInfoService;

    /**
     * 查询车位相机信息列表
     */
    @PreAuthorize("@ss.hasPermi('pile:camera:list')")
    @GetMapping("/list")
    public TableDataInfo list(PileCameraInfo pileCameraInfo) {
        startPage();
        List<PileCameraInfo> list = pileCameraInfoService.selectPileCameraInfoList(pileCameraInfo);
        return getDataTable(list);
    }

    /**
     * 导出车位相机信息列表
     */
    @PreAuthorize("@ss.hasPermi('pile:camera:export')")
    @Log(title = "车位相机信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PileCameraInfo pileCameraInfo) {
        List<PileCameraInfo> list = pileCameraInfoService.selectPileCameraInfoList(pileCameraInfo);
        ExcelUtil<PileCameraInfo> util = new ExcelUtil<PileCameraInfo>(PileCameraInfo.class);
        util.exportExcel(response, list, "车位相机信息数据");
    }

    /**
     * 获取车位相机信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('pile:camera:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(pileCameraInfoService.selectPileCameraInfoById(id));
    }

    /**
     * 新增车位相机信息
     */
    @PreAuthorize("@ss.hasPermi('pile:camera:add')")
    @Log(title = "车位相机信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PileCameraInfo pileCameraInfo) {
        return toAjax(pileCameraInfoService.insertPileCameraInfo(pileCameraInfo));
    }

    /**
     * 修改车位相机信息
     */
    @PreAuthorize("@ss.hasPermi('pile:camera:edit')")
    @Log(title = "车位相机信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PileCameraInfo pileCameraInfo) {
        return toAjax(pileCameraInfoService.updatePileCameraInfo(pileCameraInfo));
    }

    /**
     * 删除车位相机信息
     */
    @PreAuthorize("@ss.hasPermi('pile:camera:remove')")
    @Log(title = "车位相机信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(pileCameraInfoService.deletePileCameraInfoByIds(ids));
    }
}
