config: config set

dev
minuk926 2 years ago
parent 420302fee9
commit 5ed807b717

@ -135,6 +135,9 @@ dependencies {
//-----------------------------------------------------------------------------------//
runtimeOnly 'com.h2database:h2:1.4.199' // 2.0.202
// implementation 'org.postgresql:postgresql:42.3.1'
// https://mvnrepository.com/artifact/com.oracle.jdbc/ojdbc8
//implementation group: 'com.oracle.jdbc', name: 'ojdbc8', version: '12.2.0.1'
//-----------------------------------------------------------------------------------//
@ -209,8 +212,8 @@ dependencies {
testImplementation 'org.springframework.security:spring-security-test'
// querydsl
testImplementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
testAnnotationProcessor "com.querydsl:querydsl-apt:${queryDslVersion}"
//testImplementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
//testAnnotationProcessor "com.querydsl:querydsl-apt:${queryDslVersion}"
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

@ -1,3 +1,4 @@
/*
package com.xit.biz.cmm.repository;
import com.xit.biz.cmm.entity.CmmUser;
@ -13,3 +14,5 @@ public interface ICmmUserRepository extends JpaRepository<CmmUser, String> {
//Optional<CmmUser> findOneWithAuthorities(String userId);
}
*/

@ -1,9 +1,8 @@
package com.xit.biz.ctgy.auth.service.impl;
import com.xit.biz.ctgy.auth.UserMinPrincipal;
import com.xit.biz.ctgy.dto.MinUserinfoDto;
import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.biz.ctgy.repository.IMinUserRepository;
import com.xit.biz.ctgy.v2.repository.UserDao;
import com.xit.core.oauth2.oauth.entity.ProviderType;
import com.xit.core.oauth2.oauth.info.AbstractOAuth2UserInfo;
import com.xit.core.oauth2.oauth.info.OAuth2UserInfoFactory;
@ -22,7 +21,7 @@ import java.util.Optional;
@RequiredArgsConstructor
public class CustomMinOAuth2UserService extends DefaultOAuth2UserService {
private final IMinUserRepository userRepository;
private final UserDao userDao;
@Override
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
@ -44,7 +43,7 @@ public class CustomMinOAuth2UserService extends DefaultOAuth2UserService {
AbstractOAuth2UserInfo userInfo = OAuth2UserInfoFactory.getOAuth2UserInfo(providerType, user.getAttributes());
MinUserinfo savedUser = null;
Optional<MinUserinfo> optionalCmmUser = userRepository.findByUserid(userInfo.getId());
Optional<MinUserinfo> optionalCmmUser = userDao.findByUseridUseAuth(userInfo.getId());
if(optionalCmmUser.isPresent()) {
// savedUser = optionalCmmUser.get();
@ -81,7 +80,8 @@ public class CustomMinOAuth2UserService extends DefaultOAuth2UserService {
.name(userInfo.getName())
.email(userInfo.getEmail())
.build();
return userRepository.saveAndFlush(user);
userDao.insertMinUserinfo(user);
return userDao.findByUseridUseAuth(userInfo.getId()).get();
}
// private void updateUser(MinUserinfo user, AbstractOAuth2UserInfo userInfo) {

@ -16,11 +16,11 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class CustomMinUserDetailsService implements UserDetailsService {
private final UserDao minUserinfoDao;
private final UserDao userDao;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
MinUserinfoDto user = minUserinfoDao.findByUserid(username).orElseThrow(() -> new CustomBaseException(ErrorCode.USER_NOT_FOUND));
MinUserinfoDto user = userDao.findByUserid(username).orElseThrow(() -> new CustomBaseException(ErrorCode.USER_NOT_FOUND));
return UserMinPrincipal.create(MinUserinfo.builder()
.userid(user.getUserid())
.passwd(user.getPasswd())

@ -1,30 +0,0 @@
package com.xit.biz.ctgy.repository;
import com.xit.biz.ctgy.CtgyConstants;
import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.core.oauth2.utils.SecurityUtil;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
public interface IMinUserRepository extends JpaRepository<MinUserinfo, String> {
Optional<MinUserinfo> findByUserid(final String userid);
@Query(value = "SELECT TRAFFIC.ECL_ENCRYPT(?1) AS passwd FROM DUAL C", nativeQuery = true)
//@Query(value = "SELECT ECL_ENCRYPT(?1) AS passwd", nativeQuery = true)
String queryGetPasswdEncode(@Param("passwd") final String passwd);
@Query(value = "SELECT ECL_DECRYPT(MU.passwd) AS passwd FROM min_userinfo MU WHERE MU.userid = ?1", nativeQuery = true)
String queryGetPasswd(@Param("userid") final String userid);
MinUserinfo findMinUserinfoByUserid(final String userid);
//-------------------------------------------------------------------------
// 주정차위반 심사대상 등록 - 등록 대상 심사자 조회
//-------------------------------------------------------------------------
List<MinUserinfo> findAllByTeamAndIsenableAndAccesstype(String msuTeam, String isenabled, String accesstype);
}

@ -1,6 +1,7 @@
package com.xit.biz.ctgy.v2.repository;
import com.xit.biz.ctgy.dto.MinUserinfoDto;
import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.core.config.database.BaseMpowerDaoSupport;
import com.xit.core.support.sql.parser.QueryGenerator;
import lombok.extern.slf4j.Slf4j;
@ -25,6 +26,14 @@ public class UserDao extends BaseMpowerDaoSupport {
return Optional.ofNullable(selectOne(MinUserinfoDto.class, sql, fieldsStrs));
}
public Optional<MinUserinfo> findByUseridUseAuth(@NotNull final String userid){
final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "selectUserInfo")
.setParameter("userid", userid)
.getQueryString();
final String fieldsStrs = "userid, passwd, name, regnum, mphone, email, accesstype, team, isenable, gu";
return Optional.ofNullable(selectOne(MinUserinfo.class, sql, fieldsStrs));
}
public String queryGetPasswdEncode(@NotNull final String passwd){
final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "selectPasswdEnc")
.setParameter("passwd", passwd)
@ -78,7 +87,36 @@ public class UserDao extends BaseMpowerDaoSupport {
return selectList(MinUserinfoDto.class, listSql, cntSql, fieldStrs, pageable);
}
public void insertMinUserinfo(@NotNull final MinUserinfoDto dto) {
public void insertMinUserinfoDto(@NotNull final MinUserinfoDto dto) {
final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "insertMinUserinfo")
.setParameter("userid", dto.getUserid())
.setParameter("accesstype", dto.getAccesstype())
.setParameter("email", dto.getEmail())
.setParameter("isenable", dto.getIsenable())
.setParameter("mphone", dto.getMphone())
.setParameter("name", dto.getName())
.setParameter("passwd", dto.getPasswd())
.setParameter("regdate", dto.getRegdate())
.setParameter("team", dto.getTeam())
.setParameter("gu", dto.getGu())
.getQueryString();
insert(sql);
}
public void updateMinUserinfoDto(MinUserinfoDto dto) {
final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "updateMinUserinfo")
.setParameter("userid", dto.getUserid())
.setParameter("accesstype", dto.getAccesstype())
.setParameter("email", dto.getEmail())
.setParameter("mphone", dto.getMphone())
.setParameter("name", dto.getName())
.setParameter("passwd", dto.getPasswd())
.setParameter("team", dto.getTeam())
.getQueryString();
update(sql);
}
public void insertMinUserinfo(@NotNull final MinUserinfo dto) {
final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "insertMinUserinfo")
.setParameter("userid", dto.getUserid())
.setParameter("accesstype", dto.getAccesstype())
@ -94,7 +132,7 @@ public class UserDao extends BaseMpowerDaoSupport {
insert(sql);
}
public void updateMinUserinfo(MinUserinfoDto dto) {
public void updateMinUserinfo(MinUserinfo dto) {
final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "updateMinUserinfo")
.setParameter("userid", dto.getUserid())
.setParameter("accesstype", dto.getAccesstype())

@ -1,7 +1,6 @@
package com.xit.biz.ctgy.v2.service.impl;
import com.xit.biz.ctgy.dto.MinUserinfoDto;
import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.biz.ctgy.v2.repository.UserDao;
import com.xit.biz.ctgy.v2.service.IMinUserService;
import com.xit.core.constant.ErrorCode;
@ -16,8 +15,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
@AllArgsConstructor
@Service
public class MinUserService implements IMinUserService {
@ -51,11 +48,11 @@ public class MinUserService implements IMinUserService {
if("Y".equals(dto.getNewYn())){
if(opUser.isPresent() && !Checks.isEmpty(opUser.get().getUserid())) throw new CustomBaseException(ErrorCode.MEMBER_EXISTS);
dto.setSaveInit();
userDao.insertMinUserinfo(dto);
userDao.insertMinUserinfoDto(dto);
}else{
// 비밀번호가 다른 경우
//if(!savedDto.get().getPasswd().equals(encPasswd)) dto.setPasswd(encPasswd);
userDao.updateMinUserinfo(dto);
userDao.updateMinUserinfoDto(dto);
}
}

Loading…
Cancel
Save