//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.luozhihui.project.mapper;

import com.luozhihui.project.entity.Repair;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

public interface RepairShowMapper {
    @Select({"select `repair`.*,`car`.* from  `repair` INNER JOIN `car` ON `repair`.CarId=`car`.CarId"})
    List<Repair> FindAllRepair();

    @Select({"select * from  `repair` where RepairId = #{RepairId}"})
    Repair FindRepairById(String RepairId);

    @Insert({"insert into `repair`(`CarId`,`RepairReason`,`RepairMoney`,`RepairStatus`) VALUES(#{CarId},#{RepairReason},#{RepairMoney},#{RepairStatus})"})
    @Transactional
    void addRepair(Repair repair);

    @Delete({"delete  from  `repair` where `RepairId`=#{RepairId}"})
    boolean DeleteRepairById(String CarId);

    @Update({"UPDATE repair SET RepairReason = #{RepairReason}, RepairMoney = #{RepairMoney}, RepairStatus = #{RepairStatus} where RepairId = #{RepairId}"})
    void update(Repair repair);

    @Update({"UPDATE `car` SET carStatus = 2 WHERE carId = #{carId}"})
    void updateCarStatusToRepair(Integer carId);

    @Update({"UPDATE `car` SET carStatus = 0 WHERE carId = #{carId}"})
    void updateCarStatusToAvailable(int carId);
}
