package com.css.simulation.resource.server.infra.db.mysql.mapper;

import api.common.pojo.param.model.VehicleParam;
import api.common.pojo.po.model.VehiclePO;
import api.common.pojo.vo.model.VehicleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface VehicleMapper {

    List<VehicleVO> getVehicleList(VehicleParam vehicleParam);

    List<VehicleVO> selectPrivateAndPublicByCreateUserId(@Param("createUserId") String createUserId);

    VehicleVO getVehicleInfo(VehicleParam vehicleParam);


    List<VehicleVO> checkVehicleName(VehiclePO vehiclePO);

    void insert(VehiclePO vehiclePO);

    void update(VehiclePO vehiclePO);

    void delVehicleById(VehiclePO vehiclePO);

    @Update("update model_vehicle \n" +
            "set model_label = #{newModelLabel}\n" +
            "where model_label = #{oldModelLabel}")
    void updateModelLabel(@Param("oldModelLabel") String oldModelLabel, @Param("newModelLabel") String newModelLabel);

    @Select("select parameter_type from model_vehicle where id = (select vehicle_id from model_config where id = #{id})")
    String selectParameterTypeById(@Param("id") String id);

    List<VehicleVO> selectPrivateAndPublicByCreateUserIdGy(@Param("createUserId") String createUserId);
    List<VehicleVO> selectPrivateAndPublicByCreateUserIdSy(@Param("createUserId") String createUserId);

}
