package com.yh.saas.plugin.yiliangyiyun.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.winsea.svc.base.security.util.AuthSecurityUtils;
import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
import com.yh.saas.plugin.yiliangyiyun.entity.DriverCarInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.TranCarInfo;
import com.yh.saas.plugin.yiliangyiyun.mapper.DriverCarInfoMapper;
import com.yh.saas.plugin.yiliangyiyun.service.IDriverCarInfoService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 记录货车信息 服务实现类
 * </p>
 *
 * @author Gongdc
 * @since 2021-05-29
 */
@Service
public class DriverCarInfoServiceImpl extends ServiceImpl<DriverCarInfoMapper, DriverCarInfo> implements IDriverCarInfoService {

    /**
     * 删除货车信息
     *
     * @param id
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteDriverCar(String id) {
        DriverCarInfo driverCarInfo = this.selectById(id);
        if (driverCarInfo != null) {
            this.deleteById(driverCarInfo.getId());
        }
    }

    /**
     * 车牌号下拉列表
     *
     * @param driverId
     * @return
     */
    @Override
    public List<DriverCarInfo> selectCarNumber(String driverId) {
        List<DriverCarInfo> driverCarInfoLists = this.selectList(new EntityWrapper<DriverCarInfo>()
                .eq(DriverCarInfo.QueryFiles.DRIVER_ID, driverId).eq(DriverCarInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
        return driverCarInfoLists;
    }
}
