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

package com.luozhihui.project.mapper;

import com.luozhihui.project.entity.Order;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface OrderShowMapper {
    @Select({"SELECT `order`.*, `car`.CarContent, `car`.CarNumber, `user`.UserName ,`mode`.ModeName,`parking`.parkingName FROM `order` JOIN car ON `order`.CarId = `car`.CarId JOIN parking ON `order`.parking_id = `parking`.id JOIN mode ON `order`.modeId = `mode`.ModeId JOIN user ON `order`.UserId = `user`.UserId"})
    List<Order> FindAllOrder();

    @Select({"SELECT `OrderId` , `OrderMoney` ,`Mode` , `OrderStatus`, `InTime`, `car`.CarContent ,`car`.CarNumber,`user`.UserName ,`parking`.parkingName FROM `order` JOIN `car` ON `car`.CarId=`order`.CarId JOIN `user` ON `user`.UserId=`order`.UserId JOIN `parking` ON `parking`.id=`order`.parking_id ORDER BY `OrderId` DESC LIMIT 16"})
    List<Order> GetOrder();

    @Select({"SELECT `order`.*,`car`.CarContent,car.CarNumber, `mode`.ModeName,`user`.UserName,parking.parkingName,`mode`.DayMoney,`mode`.HourMoney  FROM `order` JOIN `car` ON `car`.CarId=`order`.CarId JOIN `user` ON `user`.UserId=`order`.UserId JOIN  `mode` ON `mode`.modeId=`order`.modeId JOIN  `parking` ON `parking`.id=`order`.parking_id Where `order`.`UserId`=#{userId}  ORDER BY `OrderId` LIMIT #{pageNum}, #{pageSize}"})
    List<Order> findOrdersByUserId(@Param("userId") Integer userId, @Param("pageNum") int pageNum, @Param("pageSize") int pageSize);

    @Delete({"delete  from  `order` where `OrderId`=#{OrderId}"})
    boolean DeleteOrderById(String orderId);

    @Select({"select * from  `order` where `OrderId`=#{OrderId}"})
    Order OrderId(Integer OrderId);

    @Update({"UPDATE `order` SET OrderMoney = #{OrderMoney}, OrderStatus = #{OrderStatus} where OrderId = #{OrderId}"})
    void update(Order order);

    @Select({" SELECT COUNT(*) FROM `order` WHERE `userId` = #{userId}"})
    int countOrdersByUserId(String userId);
}
