Skip to content

Commit

Permalink
Merge pull request #146 from Lixuhuilll/NotEnoughRating
Browse files Browse the repository at this point in the history
修改默认情况下显示评分不足时所需的评分量,并允许该项配置修改
  • Loading branch information
LuoRenMu authored Nov 19, 2023
2 parents 476402f + 625e2ba commit 565c4d1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/main/java/plus/maa/backend/config/external/Copilot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package plus.maa.backend.config.external;

import lombok.Data;

@Data
public class Copilot {

/**
* 作业评分总数少于指定值时显示评分不足
* <p>
* 默认值:50
*/
private int minValueShowNotEnoughRating = 50;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package plus.maa.backend.config.external;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties("maa-copilot")
@lombok.Data
public class MaaCopilotProperties {
@NestedConfigurationProperty
private Jwt jwt;
Expand All @@ -26,4 +29,6 @@ public class MaaCopilotProperties {
private Mail mail;
@NestedConfigurationProperty
private SensitiveWord sensitiveWord;
@NestedConfigurationProperty
private Copilot copilot = new Copilot();
}
4 changes: 3 additions & 1 deletion src/main/java/plus/maa/backend/service/CopilotService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import plus.maa.backend.common.utils.converter.CopilotConverter;
import plus.maa.backend.config.external.MaaCopilotProperties;
import plus.maa.backend.controller.request.copilot.CopilotCUDRequest;
import plus.maa.backend.controller.request.copilot.CopilotDTO;
import plus.maa.backend.controller.request.copilot.CopilotQueriesRequest;
Expand Down Expand Up @@ -62,6 +63,7 @@ public class CopilotService {
private final RedisCache redisCache;
private final UserRepository userRepository;
private final CommentsAreaRepository commentsAreaRepository;
private final MaaCopilotProperties properties;

private final CopilotConverter copilotConverter;
private final AtomicLong copilotIncrementId = new AtomicLong(20000);
Expand Down Expand Up @@ -525,7 +527,7 @@ private CopilotInfo formatCopilot(Copilot copilot, @Nullable RatingType ratingTy
info.setRatingType(ratingType.getDisplay());
}
// 评分数少于一定数量
info.setNotEnoughRating(copilot.getLikeCount() + copilot.getDislikeCount() <= 5);
info.setNotEnoughRating(copilot.getLikeCount() + copilot.getDislikeCount() <= properties.getCopilot().getMinValueShowNotEnoughRating());

info.setAvailable(true);

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ maa-copilot:
ssl: false
#邮件通知
notification: true
copilot:
min-value-show-not-enough-rating: 50



Expand Down

0 comments on commit 565c4d1

Please sign in to comment.