AppProperties.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.example.hrlab.config;
  2. import java.time.Duration;
  3. import org.springframework.boot.context.properties.ConfigurationProperties;
  4. @ConfigurationProperties(prefix = "app")
  5. public record AppProperties(
  6. String name,
  7. String version,
  8. Jwt jwt,
  9. Security security,
  10. Tasks tasks,
  11. Storage storage,
  12. Lab lab) {
  13. public record Jwt(String issuer, String secret, long accessTokenMinutes, long refreshTokenDays) {
  14. public Duration accessDuration() {
  15. return Duration.ofMinutes(accessTokenMinutes);
  16. }
  17. public Duration refreshDuration() {
  18. return Duration.ofDays(refreshTokenDays);
  19. }
  20. }
  21. public record Security(int loginFailureThreshold, long lockMinutes, String webhookSecret) {
  22. public Duration lockDuration() {
  23. return Duration.ofMinutes(lockMinutes);
  24. }
  25. }
  26. public record Tasks(boolean inline, String exchange, String payrollQueue, String exportQueue, String importQueue, String webhookQueue) {
  27. }
  28. public record Storage(String exportDir, String importDir) {
  29. }
  30. public record Lab(boolean enabled, String fixedClock, Seed seed, Failpoint failpoint) {
  31. }
  32. public record Seed(boolean enabled, long randomSeed, int employeeCount, int candidateCount, int attendanceDays) {
  33. }
  34. public record Failpoint(boolean enabled, long exportDelayMs, long payrollExtraDelayMs, boolean webhookForce5xx,
  35. boolean mqRequeueOnce, boolean formulaException, boolean cacheDisabled) {
  36. }
  37. }