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

음악신청 조회시 자신이 좋아요 눌렀는지 유무 확인 #436

Merged
merged 46 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fe7a54d
add :: NotValidMusicLikeException
ta2ye0n Sep 11, 2024
c5fd30f
create :: Like
ta2ye0n Sep 11, 2024
0a5fb23
create :: LikeRepository
ta2ye0n Sep 11, 2024
4fea780
add :: PostMusicLikeService
ta2ye0n Sep 11, 2024
83f3be8
add :: DeleteMusicLikeService
ta2ye0n Sep 11, 2024
5bda02b
add :: 좋아요, 좋아요 취소 controller에 추가
ta2ye0n Sep 11, 2024
24dff65
refactor :: music 엔티티 내 함수로 처리
ta2ye0n Sep 11, 2024
bcafe3d
add :: validDayOfWeek
ta2ye0n Sep 11, 2024
d1cf727
add :: ToggleMusicLikeService
ta2ye0n Sep 12, 2024
1841588
update :: 동시성 제어
ta2ye0n Sep 12, 2024
7ab700f
add :: 컨트롤러 추가
ta2ye0n Sep 12, 2024
11696e3
Update src/main/kotlin/com/dotori/v2/domain/music/service/impl/Toggle…
ta2ye0n Sep 12, 2024
ffbbd39
Update src/main/kotlin/com/dotori/v2/global/error/ErrorCode.kt
ta2ye0n Sep 12, 2024
945b2a1
Update src/main/kotlin/com/dotori/v2/domain/music/exception/NotValidM…
ta2ye0n Sep 12, 2024
1c1a8f6
refactor :: Type 삭제
ta2ye0n Sep 12, 2024
48d14de
update :: 객체 -> 아이디
ta2ye0n Sep 12, 2024
a1c7097
Merge remote-tracking branch 'origin/413-music-like-cancel-function' …
ta2ye0n Sep 12, 2024
29e5c10
refactor :: updateLike 추가
ta2ye0n Sep 12, 2024
82d469b
refactor :: imageUpload refactor
yena5511 Sep 12, 2024
1865cd2
Merge pull request #423 from Team-Ampersand/413-music-like-cancel-fun…
ta2ye0n Sep 15, 2024
6f8a6dc
Merge pull request #424 from Team-Ampersand/refactor/member
yena5511 Sep 15, 2024
142ccc4
create :: ToggleMusicResDto
ta2ye0n Sep 17, 2024
17f9d93
update :: 반환 값 추가
ta2ye0n Sep 17, 2024
0413e09
update :: 컨트롤러 수정
ta2ye0n Sep 17, 2024
bdb0da6
add :: music field
esperar Sep 17, 2024
ce0b681
충돌 해결
esperar Sep 17, 2024
504fb25
create :: music rank query service
esperar Sep 17, 2024
e93555a
add :: music rank query api
esperar Sep 17, 2024
8565fe9
update :: rank 조회 쿼리 수정
esperar Sep 17, 2024
824c471
add :: music response like count value
esperar Sep 17, 2024
d7d0a91
refactor :: 패키지 구조 이동 및 이름 수정
ta2ye0n Sep 17, 2024
927abcb
update :: ToggleMusicResDto -> MusicLikeCountResDto
ta2ye0n Sep 17, 2024
69f37de
Merge pull request #427 from Team-Ampersand/426-return-the-current-nu…
ta2ye0n Sep 17, 2024
a14199d
update :: 접근제어자 삭제
ta2ye0n Sep 18, 2024
022f59d
Merge branch 'develop' into 415-feat/music-rank-query
esperar Sep 18, 2024
e592561
Merge pull request #430 from Team-Ampersand/429-not-return-the-curren…
ta2ye0n Sep 18, 2024
46d18b5
Merge branch 'develop' of https://github.com/Team-Ampersand/Dotori-se…
esperar Sep 18, 2024
70327e2
Merge pull request #428 from Team-Ampersand/415-feat/music-rank-query
esperar Sep 19, 2024
3b48f8e
update :: 반환값 변경
ta2ye0n Sep 19, 2024
7015786
add :: memberLikeCheck
ta2ye0n Sep 19, 2024
4c2220f
Merge pull request #432 from Team-Ampersand/431-add-music-like-check
ta2ye0n Sep 19, 2024
4884233
update :: find music rank desc
esperar Sep 20, 2024
009a0f7
Merge pull request #434 from Team-Ampersand/433-feat/music-desc
esperar Sep 20, 2024
f0a502c
add :: memberLikeCheck
ta2ye0n Sep 23, 2024
9ba1cd2
add :: deleteFromCacheMusic
ta2ye0n Sep 23, 2024
02db7ac
update :: exists 쿼리로 변경
ta2ye0n Sep 23, 2024
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
@@ -1,7 +1,9 @@
package com.dotori.v2.domain.member.domain.entity

