package cn.iocoder.yudao.module.asset.dal.mysql.vehiclemodel;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.asset.dal.dataobject.vehiclemodel.VehicleModelMaintainItemDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 车型维保项目关联 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface VehicleModelMaintainItemMapper extends BaseMapperX<VehicleModelMaintainItemDO> {

    default List<VehicleModelMaintainItemDO> selectListByVehicleModelId(Long vehicleModelId) {
        return selectList(VehicleModelMaintainItemDO::getVehicleModelId, vehicleModelId);
    }

    default void deleteByVehicleModelId(Long vehicleModelId) {
        delete(VehicleModelMaintainItemDO::getVehicleModelId, vehicleModelId);
    }

    /**
     * 查询所有已使用的保养项目名称（去重）
     */
    @Select("SELECT DISTINCT maintain_item FROM asset_vehicle_model_maintain_item WHERE deleted = 0 AND maintain_item IS NOT NULL AND maintain_item != '' ORDER BY maintain_item")
    List<String> selectDistinctMaintainItems();

}
