StaffController.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package com.lemon.lifecenter.controller;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.json.JSONObject;
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.ModelAttribute;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestMethod;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.ResponseBody;
  14. import org.springframework.web.servlet.ModelAndView;
  15. import com.lemon.lifecenter.common.LifeCenterConfigVO;
  16. import com.lemon.lifecenter.common.LifeCenterController;
  17. import com.lemon.lifecenter.common.LifeCenterFunction;
  18. import com.lemon.lifecenter.common.LifeCenterPaging;
  19. import com.lemon.lifecenter.dto.CenterInfoDTO;
  20. import com.lemon.lifecenter.dto.LocationDTO;
  21. import com.lemon.lifecenter.dto.LoginDTO;
  22. import com.lemon.lifecenter.dto.StaffDTO;
  23. import com.lemon.lifecenter.service.CenterService;
  24. import com.lemon.lifecenter.service.LoginService;
  25. import com.lemon.lifecenter.service.StaffService;
  26. // 의료진관리 contorller
  27. @Controller
  28. @RequestMapping("/staff")
  29. public class StaffController extends LifeCenterController {
  30. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  31. @Autowired
  32. private LoginService loginService;
  33. @Autowired
  34. private StaffService memberService;
  35. @Autowired
  36. private LifeCenterConfigVO config;
  37. private LifeCenterPaging paging;
  38. @RequestMapping("/new")
  39. public ModelAndView staffNew() {
  40. List<CenterInfoDTO> centerList = memberService.selectCenterList();
  41. ModelAndView mv = setMV("staff/new");
  42. mv.addObject("centerList", centerList);
  43. return mv;
  44. }
  45. @RequestMapping("/newRegist")
  46. public String staffNewRegist(
  47. @ModelAttribute("dto") final StaffDTO dto,
  48. @RequestParam(value="centerCode", required=true) String centerCode,
  49. @RequestParam(value="passwordConfirm", required=true) String passwordConfirm) throws Exception {
  50. String pw = dto.getPassword();
  51. dto.setPassword(LifeCenterFunction.aesEncrypt(config.aesKey, config.IV, pw));
  52. dto.setGroupIdx("3");
  53. memberService.insertStaff(dto);
  54. return "redirect:./info?staffId=" + dto.getId();
  55. }
  56. @RequestMapping("/info")
  57. public ModelAndView staffInfo(
  58. @RequestParam(value="staffId", required=false, defaultValue="") String staffID) {
  59. StaffDTO dto = new StaffDTO();
  60. dto.setId(staffID);
  61. dto = memberService.selectMemberInfo(dto);
  62. ModelAndView mv = setMV("staff/info");
  63. mv.addObject("info", dto);
  64. return mv;
  65. }
  66. @RequestMapping("/edit")
  67. public ModelAndView staffEdit(
  68. @RequestParam(value="staffId", required=false, defaultValue="") String staffId,
  69. @RequestParam(value="centerCode", required=false, defaultValue="") String centerCode,
  70. @RequestParam(value="groupIdx", required=false, defaultValue="") String groupIdx) {
  71. List<CenterInfoDTO> centerList = memberService.selectCenterList();
  72. StaffDTO dto = new StaffDTO();
  73. dto.setId(staffId);
  74. dto = memberService.selectMemberInfo(dto);
  75. ModelAndView mv = setMV("staff/edit");
  76. mv.addObject("info", dto);
  77. mv.addObject("centerCode", centerCode);
  78. mv.addObject("groupIdx", groupIdx);
  79. mv.addObject("centerList", centerList);
  80. return mv;
  81. }
  82. @RequestMapping("/myinfo")
  83. public ModelAndView staffMyinfo() {
  84. ModelAndView mv = setMV("staff/myinfo");
  85. return mv;
  86. }
  87. @RequestMapping("/list")
  88. public ModelAndView staffList(
  89. @ModelAttribute("dto") final StaffDTO dto,
  90. @RequestParam(value="selectState", required=false, defaultValue="") String selectState,
  91. @RequestParam(value="sData", required=false, defaultValue="") String sData,
  92. @RequestParam(value="useYn", required=false, defaultValue="") String useYn,
  93. @RequestParam(value="page", required=false, defaultValue="1") int page) {
  94. logger.error("selectState -- > " + selectState);
  95. logger.error("sData -- > " + sData);
  96. logger.error("useYn -- > " + useYn);
  97. if (selectState.equals("sId")) {
  98. dto.setId(sData);
  99. } else if (selectState.equals("sName")) {
  100. dto.setName(sData);
  101. } else {
  102. dto.setCenterName(sData);
  103. }
  104. dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
  105. dto.setLimitMax( config.pageDataSize );
  106. int total = memberService.selectMemeberListCount(dto);
  107. List<StaffDTO> list = new ArrayList<StaffDTO>();
  108. if (total > 0) {
  109. list = memberService.selectMemberList(dto);
  110. }
  111. String param = "";
  112. paging = LifeCenterPaging.getInstance();
  113. paging.paging(config, total, page, param);
  114. ModelAndView mv = setMV("staff/list");
  115. mv.addObject("total", total);
  116. mv.addObject("selectState", selectState);
  117. mv.addObject("sData", sData);
  118. mv.addObject("useYn", useYn);
  119. mv.addObject("item", list);
  120. mv.addObject("paging", paging);
  121. return mv;
  122. }
  123. @RequestMapping( value="/duplicateIdCheck", method = RequestMethod.POST )
  124. @ResponseBody
  125. public boolean duplicateIdCheck( @RequestParam( value="staffId", required = false, defaultValue = "" ) String id ) {
  126. boolean result = false; // false : 중복 , true : 중복아님
  127. JSONObject obj = new JSONObject();
  128. LoginDTO dto = new LoginDTO();
  129. if( id.trim().equals( "" ) ) {
  130. result = false;
  131. } else {
  132. dto.setId( id.trim() );
  133. int count = loginService.selectMemberIdCount( dto );
  134. if( count == 0 ) {
  135. result = true;
  136. }
  137. }
  138. // obj.put( "result" , result );
  139. return result;
  140. }
  141. }