package com.jsowell.web.controller.pile;

import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.annotation.Log;
import com.jsowell.common.core.controller.BaseController;
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.PileConnectorInfo;
import com.jsowell.pile.dto.QueryConnectorDTO;
import com.jsowell.pile.dto.QueryConnectorListDTO;
import com.jsowell.pile.service.IPileConnectorInfoService;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 充电桩枪口信息Controller
 *
 * @author jsowell
 * @date 2022-08-31
 */
@RestController
@RequestMapping("/pile/connector")
public class PileConnectorInfoController extends BaseController {
	@Autowired
	private IPileConnectorInfoService pileConnectorInfoService;

	/**
	 * 查询充电桩枪口信息列表
	 */
	@PreAuthorize("@ss.hasPermi('pile:connector:list')")
	@GetMapping("/list")
	public TableDataInfo list(QueryConnectorDTO queryConnectorDTO) {
		startPage();
		List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(queryConnectorDTO);
		return getDataTable(list);
	}

	/**
	 * 导出充电桩枪口信息列表
	 */
	@PreAuthorize("@ss.hasPermi('pile:connector:export')")
	@Log(title = "充电桩枪口信息", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, PileConnectorInfo pileConnectorInfo) {
		List<PileConnectorInfo> list = pileConnectorInfoService.selectPileConnectorInfoList(pileConnectorInfo);
		ExcelUtil<PileConnectorInfo> util = new ExcelUtil<PileConnectorInfo>(PileConnectorInfo.class);
		util.exportExcel(response, list, "充电桩枪口信息数据");
	}

	/**
	 * 通过入参 查询接口列表
	 * http://localhost:8080/pile/connector/getConnectorInfoListByParams?pileIds=1,2
	 * 多id使用逗号拼接
	 */
	@PostMapping("/getConnectorInfoListByParams")
	public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) {
		logger.info("查询接口列表 param:{}", JSONObject.toJSONString(dto));
		List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(dto);
		logger.info("查询接口列表 result:{}", JSONObject.toJSONString(list));
		return getDataTable(list);
	}

	/**
	 * 获取充电桩枪口信息详细信息
	 */
	// @PreAuthorize("@ss.hasPermi('pile:connector:query')")
	// @GetMapping(value = "/{id}")
	// public AjaxResult getInfo(@PathVariable("id") Integer id) {
	// 	return AjaxResult.success(pileConnectorInfoService.selectPileConnectorInfoById(id));
	// }

	/**
	 * 新增充电桩枪口信息
	 */
	// @PreAuthorize("@ss.hasPermi('pile:connector:add')")
	// @Log(title = "充电桩枪口信息", businessType = BusinessType.INSERT)
	// @PostMapping
	// public AjaxResult add(@RequestBody PileConnectorInfo pileConnectorInfo) {
	// 	return toAjax(pileConnectorInfoService.insertPileConnectorInfo(pileConnectorInfo));
	// }

	/**
	 * 修改充电桩枪口信息
	 */
	// @PreAuthorize("@ss.hasPermi('pile:connector:edit')")
	// @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE)
	// @PutMapping
	// public AjaxResult edit(@RequestBody PileConnectorInfo pileConnectorInfo) {
	// 	return toAjax(pileConnectorInfoService.updatePileConnectorInfo(pileConnectorInfo));
	// }

	/**
	 * 删除充电桩枪口信息
	 */
	// @PreAuthorize("@ss.hasPermi('pile:connector:remove')")
	// @Log(title = "充电桩枪口信息", businessType = BusinessType.DELETE)
	// @DeleteMapping("/{ids}")
	// public AjaxResult remove(@PathVariable Integer[] ids) {
	// 	return toAjax(pileConnectorInfoService.deletePileConnectorInfoByIds(ids));
	// }


}
