package com.jsowell.web.controller.pile;

import com.jsowell.common.annotation.Log;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.core.page.TableDataInfo;
import com.jsowell.common.enums.BusinessType;
import com.jsowell.common.util.poi.ExcelUtil;
import com.jsowell.pile.domain.PileLicenceInfo;
import com.jsowell.pile.service.IPileLicenceInfoService;
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 jsowell
 * @date 2022-08-27
 */
@RestController
@RequestMapping("/pile/licence")
public class PileLicenceInfoController extends BaseController
{
    @Autowired
    private IPileLicenceInfoService pileLicenceInfoService;

    /**
     * 查询充电桩证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('pile:licence:list')")
    @GetMapping("/list")
    public TableDataInfo list(PileLicenceInfo pileLicenceInfo)
    {
        startPage();
        List<PileLicenceInfo> list = pileLicenceInfoService.selectPileLicenceInfoList(pileLicenceInfo);
        return getDataTable(list);
    }

    /**
     * 导出充电桩证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('pile:licence:export')")
    @Log(title = "充电桩证书信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PileLicenceInfo pileLicenceInfo)
    {
        List<PileLicenceInfo> list = pileLicenceInfoService.selectPileLicenceInfoList(pileLicenceInfo);
        ExcelUtil<PileLicenceInfo> util = new ExcelUtil<PileLicenceInfo>(PileLicenceInfo.class);
        util.exportExcel(response, list, "充电桩证书信息数据");
    }

    /**
     * 获取充电桩证书信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('pile:licence:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pileLicenceInfoService.selectPileLicenceInfoById(id));
    }

    /**
     * 新增充电桩证书信息
     */
    @PreAuthorize("@ss.hasPermi('pile:licence:add')")
    @Log(title = "充电桩证书信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PileLicenceInfo pileLicenceInfo)
    {
        return toAjax(pileLicenceInfoService.insertPileLicenceInfo(pileLicenceInfo));
    }

    /**
     * 修改充电桩证书信息
     */
    @PreAuthorize("@ss.hasPermi('pile:licence:edit')")
    @Log(title = "充电桩证书信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PileLicenceInfo pileLicenceInfo)
    {
        return toAjax(pileLicenceInfoService.updatePileLicenceInfo(pileLicenceInfo));
    }

    /**
     * 删除充电桩证书信息
     */
    @PreAuthorize("@ss.hasPermi('pile:licence:remove')")
    @Log(title = "充电桩证书信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pileLicenceInfoService.deletePileLicenceInfoByIds(ids));
    }
}
