diff --git a/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java b/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java index 0d51a37..e34041b 100644 --- a/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java +++ b/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java @@ -17,6 +17,12 @@ import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; import org.egovframe.rte.psl.dataaccess.mapper.EgovMapper; import egovframework.example.sample.service.SampleVO; @@ -45,6 +51,7 @@ public interface SampleMapper { * @return 등록 결과 * @exception Exception */ + @Insert("INSERT INTO SAMPLE ( ID, NAME, DESCRIPTION, USE_YN, REG_USER ) VALUES ( #{id}, #{name}, #{description}, #{useYn}, #{regUser} )") void insertSample(SampleVO vo) throws Exception; /** @@ -53,6 +60,7 @@ public interface SampleMapper { * @return void형 * @exception Exception */ + @Update("UPDATE SAMPLE SET ID=#{id}, NAME=#{name}, DESCRIPTION=#{description}, USE_YN=#{useYn} WHERE ID=#{id}") void updateSample(SampleVO vo) throws Exception; /** @@ -61,6 +69,7 @@ public interface SampleMapper { * @return void형 * @exception Exception */ + @Delete("DELETE FROM SAMPLE WHERE ID=#{id}") void deleteSample(SampleVO vo) throws Exception; /** @@ -69,6 +78,14 @@ public interface SampleMapper { * @return 조회한 글 * @exception Exception */ + @Select("SELECT ID, NAME, DESCRIPTION, USE_YN, REG_USER FROM SAMPLE WHERE ID=#{id}") + @Results(id = "sampleResult", value = { + @Result(property = "id", column = "id", id = true), + @Result(property = "name", column = "name"), + @Result(property = "description", column = "description"), + @Result(property = "useYn", column = "use_yn"), + @Result(property = "regUser", column = "reg_user") + }) SampleVO selectSample(SampleVO vo) throws Exception; /** diff --git a/src/main/resources/egovframework/sqlmap/example/mappers/EgovSample_Sample_SQL.xml b/src/main/resources/egovframework/sqlmap/example/mappers/EgovSample_Sample_SQL.xml index d881b2d..7d2a43e 100644 --- a/src/main/resources/egovframework/sqlmap/example/mappers/EgovSample_Sample_SQL.xml +++ b/src/main/resources/egovframework/sqlmap/example/mappers/EgovSample_Sample_SQL.xml @@ -1,83 +1,32 @@ - + - - - - - - - - - - - INSERT INTO SAMPLE - ( ID - , NAME - , DESCRIPTION - , USE_YN - , REG_USER ) - VALUES ( #{id} - , #{name} - , #{description} - , #{useYn} - , #{regUser} ) + - - SELECT - ID, NAME, DESCRIPTION, USE_YN, REG_USER - FROM SAMPLE - WHERE ID=#{id} - - - - - - + + - + + + \ No newline at end of file diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java index d9bc5cd..643b069 100644 --- a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java @@ -66,7 +66,7 @@ void test() throws Exception { // when mockMvc.perform( - post("/sample/add") + post("/addSample.do") .param("name", sampleVO.getName())