-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectController.java
127 lines (108 loc) · 4.7 KB
/
ProjectController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package org.scit.app.controllers;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.type.IntegerTypeHandler;
import org.apache.log4j.Logger;
import org.scit.app.persistence.ProjectDao;
import org.scit.app.persistence.UserDao;
import org.scit.app.vo.Project;
import org.scit.app.vo.Theme;
import org.scit.app.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class ProjectController {
@Autowired
SqlSession sqlSession;
private static final Logger logger = Logger.getLogger(UserController.class);
@RequestMapping(value="insertProject", method=RequestMethod.GET)
public String insertProject(String title, String userNum, Project project, Model model) {
ProjectDao dao = sqlSession.getMapper(ProjectDao.class);
int result = dao.insertProject(project);
dao.insertLeader(userNum);
return "redirect:afterLogin";
}
@RequestMapping(value="gotoGroup", method=RequestMethod.GET)
public String gotoGroup(String proNum,HttpSession session,Model model) {
model.addAttribute("theme", "open");
model.addAttribute("proNum", proNum);
ProjectDao dao = sqlSession.getMapper(ProjectDao.class);
UserDao userDao = sqlSession.getMapper(UserDao.class);
List<Project>proList = userDao.selectProjectList((String)session.getAttribute("userNum"));
List<Theme> themeList = dao.selectThemeList(proNum);
model.addAttribute("TList", themeList);
model.addAttribute("proList", proList);
String leaderNum = dao.selectLeader(proNum);
User vo = (User) session.getAttribute("user");
if(leaderNum.equals(vo.getUserNum())) {
System.out.println("leaderNum matches : " + leaderNum);
session.setAttribute("isLeader", true);
session.setAttribute("proNum", proNum);
} else {
System.out.println("leaderNum does not matches : " + leaderNum);
session.setAttribute("isLeader", false);
session.setAttribute("proNum", proNum);
}
return "index";
}
@RequestMapping(value="gotoGroupMember", method=RequestMethod.GET)
public String gotoGroupMember(String proNum,HttpSession session,Model model) {
model.addAttribute("theme", "open");
model.addAttribute("proNum", proNum);
ProjectDao dao = sqlSession.getMapper(ProjectDao.class);
UserDao userDao = sqlSession.getMapper(UserDao.class);
List<Project>proList = userDao.selectProjectList((String)session.getAttribute("userNum"));
List<Theme> themeList = dao.selectThemeList(proNum);
model.addAttribute("TList", themeList);
model.addAttribute("proList", proList);
return "indexMember";
}
@RequestMapping(value="gotoGroupLeader", method=RequestMethod.GET)
public String gotoGroupLeader(/*String proNum,*/HttpSession session ,Model model) {
/* model.addAttribute("theme", "open");
model.addAttribute("proNum", proNum);
ProjectDao dao = sqlSession.getMapper(ProjectDao.class);
UserDao userDao = sqlSession.getMapper(UserDao.class);
List<Project>proList = userDao.selectProjectList((String)session.getAttribute("userNum"));
List<Theme> themeList = dao.selectThemeList(proNum);
model.addAttribute("TList", themeList);
model.addAttribute("proList", proList);
*/
return "indexLeader";
}
@RequestMapping(value="insertTheme", method=RequestMethod.POST)
public @ResponseBody List<Theme> insertTheme(@RequestBody Map<String, Object>json, Theme theme) {
String themeName = (String) json.get("themeName");
String proNum = (String) json.get("proNum");
theme.setThemeName(themeName);
theme.setProNum(proNum);
ProjectDao dao = sqlSession.getMapper(ProjectDao.class);
dao.insertTheme(theme);
List<Theme> themeList = dao.selectThemeList(proNum);
return themeList;
}
@RequestMapping(value="deleteGroup",method=RequestMethod.POST)
public String deleteProject(String proNum){
ProjectDao dao = sqlSession.getMapper(ProjectDao.class);
int i = dao.deleteALLMember(proNum);
int k = dao.deleteALLTheme(proNum);
int y = dao.deleteProject(proNum);
return "redirect:afterLogin";
}
@RequestMapping(value="deleteTheme",method=RequestMethod.POST)
public @ResponseBody List<Theme> deleteTheme(@RequestBody Map<String, Object>json){
String thmNum = (String) json.get("thmNum");
String proNum = (String) json.get("proNum");
ProjectDao dao = sqlSession.getMapper(ProjectDao.class);
dao.deleteTheme(thmNum);
List<Theme> themeList = dao.selectThemeList(proNum);
return themeList;
}
}