package com.cmvr.aima.service.impl;

import java.util.List;
import java.util.UUID;
import com.baomidou.mybatisplus.spring.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cmvr.common.utils.DateUtils;
import com.cmvr.common.utils.SecurityUtils;
import com.cmvr.aima.mapper.AimaVehicleMapper;
import com.cmvr.aima.domain.AimaVehicle;
import com.cmvr.aima.service.IAimaVehicleService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 爱玛车辆管理Service业务层处理
 * 
 * @author cmvr-iot
 * @since 2026-06-22
 */
@Service
@Transactional
public class AimaVehicleServiceImpl extends ServiceImpl<AimaVehicleMapper, AimaVehicle> implements IAimaVehicleService {
    @Autowired
    private AimaVehicleMapper aimaVehicleMapper;

    @Override
    public AimaVehicle selectAimaVehicleById(String id) {
        return aimaVehicleMapper.selectAimaVehicleById(id);
    }

    @Override
    public List<AimaVehicle> selectAimaVehicleList(AimaVehicle aimaVehicle) {
        return aimaVehicleMapper.selectAimaVehicleList(aimaVehicle);
    }

    @Override
    public int insertAimaVehicle(AimaVehicle aimaVehicle) {
        if (aimaVehicle.getId() == null || aimaVehicle.getId().isEmpty()) {
            aimaVehicle.setId(UUID.randomUUID().toString().replace("-", ""));
        }
        aimaVehicle.setCreateTime(DateUtils.getNowDate());
        aimaVehicle.setCreateBy(SecurityUtils.getUsername());
        return aimaVehicleMapper.insertAimaVehicle(aimaVehicle);
    }

    @Override
    public int updateAimaVehicle(AimaVehicle aimaVehicle) {
        aimaVehicle.setUpdateTime(DateUtils.getNowDate());
        aimaVehicle.setUpdateBy(SecurityUtils.getUsername());
        return aimaVehicleMapper.updateAimaVehicle(aimaVehicle);
    }

    @Override
    public int deleteAimaVehicleByIds(String[] ids) {
        return aimaVehicleMapper.deleteAimaVehicleByIds(ids);
    }

    @Override
    public int deleteAimaVehicleById(String id) {
        return aimaVehicleMapper.deleteAimaVehicleById(id);
    }
}
