Skip to content

Commit

Permalink
Merge branch 'main' into restdocs/group-member
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/docs/asciidoc/index.adoc
#	src/main/java/com/postsquad/scoup/web/group/controller/GroupController.java
#	src/test/java/com/postsquad/scoup/web/group/GroupAcceptanceTest.java
  • Loading branch information
Dae-Hwa committed Nov 29, 2021
2 parents 508048d + 1dd3f61 commit 216f4bf
Show file tree
Hide file tree
Showing 25 changed files with 442 additions and 88 deletions.
7 changes: 7 additions & 0 deletions src/docs/asciidoc/group/group-deletion.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== 그룹 삭제

=== `POST /api/groups/{groupId}`

=== `204 No Content`

operation::group_acceptance_test/delete_group[snippets='path-parameters,http-request,http-response']
7 changes: 7 additions & 0 deletions src/docs/asciidoc/group/group-name-validation.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== 그룹 이름 중복 확인

=== `GET /groups/{groupId}`

=== `200 Ok`

operation::group_acceptance_test/validate_group_name[snippets='request-parameters,response-fields,http-request,http-response']
7 changes: 7 additions & 0 deletions src/docs/asciidoc/group/group-read-one.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== 그룹 상세 조회

=== `GET /groups/{groupId}`

=== `200 Ok`

operation::group_acceptance_test/read_one[snippets='path-parameters,response-fields,http-request,http-response']
9 changes: 9 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ include::user/email-validation.adoc[]
// 닉네임 중복확인
include::user/nickname-validation.adoc[]

// 그룹 상세 조회
include::group/group-read-one.adoc[]

// 그룹 생성
include::group/group-creation.adoc[]

// 그룹 수정
include::group/group-modification.adoc[]

// 그룹 삭제
include::group/group-deletion.adoc[]

// 그룹 이름 중복확인
include::group/group-name-validation.adoc[]

// 그룹 탈퇴
include::group/group-leave.adoc[]

Expand Down
28 changes: 0 additions & 28 deletions src/main/java/com/postsquad/scoup/ScoupApplication.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,14 @@
package com.postsquad.scoup;

import com.google.common.base.Predicates;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@EnableJpaAuditing
@SpringBootApplication
public class ScoupApplication {

public static void main(String[] args) {
SpringApplication.run(ScoupApplication.class, args);
}

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("Scoup")
.apiInfo(apiInfo())
.select()
.paths(Predicates.not(PathSelectors.regex("/error")))
.paths(PathSelectors.ant("/**"))
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Scoup API Documentation")
.version("1.0")
.description("Scoup의 API 문서입니다.")
.build();
}
}
49 changes: 49 additions & 0 deletions src/main/java/com/postsquad/scoup/web/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.postsquad.scoup.web.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverers;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer;
import org.springframework.plugin.core.SimplePluginRegistry;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

@EnableSwagger2
@Configuration
public class SwaggerConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("Scoup")
.apiInfo(apiInfo())
.select()
.paths(Predicates.not(PathSelectors.regex("/error")))
.paths(PathSelectors.ant("/**"))
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Scoup API Documentation")
.version("1.0")
.description("Scoup의 API 문서입니다.")
.build();
}

@Bean
public LinkDiscoverers discoverers() {
List<LinkDiscoverer> plugins = new ArrayList<>();
plugins.add(new CollectionJsonLinkDiscoverer());
return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
}
}
12 changes: 0 additions & 12 deletions src/main/java/com/postsquad/scoup/web/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverers;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.plugin.core.SimplePluginRegistry;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
Expand All @@ -21,7 +17,6 @@
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import reactor.netty.http.client.HttpClient;

import java.util.ArrayList;
import java.util.List;

@RequiredArgsConstructor
Expand Down Expand Up @@ -76,11 +71,4 @@ public void addInterceptors(InterceptorRegistry registry) {
.addPathPatterns("/**")
.excludePathPatterns(SIGNIN_PATH_TO_EXCLUDE);
}

