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

import com.sw.common.accessory.server.entity.AccessoryPart;
import com.sw.common.mybatisplus.base.BaseDao;
import io.swagger.models.auth.In;
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 AccessoryPartMapper extends BaseDao<AccessoryPart> {
    @Delete("delete from accy_accessory_part where material_id = #{materialId}")
    Boolean deleteByMaterialId(Integer materialId);
    @Select("select * from accy_accessory_part where material_code = #{materialCode}")
    List<AccessoryPart> getByMaterialCode(String materialCode);
    @Select("select * from accy_accessory_part where part_code = #{partCode}")
    List<AccessoryPart> getByPartCode(String partCode);
    @Select("select * from accy_accessory_part where device_type_code = #{deviceTypeCode} and device_model_code = #{deviceCode} and material_code = #{materialCode} and part_code = #{partCode}")
    AccessoryPart getByCode(String deviceTypeCode,String deviceCode,String materialCode,String partCode);
    @Select("select * from accy_accessory_part where device_type_code = #{deviceTypeCode} and material_code = #{materialCode} and part_code = #{partCode}")
    AccessoryPart getByTypeCode(String deviceTypeCode,String materialCode,String partCode);
    @Select("select * from accy_accessory_part where device_model_code = #{deviceCode} and material_code = #{materialCode} limit 1")
    AccessoryPart getByDeviceCodeAndMaterialCode(String deviceCode,String materialCode);
}
