package com.luozhihui.project.mapper;
import com.luozhihui.project.entity.Brand;
import org.apache.ibatis.annotations.*;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface BrandMapper {
    // 查询所有车辆信息
    @Select("select * from  `brand`  LIMIT #{pageNum}, #{pageSize}")
    List<Brand> FindAllBrandpage( @Param("pageNum") int pageNum, @Param("pageSize") int pageSize);

    @Select("select * from  `brand`  ")
    List<Brand> FindAllBrand();
    @Select("select * from  `brand` where `id`=#{id}")
    List<Brand> FindBrandById(String Id);
    @Insert("insert into `brand`(`brand_name_ch`,`brand_name_en`,`brand_logo`,`status`) VALUES(#{brand_name_ch},#{brand_name_en},#{brand_logo},#{status})")
    @Transactional
    void addBrand(Brand brand);

    //通过id删除信息
    @Delete("delete  from  `brand` where `id`=#{id}")
    boolean DeleteBrandById(String Id);
    //通过id查询信息
    @Select("select * from  `brand` where `id`=#{id}")
    Brand BrandId(Integer Id);
    //    更新品牌信息
    @Update("UPDATE brand SET brand_name_ch = #{brand_name_ch}, brand_name_en = #{brand_name_en}, brand_logo = #{brand_logo}, status = #{status} where `id`=#{id}")
    void update(Brand brand);
    //查询数据数量
    @Select(" SELECT COUNT(*) FROM `brand` ")
    int countBrand();
}
