package org.itevents.mapper;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.itevents.model.City;
import org.itevents.model.Location;

public interface CityMapper {
    @Results(value = {
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "location", javaType = Location.class,
                    column = "id", one = @One(select = "org.itevents.mapper.LocationMapper.getCityLocation"))
    })
    @Select("SELECT id, name FROM cities WHERE id = #{id}")
    City getCity(int id);
}
@@ -64,147 +64,9 @@
 ons.
-One;%0Aimport org.apache.ibatis.annotations.Result;%0Aimport org.apache.ibatis.annotations.Results;%0Aimport org.apache.ibatis.annotations.Select
+*
 ;%0Aim
@@ -568,9 +568,324 @@
 nt id);%0A
+%0A    @Insert(%22INSERT INTO cities(id, name, point) VALUES(#%7Bid%7D, #%7Bname%7D, #%7Bpoint%7D%22)%0A    void addCity(City city);%0A%0A    @Update(%22UPDATE cities SET id=#%7Bid%7D, name=#%7Bname%7D, point=#%7Bpoint%7D WHERE id =#%7Bid%7D%22)%0A    void updateCity(City city);%0A%0A    @Delete(%22DELETE FROM cities WHERE id =#%7Bid%7D%22)%0A    void removeCity(int id);%0A%0A
 %7D

add CRUD to CityMapper