package com.xhpc.charging.station.controller;


import com.xhpc.charging.station.service.IXhpcEquipmentAccidentService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.domain.XhpcChargingPile;
import com.xhpc.common.domain.XhpcEquipmentAccident;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/accident")
public class XhpcEquipmentAccidentController extends BaseController {


    @Resource
    IXhpcEquipmentAccidentService xhpcEquipmentAccidentService;

    @GetMapping("/list")
    public TableDataInfo list(HttpServletRequest request, String address) {
        List<Map<String, Object>> list = xhpcEquipmentAccidentService.getLsit(address);
        return getDataTable(list);
    }

    @PostMapping(value = "/addXhpcEquipmentAccident")
    public R addXhpcEquipmentAccident(@RequestBody XhpcEquipmentAccident xhpcEquipmentAccident) {
        return xhpcEquipmentAccidentService.insertXhpcEquipmentAccident(xhpcEquipmentAccident);
    }

    @PostMapping(value = "/updateXhpcEquipmentAccident")
    public R updateXhpcEquipmentAccident(@RequestBody XhpcEquipmentAccident xhpcEquipmentAccident) {
        return xhpcEquipmentAccidentService.updateXhpcEquipmentAccident(xhpcEquipmentAccident);
    }

    @GetMapping("/getXhpcEquipmentAccidentById")
    public R getXhpcEquipmentAccidentById(Long equipmentAccidentId) {
        Map<String, Object> map = xhpcEquipmentAccidentService.getXhpcEquipmentAccidentById(equipmentAccidentId);
        return R.ok(map);
    }

    @Log(title = "删除事故", businessType = BusinessType.DELETE)
    @GetMapping("/deleteXhpcEquipmentAccidentById")
    public R deleteXhpcEquipmentAccidentById(Long equipmentAccidentId) {
        return xhpcEquipmentAccidentService.deleteXhpcEquipmentAccidentById(equipmentAccidentId);
    }

}
