package com.xhpc.charging.station.service;

import com.xhpc.charging.station.mapper.XhpcEquipmentAccidentMapper;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.domain.XhpcEquipmentAccident;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class XhpcEquipmentAccidentImpl extends BaseService implements IXhpcEquipmentAccidentService {

    @Resource
    XhpcEquipmentAccidentMapper xhpcEquipmentAccidentMapper;
    @Autowired
    private TokenService tokenService;

    @Override
    public List<Map<String, Object>> getLsit(String address) {
        return xhpcEquipmentAccidentMapper.getLsit(address);
    }

    @Override
    public R insertXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident) {
        if(xhpcEquipmentAccident.getEquipmentAccidentId() !=null){
            xhpcEquipmentAccidentMapper.updateXhpcEquipmentAccident(xhpcEquipmentAccident);
        }else {
            xhpcEquipmentAccidentMapper.insertXhpcEquipmentAccident(xhpcEquipmentAccident);
        }

        return R.ok();
    }

    @Override
    public R updateXhpcEquipmentAccident(XhpcEquipmentAccident xhpcEquipmentAccident) {
        xhpcEquipmentAccidentMapper.updateXhpcEquipmentAccident(xhpcEquipmentAccident);
        return R.ok();
    }

    @Override
    public Map<String, Object> getXhpcEquipmentAccidentById(Long equipmentAccidentId) {
        return xhpcEquipmentAccidentMapper.getXhpcEquipmentAccidentById(equipmentAccidentId);
    }

    @Override
    public R deleteXhpcEquipmentAccidentById(Long equipmentAccidentId) {

        xhpcEquipmentAccidentMapper.deleteXhpcEquipmentAccidentById(equipmentAccidentId);

        return R.ok();
    }
}
