feat : 로그인관련 설정 및 다이나믹 트랜젝션 설정중
parent
e7618fbb2e
commit
ee46e4f56f
@ -0,0 +1,36 @@
|
||||
package egovframework.config.myBatisConf;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class CpMyBatisConf {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public SqlSessionFactory cpSqlSessionFactory(@Qualifier("cpDataSource") DataSource cpDataSource) throws Exception {
|
||||
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||
factoryBean.setDataSource(cpDataSource);
|
||||
return factoryBean.getObject();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public SqlSessionTemplate cpSqlSessionTemplate(@Qualifier("cpSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
|
||||
@Bean(name = "cpMyBatisTransactionManager")
|
||||
@Primary
|
||||
public DataSourceTransactionManager cpMyBatisTransactionManager(@Qualifier("cpDataSource") DataSource cpDataSource) {
|
||||
return new DataSourceTransactionManager(cpDataSource);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package egovframework.config.myBatisConf;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class EpMyBatisConf {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public SqlSessionFactory epSqlSessionFactory(@Qualifier("epDataSource") DataSource epDataSource) throws Exception {
|
||||
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||
factoryBean.setDataSource(epDataSource);
|
||||
return factoryBean.getObject();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public SqlSessionTemplate epSqlSessionTemplate(@Qualifier("epSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
|
||||
@Bean(name = "epMyBatisTransactionManager")
|
||||
@Primary
|
||||
public DataSourceTransactionManager epMyBatisTransactionManager(@Qualifier("epDataSource") DataSource epDataSource) {
|
||||
return new DataSourceTransactionManager(epDataSource);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,133 @@
|
||||
package go.kr.project.domain.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tb_user")
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class TbUser {
|
||||
|
||||
@Id
|
||||
@Column(name = "USER_ID", length = 12, nullable = false)
|
||||
private String userId;
|
||||
|
||||
@Column(name = "USER_ACNT", length = 20, nullable = false, unique = true)
|
||||
private String userAcnt;
|
||||
|
||||
@Column(name = "USER_NM", length = 50, nullable = false)
|
||||
private String userNm;
|
||||
|
||||
@Column(name = "PASSWD", length = 200, nullable = false)
|
||||
private String passwd;
|
||||
|
||||
@Column(name = "PASSWD_HINT", length = 100)
|
||||
private String passwdHint;
|
||||
|
||||
@Column(name = "PASSWD_NSR", length = 100)
|
||||
private String passwdNsr;
|
||||
|
||||
@Column(name = "EMP_NO", length = 20)
|
||||
private String empNo;
|
||||
|
||||
@Column(name = "GENDER", length = 1)
|
||||
private String gender;
|
||||
|
||||
@Column(name = "ZIP", length = 6)
|
||||
private String zip;
|
||||
|
||||
@Column(name = "ADDR", length = 150)
|
||||
private String addr;
|
||||
|
||||
@Column(name = "DADDR", length = 150)
|
||||
private String daddr;
|
||||
|
||||
@Column(name = "AREA_NO", length = 10)
|
||||
private String areaNo;
|
||||
|
||||
@Column(name = "EML_ADDR", length = 50)
|
||||
private String emlAddr;
|
||||
|
||||
@Column(name = "ORG_CD", length = 20)
|
||||
private String orgCd;
|
||||
|
||||
@Column(name = "USER_GROUP_ID", length = 20)
|
||||
private String userGroupId;
|
||||
|
||||
@Column(name = "NSTT_CD", length = 8, nullable = false)
|
||||
private String nsttCd;
|
||||
|
||||
@Column(name = "POS_NM", length = 60)
|
||||
private String posNm;
|
||||
|
||||
@Column(name = "CRTFC_DN", length = 20)
|
||||
private String crtfcDn;
|
||||
|
||||
@Column(name = "LOCK_YN", length = 1)
|
||||
private String lockYn;
|
||||
|
||||
@Column(name = "LOCK_CNT", nullable = false)
|
||||
private Integer lockCnt;
|
||||
|
||||
@Column(name = "LOCK_DTTM")
|
||||
private LocalDateTime lockDttm;
|
||||
|
||||
@Column(name = "REG_DTTM")
|
||||
private LocalDateTime regDttm;
|
||||
|
||||
@Column(name = "RGTR", length = 12)
|
||||
private String rgtr;
|
||||
|
||||
@Column(name = "MDFCN_DTTM")
|
||||
private LocalDateTime mdfcnDttm;
|
||||
|
||||
@Column(name = "MDFR", length = 12)
|
||||
private String mdfr;
|
||||
|
||||
@Column(name = "USER_STATUS", length = 20, nullable = false)
|
||||
private String userStatus;
|
||||
|
||||
@Column(name = "FXNO", length = 20)
|
||||
private String fxno;
|
||||
|
||||
@Column(name = "TELNO", length = 20)
|
||||
private String telno;
|
||||
|
||||
@Column(name = "MBL_TELNO", length = 20)
|
||||
private String mblTelno;
|
||||
|
||||
@Column(name = "BRDT", length = 20)
|
||||
private String brdt;
|
||||
|
||||
@Column(name = "DEPT_CD", length = 7)
|
||||
private String deptCd;
|
||||
|
||||
@Column(name = "USE_YN", length = 1, nullable = false)
|
||||
private String useYn;
|
||||
|
||||
@Column(name = "RSDNT_NO", length = 200)
|
||||
private String rsdntNo;
|
||||
|
||||
@Column(name = "PASSWD_INIT_YN", length = 1)
|
||||
private String passwdInitYn;
|
||||
|
||||
@Column(name = "UM_CODE", length = 50, unique = true)
|
||||
private String umCode;
|
||||
|
||||
@Column(name = "SSG_CODE", length = 50)
|
||||
private String ssgCode;
|
||||
|
||||
@Column(name = "DB_KEY", length = 2)
|
||||
private String dbKey;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package go.kr.project.domain.repo.cp;
|
||||
|
||||
import go.kr.project.domain.entity.TbUser;
|
||||
import go.kr.project.system.login.model.LoginUserVO;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface CpTbUserRepository extends JpaRepository<TbUser, Long> {
|
||||
TbUser findByUserAcnt(String userAcnt);
|
||||
}
|
||||
@ -1,7 +1,11 @@
|
||||
package go.kr.project.domain.repo.cp;
|
||||
|
||||
import go.kr.project.domain.entity.CpUser;
|
||||
import go.kr.project.system.login.model.LoginUserVO;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CpUserRepository extends JpaRepository<CpUser, Long> {
|
||||
LoginUserVO findByUmName(String userAcnt);
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
package go.kr.project.domain.repo.ep;
|
||||
|
||||
import go.kr.project.domain.entity.TbUser;
|
||||
import go.kr.project.system.login.model.LoginUserVO;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface EpTbUserRepository extends JpaRepository<TbUser, Long> {
|
||||
TbUser findByUserAcnt(String userAcnt);
|
||||
}
|
||||
@ -1,7 +1,12 @@
|
||||
package go.kr.project.domain.repo.ep;
|
||||
|
||||
import go.kr.project.domain.entity.CpUser;
|
||||
import go.kr.project.system.login.model.LoginUserVO;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface EpUserRepository extends JpaRepository<CpUser, Long> {
|
||||
LoginUserVO findByUmName(String userAcnt);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,103 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
|
||||
<div class="logins">
|
||||
<div class="login_body">
|
||||
<div class="login">
|
||||
<div class="login_head">
|
||||
<ul>
|
||||
<%--<li><img src="<c:url value="/img/h1_logo_main.png"/>"></li>--%>
|
||||
<%--<li>로고 이미지</li>--%>
|
||||
<li class="tit">XIT<br>FRAMEWORK</li>
|
||||
</ul>
|
||||
<p>Login</p>
|
||||
</div>
|
||||
<div class="login_con">
|
||||
<ul>
|
||||
<li><input type="text" class="login_input" placeholder="아이디" name="userAcnt" id="userAcnt" value="${not empty savedUserId ? savedUserId : 'admin'}"/></li>
|
||||
<li><input type="text" class="login_input" placeholder="비밀번호" name="passwd" id="passwd" value="xitpassword"/></li>
|
||||
<li class="line"></li>
|
||||
<li class="logbtn">
|
||||
<button type="button" class="login_btn bg1" id="loginBtn">로그인</button>
|
||||
</li>
|
||||
<li>
|
||||
<label for="saveId"><input type="checkbox" id="saveId" name="saveId" ${isSaveId ? 'checked' : ''}> ID저장</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function(){
|
||||
|
||||
// 로그인 버튼 클릭 이벤트
|
||||
$("#loginBtn").on("click", function() {
|
||||
login();
|
||||
});
|
||||
|
||||
// 엔터키 이벤트
|
||||
$("#userAcnt, #passwd").on("keypress", function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
e.preventDefault();
|
||||
login();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 로그인 처리 함수
|
||||
function login() {
|
||||
// 유효성 검사
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 폼 데이터 준비
|
||||
var formData = {
|
||||
userAcnt: $("#userAcnt").val(),
|
||||
passwd: $("#passwd").val(),
|
||||
saveId: $("#saveId").is(":checked") ? "Y" : "N",
|
||||
kind: "ep"
|
||||
};
|
||||
|
||||
// AJAX 요청
|
||||
$.ajax({
|
||||
url: "<c:url value="/login/login.ajax"/>",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
if (response.result) {
|
||||
// 로그인 성공
|
||||
location.href = response.data.redirectUrl;
|
||||
} else {
|
||||
// 로그인 실패
|
||||
alert(response.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 폼 유효성 검사
|
||||
function validateForm() {
|
||||
var userAcnt = $("#userAcnt").val();
|
||||
var passwd = $("#passwd").val();
|
||||
|
||||
if (!userAcnt) {
|
||||
alert("아이디를 입력해주세요.");
|
||||
$("#userAcnt").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!passwd) {
|
||||
alert("비밀번호를 입력해주세요.");
|
||||
$("#passwd").focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue