diff --git a/src/main/java/plus/maa/backend/config/external/Copilot.java b/src/main/java/plus/maa/backend/config/external/Copilot.java new file mode 100644 index 00000000..9d06b5dd --- /dev/null +++ b/src/main/java/plus/maa/backend/config/external/Copilot.java @@ -0,0 +1,14 @@ +package plus.maa.backend.config.external; + +import lombok.Data; + +@Data +public class Copilot { + + /** + * 作业评分总数少于指定值时显示评分不足 + *
+ * 默认值:50 + */ + private int minValueShowNotEnoughRating = 50; +} diff --git a/src/main/java/plus/maa/backend/config/external/MaaCopilotProperties.java b/src/main/java/plus/maa/backend/config/external/MaaCopilotProperties.java index c7975d63..7ecc8141 100644 --- a/src/main/java/plus/maa/backend/config/external/MaaCopilotProperties.java +++ b/src/main/java/plus/maa/backend/config/external/MaaCopilotProperties.java @@ -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; @@ -26,4 +29,6 @@ public class MaaCopilotProperties { private Mail mail; @NestedConfigurationProperty private SensitiveWord sensitiveWord; + @NestedConfigurationProperty + private Copilot copilot = new Copilot(); } diff --git a/src/main/java/plus/maa/backend/service/CopilotService.java b/src/main/java/plus/maa/backend/service/CopilotService.java index 12b7f2e0..ee088492 100644 --- a/src/main/java/plus/maa/backend/service/CopilotService.java +++ b/src/main/java/plus/maa/backend/service/CopilotService.java @@ -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; @@ -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); @@ -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); diff --git a/src/main/resources/application-template.yml b/src/main/resources/application-template.yml index f04a8ee3..bea8501b 100644 --- a/src/main/resources/application-template.yml +++ b/src/main/resources/application-template.yml @@ -60,6 +60,8 @@ maa-copilot: ssl: false #邮件通知 notification: true + copilot: + min-value-show-not-enough-rating: 50