Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#172-project_api
Browse files Browse the repository at this point in the history
  • Loading branch information
JIN-076 authored Feb 28, 2024
2 parents eacaf3d + f1669fe commit 619a456
Show file tree
Hide file tree
Showing 43 changed files with 668 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import io.oeid.mogakgo.common.base.CursorPaginationInfoReq;
import io.oeid.mogakgo.common.base.CursorPaginationResult;
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerChatErrorExamples;
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerProjectErrorExamples;
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerUserErrorExamples;
import io.oeid.mogakgo.domain.chat.application.dto.res.ChatDataRes;
import io.oeid.mogakgo.domain.chat.application.dto.res.ChatRoomDataRes;
import io.oeid.mogakgo.domain.chat.application.dto.res.ChatRoomPublicRes;
import io.oeid.mogakgo.exception.dto.ErrorResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
Expand All @@ -28,28 +32,52 @@ public interface ChatSwagger {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "채팅방 목록 조회 성공"),
@ApiResponse(responseCode = "404", description = "요청한 유저가 존재하지 않음",
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND)
))
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND)
))
})
ResponseEntity<List<ChatRoomPublicRes>> getChatRoomList(@Parameter(hidden = true) Long userId);

@Operation(summary = "채팅방 상세 조회", description = "채팅방의 상세 정보를 조회하는 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "채팅방 상세 조회 성공"),
@ApiResponse(responseCode = "404", description = "요청한 데이터가 유효하지 않음",
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND),
@ExampleObject(name = "E030301", value = SwaggerProjectErrorExamples.PROJECT_NOT_FOUND),
@ExampleObject(name = "E110301", value = SwaggerChatErrorExamples.CHAT_ROOM_NOT_FOUND)
}
))
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND),
@ExampleObject(name = "E030301", value = SwaggerProjectErrorExamples.PROJECT_NOT_FOUND),
@ExampleObject(name = "E110301", value = SwaggerChatErrorExamples.CHAT_ROOM_NOT_FOUND)
}
))
})
ResponseEntity<ChatRoomDataRes> getChatRoomDetailData(@Parameter(hidden = true) Long userId,
ResponseEntity<ChatRoomDataRes> getChatRoomDetailData(
@Parameter(hidden = true) Long userId,
@Parameter(in = ParameterIn.PATH) String chatRoomId);

@Operation(summary = "채팅 내용 조회", description = "채팅방의 채팅 내용을 조회하는 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "채팅 내용 조회 성공"),
@ApiResponse(responseCode = "404", description = "요청한 데이터가 유효하지 않음",
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND),
@ExampleObject(name = "E110301", value = SwaggerChatErrorExamples.CHAT_ROOM_NOT_FOUND)
}
))
})
@Parameters({
@Parameter(name = "cursorId", description = "기준이 되는 커서 ID", example = "1"),
@Parameter(name = "pageSize", description = "요청할 데이터 크기", example = "5", required = true),
@Parameter(name = "sortOrder", description = "정렬 방향", example = "ASC"),
})
ResponseEntity<CursorPaginationResult<ChatDataRes>> getChatData(
@Parameter(in = ParameterIn.PATH) String chatRoomId,
@Parameter(hidden = true) Long userId,
@Parameter(hidden = true) CursorPaginationInfoReq pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import io.oeid.mogakgo.core.properties.swagger.error.SwaggerUserErrorExamples;
import io.oeid.mogakgo.domain.user.application.dto.res.UserJandiRateRes;
import io.oeid.mogakgo.domain.user.presentation.dto.req.UserSignUpApiReq;
import io.oeid.mogakgo.domain.user.presentation.dto.req.UserUpdateApiReq;
import io.oeid.mogakgo.domain.user.presentation.dto.res.UserDevelopLanguageApiRes;
Expand All @@ -13,6 +14,7 @@
import io.oeid.mogakgo.exception.dto.ErrorResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down Expand Up @@ -109,5 +111,18 @@ ResponseEntity<List<UserDevelopLanguageApiRes>> userDevelopLanguageApi(
})
ResponseEntity<UserUpdateApiRes> userUpdateApi(@Parameter(hidden = true) Long userId,
UserUpdateApiReq request);


