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

마커 조회 기능 추가 및 회사 위도, 경도 저장 수정 #171

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class MentorController(
private val deleteMentorInfoByIdUseCase: DeleteMentorInfoByIdUseCase,
private val modifyMentorInfoByIdUseCase: ModifyMentorInfoByIdUseCase,
private val authenticatedUserManager: AuthenticatedUserManager,
private val generateCompanyAddressUseCase: GenerateCompanyAddressUseCase
private val generateCompanyAddressUseCase: GenerateCompanyAddressUseCase,
private val queryAllMentorCompanyAddressUseCase: QueryAllMentorCompanyAddressUseCase
) {

@PostMapping
Expand Down Expand Up @@ -68,4 +69,9 @@ class MentorController(
return ResponseEntity.status(HttpStatus.CREATED).build()
}

@GetMapping("/marker")
fun queryAllMentorAddress(): ResponseEntity<List<MentorCompanyAddressListDto>> {
return ResponseEntity.ok(queryAllMentorCompanyAddressUseCase.queryAllMentorCompanyAddress())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class Career(
val companyUrl: String,

@Column(nullable = true)
var companyAddress: String?,
var lat: Double?,

@Column(nullable = true)
var lon: Double?,

@Column(nullable = false)
val position: String,
Expand All @@ -46,7 +49,8 @@ class Career(
mentor = mentor,
companyName = it.companyName,
companyUrl = it.companyUrl ?: "",
companyAddress = it.companyAddress ?: "",
lat = it.lat,
lon = it.lon,
position = it.position,
startDate = it.startDate,
endDate = it.endDate,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.themoment.gsmNetworking.domain.mentor.dto

data class CompanyAddressDto (
val name: String,
val position: String,
val lat: Double,
val lon: Double
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package team.themoment.gsmNetworking.domain.mentor.dto

data class CompanyAddressRegistrationDto (
val id: Long,
val companyAddress: String?
val lat: Double,
val lon: Double
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ data class CompanyInfoDto(
val name: String,
@field:JsonProperty("URL")
val url: String?,
val address: String?
val lat: Double?,
val lon: Double?
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ data class MentorCareerDto(

val companyUrl: String?,

val companyAddress: String?,
val lat: Double?,

val lon: Double?,

@field:NotBlank
val position: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package team.themoment.gsmNetworking.domain.mentor.dto

data class MentorCompanyAddressListDto (
val id: Long,
val name: String,
val generation: Int,
val company: CompanyAddressDto
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ data class MyCareerInfoDto(
val position: String,
val companyName: String,
val companyUrl: String?,
val companyAddress: String?,
val lat: Double?,
val lon: Double?,
val startDate: LocalDate,
val endDate: LocalDate?,
val isWorking: Boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.themoment.gsmNetworking.domain.mentor.repository

import team.themoment.gsmNetworking.domain.mentor.dto.MentorCompanyAddressListDto

interface CareerCustomRepository {
fun queryAllCompanyAddress(): List<MentorCompanyAddressListDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package team.themoment.gsmNetworking.domain.mentor.repository

import com.querydsl.core.types.Projections
import com.querydsl.jpa.impl.JPAQueryFactory
import team.themoment.gsmNetworking.domain.mentor.dto.MentorCompanyAddressListDto
import team.themoment.gsmNetworking.domain.mentor.domain.QCareer.career
import team.themoment.gsmNetworking.domain.user.domain.QUser.user
import team.themoment.gsmNetworking.domain.mentor.domain.QMentor.mentor
import team.themoment.gsmNetworking.domain.mentor.dto.CompanyAddressDto

class CareerCustomRepositoryImpl (
private val queryFactory: JPAQueryFactory
) : CareerCustomRepository {
override fun queryAllCompanyAddress(): List<MentorCompanyAddressListDto> {
return queryFactory.select(
Projections.constructor(
MentorCompanyAddressListDto::class.java,
mentor.id,
mentor.user.name,
mentor.user.generation,
Projections.constructor(
CompanyAddressDto::class.java,
career.companyName,
career.position,
career.lat,
career.lon
)
)
)
.from(career)
.innerJoin(career.mentor, mentor)
.on(career.mentor.eq(mentor))
.innerJoin(mentor.user, user)
.on(mentor.user.eq(user))
.where(career.isWorking.isTrue)
.fetch()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import team.themoment.gsmNetworking.domain.mentor.domain.Mentor
/**
* Career Entity를 위한 Repository 인터페이스 입니다.
*/
interface CareerRepository : CrudRepository<Career, Long> {
interface CareerRepository : CrudRepository<Career, Long>, CareerCustomRepository {

fun deleteByMentor(mentor: Mentor)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class MentorCustomRepositoryImpl(
CompanyInfoDto::class.java,
career.companyName,
career.companyUrl,
career.companyAddress
career.lat,
career.lon
),
mentor.user.snsUrl,
mentor.user.profileUrl,
Expand Down Expand Up @@ -81,7 +82,8 @@ class MentorCustomRepositoryImpl(
career.position,
career.companyName,
career.companyUrl,
career.companyAddress,
career.lat,
career.lon,
career.startDate,
career.endDate,
career.isWorking
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.themoment.gsmNetworking.domain.mentor.service

import team.themoment.gsmNetworking.domain.mentor.dto.MentorCompanyAddressListDto

interface QueryAllMentorCompanyAddressUseCase {
fun queryAllMentorCompanyAddress(): List<MentorCompanyAddressListDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import team.themoment.gsmNetworking.common.exception.ExpectedException
import team.themoment.gsmNetworking.domain.mentor.domain.Career
import team.themoment.gsmNetworking.domain.mentor.domain.Mentor
import team.themoment.gsmNetworking.domain.mentor.dto.*
import team.themoment.gsmNetworking.domain.mentor.repository.CareerCustomRepository
import team.themoment.gsmNetworking.domain.mentor.repository.CareerRepository
import team.themoment.gsmNetworking.domain.mentor.repository.MentorRepository
import team.themoment.gsmNetworking.domain.mentor.service.*
Expand All @@ -29,13 +30,14 @@ class MentorService(
private val generateUserUseCase: GenerateUserUseCase,
private val modifyUserInfoByIdUseCase: ModifyUserInfoByIdUseCase,
private val deleteUserInfoByIdUseCase: DeleteUserInfoByIdUseCase,
private val queryUserByIdUseCase: QueryUserByIdUseCase
private val queryUserByIdUseCase: QueryUserByIdUseCase,
) : QueryAllMentorsUseCase,
MentorRegistrationUseCase,
QueryMentorInfoByIdUseCase,
DeleteMentorInfoByIdUseCase,
ModifyMentorInfoByIdUseCase,
GenerateCompanyAddressUseCase{
GenerateCompanyAddressUseCase,
QueryAllMentorCompanyAddressUseCase {

/**
* 모든 멘토 리스트를 가져와서 리턴해주는 메서드 입니다.
Expand Down Expand Up @@ -76,7 +78,8 @@ class MentorService(
mentor = mentor,
companyName = it.companyName,
companyUrl = it.companyUrl ?: "",
companyAddress = it.companyAddress ?: "",
lat = it.lat,
lon = it.lon,
position = it.position,
startDate = it.startDate,
endDate = it.endDate,
Expand Down Expand Up @@ -134,6 +137,14 @@ class MentorService(
override fun generateCompanyAddress( companyAddressRegistrationDto: CompanyAddressRegistrationDto) {
val career = careerRepository.findById(companyAddressRegistrationDto.id)
.orElseThrow { ExpectedException("career를 찾을 수 없습니다.", HttpStatus.NOT_FOUND) }
career.companyAddress = companyAddressRegistrationDto.companyAddress
career.lat = companyAddressRegistrationDto.lat
career.lon = companyAddressRegistrationDto.lon
careerRepository.save(career)
}

@Transactional(readOnly = true)
override fun queryAllMentorCompanyAddress(): List<MentorCompanyAddressListDto> {
return careerRepository.queryAllCompanyAddress()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class TempMentorService(
company = CompanyInfoDto(
name = tempMentor.companyName,
url = tempMentor.companyUrl,
address = ""
lat = null,
lon = null
),
snsUrl = tempMentor.sns,
defaultImgNumber = tempMentor.defaultImgNumber
Expand Down Expand Up @@ -69,7 +70,8 @@ class TempMentorService(
company = CompanyInfoDto(
name = tempMentor.companyName,
url = tempMentor.companyUrl,
address = ""
lat = null,
lon = null
),
snsUrl = tempMentor.sns,
defaultImgNumber = tempMentor.defaultImgNumber
Expand All @@ -94,7 +96,8 @@ class TempMentorService(
company = CompanyInfoDto(
name = tempMentor.companyName,
url = tempMentor.companyUrl,
address = ""
lat = null,
lon = null
),
snsUrl = tempMentor.sns,
defaultImgNumber = tempMentor.defaultImgNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class SecurityConfig(
Authority.ADMIN.name,
Authority.TEACHER.name
)
.mvcMatchers("/api/v1/mentor/marker").hasAnyRole(
Authority.TEMP_USER.name,
Authority.USER.name,
Authority.ADMIN.name,
Authority.TEACHER.name
)
.mvcMatchers(HttpMethod.POST, "/api/v1/mentor").hasAnyRole(
Authority.UNAUTHENTICATED.name,
Authority.TEMP_USER.name
Expand Down
Loading