Commit 10d20dbd60bf6bf0c64228be4ebd5336345cfd9f
1 parent
9b21f059
Mybatis 추가
application.yml에 환경추가 HomeController --> /hello에 테스트 페이지 추가 HomeService, Home(Mapper, xml) 화면의 경우 Thymeleaf를 사용해야함. application.yml에 환경추가 http://localhost:8080/social/login 테스트페이지
Showing
9 changed files
with
113 additions
and
16 deletions
Show diff stats
.classpath
... | ... | @@ -19,6 +19,12 @@ |
19 | 19 | <attribute name="test" value="true"/> |
20 | 20 | </attributes> |
21 | 21 | </classpathentry> |
22 | + <classpathentry kind="src" output="bin/querydsl" path="build/generated/querydsl"> | |
23 | + <attributes> | |
24 | + <attribute name="gradle_scope" value="querydsl"/> | |
25 | + <attribute name="gradle_used_by_scope" value="querydsl"/> | |
26 | + </attributes> | |
27 | + </classpathentry> | |
22 | 28 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/> |
23 | 29 | <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> |
24 | 30 | <classpathentry kind="output" path="bin/default"/> | ... | ... |
build.gradle
... | ... | @@ -39,6 +39,7 @@ dependencies { |
39 | 39 | implementation 'com.google.code.gson:gson' |
40 | 40 | |
41 | 41 | implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' |
42 | + implementation('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect') | |
42 | 43 | implementation 'io.springfox:springfox-boot-starter:3.0.0' |
43 | 44 | |
44 | 45 | compileOnly 'org.projectlombok:lombok' |
... | ... | @@ -46,6 +47,9 @@ dependencies { |
46 | 47 | testImplementation 'org.springframework.boot:spring-boot-starter-test' |
47 | 48 | testImplementation 'org.springframework.security:spring-security-test' |
48 | 49 | |
50 | + implementation 'org.springframework.boot:spring-boot-starter-jdbc' | |
51 | + implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2' | |
52 | + | |
49 | 53 | } |
50 | 54 | |
51 | 55 | test { | ... | ... |
src/main/java/daeucna/Security/domain/mapper/Home.java
0 → 100644
src/main/java/daeucna/Security/domain/service/HomeService.java
0 → 100644
1 | +package daeucna.Security.domain.service; | |
2 | + | |
3 | +import java.util.List; | |
4 | +import java.util.Map; | |
5 | + | |
6 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | +import org.springframework.stereotype.Service; | |
8 | +import org.springframework.transaction.annotation.Transactional; | |
9 | + | |
10 | +import daeucna.Security.domain.mapper.Home; | |
11 | +import lombok.extern.slf4j.Slf4j; | |
12 | + | |
13 | +@Slf4j | |
14 | +@Service | |
15 | +@Transactional(readOnly = true) | |
16 | +public class HomeService { | |
17 | + | |
18 | + @Autowired | |
19 | + Home home; | |
20 | + | |
21 | + public List<Map<String, Object>> getTestData(Map<String, Object> param) { | |
22 | + List<Map<String, Object>> result = home.getTestData(param); | |
23 | + return result; | |
24 | + } | |
25 | + | |
26 | +} | ... | ... |
src/main/java/daeucna/Security/domain/service/SignService.java
1 | 1 | package daeucna.Security.domain.service; |
2 | 2 | |
3 | -import lombok.RequiredArgsConstructor; | |
4 | -import lombok.extern.slf4j.Slf4j; | |
3 | +import java.util.Optional; | |
4 | +import java.util.UUID; | |
5 | + | |
5 | 6 | import org.springframework.security.crypto.password.PasswordEncoder; |
6 | 7 | import org.springframework.stereotype.Service; |
7 | 8 | import org.springframework.transaction.annotation.Transactional; |
8 | 9 | |
9 | -import daeucna.Security.advice.exception.*; | |
10 | +import daeucna.Security.advice.exception.EmailNotAuthenticatedException; | |
11 | +import daeucna.Security.advice.exception.InvalidRefreshTokenException; | |
12 | +import daeucna.Security.advice.exception.LoginFailureException; | |
13 | +import daeucna.Security.advice.exception.MemberIdAlreadyExistsException; | |
14 | +import daeucna.Security.advice.exception.MemberNotFoundException; | |
10 | 15 | import daeucna.Security.config.security.jwt.JwtTokenProvider; |
11 | 16 | import daeucna.Security.domain.auth.AccessToken; |
12 | 17 | import daeucna.Security.domain.auth.Profile.ProfileDto; |
... | ... | @@ -16,13 +21,11 @@ import daeucna.Security.domain.dto.TokenResponseDto; |
16 | 21 | import daeucna.Security.domain.entity.Member; |
17 | 22 | import daeucna.Security.domain.rediskey.RedisKey; |
18 | 23 | import daeucna.Security.domain.repository.MemberRepository; |
19 | -import daeucna.Security.web.dto.EmailAuthRequestDto; | |
20 | 24 | import daeucna.Security.web.dto.MemberLoginRequestDto; |
21 | 25 | import daeucna.Security.web.dto.MemberRegisterRequestDto; |
22 | 26 | import daeucna.Security.web.dto.ReIssueRequestDto; |
23 | - | |
24 | -import java.util.Optional; | |
25 | -import java.util.UUID; | |
27 | +import lombok.RequiredArgsConstructor; | |
28 | +import lombok.extern.slf4j.Slf4j; | |
26 | 29 | |
27 | 30 | @Slf4j |
28 | 31 | @Service | ... | ... |
src/main/java/daeucna/Security/web/controller/HomeController.java
... | ... | @@ -3,22 +3,37 @@ package daeucna.Security.web.controller; |
3 | 3 | import io.swagger.annotations.ApiOperation; |
4 | 4 | import lombok.RequiredArgsConstructor; |
5 | 5 | import lombok.extern.slf4j.Slf4j; |
6 | + | |
7 | +import java.util.HashMap; | |
8 | +import java.util.List; | |
9 | +import java.util.Map; | |
10 | + | |
11 | +import org.slf4j.Logger; | |
12 | +import org.slf4j.LoggerFactory; | |
13 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | 14 | import org.springframework.web.bind.annotation.GetMapping; |
7 | 15 | import org.springframework.web.bind.annotation.RestController; |
8 | 16 | |
17 | +import daeucna.Security.domain.service.HomeService; | |
9 | 18 | import daeucna.Security.domain.service.SignService; |
10 | 19 | |
11 | 20 | @Slf4j |
12 | 21 | @RestController |
13 | 22 | @RequiredArgsConstructor |
14 | 23 | public class HomeController { |
15 | - | |
24 | + private Logger logger = LoggerFactory.getLogger(HomeController.class); | |
25 | + | |
26 | + @Autowired | |
16 | 27 | private final SignService memberService; |
17 | 28 | |
29 | + @Autowired | |
30 | + private final HomeService homeService; | |
31 | + | |
18 | 32 | @ApiOperation(value = "테스트 페이지", notes = "인증을 위한 테스트 페이지입니다.") |
19 | 33 | @GetMapping("/hello") |
20 | - public String hello() { | |
21 | - return "Hello"; | |
34 | + public List<Map<String, Object>> hello() { | |
35 | + List<Map<String, Object>> lResult = homeService.getTestData(new HashMap<String, Object>()); | |
36 | + return lResult; | |
22 | 37 | } |
23 | 38 | |
24 | 39 | } | ... | ... |
src/main/java/daeucna/Security/web/controller/SignController.java
1 | 1 | package daeucna.Security.web.controller; |
2 | 2 | |
3 | -import io.swagger.annotations.ApiOperation; | |
4 | -import lombok.RequiredArgsConstructor; | |
5 | -import lombok.extern.slf4j.Slf4j; | |
6 | -import org.springframework.web.bind.annotation.*; | |
3 | +import org.springframework.web.bind.annotation.PathVariable; | |
4 | +import org.springframework.web.bind.annotation.PostMapping; | |
5 | +import org.springframework.web.bind.annotation.RequestBody; | |
6 | +import org.springframework.web.bind.annotation.RequestMapping; | |
7 | +import org.springframework.web.bind.annotation.RestController; | |
7 | 8 | |
8 | 9 | import daeucna.Security.domain.auth.AuthCode; |
9 | 10 | import daeucna.Security.domain.dto.MemberLoginResponseDto; |
... | ... | @@ -12,10 +13,12 @@ import daeucna.Security.domain.dto.TokenResponseDto; |
12 | 13 | import daeucna.Security.domain.result.SingleResult; |
13 | 14 | import daeucna.Security.domain.service.ResponseService; |
14 | 15 | import daeucna.Security.domain.service.SignService; |
15 | -import daeucna.Security.web.dto.EmailAuthRequestDto; | |
16 | 16 | import daeucna.Security.web.dto.MemberLoginRequestDto; |
17 | 17 | import daeucna.Security.web.dto.MemberRegisterRequestDto; |
18 | 18 | import daeucna.Security.web.dto.ReIssueRequestDto; |
19 | +import io.swagger.annotations.ApiOperation; | |
20 | +import lombok.RequiredArgsConstructor; | |
21 | +import lombok.extern.slf4j.Slf4j; | |
19 | 22 | |
20 | 23 | @Slf4j |
21 | 24 | @RestController | ... | ... |
src/main/resources/application.yml
... | ... | @@ -51,4 +51,16 @@ spring: |
51 | 51 | url: |
52 | 52 | login: https://nid.naver.com/oauth2.0/authorize |
53 | 53 | token: https://nid.naver.com/oauth2.0/token |
54 | - profile: https://openapi.naver.com/v1/nid/me | |
55 | 54 | \ No newline at end of file |
55 | + profile: https://openapi.naver.com/v1/nid/me | |
56 | + | |
57 | + #jsp의 설정이 기존에 있기 때문에 thymeleaf/ 로 호출되면 타임리프가 처리되도록 반영하기 위한 코드 | |
58 | + thymeleaf: | |
59 | + prefix: classpath:/templates/ | |
60 | + suffix: .html | |
61 | + #thymeleaf 수정 사항 발생 시, 서버 재기동 없이 캐시를 무시하기 위한 코드 | |
62 | + cache: false | |
63 | + check-template-location: true | |
64 | + | |
65 | +mybatis: | |
66 | + mapper-locations: classpath:mybatis/mapper/**.xml | |
67 | + | ... | ... |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
3 | +<mapper namespace="daeucna.Security.domain.mapper.Home"> | |
4 | + | |
5 | + <select id="getTestData" parameterType="map" resultType="map"> | |
6 | + /* getTestData */ | |
7 | + SELECT TOP (1000) [member_id] | |
8 | + ,[email] | |
9 | + ,[email_auth] | |
10 | + ,[password] | |
11 | + ,[provider] | |
12 | + FROM [dbo].[members] | |
13 | + </select> | |
14 | + | |
15 | +</mapper> | |
0 | 16 | \ No newline at end of file | ... | ... |