@Operation(summary = "회원 잔디 점수 조회", description = "회원의 잔디 점수를 조회할 때 사용하는 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "회원 잔디 점수 조회 성공",
content = @Content(schema = @Schema(implementation = UserJandiRateRes.class))),
@ApiResponse(responseCode = "404", description = "해당 유저가 존재하지 않음",
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND))),
})
ResponseEntity<UserJandiRateRes> userJandiRateApi(@Parameter(in = ParameterIn.PATH) Long userId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ SecurityFilterChain filterChainApi(HttpSecurity http) throws Exception {
.sessionManagement(
management -> management.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(
requests -> requests.anyRequest().authenticated())
requests -> {
requests.requestMatchers("/api/v1/auth/**").permitAll();
requests.anyRequest().authenticated();
})
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
.exceptionHandling(handling ->
handling.accessDeniedHandler(jwtAccessDeniedHandler)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.oeid.mogakgo.domain.achievement.domain;
package io.oeid.mogakgo.domain.achievement.domain.entity;

import io.oeid.mogakgo.domain.achievement.domain.enums.AchievementType;
import io.oeid.mogakgo.domain.achievement.domain.entity.enums.ActivityType;
import io.oeid.mogakgo.domain.achievement.domain.entity.enums.RequirementType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand All @@ -9,7 +10,6 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -33,16 +33,18 @@ public class Achievement {
@Column(name = "img_url")
private String imgUrl;

@Column(name = "progress_level")
private Integer progressLevel;

@Enumerated(EnumType.STRING)
@Column(name = "type")
private AchievementType achievementType;

@Builder
private Achievement(String title, String description, String imgUrl,
AchievementType achievementType) {
this.title = title;
this.description = description;
this.imgUrl = imgUrl;
this.achievementType = achievementType;
}
@Column(name = "requirement_type")
private RequirementType requirementType;

@Column(name = "requirement_value")
private Integer requirementValue;

@Enumerated(EnumType.STRING)
@Column(name = "activity_type")
private ActivityType activityType;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.oeid.mogakgo.domain.achievement.domain.entity;

import io.oeid.mogakgo.domain.user.domain.User;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Getter
@Entity
@Table(name = "user_achievement_tb")
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
public class UserAchievement {

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "achievement_id")
private Achievement achievement;

// TODO: 필요하면 개발하다가 추가
// @Column(name = "progress_count")
// private Integer progressCount;

@Column(name = "completed")
private Boolean completed;

@CreatedDate
@Column(name = "created_at")
private LocalDateTime createdAt;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.oeid.mogakgo.domain.achievement.domain.entity;

import io.oeid.mogakgo.domain.achievement.domain.entity.enums.ActivityType;
import io.oeid.mogakgo.domain.user.domain.User;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Getter
@Entity
@Table(name = "user_activity_tb")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
public class UserActivity {

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

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@Enumerated(EnumType.STRING)
@Column(name = "activity_type")
private ActivityType activityType;

@CreatedDate
@Column(name = "created_at")
private LocalDateTime createdAt;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.oeid.mogakgo.domain.achievement.domain.entity.enums;

import java.util.List;
import lombok.Getter;

@Getter
public enum ActivityType {

FROM_ONE_STEP(List.of(2, 3, 4)),
GOOD_PERSON_GOOD_MEETUP(List.of(5, 6, 7)),
LIKE_E(List.of(8, 9, 10)),
MY_DESTINY(List.of(11)),
CAPTURE_FAIL_EXIST(List.of(12)),
RUN_AWAY_FROM_MONSTAR_BALL(List.of(13)),
PLEASE_GIVE_ME_MOGAK(List.of(14, 15, 16)),
BRAVE_EXPLORER(List.of(17)),
NOMAD_CODER(List.of(18)),
CATCH_ME_IF_YOU_CAN(List.of(19, 20, 21)),
LEAVE_YOUR_MARK(List.of(22)),
WHAT_A_POPULAR_PERSON(List.of(23, 24, 25)),
CONTACT_WITH_GOD(List.of(26)),
FRESH_DEVELOPER(List.of(28, 29, 30)),
;

private final List<Integer> includedDbIdList;

ActivityType(List<Integer> includedDbIdList) {
this.includedDbIdList = includedDbIdList;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.oeid.mogakgo.domain.achievement.domain.entity.enums;

public enum RequirementType {
SEQUENCE,
ACCUMULATE,
;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.oeid.mogakgo.domain.achievement.infrastructure;

import io.oeid.mogakgo.domain.achievement.domain.Achievement;
import io.oeid.mogakgo.domain.achievement.domain.entity.Achievement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface AchievementJpaRepository extends JpaRepository<Achievement, Long> {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.oeid.mogakgo.domain.chat.application;

import static org.springframework.data.mongodb.core.FindAndModifyOptions.options;
import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

import io.oeid.mogakgo.domain.chat.entity.document.ChatIdSequence;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ChatIdSequenceGeneratorService {

private final MongoOperations mongoOperations;

public Long generateSequence(String collectionName) {
ChatIdSequence counter = mongoOperations.findAndModify(
query(where("_id").is(collectionName)), new Update().inc("seq", 1),
options().returnNew(true).upsert(true), ChatIdSequence.class);
return !Objects.isNull(counter) ? counter.getSeq() : 1;
}
}
Loading

0 comments on commit 619a456

Please sign in to comment.