package com.ruoyi.web.controller.ss;

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.ss.billEleRecord.domain.BillEleRecordQuery;
import com.ruoyi.ss.billEleRecord.domain.BillEleRecordVO;
import com.ruoyi.ss.billEleRecord.service.BillEleRecordService;
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 ruoyi
 * @date 2025-01-04
 */
@RestController
@RequestMapping("/ss/billEleRecord")
public class BillEleRecordController extends BaseController
{
    @Autowired
    private BillEleRecordService billEleRecordService;

    /**
     * 查询订单电量记录列表
     */
    @PreAuthorize("@ss.hasPermi('ss:billEleRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BillEleRecordQuery query)
    {
        startPage();
        startOrderBy();
        List<BillEleRecordVO> list = billEleRecordService.selectBillEleRecordList(query);
        return getDataTable(list);
    }

    /**
     * 导出订单电量记录列表
     */
    @PreAuthorize("@ss.hasPermi('ss:billEleRecord:export')")
    @Log(title = "订单电量记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BillEleRecordQuery query)
    {
        List<BillEleRecordVO> list = billEleRecordService.selectBillEleRecordList(query);
        ExcelUtil<BillEleRecordVO> util = new ExcelUtil<BillEleRecordVO>(BillEleRecordVO.class);
        util.exportExcel(response, list, "订单电量记录数据");
    }

    /**
     * 获取订单电量记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ss:billEleRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(billEleRecordService.selectBillEleRecordById(id));
    }

    /**
     * 新增订单电量记录
     */
//    @PreAuthorize("@ss.hasPermi('ss:billEleRecord:add')")
//    @Log(title = "订单电量记录", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody BillEleRecord billEleRecord)
//    {
//        return toAjax(billEleRecordService.insertBillEleRecord(billEleRecord));
//    }
//
//    /**
//     * 修改订单电量记录
//     */
//    @PreAuthorize("@ss.hasPermi('ss:billEleRecord:edit')")
//    @Log(title = "订单电量记录", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody BillEleRecord billEleRecord)
//    {
//        return toAjax(billEleRecordService.updateBillEleRecord(billEleRecord));
//    }
//
//    /**
//     * 删除订单电量记录
//     */
//    @PreAuthorize("@ss.hasPermi('ss:billEleRecord:remove')")
//    @Log(title = "订单电量记录", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(billEleRecordService.deleteBillEleRecordByIds(ids));
//    }
}
