Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

도메인 entity, repository 세팅 #37

Merged
merged 2 commits into from
Aug 16, 2022
Merged
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
37 changes: 37 additions & 0 deletions src/main/kotlin/com/bside/activity/entity/Activity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.bside.activity.entity

import com.bside.common.type.ActivityStatus

import org.bson.types.ObjectId
import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.mongodb.core.mapping.Field

import java.time.LocalDateTime


data class Location(
val lat: Double,
val lon: Double
)

@Document
data class Activity(
@Id
@Field(name = "_id")
val id: ObjectId = ObjectId.get(),
val leaderId: ObjectId,
val crewId: ObjectId,
val memberIds: List<ObjectId> = listOf(),
val name: String,
val description: String,
val capacity: Int,
val joinCount:Int = 1,
val mainImage: String,
val location: Location,
val status: ActivityStatus = ActivityStatus.READY,
val startAt: LocalDateTime,
val createdDate: LocalDateTime = LocalDateTime.now(),
val modifiedDate: LocalDateTime = LocalDateTime.now()
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bside.activity.reposittory

import com.bside.activity.entity.Activity

import org.springframework.data.mongodb.repository.MongoRepository

interface ActivityRepository: MongoRepository<Activity, String>{
}
5 changes: 5 additions & 0 deletions src/main/kotlin/com/bside/common/type/ActivityStatus.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.bside.common.type

enum class ActivityStatus {
READY, RUNNING, FINISHED
}
20 changes: 12 additions & 8 deletions src/main/kotlin/com/bside/config/SwaggerConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package com.bside.config
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile

import springfox.documentation.builders.ApiInfoBuilder
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.service.*
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spi.service.contexts.SecurityContext
import springfox.documentation.spring.web.plugins.Docket
import java.util.*

import java.util.function.Predicate
import java.util.*

@Profile("local || dev")
@Configuration
Expand All @@ -21,13 +23,15 @@ class SwaggerConfig {
fun api(): Docket? {
//Docket: Swagger 설정의 핵심이 되는 Bean
return Docket(DocumentationType.OAS_30)
.securityContexts(listOf(securityContext()))
.securitySchemes(listOf(apiKey()) as List<SecurityScheme>?)
.select()
.apis(RequestHandlerSelectors.basePackage("com.bside.controller")) // controller package 지정
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo()) //:Swagger UI 로 노출할 정보
.securityContexts(listOf(securityContext()))
.securitySchemes(listOf(apiKey()) as List<SecurityScheme>?)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.ant("/api/**")
.and(Predicate.not(
PathSelectors.regex("/api/error.*"))))
.build()
.apiInfo(apiInfo()) //:Swagger UI 로 노출할 정보
}

// api 정보 등록
Expand Down
28 changes: 28 additions & 0 deletions src/main/kotlin/com/bside/crew/entity/Crew.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.bside.crew.entity

import org.bson.types.ObjectId

import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.mongodb.core.mapping.Field

import java.time.LocalDateTime

// 가입 인삿말 필드 추가 필요.
@Document
data class Crew(
@Id
@Field(name = "_id")
val id: ObjectId = ObjectId.get(),
val leaderId: ObjectId,
val memberIds: List<ObjectId> = listOf(),
val name: String,
val title: String,
val description: String,
val capacity: Int,
val joinCount:Int = 1,
val mainImage: String,
val location: Map<String, List<String>>,
val createdDate: LocalDateTime = LocalDateTime.now(),
val modifiedDate: LocalDateTime = LocalDateTime.now()
)
8 changes: 8 additions & 0 deletions src/main/kotlin/com/bside/crew/reposittory/CrewRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bside.crew.reposittory

import com.bside.crew.entity.Crew

import org.springframework.data.mongodb.repository.MongoRepository

interface CrewRepository: MongoRepository<Crew, String>{
}
16 changes: 16 additions & 0 deletions src/main/kotlin/com/bside/feedImage/entity/FeedImage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.bside.feedImage.entity

import org.bson.types.ObjectId
import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.mongodb.core.mapping.Field

@Document
data class FeedImage(
@Id
@Field("_id")
val id: ObjectId = ObjectId.get(),
val memberId: ObjectId,
val crewId: ObjectId,
val image: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bside.feedImage.repository

import com.bside.feedImage.entity.FeedImage

import org.springframework.data.mongodb.repository.MongoRepository

interface FeedImageRepository: MongoRepository<FeedImage, String> {
}
11 changes: 0 additions & 11 deletions src/main/kotlin/com/bside/member/MemberController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,4 @@ class MemberController(
fun getEmail(@RequestParam email: String): MemberResponseDto {
return memberService.getMemberInfo(email)
}

// 슬랙 에러알람 확인을 위한 테스트 용도 입니다. 다음 개발시 삭제 예정입니다.
@GetMapping("/error")
fun makeError() {
try {
val v = 1 / 0
} catch (e: Exception) {
logger.error("error occurred", e)
}
}

}
2 changes: 2 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
###############################
server:
port: 8080
servlet:
contextPath: /api