package kr.wisestone.owl.web.controller;
|
|
import kr.wisestone.owl.constant.Constants;
|
import kr.wisestone.owl.domain.enumType.SocialType;
|
import kr.wisestone.owl.service.UserService;
|
import kr.wisestone.owl.util.ConvertUtil;
|
import kr.wisestone.owl.web.condition.UserCondition;
|
import kr.wisestone.owl.web.form.UserForm;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Pageable;
|
import org.springframework.http.MediaType;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.servlet.ModelAndView;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* Created by jeong on 2017-08-02.
|
*/
|
@Controller
|
public class UserController extends BaseController {
|
|
@Autowired
|
private UserService userService;
|
|
// 로그인 세션 조회
|
@RequestMapping(value = "/user/getUserSession", produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> getUserSession(HttpServletRequest httpServletRequest) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
this.userService.getUserSession(resJsonData, httpServletRequest);
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 세션을 업데이트한다.
|
@RequestMapping(value = "/user/updateUserSession", produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> updateUserSession() {
|
Map<String, Object> resJsonData = new HashMap<>();
|
this.userService.updateUserSession();
|
resJsonData.put(Constants.RES_KEY_CONTENTS, this.webAppUtil.getLoginUser());
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자 생성
|
@RequestMapping(value = "/user/add", method = RequestMethod.POST)
|
public
|
@ResponseBody
|
Map<String, Object> addUser(MultipartHttpServletRequest request) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
Map<String, Object> content = ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT));
|
this.userService.addUser(UserForm.make(content), request.getFile("file"));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 구글 아이디로 회원 가입
|
@RequestMapping(value = "/googleOAuth2CallBack", method = RequestMethod.GET)
|
public ModelAndView googleOAuth2CallBack(@RequestParam("code") String code, @RequestParam("state") String state, HttpServletRequest request) {
|
return this.userService.getOAuthToken(code, state, SocialType.GOOGLE, request);
|
}
|
|
// 네이버 아이디로 회원 가입
|
@RequestMapping(value = "/naverOAuth2CallBack", method = RequestMethod.GET)
|
public ModelAndView naverOAuth2callBack(@RequestParam("code") String code, @RequestParam("state") String state, HttpServletRequest request) {
|
return this.userService.getOAuthToken(code, state, SocialType.NAVER, request);
|
}
|
|
// 카카오 아이디로 회원 가입
|
@RequestMapping(value = "/kakaoOAuth2CallBack", method = RequestMethod.GET)
|
public ModelAndView kakaoOAuth2CallBack(@RequestParam("code") String code, @RequestParam("state") String state, HttpServletRequest request) {
|
return this.userService.getOAuthToken(code, state, SocialType.KAKAO, request);
|
}
|
|
// 페이스북 아이디로 회원 가입
|
@RequestMapping(value = "/facebookOAuth2CallBack", method = RequestMethod.GET)
|
public ModelAndView facebookOAuth2CallBack(@RequestParam("code") String code, @RequestParam("state") String state, HttpServletRequest request) {
|
return this.userService.getOAuthToken(code, state, SocialType.FACEBOOK, request);
|
}
|
|
// 사용자 조회
|
@RequestMapping(value = "/user/find", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> find(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params));
|
|
this.userService.findUser(resJsonData, UserCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable);
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 전체 업무공간의 사용자 조회
|
@RequestMapping(value = "/user/findByAllWorkspace", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> findByAllWorkspace(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
Pageable pageable = this.pageUtil.convertPageable(this.getPageVo(params));
|
|
this.userService.findByAllWorkspace(resJsonData, UserCondition.make(params.get(Constants.REQ_KEY_CONTENT)), pageable);
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자 조회
|
@RequestMapping(value = "/user/findMyLevelAndDepartment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> findMyLevelAndDepartment(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
this.userService.findMyLevelAndDepartment(resJsonData);
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자 수정
|
@RequestMapping(value = "/user/modify", produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> modify(MultipartHttpServletRequest request) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
|
this.userService.modifyUser(UserForm.make(ConvertUtil.convertJsonToMap(request.getParameter(Constants.REQ_KEY_CONTENT))), request.getFile("file"));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자 비밀번호 수정
|
@RequestMapping(value = "/user/modifyPassword", produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> modifyPassword(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
this.userService.modifyPassword(UserForm.make(params.get(Constants.REQ_KEY_CONTENT)));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자 상세 조회
|
@RequestMapping(value = "/user/detail", produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> detail(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
this.userService.detailUser(resJsonData, UserCondition.make(params.get(Constants.REQ_KEY_CONTENT)));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 비밀번호 찾기
|
@RequestMapping(value = "/user/returnEmailPassword", method = RequestMethod.POST)
|
public
|
@ResponseBody
|
Map<String, Object> returnEmailPassword(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
this.userService.returnEmailPassword(UserForm.make(params.get(Constants.REQ_KEY_CONTENT)));
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자의 마지막 접근 워크스페이스 정보 업데이트
|
@RequestMapping(value = "/user/updateLastWorkspace", method = RequestMethod.POST)
|
public
|
@ResponseBody
|
Map<String, Object> updateLastWorkspace(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
|
this.userService.updateLastWorkspace(resJsonData, UserForm.make(params.get(Constants.REQ_KEY_CONTENT)));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자의 마지막 접근 프로젝트 정보 업데이트
|
@RequestMapping(value = "/user/updateLastProject", method = RequestMethod.POST)
|
public
|
@ResponseBody
|
Map<String, Object> updateLastProject(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
|
this.userService.updateLastProject(resJsonData, UserForm.make(params.get(Constants.REQ_KEY_CONTENT)));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자의 마지막 접근 이슈 유형 정보 업데이트
|
@RequestMapping(value = "/user/updateLastIssueType", method = RequestMethod.POST)
|
public
|
@ResponseBody
|
Map<String, Object> updateLastIssueType(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
|
this.userService.updateLastIssueType(resJsonData, UserForm.make(params.get(Constants.REQ_KEY_CONTENT)));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
|
// 프로젝트에 참여하는 일반 사용자 목록 조회
|
@RequestMapping(value = "/user/findProjectMember", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> findProjectMember(@RequestBody Map<String, Map<String, Object>> params) {
|
Map<String, Object> resJsonData = new HashMap<>();
|
|
this.userService.findProjectMember(resJsonData, UserCondition.make(params.get(Constants.REQ_KEY_CONTENT)));
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자 탈퇴
|
@RequestMapping(value = "/user/withDraw", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
public
|
@ResponseBody
|
Map<String, Object> withDraw() {
|
Map<String, Object> resJsonData = new HashMap<>();
|
|
this.userService.withDrawUser();
|
|
return this.setSuccessMessage(resJsonData);
|
}
|
|
// 사용자 엑셀 다운로드
|
@RequestMapping(value = "/user/downloadExcel", method = RequestMethod.POST)
|
public ModelAndView downloadExcel(HttpServletRequest request, Model model) {
|
return this.userService.downloadExcel(model);
|
}
|
|
/*// 이벤트 당첨자 엑셀 다운로드
|
@RequestMapping(value = "/user/downloadExcelEvent", method = RequestMethod.POST)
|
public ModelAndView downloadExcelEvent(HttpServletRequest request, Model model) {
|
return this.userService.downloadExcelEvent(model);
|
}*/
|
}
|