45 lines
2.1 KiB
Java
45 lines
2.1 KiB
Java
package com.erp.example.seata.mapper;
|
|
|
|
import com.erp.example.seata.entity.Order;
|
|
import org.apache.ibatis.annotations.*;
|
|
|
|
@Mapper
|
|
public interface OrderMapper {
|
|
|
|
@Insert("INSERT INTO orders (order_no, customer_id, product_id, quantity, total_amount, status, create_time, update_time) " +
|
|
"VALUES (#{orderNo}, #{customerId}, #{productId}, #{quantity}, #{totalAmount}, #{status}, #{createTime}, #{updateTime})")
|
|
@Options(useGeneratedKeys = true, keyProperty = "id")
|
|
void insert(Order order);
|
|
|
|
@Update("UPDATE orders SET status=#{status}, update_time=#{updateTime} WHERE order_no=#{orderNo}")
|
|
void update(Order order);
|
|
|
|
@Select("SELECT * FROM orders WHERE order_no = #{orderNo}")
|
|
@Results({
|
|
@Result(property = "id", column = "id"),
|
|
@Result(property = "orderNo", column = "order_no"),
|
|
@Result(property = "customerId", column = "customer_id"),
|
|
@Result(property = "productId", column = "product_id"),
|
|
@Result(property = "quantity", column = "quantity"),
|
|
@Result(property = "totalAmount", column = "total_amount"),
|
|
@Result(property = "status", column = "status"),
|
|
@Result(property = "createTime", column = "create_time"),
|
|
@Result(property = "updateTime", column = "update_time")
|
|
})
|
|
Order findByOrderNo(@Param("orderNo") String orderNo);
|
|
|
|
@Select("SELECT * FROM orders WHERE customer_id = #{customerId}")
|
|
@Results({
|
|
@Result(property = "id", column = "id"),
|
|
@Result(property = "orderNo", column = "order_no"),
|
|
@Result(property = "customerId", column = "customer_id"),
|
|
@Result(property = "productId", column = "product_id"),
|
|
@Result(property = "quantity", column = "quantity"),
|
|
@Result(property = "totalAmount", column = "total_amount"),
|
|
@Result(property = "status", column = "status"),
|
|
@Result(property = "createTime", column = "create_time"),
|
|
@Result(property = "updateTime", column = "update_time")
|
|
})
|
|
java.util.List<Order> findByCustomerId(@Param("customerId") Long customerId);
|
|
}
|