CustomerMapper
package com.example.customerservice.mapper; import com.example.customerservice.model.Customer; import org.apache.ibatis.annotations.*; import java.util.List; @Mapper public interface CustomerMapper { @Select("SELECT * FROM customers WHERE customer_id = #{customerId}") Customer findById(Integer customerId); @Select("SELECT * FROM customers") List<Customer> findAll(); @Insert("INSERT INTO customers (name, address) VALUES (#{name}, #{address})") @Options(useGeneratedKeys = true, keyProperty = "customerId") int insert(Customer customer); @Update("UPDATE customers SET name = #{name}, address = #{address} WHERE customer_id = #{customerId}") int update(Customer customer); @Delete("DELETE FROM customers WHERE customer_id = #{customerId}") int delete(Integer customerId); }
CustomerService