package com.pj.project.tb_car_record;

import java.util.List;

import com.pj.current.dto.APPLoginUserInfo;
import com.pj.current.satoken.StpAPPUserUtil;
import com.pj.enummj.DeleteStatus;
import com.pj.utils.so.SoMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

/**
 * Service: tb_car_record -- 商户司机叫车记录表
 * @author yzs 
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TbCarRecordService extends ServiceImpl<TbCarRecordMapper, TbCarRecord> implements IService<TbCarRecord>{

	/** 底层 Mapper 对象 */
	@Autowired
	TbCarRecordMapper tbCarRecordMapper;

	/** 增 */
	void add(TbCarRecord t){
		save(t);
	}

	/** 删 */
	void delete(Long id){
		removeById(id);
	}

	/** 改 */
	void update(TbCarRecord t){
		updateById(t);

	}

	/** 查 */
	TbCarRecord getById(Long id){
		return super.getById(id);
	}

	/** pc:查集合 - 根据条件（参数为空时代表忽略指定条件） */
	List<TbCarRecord> getList(SoMap so) { 
		return tbCarRecordMapper.getList(so);	
	}

	/** app:查集合 - 根据条件（参数为空时代表忽略指定条件） */
	List<TbCarRecord> getAppList(SoMap so,Integer driverResult) {
		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
		//查询自己的记录
		Long fk = appLoginInfo.getFk(); // driverId
		so.put("driverId",fk);
		so.put("deleteStatus", DeleteStatus.DELETE_STATUS_ON.getCode());
		so.put("sortType",17); // 根据日期降序
		if(driverResult != null)so.put("driverResult",driverResult);
		return tbCarRecordMapper.getList(so);
	}


}
