Skip to content

Commit

Permalink
Merge pull request #40 from LIKELION-TEAM4-HACKATHON/feature/login
Browse files Browse the repository at this point in the history
전체 문화 조회 기능 추가함 + DB 테이블명 단수 변경
  • Loading branch information
chaeyoungeee authored Jul 24, 2024
2 parents 5e12524 + 0ac3b93 commit 355a838
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package likelion.MZConnent.api.culture;

import likelion.MZConnent.dto.culture.CultureCategoryResponse;
import likelion.MZConnent.service.culture.CultureCategoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequiredArgsConstructor
public class CultureController {
private final CultureCategoryService cultureCategoryService;

// 전체 문화 카테고리 조회
@GetMapping("/api/categories/culture")
public CultureCategoryResponse getAllCultureCategories() {
CultureCategoryResponse all = cultureCategoryService.getAllCultureCategories();
log.info("전체 문화 카테고리: {}", all.getCultureCategories());
return all;
}
}
7 changes: 4 additions & 3 deletions src/main/java/likelion/MZConnent/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public class SecurityConfig {
//권한별 url
private final String[] adminUrl = {"/admin/**"};
private final String[] permitAllUrl = {"/error",
"/api/auth/login",
"/api/auth/logout",
"/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", "/api-docs/**", "/v3/api-docs/**", "/test" };
"/api/auth/login", "/api/auth/logout", // 회원
"/api/categories/culture", // 문화
"/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", "/api-docs/**", "/v3/api-docs/**", //swagger
};
private final String[] anonymousUrl = {
"/api/auth/signup"
};
Expand Down
1 change: 0 additions & 1 deletion src/main/java/likelion/MZConnent/domain/chat/Chat.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@Entity
@Getter
@NoArgsConstructor
@Table(name = "chats")
public class Chat {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
1 change: 0 additions & 1 deletion src/main/java/likelion/MZConnent/domain/club/Club.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.List;

@Entity
@Table(name="clubs")
@Getter
@NoArgsConstructor
public class Club {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@Entity
@Getter
@NoArgsConstructor
@Table(name = "club_member")
public class ClubMember {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@Entity
@NoArgsConstructor
@Getter
@Table(name = "region_categories")
public class RegionCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@Entity
@Getter
@NoArgsConstructor
@Table(name = "cultures")
public class Culture {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@Entity
@Getter
@NoArgsConstructor
@Table(name = "culture_categories")
public class CultureCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@Entity
@Getter
@NoArgsConstructor
@Table(name = "culture_interests")
public class CultureInterest {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
1 change: 0 additions & 1 deletion src/main/java/likelion/MZConnent/domain/manner/Manner.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
@Entity
@Getter
@NoArgsConstructor
@Table(name = "manners")
public class Manner {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@Entity
@Getter
@NoArgsConstructor
@Table(name = "self_introductions")
public class SelfIntroduction {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package likelion.MZConnent.dto.culture;

import likelion.MZConnent.domain.culture.CultureCategory;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class CultureCategoryResponse {
List<CultureCategoryDto> cultureCategories = new ArrayList<>();

public CultureCategoryResponse(List<CultureCategory> cultureCategory) {
this.cultureCategories = cultureCategory.stream()
.map(CultureCategoryDto::new)
.collect(Collectors.toList());
}

@Getter
private static class CultureCategoryDto {
private Long cultureCategoryId;
private String name;

public CultureCategoryDto(CultureCategory cultureCategory) {
this.cultureCategoryId = cultureCategory.getId();
this.name = getName();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;


@Repository
public interface CultureCategoryRepository extends JpaRepository<CultureCategory, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
public interface MemberRepository extends JpaRepository<Member, Long> {
Optional<Member> findByEmail(String email);
boolean existsByEmail(String email);

boolean existsByUsername(String username);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package likelion.MZConnent.service.culture;


import likelion.MZConnent.domain.culture.CultureCategory;
import likelion.MZConnent.dto.culture.CultureCategoryResponse;
import likelion.MZConnent.repository.culture.CultureCategoryRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

@Service
@Transactional
@RequiredArgsConstructor
@Slf4j
public class CultureCategoryService {
private final CultureCategoryRepository cultureCategoryRepository;

public CultureCategoryResponse getAllCultureCategories() {
List<CultureCategory> cultureCategories = cultureCategoryRepository.findAll();
log.info("cultureCategories: {}", cultureCategories);
return new CultureCategoryResponse(cultureCategories);
}
}

0 comments on commit 355a838

Please sign in to comment.