Skip to content

Commit 57c2327

Browse files
authored
Merge pull request #96 from team-ppointer/feature/#92
Feature/#92 조회수, 풀이수 통계 업데이트 공통 서비스 구현
2 parents 0883a17 + 77adb3b commit 57c2327

17 files changed

+572
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import static com.querydsl.core.types.PathMetadataFactory.*;
4+
5+
import com.querydsl.core.types.dsl.*;
6+
7+
import com.querydsl.core.types.PathMetadata;
8+
import javax.annotation.processing.Generated;
9+
import com.querydsl.core.types.Path;
10+
import com.querydsl.core.types.dsl.PathInits;
11+
12+
13+
/**
14+
* QChildProblemStatistic is a Querydsl query type for ChildProblemStatistic
15+
*/
16+
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
17+
public class QChildProblemStatistic extends EntityPathBase<ChildProblemStatistic> {
18+
19+
private static final long serialVersionUID = 1136828573L;
20+
21+
private static final PathInits INITS = PathInits.DIRECT2;
22+
23+
public static final QChildProblemStatistic childProblemStatistic = new QChildProblemStatistic("childProblemStatistic");
24+
25+
public final NumberPath<Long> childProblemId = createNumber("childProblemId", Long.class);
26+
27+
public final QCountStatistic countStatistic;
28+
29+
public final NumberPath<Long> id = createNumber("id", Long.class);
30+
31+
public QChildProblemStatistic(String variable) {
32+
this(ChildProblemStatistic.class, forVariable(variable), INITS);
33+
}
34+
35+
public QChildProblemStatistic(Path<? extends ChildProblemStatistic> path) {
36+
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
37+
}
38+
39+
public QChildProblemStatistic(PathMetadata metadata) {
40+
this(metadata, PathInits.getFor(metadata, INITS));
41+
}
42+
43+
public QChildProblemStatistic(PathMetadata metadata, PathInits inits) {
44+
this(ChildProblemStatistic.class, metadata, inits);
45+
}
46+
47+
public QChildProblemStatistic(Class<? extends ChildProblemStatistic> type, PathMetadata metadata, PathInits inits) {
48+
super(type, metadata, inits);
49+
this.countStatistic = inits.isInitialized("countStatistic") ? new QCountStatistic(forProperty("countStatistic")) : null;
50+
}
51+
52+
}
53+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import static com.querydsl.core.types.PathMetadataFactory.*;
4+
5+
import com.querydsl.core.types.dsl.*;
6+
7+
import com.querydsl.core.types.PathMetadata;
8+
import javax.annotation.processing.Generated;
9+
import com.querydsl.core.types.Path;
10+
11+
12+
/**
13+
* QCountStatistic is a Querydsl query type for CountStatistic
14+
*/
15+
@Generated("com.querydsl.codegen.DefaultEmbeddableSerializer")
16+
public class QCountStatistic extends BeanPath<CountStatistic> {
17+
18+
private static final long serialVersionUID = 1047466257L;
19+
20+
public static final QCountStatistic countStatistic = new QCountStatistic("countStatistic");
21+
22+
public final NumberPath<Long> submitCount = createNumber("submitCount", Long.class);
23+
24+
public final NumberPath<Long> viewCount = createNumber("viewCount", Long.class);
25+
26+
public QCountStatistic(String variable) {
27+
super(CountStatistic.class, forVariable(variable));
28+
}
29+
30+
public QCountStatistic(Path<? extends CountStatistic> path) {
31+
super(path.getType(), path.getMetadata());
32+
}
33+
34+
public QCountStatistic(PathMetadata metadata) {
35+
super(CountStatistic.class, metadata);
36+
}
37+
38+
}
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import static com.querydsl.core.types.PathMetadataFactory.*;
4+
5+
import com.querydsl.core.types.dsl.*;
6+
7+
import com.querydsl.core.types.PathMetadata;
8+
import javax.annotation.processing.Generated;
9+
import com.querydsl.core.types.Path;
10+
import com.querydsl.core.types.dsl.PathInits;
11+
12+
13+
/**
14+
* QProblemSetStatistic is a Querydsl query type for ProblemSetStatistic
15+
*/
16+
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
17+
public class QProblemSetStatistic extends EntityPathBase<ProblemSetStatistic> {
18+
19+
private static final long serialVersionUID = -1319940803L;
20+
21+
private static final PathInits INITS = PathInits.DIRECT2;
22+
23+
public static final QProblemSetStatistic problemSetStatistic = new QProblemSetStatistic("problemSetStatistic");
24+
25+
public final QCountStatistic countStatistic;
26+
27+
public final NumberPath<Long> id = createNumber("id", Long.class);
28+
29+
public final NumberPath<Long> problemSetId = createNumber("problemSetId", Long.class);
30+
31+
public QProblemSetStatistic(String variable) {
32+
this(ProblemSetStatistic.class, forVariable(variable), INITS);
33+
}
34+
35+
public QProblemSetStatistic(Path<? extends ProblemSetStatistic> path) {
36+
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
37+
}
38+
39+
public QProblemSetStatistic(PathMetadata metadata) {
40+
this(metadata, PathInits.getFor(metadata, INITS));
41+
}
42+
43+
public QProblemSetStatistic(PathMetadata metadata, PathInits inits) {
44+
this(ProblemSetStatistic.class, metadata, inits);
45+
}
46+
47+
public QProblemSetStatistic(Class<? extends ProblemSetStatistic> type, PathMetadata metadata, PathInits inits) {
48+
super(type, metadata, inits);
49+
this.countStatistic = inits.isInitialized("countStatistic") ? new QCountStatistic(forProperty("countStatistic")) : null;
50+
}
51+
52+
}
53+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import static com.querydsl.core.types.PathMetadataFactory.*;
4+
5+
import com.querydsl.core.types.dsl.*;
6+
7+
import com.querydsl.core.types.PathMetadata;
8+
import javax.annotation.processing.Generated;
9+
import com.querydsl.core.types.Path;
10+
import com.querydsl.core.types.dsl.PathInits;
11+
12+
13+
/**
14+
* QProblemStatistic is a Querydsl query type for ProblemStatistic
15+
*/
16+
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
17+
public class QProblemStatistic extends EntityPathBase<ProblemStatistic> {
18+
19+
private static final long serialVersionUID = 843488641L;
20+
21+
private static final PathInits INITS = PathInits.DIRECT2;
22+
23+
public static final QProblemStatistic problemStatistic = new QProblemStatistic("problemStatistic");
24+
25+
public final QCountStatistic countStatistic;
26+
27+
public final NumberPath<Long> id = createNumber("id", Long.class);
28+
29+
public final NumberPath<Long> problemId = createNumber("problemId", Long.class);
30+
31+
public QProblemStatistic(String variable) {
32+
this(ProblemStatistic.class, forVariable(variable), INITS);
33+
}
34+
35+
public QProblemStatistic(Path<? extends ProblemStatistic> path) {
36+
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
37+
}
38+
39+
public QProblemStatistic(PathMetadata metadata) {
40+
this(metadata, PathInits.getFor(metadata, INITS));
41+
}
42+
43+
public QProblemStatistic(PathMetadata metadata, PathInits inits) {
44+
this(ProblemStatistic.class, metadata, inits);
45+
}
46+
47+
public QProblemStatistic(Class<? extends ProblemStatistic> type, PathMetadata metadata, PathInits inits) {
48+
super(type, metadata, inits);
49+
this.countStatistic = inits.isInitialized("countStatistic") ? new QCountStatistic(forProperty("countStatistic")) : null;
50+
}
51+
52+
}
53+

