package com.zsElectric.boot.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsElectric.boot.business.model.entity.UserVehicle;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 用户车辆信息Mapper接口
 *
 * @author zsElectric
 * @since 2026-03-03
 */
@Mapper
public interface UserVehicleMapper extends BaseMapper<UserVehicle> {

    /**
     * 清除用户所有车辆的默认状态
     *
     * @param userId 用户ID
     * @return 更新的记录数
     */
    @Update("UPDATE c_user_vehicle SET is_default = 0 WHERE user_id = #{userId} AND is_deleted = 0")
    int clearUserDefaultVehicle(@Param("userId") Long userId);
}
