package com.sw.common.accessory.server.mapper;

import com.sw.common.accessory.server.entity.AccessoryPartDetails;
import com.sw.common.mybatisplus.base.BaseDao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AccessoryPartDetailsMapper extends BaseDao<AccessoryPartDetails> {
    @Delete("delete from accy_accessory_part_details where material_id = #{materialId}")
    Boolean deleteByMaterialId(Integer materialId);
    @Select("select * from accy_accessory_part_details where material_code = #{materialCode}")
    List<AccessoryPartDetails> getByMaterialCode(String materialCode);
    @Select("select * from accy_accessory_part_details where part_code = #{partCode}")
    List<AccessoryPartDetails> getByPartCode(String partCode);
    @Select("select * from accy_accessory_part_details where device_type_code = #{deviceTypeCode} and device_model_code = #{deviceCode} and material_code = #{materialCode} and part_code = #{partCode}")
    AccessoryPartDetails getByCode(String deviceTypeCode, String deviceCode, String materialCode, String partCode);
    @Select("select * from accy_accessory_part_details where device_type_code = #{deviceTypeCode} and material_code = #{materialCode} and part_code = #{partCode}")
    List<AccessoryPartDetails> getByNotDeviceCode(String deviceTypeCode, String materialCode, String partCode);

    @Select("select * from accy_accessory_part_details where device_type_code = #{deviceTypeCode}")
    List<AccessoryPartDetails> getByDeviceTypeCode(String deviceTypeCode);
    @Select("select * from accy_accessory_part_details where device_model_code = #{deviceCode}")
    List<AccessoryPartDetails> getByDeviceCode(String deviceCode);
    @Select("delete from accy_accessory_part_details where device_type_code = #{deviceTypeCode} and material_code = #{materialCode} and part_code = #{partCode}")
    Boolean deleteByCode(String deviceTypeCode,String materialCode,String partCode);
    @Select("select * from accy_accessory_part_details where device_model_code = #{deviceCode} and material_code = #{materialCode} limit 1")
    AccessoryPartDetails getByDeviceCodeAndMaterialCode(String deviceCode, String materialCode);
}
