diff --git a/src/main/java/cokr/xit/fims/MainController.java b/src/main/java/cokr/xit/fims/MainController.java index 401a51a7..b312252f 100644 --- a/src/main/java/cokr/xit/fims/MainController.java +++ b/src/main/java/cokr/xit/fims/MainController.java @@ -2,6 +2,8 @@ package cokr.xit.fims; import java.util.List; +import javax.annotation.Resource; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -9,6 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; +import cokr.xit.base.user.ManagedUser; +import cokr.xit.base.user.service.UserService; +import cokr.xit.fims.cmmn.dao.FactionMapper; import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.web.AbstractController; import cokr.xit.foundation.web.RequestHandlerReader; @@ -18,11 +23,51 @@ public class MainController extends AbstractController { @Autowired private RequestMappingHandlerMapping requestHandlers; + @Resource(name="factionMapper") + FactionMapper factionMapper; + + @Resource(name="userService") + private UserService userService; + @GetMapping(name="로그인", value="/login.do") public String loginPage() { return "login"; } + @GetMapping(name="회원가입 페이지", value="/error/signupPage.do") + public ModelAndView signupPage(String institute) { + ModelAndView mav = new ModelAndView("fims/user/user-info"); + + mav.addObject("allFactionList", factionMapper.selectAllFactionList()); + + DataObject params = new DataObject(); + params.set("anonymous", "Y"); + params.set("institute", institute); + List ableFactionList = factionMapper.selectAbleFactionList(params); + mav.addObject("ableFactionList", ableFactionList); + + mav.addObject("userInfo", "{}"); + + return mav; + } + + @RequestMapping(name="회원가입", value="/error/signup.do") + public ModelAndView signup(ManagedUser user) { + ModelAndView mav = new ModelAndView("jsonView"); + + boolean saved = userService.create(user); + + mav.addObject("saved",saved); + return mav; + } + + @RequestMapping(name="중복 확인", value="/error/duplicate.do") + public ModelAndView isDuplicate(String account, String institute) { + ManagedUser user = userService.getUser(account, institute); + return new ModelAndView("jsonView") + .addObject("duplicate", user != null); + } + @GetMapping(name="홈", value={"/", "/index.do"}) public ModelAndView mainPage() { return new ModelAndView("index"); diff --git a/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml b/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml index b2f8fe9c..d9f43fbf 100644 --- a/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml +++ b/src/main/resources/sql/mapper/fims/cmmn/faction-mapper.xml @@ -34,21 +34,32 @@ SELECT CONCAT(A.INST_CD,'/',B.DEPT_CD) AS FACTION_CD , A.SGG_NM FROM TB_SGG A LEFT OUTER JOIN TB_DEPT B ON (A.INST_CD = B.INST_CD) - -WHERE A.INST_CD = #{currentUser.institute} - - -UNION -SELECT 'default/default' AS FACTION_CD - , CONCAT('기본 기관',' / ','기본 부서') AS FACTION_NM - , 'default' AS INST_CD - , '기본 기관' AS INST_NM - , 'default' AS DEPT_CD - , '기본 부서' AS DEPT_NM - , 'default' AS SGG_CD - , '기본 시군구' AS SGG_NM -FROM DUAL - + + + WHERE A.INST_CD = #{institute} + + + + WHERE A.INST_CD = #{currentUser.institute} + + + UNION + SELECT 'default/default' AS FACTION_CD + , CONCAT('기본 기관',' / ','기본 부서') AS FACTION_NM + , 'default' AS INST_CD + , '기본 기관' AS INST_NM + , 'default' AS DEPT_CD + , '기본 부서' AS DEPT_NM + , 'default' AS SGG_CD + , '기본 시군구' AS SGG_NM + FROM DUAL + + + + + + + + @@ -34,6 +35,7 @@
+ @@ -69,6 +70,7 @@
+ @@ -247,6 +250,10 @@ userControl.setInfo = obj => { userFields.set(obj); let create = isEmpty(obj.USER_ACNT); + if(!create){ + $("#btnDuplicate").hide(); + } + $("input[name='account']").prop("readonly", !create); $("input[type='password']").each(function(){ let password = $(this).prop("required", create); @@ -303,7 +310,7 @@ function save(info){ var create = isEmpty(info.id) ajax.post({ - url:!create ? userControl.urls.update : userControl.urls.create, + url:!create ? userControl.urls.update : wctx.url("/error/signup.do"), data:info, success: (resp) => { if(resp.saved){ @@ -323,6 +330,33 @@ function setFactionCodeValues(institute, deptCode, sggCd){ $("#user-form [name='orgID']").val(sggCd); } +$("#btnDuplicate").on("click", function(){ + if($("#user-form").find("[name='account']").val() == ""){ + alert("계정을 입력하세요."); + return; + } + + if($("#user-form").find("[name='institute']").val() == ""){ + alert("기관을 선택하세요."); + return; + } + + ajax.get({ + url : wctx.url("/error/duplicate.do"), + data : { + account : $("#user-form").find("[name='account']").val(), + institute : $("#user-form").find("[name='institute']").val() + }, + success : resp => { + if(resp.duplicate){ + alert("이미 존재하는 ID입니다."); + } else { + alert("사용할 수 있는 ID입니다."); + } + } + }); +}); + var userInfo = ${userInfo}; userControl.setInfo(userInfo); diff --git a/src/main/webapp/WEB-INF/jsp/login.jsp b/src/main/webapp/WEB-INF/jsp/login.jsp index c19535f9..9d23ceb7 100644 --- a/src/main/webapp/WEB-INF/jsp/login.jsp +++ b/src/main/webapp/WEB-INF/jsp/login.jsp @@ -73,8 +73,8 @@ + 회원가입 @@ -87,6 +87,15 @@ + +