@Bean
public LinkDiscoverers discoverers() {
List<LinkDiscoverer> plugins = new ArrayList<>();
plugins.add(new CollectionJsonLinkDiscoverer());
return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.postsquad.scoup.web.error.controller.response.ErrorResponse;
import com.postsquad.scoup.web.group.controller.request.GroupCreationRequest;
import com.postsquad.scoup.web.group.controller.request.GroupModificationRequest;
import com.postsquad.scoup.web.group.controller.request.GroupValidationRequest;
import com.postsquad.scoup.web.group.controller.response.GroupReadOneResponse;
import com.postsquad.scoup.web.group.controller.response.GroupValidationResponse;
import com.postsquad.scoup.web.group.exception.GroupCreationFailedException;
import com.postsquad.scoup.web.group.service.GroupService;
import com.postsquad.scoup.web.user.LoggedInUser;
Expand All @@ -21,6 +24,18 @@ public class GroupController {

private final GroupService groupService;

@GetMapping("/{groupId}")
public GroupReadOneResponse readOne(@PathVariable long groupId) {
// TODO: GroupService.readOne
return GroupReadOneResponse.builder()
.id(1L)
.image("image")
.name("name")
.description("description")
.build();
}


@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public DefaultPostResponse create(@RequestBody @Valid GroupCreationRequest groupCreationRequest, @LoggedInUser User user) {
Expand All @@ -39,6 +54,19 @@ public void update(@PathVariable Long groupId, @RequestBody @Valid GroupModifica
groupService.update(groupId, groupModificationRequest, user);
}

@DeleteMapping("/{groupId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable Long groupId) {
// TODO: 삭제 서비스, 사용자 인증
}

@GetMapping("/validate/group-name")
public GroupValidationResponse validateGroupName(@Valid GroupValidationRequest groupValidationRequest) {
return GroupValidationResponse.builder()
.isExistingName(true)
.build();
}

@DeleteMapping("/{groupId}/leave")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void leaveGroup(@PathVariable long groupId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.postsquad.scoup.web.group.controller.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class GroupValidationRequest {

@NotNull
private String groupName;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.postsquad.scoup.web.group.controller.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
// TODO: 전체조회 머지되면 BaseResponse와 합치기
public class GroupReadOneResponse {

private long id;

private String name;

private String description;

private String image;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.postsquad.scoup.web.group.controller.response;

import lombok.Builder;
import lombok.Getter;
import lombok.*;

@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@Getter
public class GroupValidationResponse {

@Builder.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

import com.postsquad.scoup.web.common.DefaultPostResponse;
import com.postsquad.scoup.web.error.controller.response.ErrorResponse;
import com.postsquad.scoup.web.user.controller.request.EmailValidationRequest;
import com.postsquad.scoup.web.user.controller.request.NicknameValidationRequest;
import com.postsquad.scoup.web.user.controller.request.SignUpRequest;
import com.postsquad.scoup.web.user.controller.response.EmailValidationResponse;
import com.postsquad.scoup.web.user.controller.response.NicknameValidationResponse;
import com.postsquad.scoup.web.user.service.SignUpFailedException;
import com.postsquad.scoup.web.user.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;

@RequiredArgsConstructor
@Validated
@RequestMapping("/users")
@RestController
public class UserController {
Expand All @@ -38,12 +36,12 @@ public ErrorResponse signUpFailedExceptionHandler(SignUpFailedException signUpFa
}

@GetMapping("/validate/email")
public EmailValidationResponse validateEmail(@RequestParam @NotEmpty @Email String email) {
return userService.validateEmail(email);
public EmailValidationResponse validateEmail(@Valid EmailValidationRequest emailValidationRequest) {
return userService.validateEmail(emailValidationRequest);
}

@GetMapping("/validate/nickname")
public NicknameValidationResponse validateNickname(@RequestParam @NotEmpty String nickname) {
return userService.validateNickname(nickname);
public NicknameValidationResponse validateNickname(@Valid NicknameValidationRequest nicknameValidationRequest) {
return userService.validateNickname(nicknameValidationRequest);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.postsquad.scoup.web.user.controller.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class EmailValidationRequest {

@NotEmpty
@Email
private String email;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.postsquad.scoup.web.user.controller.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotEmpty;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class NicknameValidationRequest {

@NotEmpty
private String nickname;
}
Loading

0 comments on commit 216f4bf

Please sign in to comment.