-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: getUserStatistics * fix: clothingSalesCount admin dashboard * fix: change state to selling when refund * refactor: productService
- Loading branch information
Showing
11 changed files
with
87 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/example/repick/domain/user/repository/UserRepositoryCustom.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,8 @@ | ||
package com.example.repick.domain.user.repository; | ||
|
||
import com.example.repick.domain.user.dto.GetUserStatistics; | ||
|
||
|
||
public interface UserRepositoryCustom { | ||
GetUserStatistics getUserStatistics(); | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/example/repick/domain/user/repository/UserRepositoryImpl.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.example.repick.domain.user.repository; | ||
|
||
import com.example.repick.domain.user.dto.GetUserStatistics; | ||
import com.example.repick.domain.user.entity.Gender; | ||
import com.querydsl.core.Tuple; | ||
import com.querydsl.core.types.dsl.CaseBuilder; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import static com.example.repick.domain.user.entity.QUser.user; | ||
|
||
@RequiredArgsConstructor | ||
public class UserRepositoryImpl implements UserRepositoryCustom{ | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public GetUserStatistics getUserStatistics() { | ||
Tuple result = queryFactory | ||
.select( | ||
user.count(), // μ΄ μ μ μ | ||
new CaseBuilder() | ||
.when(user.createdDate.after(LocalDateTime.now().minusMonths(1))).then(1).otherwise(0).sum(), // μ κ· μ μ μ | ||
new CaseBuilder() | ||
.when(user.gender.eq(Gender.FEMALE)).then(1).otherwise(0).sum(), // μ¬μ± μ μ μ | ||
new CaseBuilder() | ||
.when(user.gender.eq(Gender.MALE)).then(1).otherwise(0).sum() // λ¨μ± μ μ μ | ||
) | ||
.from(user) | ||
.where(user.isDeleted.isFalse()) | ||
.fetchOne(); | ||
|
||
long totalUserCount = result.get(0, Number.class).longValue(); | ||
long newUserCount = result.get(1, Number.class).longValue(); | ||
long femaleUserCount = result.get(2, Number.class).longValue(); | ||
long maleUserCount = result.get(3, Number.class).longValue(); | ||
|
||
double femaleRatio = (double) femaleUserCount / totalUserCount; | ||
double maleRatio = (double) maleUserCount / totalUserCount; | ||
|
||
return GetUserStatistics.of(totalUserCount, newUserCount, femaleRatio, maleRatio); | ||
} | ||
|
||
} |
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