Skip to content
Open

Pr #3

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ardiary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
//spring-web
implementation 'org.springframework.boot:spring-boot-starter-web'
//swagger
//implementation 'org.springdoc:springdoc-openapi-ui:1.6.9'
//implementation 'org.springdoc:springdoc-openapi-core:1.1.49'

implementation 'io.springfox:springfox-boot-starter:3.0.0' //이건 원래 넣어져 있던거고
//implementation 'io.springfox:springfox-swagger-ui:3.0.0' //이건 새로 추가함
//lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
59 changes: 59 additions & 0 deletions ardiary/src/main/java/com/army/ardiary/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.army.ardiary.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
//import org.springdoc.core.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
public class SwaggerConfig{
//prngdoc기본 config
/* @Bean
public OpenAPI openAPI(@Value("${springdoc.version}") String springdocVersion) {
Info info = new Info()
.title("타이틀 입력")
.version(springdocVersion)
.description("API에 대한 설명 부분");

return new OpenAPI()
.components(new Components())
.info(info);
}*/

//springfox 기본 config
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Army Swagger")
.description("Army swagger config")
.version("3.0.0")
.build();
}
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.useDefaultResponseMessages(false)//swagger 제공 기본 응답 코드. false로 설정하면 안보임
.select()
.apis(RequestHandlerSelectors.basePackage("com.army.ardiary")) //api스펙이 작성되어있는 패키지(컨트롤러) 지정 RequestHandlerSelectors.any() 로 선언해도 됨
.paths(PathSelectors.any()) //path에 입력한 조건에 맞는 api를 문서화
.build()
.apiInfo(apiInfo());
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.army.ardiary.dto.EmailRequestDto;
import com.army.ardiary.dto.LoginResponseDto;
import com.army.ardiary.service.SignService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -13,6 +14,9 @@

import javax.validation.Valid;



@Tag(name = "signUp controller", description = "bear controller desc") //swagger annotation
@RestController
public class SignController {
// SignUp(회원가입) SignIn(로그인)API를 다루는 컨트롤러
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.army.ardiary.repository;

import com.army.ardiary.domain.entity.FollowEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface FollowRepository {
int insert(FollowEntity followEntity);
FollowEntity selectById(int followId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.army.ardiary.repository;

import com.army.ardiary.domain.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserRepository {
int insert(UserEntity userEntity);
UserEntity selectById(int userId);
Expand Down
27 changes: 20 additions & 7 deletions ardiary/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#mybatis
mybatis:
type-aliases-package: com.army.ardiary.domain.entity #entity 경로(db 조회 결과인 resultType 패키지 사전 지정)
mapper-locations: classpath:mapper/*.xml #매퍼.xml 경로
#swagger
#springdoc:
# packages-to-scan: com.army.ardiary.controller
# swagger-ui:
# path: /army_api.html
#paths-to-match: /api/**
spring:
application:
name: ardiary
Expand All @@ -7,14 +17,17 @@ spring:
secretKey: {Key}
#mariadb
datasource:
url: jdbc:mariadb://localhost:3306/army #접속DB명.(rds쓸때는 localhost부분 엔드포인트로 바꿔주기)
url: jdbc:mariadb://armydb.cy6dgaeyzjne.ap-northeast-2.rds.amazonaws.com:3306/ardiary_nf #접속DB명.(rds쓸때는 localhost부분 엔드포인트로 바꿔주기). ardiary_nf: no foreign 외래키 속성 제거한 데이터베이스. 외래키 속성 사용하려면 _nf지우면 됨
driver-class-name: org.mariadb.jdbc.Driver
username: admin
password: 220324
#mybatis
mybatis:
type-aliases-package: com.army.ardiary.domain.entity #entity 경로(db 조회 결과인 resultType 패키지 사전 지정)
mapper-locations: mapper/**/*.xml #매퍼.xml 경로
password: 20220324
#springfox 사용 가능
mvc:
pathmatch:
matching-strategy: ant_path_matcher



server:
port: 8088
port: 8088
forward-headers-strategy: framework
2 changes: 1 addition & 1 deletion ardiary/src/main/resources/mapper/FollowMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
keyColumn="follow_id">
UPDATE follow
SET follower = #{follower},
followee = #{followee},
followee = #{followee}
WHERE follow_id = #{followId};
</update>

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import com.army.ardiary.domain.entity.FollowEntity;
import com.army.ardiary.domain.entity.UserEntity;
import org.junit.jupiter.api.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;

import java.time.LocalDate;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
@MapperScan(basePackages = "com.army.ardiary.repository")
class FollowRepositoryTest {

@Autowired
private FollowRepository followRepository;

Expand Down