
--- src/main/java/kr/co/takensoft/ai/system/auth/dao/AuthDAO.java
+++ src/main/java/kr/co/takensoft/ai/system/auth/dao/AuthDAO.java
... | ... | @@ -1,6 +1,9 @@ |
1 | 1 |
package kr.co.takensoft.ai.system.auth.dao; |
2 | 2 |
|
3 |
+import kr.co.takensoft.ai.system.auth.vo.MemberVO; |
|
3 | 4 |
import org.egovframe.rte.psl.dataaccess.mapper.Mapper; |
5 |
+ |
|
6 |
+import java.util.List; |
|
4 | 7 |
|
5 | 8 |
/** |
6 | 9 |
* @author : 박민혁 |
... | ... | @@ -12,5 +15,13 @@ |
12 | 15 |
* 사용자 정보 관련 DAO |
13 | 16 |
*/ |
14 | 17 |
@Mapper("authDAO") |
15 |
-public class AuthDAO { |
|
18 |
+public interface AuthDAO { |
|
19 |
+ |
|
20 |
+ /** |
|
21 |
+ * @param member 사용자 정보 |
|
22 |
+ * @return 등록 성공 여부 |
|
23 |
+ * |
|
24 |
+ * 사용자 회원 가입 |
|
25 |
+ */ |
|
26 |
+ int memberRegister(MemberVO memberVO) throws Exception; |
|
16 | 27 |
} |
+++ src/main/java/kr/co/takensoft/ai/system/auth/dto/LoginDTO.java
... | ... | @@ -0,0 +1,23 @@ |
1 | +package kr.co.takensoft.ai.system.auth.dto; | |
2 | + | |
3 | + | |
4 | +import jakarta.validation.constraints.NotNull; | |
5 | +import lombok.*; | |
6 | + | |
7 | +/** | |
8 | + * @author : 박민혁 | |
9 | + * @since : 2025.07.09 | |
10 | + * @modification | |
11 | + * since | author | description | |
12 | + * 2025.07.09 | 박민혁 | 최초 등록 | |
13 | + * | |
14 | + * 로그인 관련 DTO | |
15 | + */ | |
16 | +@Setter | |
17 | +@Getter | |
18 | +public class LoginDTO { | |
19 | + @NotNull | |
20 | + private String loginId; // 로그인 아이디 | |
21 | + @NotNull | |
22 | + private String password; // 비밀번호 | |
23 | +} |
+++ src/main/java/kr/co/takensoft/ai/system/auth/service/AuthService.java
... | ... | @@ -0,0 +1,23 @@ |
1 | +package kr.co.takensoft.ai.system.auth.service; | |
2 | + | |
3 | +import kr.co.takensoft.ai.system.auth.vo.MemberVO; | |
4 | + | |
5 | +/* | |
6 | + * @author : 박민혁 | |
7 | + * @since : 2025.07.08 | |
8 | + * @modification | |
9 | + * since | author | description | |
10 | + * 2025.07.08 | 박민혁 | 최초 등록 | |
11 | + * | |
12 | + * 사용자 정보 관련 서비스 | |
13 | + */ | |
14 | +public interface AuthService { | |
15 | + /** | |
16 | + * @param member 사용자 정보 | |
17 | + * @return 등록 성공 여부 | |
18 | + * | |
19 | + * 사용자 회원가입 | |
20 | + */ | |
21 | + int memberRegister(MemberVO memberVO); | |
22 | + | |
23 | +} |
+++ src/main/java/kr/co/takensoft/ai/system/auth/service/impl/AuthServiceImpl.java
... | ... | @@ -0,0 +1,50 @@ |
1 | +package kr.co.takensoft.ai.system.auth.service.impl; | |
2 | + | |
3 | +/* | |
4 | + * @author : 박민혁 | |
5 | + * @since : 2025.07.08 | |
6 | + * @modification | |
7 | + * since | author | description | |
8 | + * 2025.07.08 | 박민혁 | 최초 등록 | |
9 | + * | |
10 | + * 사용자 정보 관련 서비스 | |
11 | + */ | |
12 | +import kr.co.takensoft.ai.system.auth.dao.AuthDAO; | |
13 | +import kr.co.takensoft.ai.system.auth.service.AuthService; | |
14 | +import kr.co.takensoft.ai.system.auth.vo.MemberVO; | |
15 | +import kr.co.takensoft.ai.system.common.idgen.service.IdgenService; | |
16 | +import kr.co.takensoft.ai.system.common.util.Secret; | |
17 | +import lombok.RequiredArgsConstructor; | |
18 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
19 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
20 | +import org.springframework.stereotype.Service; | |
21 | + | |
22 | +@Service | |
23 | +@RequiredArgsConstructor | |
24 | +public class AuthServiceImpl extends EgovAbstractServiceImpl implements AuthService { | |
25 | + | |
26 | + private final AuthDAO authDAO; | |
27 | + private final BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); | |
28 | + private final IdgenService memberIdgn; | |
29 | + | |
30 | + /** | |
31 | + * @param member 사용자 정보 | |
32 | + * @return 등록 성공 여부 | |
33 | + * | |
34 | + * 사용자 회원가입 | |
35 | + */ | |
36 | + public int memberRegister(MemberVO member) { | |
37 | + try { | |
38 | + String memberId = memberIdgn.getNextStringId(); // 사용자 구분 아이디 생성 | |
39 | + member.setMemberId(memberId); // 사용자 구분 아이디 등록 | |
40 | + member.setPassword(bCryptPasswordEncoder.encode(member.getPassword())); // 비밀 번호 단방향 암호화 | |
41 | + member.setEmail(Secret.encrypt(member.getEmail())); // 이메일 양방향 암호화 | |
42 | + member.setPhoneNumber(Secret.encrypt(member.getPhoneNumber())); // 전화번호 양방향 암호화 | |
43 | + return authDAO.memberRegister(member); | |
44 | + } catch (Exception e) { | |
45 | + e.printStackTrace(); | |
46 | + return -1; | |
47 | + } | |
48 | + }; | |
49 | + | |
50 | +} |
+++ src/main/java/kr/co/takensoft/ai/system/auth/vo/MemberVO.java
... | ... | @@ -0,0 +1,31 @@ |
1 | +package kr.co.takensoft.ai.system.auth.vo; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import lombok.Setter; | |
7 | + | |
8 | +/* | |
9 | + * @author : 박민혁 | |
10 | + * @since : 2025.07.08 | |
11 | + * @modification | |
12 | + * since | author | description | |
13 | + * 2025.07.08 | 박민혁 | 최초 등록 | |
14 | + * | |
15 | + * 유저 관련 정보를 담은 VO | |
16 | + */ | |
17 | + | |
18 | +@Getter | |
19 | +@Setter | |
20 | +@AllArgsConstructor | |
21 | +@NoArgsConstructor | |
22 | +public class MemberVO { | |
23 | + private String memberId; | |
24 | + private String loginId; | |
25 | + private String password; | |
26 | + private String email; | |
27 | + private String phoneNumber; | |
28 | + private String memberName; | |
29 | + private String createdAt; | |
30 | + private String updatedDt; | |
31 | +} |
+++ src/main/java/kr/co/takensoft/ai/system/auth/web/AuthController.java
... | ... | @@ -0,0 +1,45 @@ |
1 | +package kr.co.takensoft.ai.system.auth.web; | |
2 | + | |
3 | +import kr.co.takensoft.ai.system.auth.service.AuthService; | |
4 | +import kr.co.takensoft.ai.system.auth.vo.MemberVO; | |
5 | +import lombok.RequiredArgsConstructor; | |
6 | +import org.springframework.http.HttpStatus; | |
7 | +import org.springframework.http.ResponseEntity; | |
8 | +import org.springframework.web.bind.annotation.PostMapping; | |
9 | +import org.springframework.web.bind.annotation.RequestBody; | |
10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
11 | +import org.springframework.web.bind.annotation.RestController; | |
12 | + | |
13 | +import java.util.HashMap; | |
14 | + | |
15 | +/* | |
16 | + * @author : 박민혁 | |
17 | + * @since : 2025.07.08 | |
18 | + * @modification | |
19 | + * since | author | description | |
20 | + * 2025.07.08 | 박민혁 | 최초 등록 | |
21 | + * | |
22 | + * 사용자 정보 관련 서비스 | |
23 | + */ | |
24 | +@RestController | |
25 | +@RequiredArgsConstructor | |
26 | +@RequestMapping(value = "/api/auth") | |
27 | +public class AuthController { | |
28 | + | |
29 | + private final AuthService authService; | |
30 | + | |
31 | + /** | |
32 | + * @param member 사용자 정보 | |
33 | + * @return ResponseEntity 회원가입 등록 결과를 포함하는 응답 | |
34 | + * | |
35 | + * 사용자 회원 가입 | |
36 | + */ | |
37 | + @PostMapping("/register.json") | |
38 | + public ResponseEntity<?> register(@RequestBody MemberVO member) { | |
39 | + HashMap<String, Object> result = new HashMap<>(); | |
40 | + result.put("result", authService.memberRegister(member)); | |
41 | + return new ResponseEntity<>(result, HttpStatus.OK); | |
42 | + } | |
43 | + | |
44 | + | |
45 | +}(No newline at end of file) |
--- src/main/java/kr/co/takensoft/ai/system/common/config/SecurityConfig.java
+++ src/main/java/kr/co/takensoft/ai/system/common/config/SecurityConfig.java
... | ... | @@ -26,8 +26,8 @@ |
26 | 26 |
http |
27 | 27 |
.csrf(csrf -> csrf.disable()) // CSRF 비활성화 |
28 | 28 |
.authorizeHttpRequests(auth -> auth |
29 |
- .requestMatchers("/api/auth/**").permitAll() // 로그인, 회원가입 관련 로직 허용 |
|
30 |
- //.requestMatchers("/**").permitAll() // 테스트 중이라 경로 전부 허용 |
|
29 |
+ //.requestMatchers("/api/auth/**").permitAll() // 로그인, 회원가입 관련 로직 허용 |
|
30 |
+ .requestMatchers("/**").permitAll() // 테스트 중이라 경로 전부 허용 |
|
31 | 31 |
.anyRequest().authenticated() // 나머지 요청은 인증 필요 |
32 | 32 |
) |
33 | 33 |
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); |
--- src/main/java/kr/co/takensoft/ai/system/common/idgen/context/ContextIdgen.java
+++ src/main/java/kr/co/takensoft/ai/system/common/idgen/context/ContextIdgen.java
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 |
public class ContextIdgen { |
9 | 9 |
|
10 | 10 |
// 회원(유저)정보 |
11 |
- @Bean(name = "userIdgn") |
|
11 |
+ @Bean(name = "memberIdgn") |
|
12 | 12 |
public IdgenService user() { |
13 | 13 |
IdgenService idgenServiceImpl = new IdgenService(); |
14 | 14 |
idgenServiceImpl.setCipers(15); |
--- src/main/resources/application.yml
+++ src/main/resources/application.yml
... | ... | @@ -1,6 +1,6 @@ |
1 | 1 |
spring: |
2 | 2 |
datasource: |
3 |
- url: jdbc:postgresql://210.180.118.83:5432/vgpu?currentSchema=vgpu |
|
3 |
+ url: jdbc:postgresql://210.180.118.83:5432/ai_system?currentSchema=ai_system |
|
4 | 4 |
username: takensoft |
5 | 5 |
password: tts96314728!@ |
6 | 6 |
driver-class-name: org.postgresql.Driver |
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 |
refreshTime: 86400000 # 24시간 86400000 |
11 | 11 |
|
12 | 12 |
# front url |
13 |
-frontUrls: http://localhost:10900/ |
|
13 |
+frontUrls: http://localhost:10910/ |
|
14 | 14 |
|
15 | 15 |
# port setting |
16 | 16 |
server: |
--- src/main/resources/mybatis/mapper/auth/auth-SQL.xml
+++ src/main/resources/mybatis/mapper/auth/auth-SQL.xml
... | ... | @@ -1,5 +1,44 @@ |
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 |
<mapper namespace="kr.co.takensoft.ai.system.auth.dao.AuthDAO"> |
4 |
+ <!-- |
|
5 |
+ 작 성 자 : 박민혁 |
|
6 |
+ 작 성 일 : 2025.07.08 |
|
7 |
+ 내 용 : 사용자 회원가입 |
|
8 |
+ --> |
|
9 |
+ <insert id="memberRegister" parameterType="memberVO"> |
|
10 |
+ INSERT INTO member |
|
11 |
+ (member_id, |
|
12 |
+ login_id, |
|
13 |
+ password, |
|
14 |
+ email, |
|
15 |
+ phone_number, |
|
16 |
+ member_name, |
|
17 |
+ created_at, |
|
18 |
+ updated_at |
|
19 |
+ ) |
|
20 |
+ VALUES ( |
|
21 |
+ #{memberId}, |
|
22 |
+ #{loginId}, |
|
23 |
+ #{password}, |
|
24 |
+ #{email}, |
|
25 |
+ #{phoneNumber}, |
|
26 |
+ #{memberName}, |
|
27 |
+ CURRENT_TIMESTAMP, |
|
28 |
+ CURRENT_TIMESTAMP |
|
29 |
+ ) |
|
30 |
+ </insert> |
|
31 |
+ |
|
32 |
+ |
|
33 |
+ <!-- |
|
34 |
+ 작 성 자 : 박민혁 |
|
35 |
+ 작 성 일 : 2025.07.08 |
|
36 |
+ 내 용 : 사용자 정보 찾기 (테스트용) |
|
37 |
+ --> |
|
38 |
+ <select id="findMemberId" > |
|
39 |
+ select |
|
40 |
+ member_id |
|
41 |
+ from member |
|
42 |
+ </select> |
|
4 | 43 |
|
5 | 44 |
</mapper>(No newline at end of file) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?