회원가입 화면 추가

main
이범준 11 months ago
parent 07a85cc4b3
commit e2af1d5528

@ -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<DataObject> 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");

@ -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)
<if test="currentUser.institute != 'default'">
WHERE A.INST_CD = #{currentUser.institute}
</if>
<if test="currentUser.institute == 'default'">
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
</if>
<choose>
<when test='anonymous == "Y" '>
WHERE A.INST_CD = #{institute}
</when>
<otherwise>
<if test="currentUser.institute != 'default'">
WHERE A.INST_CD = #{currentUser.institute}
</if>
<if test="currentUser.institute == 'default'">
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
</if>
</otherwise>
</choose>
</select>
<select id="selectFactionInfoOfUser" parameterType="string" resultType="dataobject">

@ -27,6 +27,7 @@
<div class="col-sm-9">
<select name="institute" class="form-select" data-map="NSTT_CD"
required title="기관/부서" disabled style="background-image:none;">
<option value=""></option>
<c:forEach items="${allFactionList}" var="item">
<option value="${item.INST_CD}">${item.INST_NM}</option>
</c:forEach>
@ -34,6 +35,7 @@
<br/>
<select name="deptCode" class="form-select" data-map="DEPT_CD"
required title="기관/부서" disabled style="background-image:none;">
<option value=""></option>
<c:forEach items="${allFactionList}" var="item">
<option value="${item.DEPT_CD}">${item.DEPT_NM}</option>
</c:forEach>

@ -62,6 +62,7 @@
<div class="col-sm-9">
<select name="institute" class="form-select" data-map="NSTT_CD"
required title="기관/부서" disabled style="background-image:none;">
<option value=""></option>
<c:forEach items="${allFactionList}" var="item">
<option value="${item.INST_CD}">${item.INST_NM}</option>
</c:forEach>
@ -69,6 +70,7 @@
<br/>
<select name="deptCode" class="form-select" data-map="DEPT_CD"
required title="기관/부서" disabled style="background-image:none;">
<option value=""></option>
<c:forEach items="${allFactionList}" var="item">
<option value="${item.DEPT_CD}">${item.DEPT_NM}</option>
</c:forEach>
@ -87,6 +89,7 @@
<input name="id" type="hidden" data-map="USER_ID" />
<input name="account" type="text" required data-map="USER_ACNT" class="form-control"
placeholder="사용자 계정" />
<button type="button" id="btnDuplicate" class="btn btn-primary">중복 확인</button>
</div>
</div>
</div>
@ -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);

@ -73,8 +73,8 @@
<!--
<a href="#" onclick="javascript:fn_FindId(); return false;">아이디 찾기</a>
<a href="#" onclick="javascript:fn_FindPw(); return false;" class="line">비밀번호 찾기</a>
<a href="#" onclick="javascript:fnReg(); return false;" class="line">회원가입</a>
-->
<a href="#" onclick="javascript:fnOpenSignup(); return false;" class="line">회원가입</a>
</div>
</div>
<input type="hidden" name="message" value="${message}" />
@ -87,6 +87,15 @@
</div>
</div>
<template id="selectInstDialogTemplate">
<select class="form-select form-control-sm" id="selectInst">
<option value="">선택</option>
<option value="4060000">파주시</option>
<option value="4050000">용인시</option>
<option value="3910000">평택시</option>
</select>
</template>
<jsp:include page="/WEB-INF/jsp/include/tail.jsp" />
<script type="text/javascript">
@ -129,14 +138,30 @@ $(function(){
$("#password").focus();
});
/**
* 회원가입 팝업
*/
function fnReg(){
window.open(".do", "regAccount", {width: 1100, height:570});
function fnOpenSignup(){
dialog.open({
id : "selectInstDialog",
title : "기관 선택",
content : document.getElementById("selectInstDialogTemplate").innerHTML,
size : "sm",
init : () => {},
onOK : () => {
if($("#selectInst").val() == ""){
alert("기관을 선택하세요.");
return;
}
dialog.close("selectInstDialog");
window.open(wctx.url("/error/signupPage.do")+"?institute="+$("#selectInst").val(),
"regAccount",
"width=950, height=500");
},
onClose : () => {}
});
}
/**

Loading…
Cancel
Save