diff --git a/module-admin/src/main/java/com/kernel360/member/code/MemberBusinessCode.java b/module-admin/src/main/java/com/kernel360/member/code/MemberBusinessCode.java new file mode 100644 index 00000000..10cf42c2 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/code/MemberBusinessCode.java @@ -0,0 +1,30 @@ +package com.kernel360.member.code; + +import com.kernel360.code.BusinessCode; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; + +@RequiredArgsConstructor +public enum MemberBusinessCode implements BusinessCode { + + SUCCESS_REQUEST_ALL_MEMBER_LIST(HttpStatus.OK.value(), "BMC001", "전체회원목록 조회 성공"); + + private final int status; + private final String code; + private final String message; + + @Override + public int getStatus() { + return status; + } + + @Override + public String getCode() { + return code; + } + + @Override + public String getMessage() { + return message; + } +} diff --git a/module-admin/src/main/java/com/kernel360/member/controller/MemberController.java b/module-admin/src/main/java/com/kernel360/member/controller/MemberController.java new file mode 100644 index 00000000..63b837de --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/controller/MemberController.java @@ -0,0 +1,26 @@ +package com.kernel360.member.controller; + +import com.kernel360.member.code.MemberBusinessCode; +import com.kernel360.member.dto.MemberResponse; +import com.kernel360.member.service.MemberService; +import com.kernel360.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/admin") +public class MemberController { + + private final MemberService memberService; + + @GetMapping("members") + public ResponseEntity>> getMemberList(Pageable pageable) { + Page members = memberService.getAllMembers(pageable); + + return ApiResponse.toResponseEntity(MemberBusinessCode.SUCCESS_REQUEST_ALL_MEMBER_LIST, members); + } +} diff --git a/module-admin/src/main/java/com/kernel360/member/dto/MemberDto.java b/module-admin/src/main/java/com/kernel360/member/dto/MemberDto.java new file mode 100644 index 00000000..f003ca58 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/dto/MemberDto.java @@ -0,0 +1,46 @@ +package com.kernel360.member.dto; + + +import java.time.LocalDateTime; + + +public record MemberDto(Long memberNo, + String id, + String email, + String password, + String gender, + String age, + LocalDateTime createdAt, + String createdBy, + LocalDateTime modifiedAt, + String modifiedBy +) { + + public static MemberDto of( + Long memberNo, + String id, + String email, + String password, + String gender, + String age, + LocalDateTime createdAt, + String createdBy, + LocalDateTime modifiedAt, + String modifiedBy + ) { + return new MemberDto( + memberNo, + id, + email, + password, + gender, + age, + createdAt, + createdBy, + modifiedAt, + modifiedBy + ); + } + + +} \ No newline at end of file diff --git a/module-admin/src/main/java/com/kernel360/member/dto/MemberResponse.java b/module-admin/src/main/java/com/kernel360/member/dto/MemberResponse.java new file mode 100644 index 00000000..3eba9363 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/dto/MemberResponse.java @@ -0,0 +1,38 @@ +package com.kernel360.member.dto; + + +import com.kernel360.carinfo.entity.CarInfo; +import com.kernel360.washinfo.entity.WashInfo; +import com.querydsl.core.annotations.QueryProjection; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor +public class MemberResponse { + private Long memberNo; + private String id; + private String email; + private int gender; + private int age; + private LocalDateTime registerDate; + private String accountType; + private WashInfo washInfo; + private CarInfo carInfo; + @QueryProjection + public MemberResponse(Long memberNo, String id, String email, int gender, int age, LocalDateTime registerDate, + String accountType, WashInfo washInfo, CarInfo carInfo) { + this.memberNo = memberNo; + this.id = id; + this.email = email; + this.gender = gender; + this.age = age; + this.registerDate = registerDate; + this.accountType = accountType; + this.washInfo = washInfo; + this.carInfo = carInfo; + } + +} diff --git a/module-admin/src/main/java/com/kernel360/member/dto/MemberSearchDto.java b/module-admin/src/main/java/com/kernel360/member/dto/MemberSearchDto.java new file mode 100644 index 00000000..5c3c78d5 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/dto/MemberSearchDto.java @@ -0,0 +1,19 @@ +package com.kernel360.member.dto; + +import com.kernel360.carinfo.entity.CarInfo; +import com.kernel360.washinfo.entity.WashInfo; +import lombok.Builder; + +import java.time.LocalDateTime; + +@Builder +public record MemberSearchDto( + String id, + String name, + String email, + String age, + LocalDateTime registerDate, + WashInfo washInfo, + CarInfo carInfo +) { +} diff --git a/module-admin/src/main/java/com/kernel360/member/enumset/Age.java b/module-admin/src/main/java/com/kernel360/member/enumset/Age.java new file mode 100644 index 00000000..8fc70e47 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/enumset/Age.java @@ -0,0 +1,16 @@ +package com.kernel360.member.enumset; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public enum Age { + AGE_20(20), + AGE_30(30), + AGE_40(40), + AGE_50(50), + AGE_60(60), + AGE_99(99); + + private final int value; + +} diff --git a/module-admin/src/main/java/com/kernel360/member/enumset/Gender.java b/module-admin/src/main/java/com/kernel360/member/enumset/Gender.java new file mode 100644 index 00000000..050ffa4e --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/enumset/Gender.java @@ -0,0 +1,13 @@ +package com.kernel360.member.enumset; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public enum Gender { + MALE(0), + FEMALE(1), + OTHERS(99); + + private final int value; + +} diff --git a/module-admin/src/main/java/com/kernel360/member/enumset/Sort.java b/module-admin/src/main/java/com/kernel360/member/enumset/Sort.java new file mode 100644 index 00000000..7538f52f --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/enumset/Sort.java @@ -0,0 +1,23 @@ +package com.kernel360.member.enumset; + +public enum Sort { + ID_ORDER("id-order"), + GENDER_ORDER("gender-order"), + AGE_ORDER("age-order"), + REGISTER_ORDER("register-order"), + RECENT_PRODUCT_ORDER("recent-order"); + + + private final String orderType; + + Sort(String orderType) { + this.orderType = orderType; + } + + public String getOrderType() { + return orderType; + } +} + + + diff --git a/module-admin/src/main/java/com/kernel360/member/repository/MemberRepository.java b/module-admin/src/main/java/com/kernel360/member/repository/MemberRepository.java new file mode 100644 index 00000000..b6b56a89 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/repository/MemberRepository.java @@ -0,0 +1,5 @@ +package com.kernel360.member.repository; + + +public interface MemberRepository extends MemberRepositoryJpa, MemberRepositoryDsl { +} diff --git a/module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryDsl.java b/module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryDsl.java new file mode 100644 index 00000000..b0bdb1e3 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryDsl.java @@ -0,0 +1,10 @@ +package com.kernel360.member.repository; + +import com.kernel360.member.dto.MemberResponse; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface MemberRepositoryDsl { + Page findAllMember(Pageable pageable); + +} diff --git a/module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryImpl.java b/module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryImpl.java new file mode 100644 index 00000000..3618b67d --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryImpl.java @@ -0,0 +1,59 @@ +package com.kernel360.member.repository; + + +import com.kernel360.member.dto.MemberResponse; +import com.kernel360.member.dto.QMemberResponse; + +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.support.PageableExecutionUtils; + +import java.util.List; + +import static com.kernel360.carinfo.entity.QCarInfo.*; +import static com.kernel360.member.entity.QMember.*; +import static com.kernel360.washinfo.entity.QWashInfo.*; + + +@RequiredArgsConstructor +public class MemberRepositoryImpl implements MemberRepositoryDsl { + + private final JPAQueryFactory query; + + @Override + public Page findAllMember(Pageable pageable) { + List members = query.select(new QMemberResponse( + member.memberNo, + member.id, + member.email, + member.gender, + member.age, + member.createdAt, + member.accountType, + washInfo, + carInfo + )) + .from(member) + .leftJoin(member.washInfo, washInfo).on(isWashInfoNotNull()) + .leftJoin(member.carInfo, carInfo).on(isCarInfoNotNull()) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .orderBy(member.memberNo.desc()) + .fetch(); + + return PageableExecutionUtils.getPage(members, pageable, members::size); + } + + private static BooleanExpression isCarInfoNotNull() { + return member.carInfo.carNo.isNotNull(); + } + + private static BooleanExpression isWashInfoNotNull() { + return member.washInfo.washNo.isNotNull(); + } + + +} diff --git a/module-admin/src/main/java/com/kernel360/member/service/MemberService.java b/module-admin/src/main/java/com/kernel360/member/service/MemberService.java new file mode 100644 index 00000000..74d872a5 --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/member/service/MemberService.java @@ -0,0 +1,23 @@ +package com.kernel360.member.service; + +import com.kernel360.member.dto.MemberResponse; +import com.kernel360.member.repository.MemberRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + + +@Slf4j +@Service +@RequiredArgsConstructor +public class MemberService { + + private final MemberRepository memberRepository; + + public Page getAllMembers(Pageable pageable) { + + return memberRepository.findAllMember(pageable); + } +} diff --git a/module-admin/src/main/java/com/kernel360/review/repository/ReviewRepository.java b/module-admin/src/main/java/com/kernel360/review/repository/ReviewRepository.java new file mode 100644 index 00000000..619f004f --- /dev/null +++ b/module-admin/src/main/java/com/kernel360/review/repository/ReviewRepository.java @@ -0,0 +1,4 @@ +package com.kernel360.review.repository; + +public interface ReviewRepository extends ReviewRepositoryJpa, ReviewRepositoryDsl{ +} diff --git a/module-admin/src/main/java/com/kernel360/review/respository/ReviewRepositoryDsl.java b/module-admin/src/main/java/com/kernel360/review/repository/ReviewRepositoryDsl.java similarity index 89% rename from module-admin/src/main/java/com/kernel360/review/respository/ReviewRepositoryDsl.java rename to module-admin/src/main/java/com/kernel360/review/repository/ReviewRepositoryDsl.java index 55c9e501..6480742b 100644 --- a/module-admin/src/main/java/com/kernel360/review/respository/ReviewRepositoryDsl.java +++ b/module-admin/src/main/java/com/kernel360/review/repository/ReviewRepositoryDsl.java @@ -1,4 +1,4 @@ -package com.kernel360.review.respository; +package com.kernel360.review.repository; import com.kernel360.review.dto.ReviewSearchDto; import com.kernel360.review.entity.Review; diff --git a/module-admin/src/main/java/com/kernel360/review/respository/ReviewRepositoryImpl.java b/module-admin/src/main/java/com/kernel360/review/repository/ReviewRepositoryImpl.java similarity index 97% rename from module-admin/src/main/java/com/kernel360/review/respository/ReviewRepositoryImpl.java rename to module-admin/src/main/java/com/kernel360/review/repository/ReviewRepositoryImpl.java index 6885b68c..5aee21d1 100644 --- a/module-admin/src/main/java/com/kernel360/review/respository/ReviewRepositoryImpl.java +++ b/module-admin/src/main/java/com/kernel360/review/repository/ReviewRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.kernel360.review.respository; +package com.kernel360.review.repository; import static com.kernel360.review.entity.QReview.review; @@ -9,7 +9,6 @@ import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; -import java.util.function.LongSupplier; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; diff --git a/module-admin/src/main/java/com/kernel360/review/respository/ReviewRepository.java b/module-admin/src/main/java/com/kernel360/review/respository/ReviewRepository.java deleted file mode 100644 index e7edbc87..00000000 --- a/module-admin/src/main/java/com/kernel360/review/respository/ReviewRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.kernel360.review.respository; - -import com.kernel360.review.repository.ReviewRepositoryJpa; - -public interface ReviewRepository extends ReviewRepositoryJpa, ReviewRepositoryDsl{ -} diff --git a/module-admin/src/main/java/com/kernel360/review/service/ReviewServiceImpl.java b/module-admin/src/main/java/com/kernel360/review/service/ReviewServiceImpl.java index e03b326d..e9e4826d 100644 --- a/module-admin/src/main/java/com/kernel360/review/service/ReviewServiceImpl.java +++ b/module-admin/src/main/java/com/kernel360/review/service/ReviewServiceImpl.java @@ -4,7 +4,7 @@ import com.kernel360.review.code.ReviewErrorCode; import com.kernel360.review.dto.AdminReviewDto; import com.kernel360.review.dto.ReviewSearchDto; -import com.kernel360.review.respository.ReviewRepository; +import com.kernel360.review.repository.ReviewRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; diff --git a/module-api/src/main/java/com/kernel360/member/service/KakaoRequest.java b/module-api/src/main/java/com/kernel360/member/service/KakaoRequest.java index 444c7025..3551c959 100644 --- a/module-api/src/main/java/com/kernel360/member/service/KakaoRequest.java +++ b/module-api/src/main/java/com/kernel360/member/service/KakaoRequest.java @@ -39,9 +39,8 @@ public KakaoUserDto getKakaoUserByToken(String accessToken) { } Map kakaoAccount = mapper.convertValue(kakaoResponse.get("kakao_account"), HashMap.class); - KakaoUserDto dto = KakaoUserDto.of(kakaoResponse.get("id").toString(),kakaoAccount.get("email").toString()); + return KakaoUserDto.of(kakaoResponse.get("id").toString(),kakaoAccount.get("email").toString()); - return dto; } diff --git a/module-domain/src/main/java/com/kernel360/member/entity/Admin.java b/module-domain/src/main/java/com/kernel360/admin/entity/Admin.java similarity index 97% rename from module-domain/src/main/java/com/kernel360/member/entity/Admin.java rename to module-domain/src/main/java/com/kernel360/admin/entity/Admin.java index 42d0865b..41f691ee 100644 --- a/module-domain/src/main/java/com/kernel360/member/entity/Admin.java +++ b/module-domain/src/main/java/com/kernel360/admin/entity/Admin.java @@ -1,4 +1,4 @@ -package com.kernel360.member.entity; +package com.kernel360.admin.entity; import com.kernel360.base.BaseEntity; diff --git a/module-domain/src/main/java/com/kernel360/admin/repository/AdminRepository.java b/module-domain/src/main/java/com/kernel360/admin/repository/AdminRepository.java new file mode 100644 index 00000000..c7bea761 --- /dev/null +++ b/module-domain/src/main/java/com/kernel360/admin/repository/AdminRepository.java @@ -0,0 +1,7 @@ +package com.kernel360.admin.repository; + +import com.kernel360.admin.entity.Admin; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface AdminRepository extends JpaRepository { +} diff --git a/module-domain/src/main/java/com/kernel360/carinfo/entity/CarInfo.java b/module-domain/src/main/java/com/kernel360/carinfo/entity/CarInfo.java index 48a27ede..ad106037 100644 --- a/module-domain/src/main/java/com/kernel360/carinfo/entity/CarInfo.java +++ b/module-domain/src/main/java/com/kernel360/carinfo/entity/CarInfo.java @@ -23,17 +23,21 @@ public class CarInfo extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "car_info_id_gen") @SequenceGenerator(name = "car_info_id_gen", sequenceName = "car_info_car_no_seq") - @Column(nullable = false) + @Column(name = "car_no", nullable = false) private Long carNo; @OneToOne @JoinColumn(name = "member_no") private Member member; - + @Column(name = "car_type") private Integer carType; + @Column(name = "car_size") private Integer carSize; + @Column(name = "car_color") private Integer carColor; + @Column(name = "driving_env") private Integer drivingEnv; + @Column(name = "parking_env") private Integer parkingEnv; public CarInfo(Integer carType, Integer carSize, Integer carColor, Integer drivingEnv, Integer parkingEnv) { diff --git a/module-domain/src/main/java/com/kernel360/member/repository/MemberRepository.java b/module-domain/src/main/java/com/kernel360/member/repository/MemberRepositoryJpa.java similarity index 91% rename from module-domain/src/main/java/com/kernel360/member/repository/MemberRepository.java rename to module-domain/src/main/java/com/kernel360/member/repository/MemberRepositoryJpa.java index bf021316..4c3e7b98 100644 --- a/module-domain/src/main/java/com/kernel360/member/repository/MemberRepository.java +++ b/module-domain/src/main/java/com/kernel360/member/repository/MemberRepositoryJpa.java @@ -7,7 +7,7 @@ import org.springframework.data.repository.query.Param; -public interface MemberRepository extends JpaRepository { +public interface MemberRepositoryJpa extends JpaRepository { Member findOneByIdAndPassword(String id, String password); diff --git a/module-domain/src/main/java/com/kernel360/product/entity/SafetyStatusConverter.java b/module-domain/src/main/java/com/kernel360/product/converter/SafetyStatusConverter.java similarity index 95% rename from module-domain/src/main/java/com/kernel360/product/entity/SafetyStatusConverter.java rename to module-domain/src/main/java/com/kernel360/product/converter/SafetyStatusConverter.java index 61b91c3e..1e919ec6 100644 --- a/module-domain/src/main/java/com/kernel360/product/entity/SafetyStatusConverter.java +++ b/module-domain/src/main/java/com/kernel360/product/converter/SafetyStatusConverter.java @@ -1,4 +1,4 @@ -package com.kernel360.product.entity; +package com.kernel360.product.converter; import com.kernel360.product.enumset.SafetyStatus; import jakarta.persistence.AttributeConverter; diff --git a/module-domain/src/main/java/com/kernel360/washinfo/entity/WashInfo.java b/module-domain/src/main/java/com/kernel360/washinfo/entity/WashInfo.java index 482683af..0cb44133 100644 --- a/module-domain/src/main/java/com/kernel360/washinfo/entity/WashInfo.java +++ b/module-domain/src/main/java/com/kernel360/washinfo/entity/WashInfo.java @@ -31,8 +31,11 @@ public class WashInfo extends BaseEntity { @JoinColumn(name = "member_no", nullable = false) private Member member; + @Column(name= "wash_count") private Integer washCount; + @Column(name = "monthly_expense") private Integer monthlyExpense; + @Column(name = "interest") private Integer interest; private WashInfo(Integer washCount, Integer monthlyExpense, Integer interest) {