Skip to content

Commit

Permalink
M3-129 Fat : 개행 문자 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
tkdals802 committed Jun 26, 2024
1 parent a0b25f1 commit ce40562
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
package com.m3pro.groundflip.controller;import java.util.List;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController;import com.m3pro.groundflip.domain.dto.community.ListResponseCommunity;import com.m3pro.groundflip.domain.dto.community.ResponseGetGroup;import com.m3pro.groundflip.domain.entity.Community;import com.m3pro.groundflip.service.CommunityService;import lombok.RequiredArgsConstructor;@RestController@RequiredArgsConstructorpublic class CommunityController { private final CommunityService communityService; @GetMapping("/api/groups")//그룹 검색 public List<ListResponseCommunity> getCommunitys(@RequestParam String searchKeyword) { return communityService.findCommunityByName(searchKeyword); } @GetMapping("/api/groups/{groupId}")//그룹 정보 api인데 아직 미완성 public ResponseGetGroup findGroupById(@PathVariable Long groupId) { return communityService.findCommunityById(groupId); }}
package com.m3pro.groundflip.controller;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.m3pro.groundflip.domain.dto.community.ListResponseCommunity;
import com.m3pro.groundflip.domain.dto.community.ResponseGetGroup;
import com.m3pro.groundflip.domain.entity.Community;
import com.m3pro.groundflip.service.CommunityService;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
public class CommunityController {
private final CommunityService communityService;

@GetMapping("/api/groups")//그룹 검색
public List<ListResponseCommunity> getCommunitys(@RequestParam String searchKeyword) {
return communityService.findCommunityByName(searchKeyword);
}

@GetMapping("/api/groups/{groupId}")//그룹 정보 api인데 아직 미완성
public ResponseGetGroup findGroupById(@PathVariable Long groupId) {
return communityService.findCommunityById(groupId);
}

}
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
package com.m3pro.groundflip.repository;import java.util.List;import org.springframework.data.jpa.repository.JpaRepository;import org.springframework.data.jpa.repository.Query;import org.springframework.data.repository.query.Param;import com.m3pro.groundflip.domain.entity.Community;public interface CommunityRepository extends JpaRepository<Community, Long> { List<Community> findByNameLike(String name);}
package com.m3pro.groundflip.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.m3pro.groundflip.domain.entity.Community;

public interface CommunityRepository extends JpaRepository<Community, Long> {

List<Community> findByNameLike(String name);
}
35 changes: 34 additions & 1 deletion src/main/java/com/m3pro/groundflip/service/CommunityService.java
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
package com.m3pro.groundflip.service;import java.util.List;import org.springframework.stereotype.Service;import com.m3pro.groundflip.domain.dto.community.ListResponseCommunity;import com.m3pro.groundflip.domain.dto.community.ResponseGetGroup;import com.m3pro.groundflip.domain.entity.Community;import com.m3pro.groundflip.repository.CommunityRepository;import jakarta.transaction.Transactional;import lombok.RequiredArgsConstructor;@Service@RequiredArgsConstructorpublic class CommunityService { private final CommunityRepository communityRepository; //그룹 검색 api public List<ListResponseCommunity> findCommunityByName(String name){ List<Community> community = communityRepository.findByNameLike("%"+name+"%"); return community.stream().map(ListResponseCommunity::from).toList(); } // 그룹 정보 get api인데 일단 검색만 하면 되는걸 깜빡하고 작성해버렸습니다. // 랭킹, 멤버카운트는 더미로 0을 넣어놨습니다. 나중에 계산해서 값을 넣을 수 있을 듯 합니다. public ResponseGetGroup findCommunityById(Long id){ Community community = communityRepository.findById(id) .orElseThrow(() -> new IllegalArgumentException("Community not found")); return ResponseGetGroup.from(community, 0,0); }}
package com.m3pro.groundflip.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.m3pro.groundflip.domain.dto.community.ListResponseCommunity;
import com.m3pro.groundflip.domain.dto.community.ResponseGetGroup;
import com.m3pro.groundflip.domain.entity.Community;
import com.m3pro.groundflip.repository.CommunityRepository;

import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class CommunityService {

private final CommunityRepository communityRepository;

//그룹 검색 api
public List<ListResponseCommunity> findCommunityByName(String name){
List<Community> community = communityRepository.findByNameLike("%"+name+"%");
return community.stream().map(ListResponseCommunity::from).toList();
}

// 그룹 정보 get api인데 일단 검색만 하면 되는걸 깜빡하고 작성해버렸습니다.
// 랭킹, 멤버카운트는 더미로 0을 넣어놨습니다. 나중에 계산해서 값을 넣을 수 있을 듯 합니다.
public ResponseGetGroup findCommunityById(Long id){
Community community = communityRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("Community not found"));
return ResponseGetGroup.from(community, 0,0);
}
}

0 comments on commit ce40562

Please sign in to comment.