25 lines
1023 B
Java
25 lines
1023 B
Java
package com.erp.example.seata.mapper;
|
|
|
|
import com.erp.example.seata.entity.Inventory;
|
|
import org.apache.ibatis.annotations.*;
|
|
|
|
@Mapper
|
|
public interface InventoryMapper {
|
|
|
|
@Update("UPDATE inventory SET stock=#{stock}, reserved_stock=#{reservedStock}, update_time=NOW() WHERE product_id=#{productId}")
|
|
void update(Inventory inventory);
|
|
|
|
@Select("SELECT * FROM inventory WHERE product_id = #{productId}")
|
|
@Results({
|
|
@Result(property = "id", column = "id"),
|
|
@Result(property = "productId", column = "product_id"),
|
|
@Result(property = "productName", column = "product_name"),
|
|
@Result(property = "stock", column = "stock"),
|
|
@Result(property = "reservedStock", column = "reserved_stock"),
|
|
@Result(property = "availableStock", column = "available_stock"),
|
|
@Result(property = "warehouse", column = "warehouse"),
|
|
@Result(property = "updateTime", column = "update_time")
|
|
})
|
|
Inventory findByProductId(@Param("productId") Long productId);
|
|
}
|