-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from HyunJunSon/feature/admin/member
Feature:: Admin 회원관리 api 추가
- Loading branch information
Showing
24 changed files
with
335 additions
and
17 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
module-admin/src/main/java/com/kernel360/member/code/MemberBusinessCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
module-admin/src/main/java/com/kernel360/member/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ApiResponse<Page<MemberResponse>>> getMemberList(Pageable pageable) { | ||
Page<MemberResponse> members = memberService.getAllMembers(pageable); | ||
|
||
return ApiResponse.toResponseEntity(MemberBusinessCode.SUCCESS_REQUEST_ALL_MEMBER_LIST, members); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
module-admin/src/main/java/com/kernel360/member/dto/MemberDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
); | ||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
module-admin/src/main/java/com/kernel360/member/dto/MemberResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
module-admin/src/main/java/com/kernel360/member/dto/MemberSearchDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) { | ||
} |
16 changes: 16 additions & 0 deletions
16
module-admin/src/main/java/com/kernel360/member/enumset/Age.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
module-admin/src/main/java/com/kernel360/member/enumset/Gender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
module-admin/src/main/java/com/kernel360/member/enumset/Sort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
|
||
|
||
|
5 changes: 5 additions & 0 deletions
5
module-admin/src/main/java/com/kernel360/member/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.kernel360.member.repository; | ||
|
||
|
||
public interface MemberRepository extends MemberRepositoryJpa, MemberRepositoryDsl { | ||
} |
10 changes: 10 additions & 0 deletions
10
module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryDsl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MemberResponse> findAllMember(Pageable pageable); | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
module-admin/src/main/java/com/kernel360/member/repository/MemberRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MemberResponse> findAllMember(Pageable pageable) { | ||
List<MemberResponse> 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(); | ||
} | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
module-admin/src/main/java/com/kernel360/member/service/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MemberResponse> getAllMembers(Pageable pageable) { | ||
|
||
return memberRepository.findAllMember(pageable); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
module-admin/src/main/java/com/kernel360/review/repository/ReviewRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.kernel360.review.repository; | ||
|
||
public interface ReviewRepository extends ReviewRepositoryJpa, ReviewRepositoryDsl{ | ||
} |
2 changes: 1 addition & 1 deletion
2
...view/respository/ReviewRepositoryDsl.java → ...eview/repository/ReviewRepositoryDsl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
module-admin/src/main/java/com/kernel360/review/respository/ReviewRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...va/com/kernel360/member/entity/Admin.java → ...ava/com/kernel360/admin/entity/Admin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.kernel360.member.entity; | ||
package com.kernel360.admin.entity; | ||
|
||
|
||
import com.kernel360.base.BaseEntity; | ||
|
7 changes: 7 additions & 0 deletions
7
module-domain/src/main/java/com/kernel360/admin/repository/AdminRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Admin,Long> { | ||
} |
Oops, something went wrong.