Skip to content

Commit

Permalink
Merge branch 'develop' into feat/YEL-193
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonjeongs authored Jan 30, 2024
2 parents ce06a65 + 902a055 commit 5503e57
Show file tree
Hide file tree
Showing 48 changed files with 1,153 additions and 311 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dependencies {

// Repositories
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.amqp:spring-rabbit:2.3.12'

runtimeOnly 'com.h2database:h2'
Expand Down
4 changes: 3 additions & 1 deletion src/docs/asciidoc/check-user-v2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include::{snippets}/api/v2/user/http-response.adoc[]
- "social": "KAKAO" | "APPLE"
- "uuid": String(10)
- "deviceToken": String
- "groupId": Long
- "group": String
- "groupType": "UNIVERSITY" | "HIGH_SCHOOL" | "MIDDLE_SCHOOL" | "SOPT"
- "groupName": String
Expand All @@ -41,4 +42,5 @@ include::{snippets}/api/v2/user/http-response.adoc[]
=== CHANGELOG

- 2024.01.07 첫 릴리즈
- 2024.01.09 필드 타입 추가
- 2024.01.09 필드 타입 추가
- 2024.01.30 groupId 필드 추가
29 changes: 29 additions & 0 deletions src/docs/asciidoc/delete-user-v2.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
:reproducible:
== 탈퇴 & 사유 저장 v2

=== 요청

include::{snippets}/api/v2/user/deleteUser/http-request.adoc[]

=== 응답

include::{snippets}/api/v2/user/deleteUser/http-response.adoc[]

*필드 타입*

- "value": String
* value는 탈퇴 사유를 보내주시면 됩니다.


*필드 타입*

=== NOTE

- AccessToken에 해당하는 User의 탈퇴 처리 및 탈퇴 사유를 저장하는 API입니다.
// - User의 다양한 정보를 저장하는 API로 범용적인 확장할 예정입니다.
// * 차후에 tag에 들어갈 수 있는 ENUM의 종류를 다양화 할 예정입니다.

=== CHANGELOG

- 2024.01.27 API 릴리즈
- 2024.01.09 명세 작성
6 changes: 4 additions & 2 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

* link:check-user.html[내 정보 조회하기 V1]

* 🆕 link:check-user-v2.html[내 정보 조회하기 V2, 2024-01-07]
* 🆕 link:check-user-v2.html[내 정보 조회하기 V2, 2024-01-30]

* 🆕 link:edit-user.html[유저 정보 수정 (명세), 2024-01-09]

* 🆕 link:user-data-get.html[프로필 수정 가능 여부 조회 (명세), 2024-01-09]

* 🆕 link:user-data-post.html[탈퇴 사유 저장 (명세), 2024-01-09]
* 🆕 link:user-data-post.html[유저 기타 정보 저장 (명세), 2024-01-30]

* 🆕 link:purchase-info.html[유저 구독 정보, 2024-01-25]

Expand All @@ -49,6 +49,8 @@

* link:delete-user.html[유저 탈퇴]

* 🆕 link:delete-user-v2.html[유저 탈퇴 V2, 2024-01-30]

=== Vote API

* link:find-votes.html[내 투표 전체 조회하기]
Expand Down
37 changes: 27 additions & 10 deletions src/docs/asciidoc/user-data-post.adoc
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
:reproducible:
== 탈퇴 & 사유 저장 v2
== 유저 기타 정보 저장 (명세)

=== 요청

include::{snippets}/api/v2/user/http-request.adoc[]

=== 응답

include::{snippets}/api/v2/user/http-response.adoc[]
[http]
----
POST /api/v1/user/data/recommended HTTP/1.1
Authorization: Bearer your-access-token
Content-Type: application-json
{
"value": "true"
}
----

*필드 타입*

- "tag": "withdraw-reason" | "account-update-at" | "recommended"
* withdraw-reason 자리가 ENUM으로 대체될 예정입니다.
- "value": String
* value는 탈퇴 사유를 보내주시면 됩니다.

=== 응답

*필드 타입*
[http,json]
----
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json
{
"status" : 200,
"message" : "탈퇴 사유 정보 저장에 성공하였습니다."
}
----

=== NOTE

- AccessToken에 해당하는 User의 탈퇴 사유를 저장하는 API입니다.
- User의 다양한 정보를 저장하는 API로 범용적인 확장할 예정입니다.
* 차후에 tag에 들어갈 수 있는 ENUM의 종류를 다양화 할 예정입니다.

=== CHANGELOG

- 2024.01.27 API 릴리즈
- 2024.01.30 탈퇴 v2 분리로 인한 명세 업데이트
- 2024.01.09 명세 작성
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.yello.server.domain.admin.controller;

import static com.yello.server.global.common.SuccessCode.CONFIGURATION_READ_ADMIN_SUCCESS;
import static com.yello.server.global.common.SuccessCode.CONFIGURATION_UPDATE_ADMIN_SUCCESS;
import static com.yello.server.global.common.SuccessCode.CREATE_VOTE_SUCCESS;
import static com.yello.server.global.common.SuccessCode.DELETE_COOLDOWN_ADMIN_SUCCESS;
import static com.yello.server.global.common.SuccessCode.DELETE_QUESTION_ADMIN_SUCCESS;
Expand All @@ -18,12 +20,15 @@
import com.yello.server.domain.admin.dto.request.AdminLoginRequest;
import com.yello.server.domain.admin.dto.request.AdminQuestionVoteRequest;
import com.yello.server.domain.admin.dto.request.AdminUserDetailRequest;
import com.yello.server.domain.admin.dto.response.AdminConfigurationResponse;
import com.yello.server.domain.admin.dto.response.AdminConfigurationUpdateRequest;
import com.yello.server.domain.admin.dto.response.AdminCooldownResponse;
import com.yello.server.domain.admin.dto.response.AdminLoginResponse;
import com.yello.server.domain.admin.dto.response.AdminQuestionDetailResponse;
import com.yello.server.domain.admin.dto.response.AdminQuestionResponse;
import com.yello.server.domain.admin.dto.response.AdminUserDetailResponse;
import com.yello.server.domain.admin.dto.response.AdminUserResponse;
import com.yello.server.domain.admin.entity.AdminConfigurationType;
import com.yello.server.domain.admin.service.AdminService;
import com.yello.server.domain.user.entity.User;
import com.yello.server.global.common.annotation.AccessTokenUser;
Expand Down Expand Up @@ -62,7 +67,7 @@ public BaseResponse<AdminUserResponse> getUserAdmin(@AccessTokenUser User user,
@RequestParam Integer page,
@Nullable @RequestParam String field,
@Nullable @RequestParam String value) {
val data = (field==null && value==null)
val data = (field == null && value == null)
? adminService.findUser(user.getId(), createPageableByNameSortDescLimitTen(page))
: adminService.findUserContaining(user.getId(),
createPageableByNameSortDescLimitTen(page),
Expand Down Expand Up @@ -94,7 +99,7 @@ public BaseResponse deleteUser(@AccessTokenUser User user, @RequestParam Long us
public BaseResponse<AdminCooldownResponse> getCooldownAdmin(@AccessTokenUser User user,
@RequestParam Integer page,
@Nullable @RequestParam String yelloId) {
val data = yelloId==null
val data = yelloId == null
? adminService.findCooldown(user.getId(), createPageableLimitTen(page))
: adminService.findCooldownContaining(user.getId(), createPageableLimitTen(page),
yelloId);
Expand Down Expand Up @@ -144,4 +149,23 @@ public BaseResponse<EmptyObject> postCustomNotificationSendAdmin(@AccessTokenUse

return BaseResponse.success(CREATE_VOTE_SUCCESS, data);
}

@GetMapping("/configuration")
public BaseResponse<AdminConfigurationResponse> getConfigurations(@RequestParam("tag") String tag,
@AccessTokenUser User user) {
final AdminConfigurationType configurationType = AdminConfigurationType.fromCode(tag);
val data = adminService.getConfigurations(user.getId(), configurationType);
return BaseResponse.success(CONFIGURATION_READ_ADMIN_SUCCESS, null);
}

@PostMapping("/configuration")
public BaseResponse<EmptyObject> postConfigurations(
@RequestBody AdminConfigurationUpdateRequest request,
@AccessTokenUser User user) {
final AdminConfigurationType configurationType = AdminConfigurationType.fromCode(request.tag());

val data = adminService.updateConfigurations(user.getId(), configurationType, request.value());

return BaseResponse.success(CONFIGURATION_UPDATE_ADMIN_SUCCESS, data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.yello.server.domain.admin.dto.response;

import lombok.Builder;

@Builder
public record AdminConfigurationResponse(
String tag,
String value
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.yello.server.domain.admin.dto.response;

import lombok.Builder;

@Builder
public record AdminConfigurationUpdateRequest(
String tag,
String value
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.yello.server.domain.admin.entity;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class AdminConfiguration {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column
@Convert(converter = AdminConfigurationTypeConverter.class)
private AdminConfigurationType tag;

@Column
private String value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.yello.server.domain.admin.entity;

import java.text.MessageFormat;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum AdminConfigurationType {
ACCESS_TOKEN_TIME("ACCESS_TOKEN_TIME"),
REFRESH_TOKEN_TIME("REFRESH_TOKEN_TIME"),
ADMIN_SITE_PASSWORD("ADMIN_SITE_PASSWORD");

private final String intial;

public static AdminConfigurationType fromCode(String dbData) {
return Arrays.stream(AdminConfigurationType.values())
.filter(v -> v.getIntial().equals(dbData))
.findAny()
.orElseThrow(() -> new IllegalArgumentException(
MessageFormat.format("존재하지 않는 태그입니다. {0}", dbData)));
}

public String intial() {
return intial;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.yello.server.domain.admin.entity;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import lombok.extern.log4j.Log4j2;

@Converter
@Log4j2
public class AdminConfigurationTypeConverter implements AttributeConverter<AdminConfigurationType, String> {

@Override
public String convertToDatabaseColumn(AdminConfigurationType type) {
if (type == null) {
return null;
}
return type.getIntial();
}

@Override
public AdminConfigurationType convertToEntityAttribute(String dbData) {
if (dbData == null) {
return null;
}
try {
return AdminConfigurationType.fromCode(dbData);
} catch (IllegalArgumentException exception) {
log.error("failure to convert cause unexpected code" + dbData + exception);
throw exception;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.yello.server.domain.admin.exception;

import com.yello.server.global.common.ErrorCode;
import com.yello.server.global.exception.CustomException;

public class AdminConfigurationNotFoundException extends CustomException {

public AdminConfigurationNotFoundException(ErrorCode error) {
super(error, "[AdminConfigurationNotFoundException] " + error.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.yello.server.domain.admin.repository;

import com.yello.server.domain.admin.entity.AdminConfiguration;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AdminConfigurationJpaRepository extends JpaRepository<AdminConfiguration, Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.yello.server.domain.admin.repository;

import com.yello.server.domain.admin.entity.AdminConfiguration;
import com.yello.server.domain.admin.entity.AdminConfigurationType;
import java.util.List;

public interface AdminConfigurationRepository {

List<AdminConfiguration> findConfigurations(AdminConfigurationType tag);

void setConfigurations(AdminConfigurationType tag, String value);

void deleteConfigurations(AdminConfigurationType tag);
}
Loading

0 comments on commit 5503e57

Please sign in to comment.