import com.dotori.v2.domain.member.domain.entity.QMember.member
import com.dotori.v2.domain.member.enums.*
import com.dotori.v2.domain.rule.domain.entity.RuleViolation
import com.dotori.v2.global.thirdparty.aws.s3.S3Service
import com.dotori.v2.domain.student.presentation.data.req.ModifyStudentInfoRequest
import com.dotori.v2.global.entity.BaseTimeEntity
import java.time.LocalDateTime
Expand Down Expand Up @@ -102,10 +104,6 @@ class Member(
this.selfStudyExpiredDate = localDateTime
}

fun updateProfileImage(profileImage: String?) {
this.profileImage = profileImage
}

fun graduate(period: String): Member {
this.stuNum = period
return this
Expand All @@ -117,4 +115,15 @@ class Member(
this.gender = request.gender
this.roles = Collections.singletonList(request.role)
}

fun updateProfileImage(profileImage: String?): Member {
this.profileImage = profileImage
return this
}

fun isProfileImageExists(): Boolean {
return !this.profileImage.isNullOrEmpty()
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ class UpdateProfileImageServiceImpl(
): UpdateProfileImageService {
override fun execute(multipartFiles: MultipartFile?) {
val member: Member = userUtil.fetchCurrentUser()
profileImageService.imageUpload(member = member, multipartFiles = multipartFiles, isUpdate = true)
profileImageService.imageUpload(member = member, multipartFiles = multipartFiles)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@ class Music(
val thumbnail: String,

@Column(name = "like_count", nullable = false, columnDefinition = "INT default 0")
val likeCount: Int = 0,
var likeCount: Int = 0,

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
val member: Member
) : BaseTimeEntity()
) : BaseTimeEntity() {

fun plusLikeCount() {
this.likeCount++
}

fun minusLikeCount() {
this.likeCount--
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.dotori.v2.domain.music.domain.entity

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.Table

@Entity
@Table(name = "likes")
class MusicLike (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "like_id")
val id: Long = 0,

@Column(name = "music_id", nullable = false)
val musicId: Long,

@Column(name = "member_id", nullable = false)
val memberId: Long,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.dotori.v2.domain.music.domain.repository

import com.dotori.v2.domain.music.domain.entity.MusicLike
import feign.Param
import javax.persistence.LockModeType
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Lock
import org.springframework.data.jpa.repository.Query

interface MusicLikeRepository : JpaRepository<MusicLike, Long> {
@Lock(LockModeType.PESSIMISTIC_WRITE)
@Query("select l from MusicLike l where l.memberId = :memberId and l.musicId = :musicId")
fun findByMemberIdAndMusicId(@Param("memberId") memberId: Long, @Param("musicId") musicId: Long): MusicLike?
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import java.time.LocalDate
import java.time.LocalDateTime

interface MusicRepository : JpaRepository<Music, Long> {

@Modifying
@Query("update member set member_music = 'CAN'", nativeQuery = true)
fun updateMusicStatusMemberByMember()
Expand All @@ -18,4 +19,7 @@ interface MusicRepository : JpaRepository<Music, Long> {

fun deleteAllByCreatedDateBefore(date: LocalDateTime)

@Query(value = "select * from music where created_date like :date% order by music.like_count desc", nativeQuery = true)
fun findAllByCreatedDateOrderByLikeCountDESC(@Param("date") date: LocalDate): List<Music>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.dotori.v2.domain.music.exception

import com.dotori.v2.global.error.ErrorCode
import com.dotori.v2.global.error.exception.BasicException

class NotValidMusicLikeException : BasicException(ErrorCode.NOT_VALID_MUSIC_LIKE) {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.dotori.v2.domain.music.presentation.admin

import com.dotori.v2.domain.music.presentation.data.res.MusicListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicRankListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicLikeCountResDto
import com.dotori.v2.domain.music.service.DeleteMusicService
import com.dotori.v2.domain.music.service.FindMusicRankService
import com.dotori.v2.domain.music.service.FindMusicsService
import com.dotori.v2.domain.music.service.ToggleMusicLikeService
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -13,8 +17,11 @@ import java.time.LocalDate
@RequestMapping("/v2/admin/music")
class AdminMusicController(
private val findMusicsService: FindMusicsService,
private val deleteMusicService: DeleteMusicService
private val deleteMusicService: DeleteMusicService,
private val toggleMusicLikeService: ToggleMusicLikeService,
private val findMusicRankService: FindMusicRankService
) {

@GetMapping
fun findMusics(
@RequestParam(
Expand All @@ -29,4 +36,16 @@ class AdminMusicController(
deleteMusicService.execute(musicId)
.run { ResponseEntity.status(HttpStatus.NO_CONTENT).build() }

@PatchMapping("/{music_id}/like")
fun toggleMusicLike(@PathVariable("music_id") musicId: Long): ResponseEntity<MusicLikeCountResDto> =
ResponseEntity.status(HttpStatus.OK).body(toggleMusicLikeService.execute(musicId))

@GetMapping("/like")
fun findMusicRank(
@RequestParam(
value = "date",
required = true
) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) date: LocalDate
): ResponseEntity<MusicRankListResDto> =
ResponseEntity.status(HttpStatus.OK).body(findMusicRankService.execute(date))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package com.dotori.v2.domain.music.presentation.councillor

import com.dotori.v2.domain.music.presentation.data.req.ApplyMusicReqDto
import com.dotori.v2.domain.music.presentation.data.res.MusicListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicRankListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicLikeCountResDto
import com.dotori.v2.domain.music.service.ApplyMusicService
import com.dotori.v2.domain.music.service.DeleteMusicService
import com.dotori.v2.domain.music.service.FindMusicRankService
import com.dotori.v2.domain.music.service.FindMusicsService
import com.dotori.v2.domain.music.service.ToggleMusicLikeService
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -17,7 +21,9 @@ import java.time.LocalDateTime
class CouncillorMusicController(
private val applyMusicService: ApplyMusicService,
private val findMusicsService: FindMusicsService,
private val deleteMusicService: DeleteMusicService
private val deleteMusicService: DeleteMusicService,
private val toggleMusicLikeService: ToggleMusicLikeService,
private val findMusicRankService: FindMusicRankService
) {
@PostMapping
fun applyMusic(@RequestBody applyMusicReqDto: ApplyMusicReqDto): ResponseEntity<Void> =
Expand All @@ -37,4 +43,17 @@ class CouncillorMusicController(
fun deleteMusic(@PathVariable("music_id") musicId: Long): ResponseEntity<Void> =
deleteMusicService.execute(musicId)
.run { ResponseEntity.status(HttpStatus.NO_CONTENT).build() }

@PatchMapping("/{music_id}/like")
fun toggleMusicLike(@PathVariable("music_id") musicId: Long): ResponseEntity<MusicLikeCountResDto> =
ResponseEntity.status(HttpStatus.OK).body(toggleMusicLikeService.execute(musicId))

@GetMapping("/like")
fun findMusicRank(
@RequestParam(
value = "date",
required = true
) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) date: LocalDate
): ResponseEntity<MusicRankListResDto> =
ResponseEntity.status(HttpStatus.OK).body(findMusicRankService.execute(date))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dotori.v2.domain.music.presentation.data.res

data class MusicLikeCountResDto(
val likeCount: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.dotori.v2.domain.music.presentation.data.res

data class MusicRankListResDto(
val content: List<MusicRankResDto>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.dotori.v2.domain.music.presentation.data.res

import java.time.LocalDateTime

data class MusicRankResDto(
val id: Long,
val rank: Int,
val url: String,
val title: String,
val thumbnail: String,
val username: String,
val email: String,
val createdTime: LocalDateTime,
val stuNum: String,
val likeCount: Int,
val memberLikeCheck: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ data class MusicResDto(
val username: String,
val email: String,
val createdTime: LocalDateTime,
val stuNum: String
val stuNum: String,
val likeCount: Int,
val memberLikeCheck: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package com.dotori.v2.domain.music.presentation.developer

import com.dotori.v2.domain.music.presentation.data.req.ApplyMusicReqDto
import com.dotori.v2.domain.music.presentation.data.res.MusicListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicRankListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicLikeCountResDto
import com.dotori.v2.domain.music.service.ApplyMusicService
import com.dotori.v2.domain.music.service.DeleteMusicService
import com.dotori.v2.domain.music.service.FindMusicRankService
import com.dotori.v2.domain.music.service.FindMusicsService
import com.dotori.v2.domain.music.service.ToggleMusicLikeService
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -17,7 +21,9 @@ import java.time.LocalDateTime
class DeveloperMusicController(
private val applyMusicService: ApplyMusicService,
private val findMusicsService: FindMusicsService,
private val deleteMusicService: DeleteMusicService
private val deleteMusicService: DeleteMusicService,
private val toggleMusicLikeService: ToggleMusicLikeService,
private val findMusicRankService: FindMusicRankService
) {
@PostMapping
fun applyMusic(@RequestBody applyMusicReqDto: ApplyMusicReqDto): ResponseEntity<Void> =
Expand All @@ -37,4 +43,17 @@ class DeveloperMusicController(
fun deleteMusic(@PathVariable("music_id") musicId: Long): ResponseEntity<Void> =
deleteMusicService.execute(musicId)
.run { ResponseEntity.status(HttpStatus.NO_CONTENT).build() }

@PatchMapping("/{music_id}/like")
fun toggleMusicLike(@PathVariable("music_id") musicId: Long): ResponseEntity<MusicLikeCountResDto> =
ResponseEntity.status(HttpStatus.OK).body(toggleMusicLikeService.execute(musicId))

@GetMapping("/like")
fun findMusicRank(
@RequestParam(
value = "date",
required = true
) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) date: LocalDate
): ResponseEntity<MusicRankListResDto> =
ResponseEntity.status(HttpStatus.OK).body(findMusicRankService.execute(date))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package com.dotori.v2.domain.music.presentation.member

import com.dotori.v2.domain.music.presentation.data.req.ApplyMusicReqDto
import com.dotori.v2.domain.music.presentation.data.res.MusicListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicRankListResDto
import com.dotori.v2.domain.music.presentation.data.res.MusicLikeCountResDto
import com.dotori.v2.domain.music.service.ApplyMusicService
import com.dotori.v2.domain.music.service.DeleteMyMusicService
import com.dotori.v2.domain.music.service.FindMusicRankService
import com.dotori.v2.domain.music.service.FindMusicsService
import com.dotori.v2.domain.music.service.ToggleMusicLikeService
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -17,7 +21,9 @@ import java.time.LocalDateTime
class MemberMusicController(
private val applyMusicService: ApplyMusicService,
private val findMusicsService: FindMusicsService,
private val deleteMyMusicService: DeleteMyMusicService
private val deleteMyMusicService: DeleteMyMusicService,
private val toggleMusicLikeService: ToggleMusicLikeService,
private val findMusicRankService: FindMusicRankService
) {
@PostMapping
fun applyMusic(@RequestBody applyMusicReqDto: ApplyMusicReqDto): ResponseEntity<Void> =
Expand All @@ -37,4 +43,17 @@ class MemberMusicController(
fun deleteMusic(@PathVariable("music_id") musicId: Long): ResponseEntity<Void> =
deleteMyMusicService.execute(musicId)
.run { ResponseEntity.status(HttpStatus.NO_CONTENT).build() }
}

@PatchMapping("/{music_id}/like")
fun toggleMusicLike(@PathVariable("music_id") musicId: Long): ResponseEntity<MusicLikeCountResDto> =
ResponseEntity.status(HttpStatus.OK).body(toggleMusicLikeService.execute(musicId))

@GetMapping("/like")
fun findMusicRank(
@RequestParam(
value = "date",
required = true
) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) date: LocalDate
): ResponseEntity<MusicRankListResDto> =
ResponseEntity.status(HttpStatus.OK).body(findMusicRankService.execute(date))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.dotori.v2.domain.music.service

import com.dotori.v2.domain.music.presentation.data.res.MusicRankListResDto
import java.time.LocalDate

interface FindMusicRankService {
fun execute(date: LocalDate): MusicRankListResDto
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.dotori.v2.domain.music.service

import com.dotori.v2.domain.music.presentation.data.res.MusicLikeCountResDto

interface ToggleMusicLikeService {
fun execute(musicId: Long) : MusicLikeCountResDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class ApplyMusicServiceImpl(
username = music.member.memberName,
email = music.member.email,
createdTime = music.createdDate,
stuNum = music.member.stuNum
stuNum = music.member.stuNum,
likeCount = music.likeCount,
memberLikeCheck = false
)

private fun validDayOfWeek(dayOfWeek: DayOfWeek) {
Expand Down
Loading
Loading