Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions first/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/sample/test2.jsp=UTF-8
47 changes: 47 additions & 0 deletions first/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,53 @@
</repositories>

<dependencies>
<!-- Jgit -->
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.1.1.201511131810-r</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.archive</artifactId>
<version>4.1.1.201511131810-r</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>

<dependency>
<groupId>org.gitective</groupId>
<artifactId>gitective-core</artifactId>
<version>0.9.9</version>
</dependency>
<!-- Smart HTTP Servlet -->

<dependency>
<groupId>com.github.rjeschke</groupId>
<artifactId>txtmark</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.http.server</artifactId>
<version>4.1.1.201511131810-r</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.junit</artifactId>
<version>4.1.1.201511131810-r</version>
</dependency>


<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
Expand Down
2 changes: 1 addition & 1 deletion first/src/main/java/first/common/common/CommandMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package first.common.common;

// git commit test 01
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
Expand Down
23 changes: 23 additions & 0 deletions first/src/main/java/first/sample/controller/SampleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ public ModelAndView openTimeline(CommandMap commandMap) throws Exception{
return mv;
}



@RequestMapping(value="/sample/test2.do")
public ModelAndView openGit(CommandMap commandMap) throws Exception{
ModelAndView mv = new ModelAndView("/sample/test2");

return mv;
}

@RequestMapping(value="/sample/test2_result.do")
public ModelAndView resultGit(CommandMap commandMap ,HttpServletRequest request) throws Exception{
ModelAndView mv = new ModelAndView("sample/test2_result");
// log.debug("request : "+request.toString() + "\n" + commandMap.get("file").toString()+ "\n");
//sampleService.insertBoard(commandMap.getMap(),request);\
String result = "";
result += sampleService.gitStore(commandMap.getMap(),request);
log.debug("result = "+ result.toString() + "\n");
mv.addObject("fileList", result);
return mv;
}


@RequestMapping(value="/sample/openBoardWrite.do")
public ModelAndView openBoardWrite(CommandMap commandMap) throws Exception{
ModelAndView mv = new ModelAndView("/sample/boardWrite");
Expand All @@ -53,6 +75,7 @@ public ModelAndView openBoardWrite(CommandMap commandMap) throws Exception{
@RequestMapping(value="/sample/insertBoard.do")
public ModelAndView insertBoard(CommandMap commandMap ,HttpServletRequest request) throws Exception{
ModelAndView mv = new ModelAndView("redirect:/sample/openBoardList.do");
log.debug("request : "+request.toString() + "\n" + commandMap.get("file")+ "\n");
sampleService.insertBoard(commandMap.getMap(),request);

return mv;
Expand Down
6 changes: 4 additions & 2 deletions first/src/main/java/first/sample/dao/SampleDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ public void insertFile(Map<String, Object> map) throws Exception{
insert("sample.insertFile", map); //파일입력
}



public void insertBoard(Map<String, Object> map) throws Exception{
insert("sample.insertBoard", map);
}
public void insertProject(Map<String, Object> map) throws Exception{
insert("sample.insertProject", map);
}


public void updateHitCnt(Map<String, Object> map) throws Exception{
update("sample.updateHitCnt", map);
Expand Down
4 changes: 4 additions & 0 deletions first/src/main/java/first/sample/service/SampleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ public interface SampleService {
void updateBoard(Map<String, Object> map) throws Exception;

void deleteBoard(Map<String, Object> map) throws Exception;

String gitStore(Map<String, Object> map,HttpServletRequest request) throws Exception;



}
24 changes: 24 additions & 0 deletions first/src/main/java/first/sample/service/SampleServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.eclipse.jgit.api.Git;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import first.common.util.FileUtils;
import first.common.util.GitUtils;
import first.common.util.ZipUtils;
import first.sample.dao.SampleDAO;

@Service("sampleService")
Expand All @@ -24,6 +27,12 @@ public class SampleServiceImpl implements SampleService{
@Resource(name="fileUtils")
private FileUtils fileUtils;

@Resource(name="zipUtils")
private ZipUtils zipUtils;

@Resource(name="gitUtils")
private GitUtils gitUtils;

@Resource(name="sampleDAO")
private SampleDAO sampleDAO;

Expand Down Expand Up @@ -79,4 +88,19 @@ public void deleteBoard(Map<String, Object> map) throws Exception {
sampleDAO.deleteBoard(map);
}

@Override
public String gitStore(Map<String, Object> map, HttpServletRequest request) throws Exception {
// TODO Auto-generated method stub
String result= "";
String projectName="";
String file = (String) map.get("file");
projectName = zipUtils.makegit(map, request);
log.debug("projectName : "+projectName );
result = gitUtils.getProjectList(projectName, 4);
map.put("projectName", projectName);

sampleDAO.insertProject(map);
return result;
}

}
29 changes: 29 additions & 0 deletions first/src/main/resources/mapper/sample/Sample_SQL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
</selectKey>
</insert>



<!-- file DB query -->
<insert id="insertFile" parameterType="hashmap" >

Expand All @@ -63,6 +65,33 @@
#{FILE_SIZE}
)
]]>
</insert>

<insert id="insertProject" parameterType="hashmap" >

<![CDATA[
INSERT INTO project
(
PRJ_IDX,
TITLE,
DATE,
COMMENT,
LANG,
IMAGE_URL
)
VALUES
(
NULL,
#{projectName},
now(),
#{comment},
'language example',
'https://www.google.com/images/nav_logo242.png/'
)
]]>
<selectKey keyProperty="board_id" resultType="Integer">
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<!-- select file and board -->
Expand Down
Binary file not shown.
Binary file modified first/target/classes/first/sample/dao/SampleDAO.class
Binary file not shown.
Binary file modified first/target/classes/first/sample/service/SampleService.class
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions first/target/classes/mapper/sample/Sample_SQL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
</selectKey>
</insert>



<!-- file DB query -->
<insert id="insertFile" parameterType="hashmap" >

Expand All @@ -63,6 +65,33 @@
#{FILE_SIZE}
)
]]>
</insert>

<insert id="insertProject" parameterType="hashmap" >

<![CDATA[
INSERT INTO project
(
PRJ_IDX,
TITLE,
DATE,
COMMENT,
LANG,
IMAGE_URL
)
VALUES
(
NULL,
#{projectName},
now(),
#{comment},
'language example',
'https://www.google.com/images/nav_logo242.png/'
)
]]>
<selectKey keyProperty="board_id" resultType="Integer">
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<!-- select file and board -->
Expand Down