[API] 멀티 데이터 소스 적용 및 이전 회원조회 작업
This commit is contained in:
@@ -44,6 +44,7 @@ dependencies {
|
|||||||
|
|
||||||
// MariaDB
|
// MariaDB
|
||||||
implementation 'org.mariadb.jdbc:mariadb-java-client'
|
implementation 'org.mariadb.jdbc:mariadb-java-client'
|
||||||
|
implementation 'com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11'
|
||||||
|
|
||||||
// swagger
|
// swagger
|
||||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.0'
|
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.0'
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.alist.api.common.utils;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
public class HashUtils {
|
||||||
|
public static String md5(String value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
|
||||||
|
byte[] digest = messageDigest.digest(value.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (byte b : digest) {
|
||||||
|
builder.append(String.format("%02x", b));
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
throw new IllegalStateException("MD5 algorithm not available", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.alist.api.config;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.logging.slf4j.Slf4jImpl;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@MapperScan(
|
||||||
|
basePackages = "com.alist.api.modules",
|
||||||
|
annotationClass = Mapper.class,
|
||||||
|
sqlSessionFactoryRef = "mainSqlSessionFactory"
|
||||||
|
)
|
||||||
|
public class MainDataSourceConfig {
|
||||||
|
|
||||||
|
@Bean(name = "mainDataSourceProperties")
|
||||||
|
@Primary
|
||||||
|
@ConfigurationProperties("spring.datasource")
|
||||||
|
public DataSourceProperties mainDataSourceProperties() {
|
||||||
|
return new DataSourceProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "mainDataSource")
|
||||||
|
@Primary
|
||||||
|
public DataSource mainDataSource(
|
||||||
|
@Qualifier("mainDataSourceProperties") DataSourceProperties mainDataSourceProperties
|
||||||
|
) {
|
||||||
|
return mainDataSourceProperties
|
||||||
|
.initializeDataSourceBuilder()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "mainSqlSessionFactory")
|
||||||
|
@Primary
|
||||||
|
public SqlSessionFactory mainSqlSessionFactory(
|
||||||
|
@Qualifier("mainDataSource") DataSource mainDataSource
|
||||||
|
) throws Exception {
|
||||||
|
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||||
|
factoryBean.setDataSource(mainDataSource);
|
||||||
|
factoryBean.setTypeAliasesPackage("com.alist.api");
|
||||||
|
factoryBean.setConfiguration(mybatisConfiguration());
|
||||||
|
factoryBean.setMapperLocations(
|
||||||
|
new PathMatchingResourcePatternResolver()
|
||||||
|
.getResources("classpath:mapper/*/*.xml")
|
||||||
|
);
|
||||||
|
return factoryBean.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "mainSqlSessionTemplate")
|
||||||
|
@Primary
|
||||||
|
public SqlSessionTemplate mainSqlSessionTemplate(
|
||||||
|
@Qualifier("mainSqlSessionFactory") SqlSessionFactory mainSqlSessionFactory
|
||||||
|
) {
|
||||||
|
return new SqlSessionTemplate(mainSqlSessionFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "mainTransactionManager")
|
||||||
|
@Primary
|
||||||
|
public DataSourceTransactionManager mainTransactionManager(
|
||||||
|
@Qualifier("mainDataSource") DataSource mainDataSource
|
||||||
|
) {
|
||||||
|
return new DataSourceTransactionManager(mainDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
private org.apache.ibatis.session.Configuration mybatisConfiguration() {
|
||||||
|
org.apache.ibatis.session.Configuration configuration =
|
||||||
|
new org.apache.ibatis.session.Configuration();
|
||||||
|
configuration.setMapUnderscoreToCamelCase(true);
|
||||||
|
configuration.setLogImpl(Slf4jImpl.class);
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,7 +59,7 @@ public class SecurityConfig {
|
|||||||
.accessDeniedHandler(new JwtAccessDeniedHandler())
|
.accessDeniedHandler(new JwtAccessDeniedHandler())
|
||||||
)
|
)
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers("/", "/actuator/health", "/sso/**", "/auth/**", "/user/signup", "/files/tusHook").permitAll()
|
.requestMatchers("/", "/actuator/health", "/sso/**", "/auth/**", "/user/signup", "/user/migrationUserList", "/files/tusHook").permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -37,11 +38,14 @@ public class CorsAllowedOriginsCache {
|
|||||||
try {
|
try {
|
||||||
List<String> origins = corsMapper.selectCorsAllowedList()
|
List<String> origins = corsMapper.selectCorsAllowedList()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.map(CorsOriginVo::getAllowedOrigin)
|
.map(CorsOriginVo::getAllowedOrigin)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(origin -> !origin.isEmpty())
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 전체 교체
|
|
||||||
this.allowedOrigins = origins;
|
this.allowedOrigins = origins;
|
||||||
|
|
||||||
log.info("CORS cache refreshed. Total origins: {}", origins.size());
|
log.info("CORS cache refreshed. Total origins: {}", origins.size());
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.alist.api.config.migration;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
import org.apache.ibatis.logging.slf4j.Slf4jImpl;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@MapperScan(
|
||||||
|
basePackages = "com.alist.api.modules.migration.alist",
|
||||||
|
sqlSessionFactoryRef = "migrationAlistSqlSessionFactory"
|
||||||
|
)
|
||||||
|
public class AlistDataSourceConfig {
|
||||||
|
|
||||||
|
@Bean(name = "migrationAlistDataSource")
|
||||||
|
@ConfigurationProperties(prefix = "migration.datasource.alist")
|
||||||
|
public HikariDataSource migrationAlistDataSource() {
|
||||||
|
return DataSourceBuilder.create()
|
||||||
|
.type(HikariDataSource.class)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "migrationAlistSqlSessionFactory")
|
||||||
|
public SqlSessionFactory migrationAlistSqlSessionFactory(
|
||||||
|
@Qualifier("migrationAlistDataSource") DataSource migrationAlistDataSource
|
||||||
|
) throws Exception {
|
||||||
|
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||||
|
factoryBean.setDataSource(migrationAlistDataSource);
|
||||||
|
factoryBean.setTypeAliasesPackage("com.alist.api.modules.migration.alist");
|
||||||
|
factoryBean.setConfiguration(mybatisConfiguration());
|
||||||
|
factoryBean.setMapperLocations(
|
||||||
|
new PathMatchingResourcePatternResolver()
|
||||||
|
.getResources("classpath:mapper/migration/alist/**/*.xml")
|
||||||
|
);
|
||||||
|
return factoryBean.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "migrationAlistTransactionManager")
|
||||||
|
public DataSourceTransactionManager migrationAlistTransactionManager(
|
||||||
|
@Qualifier("migrationAlistDataSource") DataSource migrationAlistDataSource
|
||||||
|
) {
|
||||||
|
return new DataSourceTransactionManager(migrationAlistDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
private org.apache.ibatis.session.Configuration mybatisConfiguration() {
|
||||||
|
org.apache.ibatis.session.Configuration configuration =
|
||||||
|
new org.apache.ibatis.session.Configuration();
|
||||||
|
configuration.setMapUnderscoreToCamelCase(true);
|
||||||
|
configuration.setLogImpl(Slf4jImpl.class);
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.alist.api.config.migration;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
import org.apache.ibatis.logging.slf4j.Slf4jImpl;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@MapperScan(
|
||||||
|
basePackages = "com.alist.api.modules.migration.eltown",
|
||||||
|
sqlSessionFactoryRef = "migrationEltownSqlSessionFactory"
|
||||||
|
)
|
||||||
|
public class EltownDataSourceConfig {
|
||||||
|
|
||||||
|
@Bean(name = "migrationEltownDataSource")
|
||||||
|
@ConfigurationProperties(prefix = "migration.datasource.eltown")
|
||||||
|
public HikariDataSource migrationEltownDataSource() {
|
||||||
|
return DataSourceBuilder.create()
|
||||||
|
.type(HikariDataSource.class)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "migrationEltownSqlSessionFactory")
|
||||||
|
public SqlSessionFactory migrationEltownSqlSessionFactory(
|
||||||
|
@Qualifier("migrationEltownDataSource") DataSource migrationEltownDataSource
|
||||||
|
) throws Exception {
|
||||||
|
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||||
|
factoryBean.setDataSource(migrationEltownDataSource);
|
||||||
|
factoryBean.setTypeAliasesPackage("com.alist.api.modules.migration.eltown");
|
||||||
|
factoryBean.setConfiguration(mybatisConfiguration());
|
||||||
|
factoryBean.setMapperLocations(
|
||||||
|
new PathMatchingResourcePatternResolver()
|
||||||
|
.getResources("classpath:mapper/migration/eltown/**/*.xml")
|
||||||
|
);
|
||||||
|
return factoryBean.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "migrationEltownTransactionManager")
|
||||||
|
public DataSourceTransactionManager migrationEltownTransactionManager(
|
||||||
|
@Qualifier("migrationEltownDataSource") DataSource migrationEltownDataSource
|
||||||
|
) {
|
||||||
|
return new DataSourceTransactionManager(migrationEltownDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
private org.apache.ibatis.session.Configuration mybatisConfiguration() {
|
||||||
|
org.apache.ibatis.session.Configuration configuration =
|
||||||
|
new org.apache.ibatis.session.Configuration();
|
||||||
|
configuration.setMapUnderscoreToCamelCase(true);
|
||||||
|
configuration.setLogImpl(Slf4jImpl.class);
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.alist.api.modules.migration.alist.user.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class AlistUserDto {
|
||||||
|
private String id;
|
||||||
|
private String password;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.alist.api.modules.migration.alist.user.mapper;
|
||||||
|
|
||||||
|
import com.alist.api.modules.migration.alist.user.dto.AlistUserDto;
|
||||||
|
import com.alist.api.modules.migration.alist.user.vo.AlistUserVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface AlistUserMapper {
|
||||||
|
List<AlistUserVo> selectAlistUserList(AlistUserDto alistUserDto);
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.alist.api.modules.migration.alist.user.service;
|
||||||
|
|
||||||
|
import com.alist.api.modules.migration.alist.user.dto.AlistUserDto;
|
||||||
|
import com.alist.api.modules.migration.alist.user.mapper.AlistUserMapper;
|
||||||
|
import com.alist.api.modules.migration.alist.user.vo.AlistUserVo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AlistUserService {
|
||||||
|
private final AlistUserMapper alistUserMapper;
|
||||||
|
|
||||||
|
public AlistUserService(AlistUserMapper alistUserMapper) {
|
||||||
|
this.alistUserMapper = alistUserMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AlistUserVo> selectAlistUserList(AlistUserDto alistUserDto) {
|
||||||
|
return alistUserMapper.selectAlistUserList(alistUserDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.alist.api.modules.migration.alist.user.vo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class AlistUserVo {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String hp;
|
||||||
|
private String email;
|
||||||
|
private String type;
|
||||||
|
private String joinDate;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.alist.api.modules.migration.eltown.user.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class EltownUserDto {
|
||||||
|
private String id;
|
||||||
|
private String password;
|
||||||
|
private String md5Password;
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package com.alist.api.modules.migration.eltown.user.mapper;
|
||||||
|
|
||||||
|
import com.alist.api.modules.migration.eltown.user.dto.EltownUserDto;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.vo.EltownUserVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface EltownUserMapper {
|
||||||
|
List<EltownUserVo> selectEltownUserList(EltownUserDto eltownUserDto);
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.alist.api.modules.migration.eltown.user.service;
|
||||||
|
|
||||||
|
import com.alist.api.common.utils.HashUtils;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.dto.EltownUserDto;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.mapper.EltownUserMapper;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.vo.EltownUserVo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class EltownUserService {
|
||||||
|
private final EltownUserMapper eltownUserMapper;
|
||||||
|
|
||||||
|
public EltownUserService(EltownUserMapper eltownUserMapper) {
|
||||||
|
this.eltownUserMapper = eltownUserMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EltownUserVo> selectEltownUserList(EltownUserDto eltownUserDto) {
|
||||||
|
eltownUserDto.setMd5Password(HashUtils.md5(eltownUserDto.getPassword()));
|
||||||
|
return eltownUserMapper.selectEltownUserList(eltownUserDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.alist.api.modules.migration.eltown.user.vo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class EltownUserVo {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String hp;
|
||||||
|
private String email;
|
||||||
|
private String type;
|
||||||
|
private String joinDate;
|
||||||
|
}
|
||||||
@@ -3,8 +3,10 @@ package com.alist.api.modules.user;
|
|||||||
import com.alist.api.common.response.ApiResponse;
|
import com.alist.api.common.response.ApiResponse;
|
||||||
import com.alist.api.common.response.ApiResponseCode;
|
import com.alist.api.common.response.ApiResponseCode;
|
||||||
import com.alist.api.modules.user.dto.UserDto;
|
import com.alist.api.modules.user.dto.UserDto;
|
||||||
|
import com.alist.api.modules.user.form.MigrationUserForm;
|
||||||
import com.alist.api.modules.user.form.UserSignupForm;
|
import com.alist.api.modules.user.form.UserSignupForm;
|
||||||
import com.alist.api.modules.user.service.UserService;
|
import com.alist.api.modules.user.service.UserService;
|
||||||
|
import com.alist.api.modules.user.vo.MigrationUserVo;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -15,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Tag(name = "05. 사용자 관리", description = "사용자 회원가입 및 관리 API")
|
@Tag(name = "05. 사용자 관리", description = "사용자 회원가입 및 관리 API")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@@ -43,4 +47,22 @@ public class UserController {
|
|||||||
return ApiResponse.entity(userDto, ApiResponseCode.CODE_2002, "아이디");
|
return ApiResponse.entity(userDto, ApiResponseCode.CODE_2002, "아이디");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "이전 회원 정보 조회",
|
||||||
|
description = "이전 사이트의 회원 정보를 조회 후 list로 리턴합니다."
|
||||||
|
)
|
||||||
|
@PostMapping("/migrationUserList")
|
||||||
|
public ResponseEntity<ApiResponse<MigrationUserVo>> migrationUserList(@Valid @RequestBody MigrationUserForm migrationUserForm) {
|
||||||
|
|
||||||
|
MigrationUserVo result = userService.selectMigrationUserList(migrationUserForm.toUserDto());
|
||||||
|
|
||||||
|
boolean empty = (result.getAlistUserList() == null || result.getAlistUserList().isEmpty()) && (result.getEltownUserList() == null || result.getEltownUserList().isEmpty());
|
||||||
|
|
||||||
|
if (empty) {
|
||||||
|
return ApiResponse.entity(result, ApiResponseCode.CODE_2003);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResponse.entity(result, ApiResponseCode.CODE_2001, "이전 회원");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.alist.api.modules.user.form;
|
||||||
|
|
||||||
|
import com.alist.api.modules.user.dto.UserDto;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@Schema(description = "이전회원 정보 조회")
|
||||||
|
public class MigrationUserForm {
|
||||||
|
@Schema(
|
||||||
|
description = "사용자 아이디 (공백 불가)",
|
||||||
|
example = "test"
|
||||||
|
)
|
||||||
|
@NotBlank(message = "아이디를 입력해주세요.")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@NotBlank(message = "비밀번호를 입력해주세요.")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public UserDto toUserDto() {
|
||||||
|
UserDto userDto = new UserDto();
|
||||||
|
userDto.setId(id.trim());
|
||||||
|
userDto.setPassword(password);
|
||||||
|
return userDto;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,40 @@
|
|||||||
package com.alist.api.modules.user.service;
|
package com.alist.api.modules.user.service;
|
||||||
|
|
||||||
import com.alist.api.common.utils.ApiKeyGenerator;
|
import com.alist.api.common.utils.ApiKeyGenerator;
|
||||||
|
import com.alist.api.modules.migration.alist.user.dto.AlistUserDto;
|
||||||
|
import com.alist.api.modules.migration.alist.user.service.AlistUserService;
|
||||||
|
import com.alist.api.modules.migration.alist.user.vo.AlistUserVo;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.dto.EltownUserDto;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.service.EltownUserService;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.vo.EltownUserVo;
|
||||||
import com.alist.api.modules.user.dto.UserDto;
|
import com.alist.api.modules.user.dto.UserDto;
|
||||||
import com.alist.api.modules.user.dto.UserTokenDto;
|
import com.alist.api.modules.user.dto.UserTokenDto;
|
||||||
import com.alist.api.modules.user.mapper.UserMapper;
|
import com.alist.api.modules.user.mapper.UserMapper;
|
||||||
|
import com.alist.api.modules.user.vo.MigrationUserVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
import org.springframework.dao.DuplicateKeyException;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class UserService {
|
public class UserService {
|
||||||
private final UserMapper userMapper;
|
private final UserMapper userMapper;
|
||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
public UserService(UserMapper userMapper, PasswordEncoder passwordEncoder) {
|
private final AlistUserService alistUserService;
|
||||||
|
private final EltownUserService eltownUserService;
|
||||||
|
|
||||||
|
public UserService(UserMapper userMapper, PasswordEncoder passwordEncoder, AlistUserService alistUserService, EltownUserService eltownUserService) {
|
||||||
this.userMapper = userMapper;
|
this.userMapper = userMapper;
|
||||||
this.passwordEncoder = passwordEncoder;
|
this.passwordEncoder = passwordEncoder;
|
||||||
|
this.alistUserService = alistUserService;
|
||||||
|
this.eltownUserService = eltownUserService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -59,4 +75,28 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
throw new IllegalStateException("API key generation failed after retries.");
|
throw new IllegalStateException("API key generation failed after retries.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public MigrationUserVo selectMigrationUserList(UserDto userDto) {
|
||||||
|
AlistUserDto alistUserDto = new AlistUserDto();
|
||||||
|
alistUserDto.setId(userDto.getId());
|
||||||
|
alistUserDto.setPassword(userDto.getPassword());
|
||||||
|
|
||||||
|
// alist 조회
|
||||||
|
List<AlistUserVo> alistUserList = alistUserService.selectAlistUserList(alistUserDto);
|
||||||
|
|
||||||
|
EltownUserDto eltownUserDto = new EltownUserDto();
|
||||||
|
eltownUserDto.setId(userDto.getId());
|
||||||
|
eltownUserDto.setPassword(userDto.getPassword());
|
||||||
|
|
||||||
|
// eltown 조회
|
||||||
|
List<EltownUserVo> eltownUserList = eltownUserService.selectEltownUserList(eltownUserDto);
|
||||||
|
|
||||||
|
MigrationUserVo result = new MigrationUserVo();
|
||||||
|
|
||||||
|
result.setAlistUserList(alistUserList);
|
||||||
|
result.setEltownUserList(eltownUserList);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.alist.api.modules.user.vo;
|
||||||
|
|
||||||
|
import com.alist.api.modules.migration.alist.user.vo.AlistUserVo;
|
||||||
|
import com.alist.api.modules.migration.eltown.user.vo.EltownUserVo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class MigrationUserVo {
|
||||||
|
List<AlistUserVo> alistUserList;
|
||||||
|
List<EltownUserVo> eltownUserList;
|
||||||
|
}
|
||||||
@@ -17,6 +17,25 @@ spring:
|
|||||||
port: 3001
|
port: 3001
|
||||||
password: 1qaz2wsx!@
|
password: 1qaz2wsx!@
|
||||||
|
|
||||||
|
migration:
|
||||||
|
datasource:
|
||||||
|
alist:
|
||||||
|
jdbc-url: jdbc:log4jdbc:sqlserver://bigfuntnp.co.kr:51433;databaseName=alist_dev;encrypt=false;trustServerCertificate=true
|
||||||
|
username: bigfuntnp
|
||||||
|
password: password12!@
|
||||||
|
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
|
maximum-pool-size: 5
|
||||||
|
minimum-idle: 1
|
||||||
|
connection-timeout: 10000
|
||||||
|
eltown:
|
||||||
|
jdbc-url: jdbc:log4jdbc:sqlserver://bigfuntnp.co.kr:51433;databaseName=eltown;encrypt=false;trustServerCertificate=true
|
||||||
|
username: bigfuntnp
|
||||||
|
password: password12!@
|
||||||
|
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
|
maximum-pool-size: 5
|
||||||
|
minimum-idle: 1
|
||||||
|
connection-timeout: 10000
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
config: classpath:logback-local.xml
|
config: classpath:logback-local.xml
|
||||||
|
|
||||||
@@ -26,10 +45,10 @@ jwt:
|
|||||||
refresh-token-validity-seconds: 2592000
|
refresh-token-validity-seconds: 2592000
|
||||||
|
|
||||||
cookie:
|
cookie:
|
||||||
secure: true # (HTTP) -> false
|
secure: false # (HTTP) -> false
|
||||||
domain: api-alist.pjt.kr # (HTTP) -> 비워두세요
|
domain: api-alist.pjt.kr # (HTTP) -> 비워두세요
|
||||||
name: ALIST_SSO
|
name: ALIST_SSO
|
||||||
same-site: None # (HTTP) -> Lax
|
same-site: Lax # (HTTP) -> Lax
|
||||||
|
|
||||||
swagger:
|
swagger:
|
||||||
login:
|
login:
|
||||||
|
|||||||
@@ -19,6 +19,25 @@ spring:
|
|||||||
port: ${REDIS_PORT}
|
port: ${REDIS_PORT}
|
||||||
password: ${REDIS_PASSWORD}
|
password: ${REDIS_PASSWORD}
|
||||||
|
|
||||||
|
migration:
|
||||||
|
datasource:
|
||||||
|
alist:
|
||||||
|
jdbc-url: jdbc:log4jdbc:sqlserver://${ALIST_DB_HOST}:${ALIST_DB_PORT};databaseName=${ALIST_DB_NAME};encrypt=false;trustServerCertificate=true
|
||||||
|
username: ${ALIST_DB_USERNAME}
|
||||||
|
password: ${ALIST_DB_PASSWORD}
|
||||||
|
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
|
maximum-pool-size: 5
|
||||||
|
minimum-idle: 1
|
||||||
|
connection-timeout: 10000
|
||||||
|
eltown:
|
||||||
|
jdbc-url: jdbc:log4jdbc:sqlserver://${ELTOWN_DB_HOST}:${ELTOWN_DB_PORT};databaseName=${ELTOWN_DB_NAME};encrypt=false;trustServerCertificate=true
|
||||||
|
username: ${ELTOWN_DB_USERNAME}
|
||||||
|
password: ${ELTOWN_DB_PASSWORD}
|
||||||
|
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
|
maximum-pool-size: 5
|
||||||
|
minimum-idle: 1
|
||||||
|
connection-timeout: 10000
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
config: classpath:logback-pjt.xml
|
config: classpath:logback-pjt.xml
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
|
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
|
||||||
log4jdbc.drivers=org.mariadb.jdbc.Driver
|
log4jdbc.drivers=org.mariadb.jdbc.Driver,com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||||
log4jdbc.dump.sql.maxlinelength=0
|
log4jdbc.dump.sql.maxlinelength=0
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
SELECT allowed_origin
|
SELECT allowed_origin
|
||||||
FROM ALISTLMS.test_cors_allowed_list
|
FROM ALISTLMS.test_cors_allowed_list
|
||||||
WHERE del_yn = 1
|
WHERE del_yn = 1
|
||||||
|
AND allowed_origin IS NOT NULL
|
||||||
ORDER BY cors_idx
|
ORDER BY cors_idx
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.alist.api.modules.migration.alist.user.mapper.AlistUserMapper">
|
||||||
|
<select id="selectAlistUserList" resultType="com.alist.api.modules.migration.alist.user.vo.AlistUserVo">
|
||||||
|
/*AlistUserMapper.selectAlistUserList*/
|
||||||
|
SELECT memid AS ID
|
||||||
|
, memname AS NAME
|
||||||
|
, memhp AS HP
|
||||||
|
, mememail AS EMAIL
|
||||||
|
, (
|
||||||
|
CASE memType
|
||||||
|
WHEN 'S' THEN '학생'
|
||||||
|
WHEN 'T' THEN '교사'
|
||||||
|
WHEN 'P' THEN '일반'
|
||||||
|
ELSE '기타'
|
||||||
|
END
|
||||||
|
) AS TYPE
|
||||||
|
, regdate as JOIN_DATE
|
||||||
|
FROM dbo.member WITH (NOLOCK)
|
||||||
|
WHERE memid = #{id}
|
||||||
|
AND PWDCOMPARE(#{password}
|
||||||
|
, mempw) = 1
|
||||||
|
AND memstatus <![CDATA[<>]]> 'LEAVE'
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.alist.api.modules.migration.eltown.user.mapper.EltownUserMapper">
|
||||||
|
<select id="selectEltownUserList" resultType="com.alist.api.modules.migration.eltown.user.vo.EltownUserVo">
|
||||||
|
/*EltownUserMapper.selectEltownUserList*/
|
||||||
|
SELECT '학생' AS TYPE
|
||||||
|
, User_Id AS ID
|
||||||
|
, User_Name AS NAME
|
||||||
|
, User_Email AS EMAIL
|
||||||
|
, '' AS HP
|
||||||
|
, Ins_Date AS JOIN_DATE
|
||||||
|
FROM dbo.SSL_T_PSN_MEM_01
|
||||||
|
WHERE User_Id = #{id}
|
||||||
|
AND User_Pwd = #{md5Password}
|
||||||
|
AND ISNULL(DeleteYN, 'N') = 'N'
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT '단체' AS TYPE
|
||||||
|
, Group_Id AS ID
|
||||||
|
, Group_Name AS NAME
|
||||||
|
, Group_Email AS EMAIL
|
||||||
|
, CONCAT(Group_Tel1, '-', Group_Tel2, '-', Group_Tel3) AS HP
|
||||||
|
, Ins_Date AS JOIN_DATE
|
||||||
|
FROM dbo.SSL_T_GRO_MEM_01
|
||||||
|
WHERE Group_Id = #{id}
|
||||||
|
AND Group_Pwd = #{md5Password}
|
||||||
|
AND ISNULL(DeleteYN, 'N') = 'N'
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT '교사' AS TYPE
|
||||||
|
, Teacher_Id AS ID
|
||||||
|
, Teacher_Name AS NAME
|
||||||
|
, Teacher_Email AS EMAIL
|
||||||
|
, '' AS HP
|
||||||
|
, Ins_Date AS JOIN_DATE
|
||||||
|
FROM dbo.SSL_T_TEA_MEM_01
|
||||||
|
WHERE Teacher_Id = #{id}
|
||||||
|
AND Teacher_Pwd = #{md5Password}
|
||||||
|
AND ISNULL(DeleteYN, 'N') = 'N'
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user