@Mapper public interface EmpMapper { @Delete("delete from emp where id = #{id}") public void delete(Integer id); @Options(useGeneratedKeys = true, keyProperty = "id") @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time)" + " values (#{username}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime})") public void insert(Emp emp); @Results({ @Result(column = "dept_id", property = "deptId"), @Result(column = "create_time", property = "createTime"), @Result(column = "update_time", property = "updateTime") }) @Select("select * from emp where id = #{id}") public Emp getById(Integer id); // or in application.properties // mybatis.configuration.map-underscore-to-camel-case=true //@Select("select * from emp where name like '%${name}%' and gender = #{gender} and " + // "entrydate between #{begin} and #{end} order by update_time desc ") @Select("select * from emp where name like concat('%', #{name}, '%') and gender = #{gender} and " + "entrydate between #{begin} and #{end} order by update_time desc ") public List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end); } |
refer to:
https://www.bilibili.com/video/BV1kg4y1x7o6/?p=124