Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#969
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyCh0 committed May 15, 2024
2 parents c752ca4 + a5bf7c3 commit 8ad0d77
Show file tree
Hide file tree
Showing 80 changed files with 1,016 additions and 282 deletions.
4 changes: 2 additions & 2 deletions android/festago/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId = "com.festago.festago"
minSdk = 28
targetSdk = 34
versionCode = 11
versionName = "2.0.2"
versionCode = 12
versionName = "2.0.3"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class FestivalListFragment : Fragment() {
val schoolRegions = SchoolRegion.values().map {
SchoolRegionUiState(it, it == this.schoolRegion)
}
val dialog = createRegionDialog(schoolRegions)

return mutableListOf<Any>().apply {
if (popularFestivalUiState.festivals.isNotEmpty()) {
Expand All @@ -172,10 +171,7 @@ class FestivalListFragment : Fragment() {
selectedRegion = schoolRegion,
onFilterSelected = { vm.loadFestivals(it, schoolRegion) },
) {
dialog.show(
parentFragmentManager,
RegionBottomSheetDialogFragment::class.java.name,
)
createRegionDialog(schoolRegions).show(parentFragmentManager, tag)
},
)
addAll(festivals)
Expand All @@ -201,17 +197,16 @@ class FestivalListFragment : Fragment() {

private fun FestivalListUiState.Success.createRegionDialog(
schoolRegions: List<SchoolRegionUiState>,
) = RegionBottomSheetDialogFragment.newInstance(
items = schoolRegions,
listener = object : RegionBottomSheetDialogFragment.OnRegionSelectListener {
override fun onRegionSelect(region: SchoolRegion) {
vm.loadFestivals(
festivalFilterUiState = festivalFilter,
schoolRegion = if (region == schoolRegion) null else region,
)
): RegionBottomSheetDialogFragment {
return RegionBottomSheetDialogFragment().apply {
items = schoolRegions
listener = object : RegionBottomSheetDialogFragment.OnRegionSelectListener {
override fun onRegionSelect(region: SchoolRegion) {
vm.loadFestivals(festivalFilter, region)
}
}
},
)
}
}

private fun showSearch() {
findNavController().navigate(actionFestivalListFragmentToSearchFragment())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,38 @@ import com.festago.festago.domain.model.festival.SchoolRegion
import com.festago.festago.presentation.databinding.FragmentRegionBottomSheetBinding
import com.festago.festago.presentation.ui.home.festivallist.uistate.SchoolRegionUiState
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class RegionBottomSheetDialogFragment() : BottomSheetDialogFragment() {

private var _binding: FragmentRegionBottomSheetBinding? = null
private val binding: FragmentRegionBottomSheetBinding get() = _binding!!

private lateinit var listener: OnRegionSelectListener
private lateinit var items: List<SchoolRegionUiState>
var items: List<SchoolRegionUiState>? = null
var listener: OnRegionSelectListener? = null

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
super.onCreateView(inflater, container, savedInstanceState)
_binding = FragmentRegionBottomSheetBinding.inflate(inflater)
binding.lifecycleOwner = viewLifecycleOwner
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initView()
}

private fun initView() {
val schoolRegions = items ?: return
val onRegionSelectListener = listener ?: return

binding.rvRegionList.adapter = RegionAdapter(
items = items,
onRegionSelect = listener::onRegionSelect
items = schoolRegions,
onRegionSelect = onRegionSelectListener::onRegionSelect,
) { dismiss() }
}

Expand All @@ -48,14 +51,4 @@ class RegionBottomSheetDialogFragment() : BottomSheetDialogFragment() {
interface OnRegionSelectListener {
fun onRegionSelect(region: SchoolRegion)
}

companion object {
fun newInstance(
items: List<SchoolRegionUiState>,
listener: OnRegionSelectListener,
): RegionBottomSheetDialogFragment = RegionBottomSheetDialogFragment().apply {
this.listener = listener
this.items = items
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.festago.admin.dto.artist;

import com.festago.artist.dto.command.ArtistCreateCommand;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotBlank;

public record ArtistV1CreateRequest(
@NotBlank
String name,
@NotBlank
@Nullable
String profileImageUrl,
@NotBlank
@Nullable
String backgroundImageUrl
) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.festago.admin.dto.artist;

import com.festago.artist.dto.command.ArtistUpdateCommand;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotBlank;

public record ArtistV1UpdateRequest(
@NotBlank
String name,
@NotBlank
@Nullable
String profileImageUrl,
@NotBlank
@Nullable
String backgroundImageUrl
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.festago.socialmedia.domain.OwnerType;
import com.festago.socialmedia.domain.SocialMediaType;
import com.festago.socialmedia.dto.command.SocialMediaCreateCommand;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
Expand All @@ -17,7 +18,7 @@ public record SocialMediaCreateV1Request(
SocialMediaType socialMediaType,
@NotBlank
String name,
@NotBlank
@Nullable
String logoUrl,
@NotBlank
String url
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.festago.admin.dto.socialmedia;

import com.festago.socialmedia.dto.command.SocialMediaUpdateCommand;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotBlank;
import lombok.Builder;

@Builder
public record SocialMediaUpdateV1Request(
@NotBlank
String name,
@NotBlank
@Nullable
String logoUrl,
@NotBlank
String url
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.festago.artist.application;

import com.festago.artist.dto.ArtistDetailV1Response;
import com.festago.artist.dto.ArtistFestivalDetailV1Response;
import com.festago.artist.dto.ArtistFestivalV1Response;
import com.festago.artist.repository.ArtistDetailV1QueryDslRepository;
import com.festago.artist.repository.ArtistFestivalSearchCondition;
import com.festago.common.exception.ErrorCode;
Expand All @@ -27,9 +27,9 @@ public ArtistDetailV1Response findArtistDetail(Long artistId) {
.orElseThrow(() -> new NotFoundException(ErrorCode.ARTIST_NOT_FOUND));
}

public Slice<ArtistFestivalDetailV1Response> findArtistFestivals(Long artistId, Long lastFestivalId,
LocalDate lastStartDate, boolean isPast,
Pageable pageable) {
public Slice<ArtistFestivalV1Response> findArtistFestivals(Long artistId, Long lastFestivalId,
LocalDate lastStartDate, boolean isPast,
Pageable pageable) {
return artistDetailV1QueryDslRepository.findArtistFestivals(new ArtistFestivalSearchCondition(
artistId,
isPast,
Expand Down
18 changes: 10 additions & 8 deletions backend/src/main/java/com/festago/artist/domain/Artist.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.festago.artist.domain;

import com.festago.common.domain.BaseTimeEntity;
import com.festago.common.util.ImageUrlHelper;
import com.festago.common.util.Validator;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand All @@ -13,8 +15,6 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Artist extends BaseTimeEntity {

private static final String DEFAULT_URL = "https://picsum.photos/536/354";

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand All @@ -27,24 +27,26 @@ public class Artist extends BaseTimeEntity {
private String backgroundImageUrl;

public Artist(Long id, String name, String profileImage, String backgroundImageUrl) {
validateName(name);
this.id = id;
this.name = name;
this.profileImage = profileImage;
this.backgroundImageUrl = backgroundImageUrl;
this.profileImage = ImageUrlHelper.getBlankStringIfBlank(profileImage);
this.backgroundImageUrl = ImageUrlHelper.getBlankStringIfBlank(backgroundImageUrl);
}

public Artist(String name, String profileImage) {
this(null, name, profileImage, DEFAULT_URL);
private void validateName(String name) {
Validator.notBlank(name, "name");
}

public Artist(String name, String profileImage, String backgroundImageUrl) {
this(null, name, profileImage, backgroundImageUrl);
}

public void update(String name, String profileImage, String backgroundImageUrl) {
validateName(name);
this.name = name;
this.profileImage = profileImage;
this.backgroundImageUrl = backgroundImageUrl;
this.profileImage = ImageUrlHelper.getBlankStringIfBlank(profileImage);
this.backgroundImageUrl = ImageUrlHelper.getBlankStringIfBlank(backgroundImageUrl);
}

public Long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDate;

public record ArtistFestivalDetailV1Response(
public record ArtistFestivalV1Response(
Long id,
String name,
LocalDate startDate,
Expand All @@ -19,7 +19,7 @@ public record ArtistFestivalDetailV1Response(
) {

@QueryProjection
public ArtistFestivalDetailV1Response {
public ArtistFestivalV1Response {

}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.festago.artist.dto;

import com.festago.socialmedia.domain.SocialMediaType;
import com.querydsl.core.annotations.QueryProjection;

public record ArtistMediaV1Response(
String type,
SocialMediaType type,
String name,
String logoUrl,
String url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

@RestController
@RequestMapping("/api/v1/search/artists")
@Tag(name = "์•„ํ‹ฐ์ŠคํŠธ ๊ฒ€์ƒ‰ V1")
@Tag(name = "์•„ํ‹ฐ์ŠคํŠธ ๊ฒ€์ƒ‰ ์š”์ฒญ V1")
@RequiredArgsConstructor
public class ArtistSearchV1Controller {

private final ArtistTotalSearchV1Service artistTotalSearchV1Service;

@GetMapping
@Operation(description = "ํ‚ค์›Œ๋“œ๋กœ ์•„ํ‹ฐ์ŠคํŠธ ๋ชฉ๋ก์„ ๊ฒ€์ƒ‰ํ•œ๋‹ค", summary = "์•„ํ‹ฐ์ŠคํŠธ ๋ชฉ๋ก ๊ฒ€์ƒ‰ ์กฐํšŒ")
@Operation(description = "ํ‚ค์›Œ๋“œ๋กœ ์•„ํ‹ฐ์ŠคํŠธ ๋ชฉ๋ก์„ ๊ฒ€์ƒ‰ํ•œ๋‹ค.", summary = "์•„ํ‹ฐ์ŠคํŠธ ๊ฒ€์ƒ‰")
public ResponseEntity<List<ArtistTotalSearchV1Response>> searchByKeyword(@RequestParam String keyword) {
Validator.notBlank(keyword, "keyword");
List<ArtistTotalSearchV1Response> response = artistTotalSearchV1Service.findAllByKeyword(keyword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import com.festago.artist.application.ArtistDetailV1QueryService;
import com.festago.artist.dto.ArtistDetailV1Response;
import com.festago.artist.dto.ArtistFestivalDetailV1Response;
import com.festago.artist.dto.ArtistFestivalV1Response;
import com.festago.common.aop.ValidPageable;
import com.festago.common.dto.SliceResponse;
import com.festago.common.exception.ValidException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.LocalDate;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -24,29 +24,29 @@
@RequestMapping("/api/v1/artists")
@Tag(name = "์•„ํ‹ฐ์ŠคํŠธ ์ •๋ณด ์š”์ฒญ V1")
@RequiredArgsConstructor
public class ArtistDetailV1Controller {
public class ArtistV1Controller {

private final ArtistDetailV1QueryService artistDetailV1QueryService;

@GetMapping("/{artistId}")
@Operation(description = "์•„ํ‹ฐ์ŠคํŠธ์˜ ์ •๋ณด๋ฅผ ์กฐํšŒํ•œ๋‹ค.")
public ResponseEntity<ArtistDetailV1Response> getArtistInfo(@PathVariable Long artistId) {
@Operation(description = "์•„ํ‹ฐ์ŠคํŠธ์˜ ์ •๋ณด๋ฅผ ์กฐํšŒํ•œ๋‹ค.", summary = "์•„ํ‹ฐ์ŠคํŠธ ์ •๋ณด ์กฐํšŒ")
public ResponseEntity<ArtistDetailV1Response> findArtistDetail(@PathVariable Long artistId) {
return ResponseEntity.ok(artistDetailV1QueryService.findArtistDetail(artistId));
}

@GetMapping("/{artistId}/festivals")
@Operation(description = "์•„ํ‹ฐ์ŠคํŠธ๊ฐ€ ์ฐธ์„ํ•œ ์ถ•์ œ๋ฅผ ์กฐํšŒํ•œ๋‹ค. isPast ๊ฐ’์œผ๋กœ ์ข…๋ฃŒ ์ถ•์ œ ์™€ ์ง„ํ–‰, ์˜ˆ์ • ์ถ•์ œ๋ฅผ ๊ตฌ๋ถ„ ๊ฐ€๋Šฅํ•˜๋‹ค", summary = "์•„ํ‹ฐ์ŠคํŠธ ์ถ•์ œ ์กฐํšŒ")
@Operation(description = "์•„ํ‹ฐ์ŠคํŠธ๊ฐ€ ์ฐธ์—ฌํ•œ ์ถ•์ œ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. isPast ๊ฐ’์œผ๋กœ ์ข…๋ฃŒ ์ถ•์ œ์™€ ์ง„ํ–‰, ์˜ˆ์ • ์ถ•์ œ๋ฅผ ๊ตฌ๋ถ„ ๊ฐ€๋Šฅํ•˜๋‹ค.", summary = "์•„ํ‹ฐ์ŠคํŠธ ์ฐธ์—ฌ ์ถ•์ œ ๋ชฉ๋ก ์กฐํšŒ")
@ValidPageable(maxSize = 20)
public ResponseEntity<SliceResponse<ArtistFestivalDetailV1Response>> getArtistInfo(
public ResponseEntity<SliceResponse<ArtistFestivalV1Response>> findArtistFestivals(
@PathVariable Long artistId,
@RequestParam(required = false) Long lastFestivalId,
@RequestParam(required = false) LocalDate lastStartDate,
@RequestParam(required = false, defaultValue = "false") boolean isPast,
@PageableDefault(size = 10) Pageable pageable
@Parameter(description = "0 < size <= 20") @RequestParam(defaultValue = "10") int size
) {
validate(lastFestivalId, lastStartDate);
Slice<ArtistFestivalDetailV1Response> response = artistDetailV1QueryService.findArtistFestivals(artistId,
lastFestivalId, lastStartDate, isPast, pageable);
Slice<ArtistFestivalV1Response> response = artistDetailV1QueryService.findArtistFestivals(artistId,
lastFestivalId, lastStartDate, isPast, PageRequest.ofSize(size));
return ResponseEntity.ok(SliceResponse.from(response));
}

Expand Down
Loading

0 comments on commit 8ad0d77

Please sign in to comment.