feat: limit daily AI formatting usage

This commit is contained in:
Tim
2025-07-14 18:13:36 +08:00
parent d7287deadb
commit fd6a9521c1
9 changed files with 139 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import com.openisle.model.PasswordStrength;
import com.openisle.model.PublishMode;
import com.openisle.service.PasswordValidator;
import com.openisle.service.PostService;
import com.openisle.service.AiUsageService;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -14,12 +15,14 @@ import org.springframework.web.bind.annotation.*;
public class AdminConfigController {
private final PostService postService;
private final PasswordValidator passwordValidator;
private final AiUsageService aiUsageService;
@GetMapping
public ConfigDto getConfig() {
ConfigDto dto = new ConfigDto();
dto.setPublishMode(postService.getPublishMode());
dto.setPasswordStrength(passwordValidator.getStrength());
dto.setAiFormatLimit(aiUsageService.getFormatLimit());
return dto;
}
@@ -31,6 +34,9 @@ public class AdminConfigController {
if (dto.getPasswordStrength() != null) {
passwordValidator.setStrength(dto.getPasswordStrength());
}
if (dto.getAiFormatLimit() != null) {
aiUsageService.setFormatLimit(dto.getAiFormatLimit());
}
return getConfig();
}
@@ -38,5 +44,6 @@ public class AdminConfigController {
public static class ConfigDto {
private PublishMode publishMode;
private PasswordStrength passwordStrength;
private Integer aiFormatLimit;
}
}