src/main/java/com/moplus/moplus_server/global/error/exception/ErrorCode.java

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public enum ErrorCode {
7777
ALREADY_PUBLISHED_ERROR(HttpStatus.BAD_REQUEST, "이미 발행된 문항세트는 컨펌해제할 수 없습니다."),
7878
PROBLEM_SET_DELETED(HttpStatus.BAD_REQUEST, "삭제된 문항세트는 발행할 수 없습니다"),
7979
PROBLEM_SET_NOT_CONFIRMED(HttpStatus.BAD_REQUEST, "컨펌되지 않은 문항세트는 발행할 수 없습니다"),
80+
81+
// 통계
82+
PROBLEM_STATISTIC_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 문항의 통계 정보를 찾을 수 없습니다"),
83+
PROBLEM_SET_STATISTIC_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 문항세트의 통계 정보를 찾을 수 없습니다"),
84+
CHILD_PROBLEM_STATISTIC_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 새끼 문항의 통계 정보를 찾을 수 없습니다"),
8085
FUTURE_PUBLISH_NOT_ACCESSIBLE(HttpStatus.BAD_REQUEST, "오늘 이후의 발행을 조회할 수 없습니다."),
8186

8287
// 문항 제출
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Embedded;
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.GeneratedValue;
7+
import jakarta.persistence.GenerationType;
8+
import jakarta.persistence.Id;
9+
import lombok.AccessLevel;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
13+
@Getter
14+
@Entity
15+
@NoArgsConstructor(access = AccessLevel.PROTECTED)
16+
public class ChildProblemStatistic implements StatisticCounter {
17+
18+
@Id
19+
@GeneratedValue(strategy = GenerationType.IDENTITY)
20+
@Column(name = "child_problem_statistic_id")
21+
private Long id;
22+
23+
private Long childProblemId;
24+
25+
@Embedded
26+
private CountStatistic countStatistic;
27+
28+
public ChildProblemStatistic(Long childProblemId) {
29+
this.childProblemId = childProblemId;
30+
this.countStatistic = new CountStatistic();
31+
}
32+
33+
@Override
34+
public void addViewCount() {
35+
this.countStatistic.addViewCount();
36+
}
37+
38+
@Override
39+
public void addSubmitCount() {
40+
this.countStatistic.addSubmitCount();
41+
}
42+
43+
public Long getViewCount() {
44+
return this.countStatistic.getViewCount();
45+
}
46+
47+
public Long getSubmitCount() {
48+
return this.countStatistic.getSubmitCount();
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import jakarta.persistence.Embeddable;
4+
import lombok.Getter;
5+
6+
@Getter
7+
@Embeddable
8+
public class CountStatistic implements StatisticCounter {
9+
private Long viewCount;
10+
private Long submitCount;
11+
12+
public CountStatistic() {
13+
this.viewCount = 0L;
14+
this.submitCount = 0L;
15+
}
16+
17+
@Override
18+
public void addViewCount() {
19+
this.viewCount++;
20+
}
21+
22+
@Override
23+
public void addSubmitCount() {
24+
this.submitCount++;
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Embedded;
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.GeneratedValue;
7+
import jakarta.persistence.GenerationType;
8+
import jakarta.persistence.Id;
9+
import lombok.AccessLevel;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
13+
@Getter
14+
@Entity
15+
@NoArgsConstructor(access = AccessLevel.PROTECTED)
16+
public class ProblemSetStatistic implements StatisticCounter {
17+
18+
@Id
19+
@GeneratedValue(strategy = GenerationType.IDENTITY)
20+
@Column(name = "problem_set_statistic_id")
21+
private Long id;
22+
23+
private Long problemSetId;
24+
25+
@Embedded
26+
private CountStatistic countStatistic;
27+
28+
public ProblemSetStatistic(Long problemSetId) {
29+
this.problemSetId = problemSetId;
30+
this.countStatistic = new CountStatistic();
31+
}
32+
33+
@Override
34+
public void addViewCount() {
35+
this.countStatistic.addViewCount();
36+
}
37+
38+
@Override
39+
public void addSubmitCount() {
40+
this.countStatistic.addSubmitCount();
41+
}
42+
43+
public Long getViewCount() {
44+
return this.countStatistic.getViewCount();
45+
}
46+
47+
public Long getSubmitCount() {
48+
return this.countStatistic.getSubmitCount();
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.moplus.moplus_server.statistic.Problem.domain;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Embedded;
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.GeneratedValue;
7+
import jakarta.persistence.GenerationType;
8+
import jakarta.persistence.Id;
9+
import lombok.AccessLevel;
10+
import lombok.Builder;
11+
import lombok.Getter;
12+
import lombok.NoArgsConstructor;
13+
14+
@Getter
15+
@Entity
16+
@NoArgsConstructor(access = AccessLevel.PROTECTED)
17+
public class ProblemStatistic implements StatisticCounter {
18+
19+
@Id
20+
@GeneratedValue(strategy = GenerationType.IDENTITY)
21+
@Column(name = "problem_statistic_id")
22+
private Long id;
23+
24+
private Long problemId;
25+
26+
@Embedded
27+
private CountStatistic countStatistic;
28+
29+
@Builder
30+
public ProblemStatistic(Long problemId) {
31+
this.problemId = problemId;
32+
this.countStatistic = new CountStatistic();
33+
}
34+
35+
@Override
36+
public void addViewCount() {
37+
this.countStatistic.addViewCount();
38+
}
39+
40+
@Override
41+
public void addSubmitCount() {
42+
this.countStatistic.addSubmitCount();
43+
}
44+
45+
public Long getViewCount() {
46+
return this.countStatistic.getViewCount();
47+
}
48+
49+
public Long getSubmitCount() {
50+
return this.countStatistic.getSubmitCount();
51+
}
52+
}

0 commit comments

Comments
 (0)