/* * 新增用戶 * @param user * @return * @throws Exception */ @Insert("insert into user(name,sex,age) values(#{name},#{sex},#{age})") @Options(useGeneratedKeys=true,keyProperty="id") publicintinsertUser(User user)throws Exception;
/* * 更新用戶 * @param user * @throws Exception */ @Update("update user set age = #{age} where id = #{id}") publicvoidupdateUser(User user)throws Exception;
/* * 删除用戶 * @param id * @return * @throws Exception */ @Delete("delete from user where id = #{user_id}") publicintdeleteUser(@Param("user_id") Integer id)throws Exception;
/* * 根据 id 查询用戶 * @param id * @return * @throws Exception */ @Select("select * from user where id=#{id}") @Results({ @Result(id=true, property="id", column="id"), @Result(property="name", column="name"), @Result(property="sex", column="sex"), @Result(property="age", column="age"), }) public User selectUserById(Integer id)throws Exception;
/* * 查询所有用戶 * @return * @throws Exception */ @Select("select * from user") public List<User> selectAllUser()throws Exception; }