lenghui 5 months ago
commit
efcad09e28
  1. 33
      .gitignore
  2. 410
      hs_err_pid25076.log
  3. 118
      pom.xml
  4. 13
      src/main/java/com/lh/VoteSystemApplication.java
  5. 17
      src/main/java/com/lh/bean/Candidate.java
  6. 82
      src/main/java/com/lh/bean/RespBean.java
  7. 15
      src/main/java/com/lh/bean/VoteMessage.java
  8. 18
      src/main/java/com/lh/bean/Voter.java
  9. 13
      src/main/java/com/lh/bean/dto/TokenDTO.java
  10. 84
      src/main/java/com/lh/config/CandidateCacheRepository.java
  11. 22
      src/main/java/com/lh/config/ExceptionHandler.java
  12. 37
      src/main/java/com/lh/config/RedisConfig.java
  13. 49
      src/main/java/com/lh/controller/VoteController.java
  14. 7
      src/main/java/com/lh/exception/MyException.java
  15. 17
      src/main/java/com/lh/mapper/CandidatesMapper.java
  16. 17
      src/main/java/com/lh/mapper/VoterMapper.java
  17. 74
      src/main/java/com/lh/service/VoteConsumer.java
  18. 26
      src/main/java/com/lh/service/VoteProducer.java
  19. 16
      src/main/java/com/lh/service/VoteService.java
  20. 164
      src/main/java/com/lh/service/VoteServiceImpl.java
  21. 72
      src/main/java/com/lh/until/Utils.java
  22. 39
      src/main/resources/application.properties
  23. 13
      src/main/resources/com/lh/mapper/CandidatesMapper.xml
  24. 14
      src/main/resources/com/lh/mapper/VoterMapper.xml
  25. 6
      src/main/resources/static/index.html
  26. 34
      src/test/java/com/lh/VoteSystemApplicationTests.java

33
.gitignore

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

410
hs_err_pid25076.log

@ -0,0 +1,410 @@
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaCalls.cpp:51), pid=25076, tid=0x0000000000002d34
# guarantee(thread->is_Java_thread()) failed: crucial check - the VM thread cannot and must not escape to Java code
#
# JRE version: Java(TM) SE Runtime Environment (8.0_371) (build 1.8.0_371-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.371-b11 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x000001ded177d800): VMThread [stack: 0x0000008ab0f00000,0x0000008ab1000000] [id=11572]
Stack: [0x0000008ab0f00000,0x0000008ab1000000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x34d9f9]
V [jvm.dll+0x28aa12]
V [jvm.dll+0x28b5dd]
V [jvm.dll+0x2a9756]
V [jvm.dll+0x2aa430]
V [jvm.dll+0x34d658]
C [ntdll.dll+0xa28bf]
C [ntdll.dll+0x52554]
C [ntdll.dll+0xa13ce]
C 0x000001ded8410b4a
VM_Operation (0x0000008ab14ff540): GetOrSetLocal, mode: safepoint, requested by thread 0x000001deeec74800
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x000001def3bc5800 JavaThread "kafka-coordinator-heartbeat-thread | vote-group" daemon [_thread_blocked, id=28744, stack(0x0000008ab5200000,0x0000008ab5300000)]
0x000001def3bc9000 JavaThread "http-nio-8091-Acceptor" daemon [_thread_blocked, id=32148, stack(0x0000008ab5100000,0x0000008ab5200000)]
0x000001def3bc1800 JavaThread "http-nio-8091-ClientPoller" daemon [_thread_blocked, id=32608, stack(0x0000008ab5000000,0x0000008ab5100000)]
0x000001def3bc7000 JavaThread "http-nio-8091-exec-10" daemon [_thread_blocked, id=31348, stack(0x0000008ab4f00000,0x0000008ab5000000)]
0x000001def3bc8800 JavaThread "http-nio-8091-exec-9" daemon [_thread_blocked, id=15980, stack(0x0000008ab4e00000,0x0000008ab4f00000)]
0x000001def39b5000 JavaThread "http-nio-8091-exec-8" daemon [_thread_blocked, id=29748, stack(0x0000008ab4d00000,0x0000008ab4e00000)]
0x000001def39bb000 JavaThread "http-nio-8091-exec-7" daemon [_thread_blocked, id=33636, stack(0x0000008ab4c00000,0x0000008ab4d00000)]
0x000001def39ba800 JavaThread "http-nio-8091-exec-6" daemon [_thread_blocked, id=23340, stack(0x0000008ab4b00000,0x0000008ab4c00000)]
0x000001def39b9000 JavaThread "http-nio-8091-exec-5" daemon [_thread_blocked, id=18916, stack(0x0000008ab4a00000,0x0000008ab4b00000)]
0x000001def39b8000 JavaThread "http-nio-8091-exec-4" daemon [_thread_blocked, id=23868, stack(0x0000008ab4900000,0x0000008ab4a00000)]
0x000001def39b9800 JavaThread "http-nio-8091-exec-3" daemon [_thread_blocked, id=29744, stack(0x0000008ab4800000,0x0000008ab4900000)]
0x000001def39b7800 JavaThread "http-nio-8091-exec-2" daemon [_thread_blocked, id=23860, stack(0x0000008ab4700000,0x0000008ab4800000)]
0x000001def39b6800 JavaThread "http-nio-8091-exec-1" daemon [_thread_blocked, id=14900, stack(0x0000008ab4600000,0x0000008ab4700000)]
0x000001def39bc000 JavaThread "http-nio-8091-BlockPoller" daemon [_thread_blocked, id=16256, stack(0x0000008ab4400000,0x0000008ab4500000)]
0x000001def39b6000 JavaThread "org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1" [_thread_blocked, id=17664, stack(0x0000008ab4300000,0x0000008ab4400000)]
0x000001def39ad800 JavaThread "ThreadPoolTaskScheduler-1" [_thread_blocked, id=3736, stack(0x0000008ab4200000,0x0000008ab4300000)]
0x000001def39b4800 JavaThread "File Watcher" daemon [_thread_blocked, id=744, stack(0x0000008ab4100000,0x0000008ab4200000)]
0x000001def39b3000 JavaThread "lettuce-eventExecutorLoop-62-16" daemon [_thread_blocked, id=31540, stack(0x0000008ab3f00000,0x0000008ab4000000)]
0x000001def39b2000 JavaThread "lettuce-eventExecutorLoop-62-15" daemon [_thread_blocked, id=14556, stack(0x0000008ab3e00000,0x0000008ab3f00000)]
0x000001def39b0000 JavaThread "lettuce-eventExecutorLoop-62-14" daemon [_thread_blocked, id=4308, stack(0x0000008ab3d00000,0x0000008ab3e00000)]
0x000001def39af000 JavaThread "lettuce-eventExecutorLoop-62-13" daemon [_thread_blocked, id=31568, stack(0x0000008ab3c00000,0x0000008ab3d00000)]
0x000001def39ae800 JavaThread "lettuce-eventExecutorLoop-62-12" daemon [_thread_blocked, id=29328, stack(0x0000008ab3b00000,0x0000008ab3c00000)]
0x000001def39ad000 JavaThread "lettuce-eventExecutorLoop-62-11" daemon [_thread_blocked, id=31384, stack(0x0000008ab3a00000,0x0000008ab3b00000)]
0x000001def4160000 JavaThread "lettuce-eventExecutorLoop-62-10" daemon [_thread_blocked, id=28416, stack(0x0000008ab3900000,0x0000008ab3a00000)]
0x000001def415f800 JavaThread "lettuce-eventExecutorLoop-62-9" daemon [_thread_blocked, id=33712, stack(0x0000008ab3800000,0x0000008ab3900000)]
0x000001def415d000 JavaThread "lettuce-eventExecutorLoop-62-8" daemon [_thread_blocked, id=1852, stack(0x0000008ab3700000,0x0000008ab3800000)]
0x000001def415e000 JavaThread "lettuce-eventExecutorLoop-62-7" daemon [_thread_blocked, id=20324, stack(0x0000008ab3600000,0x0000008ab3700000)]
0x000001def415c800 JavaThread "lettuce-eventExecutorLoop-62-6" daemon [_thread_blocked, id=19420, stack(0x0000008ab3500000,0x0000008ab3600000)]
0x000001def415e800 JavaThread "lettuce-eventExecutorLoop-62-5" daemon [_thread_blocked, id=22788, stack(0x0000008ab3400000,0x0000008ab3500000)]
0x000001def4155000 JavaThread "lettuce-eventExecutorLoop-62-4" daemon [_thread_blocked, id=25488, stack(0x0000008ab3300000,0x0000008ab3400000)]
0x000001def415b800 JavaThread "lettuce-eventExecutorLoop-62-3" daemon [_thread_blocked, id=32320, stack(0x0000008ab3200000,0x0000008ab3300000)]
0x000001def415b000 JavaThread "lettuce-eventExecutorLoop-62-2" daemon [_thread_blocked, id=30908, stack(0x0000008ab3100000,0x0000008ab3200000)]
0x000001def415a000 JavaThread "lettuce-eventExecutorLoop-62-1" daemon [_thread_blocked, id=27428, stack(0x0000008ab3000000,0x0000008ab3100000)]
0x000001def4159800 JavaThread "lettuce-nioEventLoop-64-1" daemon [_thread_in_native, id=25588, stack(0x0000008ab2d00000,0x0000008ab2e00000)]
0x000001def4152000 JavaThread "HwgoldHikariCP housekeeper" daemon [_thread_blocked, id=26692, stack(0x0000008ab2c00000,0x0000008ab2d00000)]
0x000001def4158800 JavaThread "lettuce-timer-63-1" [_thread_blocked, id=26464, stack(0x0000008ab2b00000,0x0000008ab2c00000)]
0x000001def4154000 JavaThread "container-0" [_thread_blocked, id=23992, stack(0x0000008ab2a00000,0x0000008ab2b00000)]
0x000001def4157000 JavaThread "Catalina-utility-2" [_thread_blocked, id=8032, stack(0x0000008ab2900000,0x0000008ab2a00000)]
0x000001def4151000 JavaThread "Catalina-utility-1" [_thread_blocked, id=25140, stack(0x0000008aafd00000,0x0000008aafe00000)]
0x000001def4156800 JavaThread "DestroyJavaVM" [_thread_blocked, id=13124, stack(0x0000008ab0100000,0x0000008ab0200000)]
0x000001def3bc4000 JavaThread "Live Reload Server" daemon [_thread_in_native, id=28364, stack(0x0000008ab4500000,0x0000008ab4600000)]
0x000001deeecfa000 JavaThread "mysql-cj-abandoned-connection-cleanup" daemon [_thread_blocked, id=13352, stack(0x0000008ab2e00000,0x0000008ab2f00000)]
0x000001def0df7000 JavaThread "RMI Scheduler(0)" daemon [_thread_blocked, id=6252, stack(0x0000008ab2700000,0x0000008ab2800000)]
0x000001def0c06000 JavaThread "RMI TCP Accept-0" daemon [_thread_in_native, id=24984, stack(0x0000008ab2400000,0x0000008ab2500000)]
0x000001deeed7d000 JavaThread "Service Thread" daemon [_thread_blocked, id=25552, stack(0x0000008ab2300000,0x0000008ab2400000)]
0x000001deeecf8800 JavaThread "C1 CompilerThread11" daemon [_thread_blocked, id=23664, stack(0x0000008ab2200000,0x0000008ab2300000)]
0x000001deeecf5800 JavaThread "C1 CompilerThread10" daemon [_thread_blocked, id=23460, stack(0x0000008ab2100000,0x0000008ab2200000)]
0x000001deeecf6000 JavaThread "C1 CompilerThread9" daemon [_thread_blocked, id=32216, stack(0x0000008ab2000000,0x0000008ab2100000)]
0x000001deeecf7800 JavaThread "C1 CompilerThread8" daemon [_thread_blocked, id=31036, stack(0x0000008ab1f00000,0x0000008ab2000000)]
0x000001deeecf7000 JavaThread "C2 CompilerThread7" daemon [_thread_blocked, id=32380, stack(0x0000008ab1e00000,0x0000008ab1f00000)]
0x000001deeecf2800 JavaThread "C2 CompilerThread6" daemon [_thread_blocked, id=19188, stack(0x0000008ab1d00000,0x0000008ab1e00000)]
0x000001deeecb7800 JavaThread "C2 CompilerThread5" daemon [_thread_blocked, id=25316, stack(0x0000008ab1c00000,0x0000008ab1d00000)]
0x000001deeecb5800 JavaThread "C2 CompilerThread4" daemon [_thread_blocked, id=15592, stack(0x0000008ab1b00000,0x0000008ab1c00000)]
0x000001deeeca8800 JavaThread "C2 CompilerThread3" daemon [_thread_blocked, id=7648, stack(0x0000008ab1a00000,0x0000008ab1b00000)]
0x000001deeeca2800 JavaThread "C2 CompilerThread2" daemon [_thread_blocked, id=32860, stack(0x0000008ab1900000,0x0000008ab1a00000)]
0x000001deeec93800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=15684, stack(0x0000008ab1800000,0x0000008ab1900000)]
0x000001deeec92000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=13424, stack(0x0000008ab1700000,0x0000008ab1800000)]
0x000001deeec79800 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=19256, stack(0x0000008ab1600000,0x0000008ab1700000)]
0x000001deeec78800 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=30992, stack(0x0000008ab1500000,0x0000008ab1600000)]
0x000001deeec74800 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=11428, stack(0x0000008ab1400000,0x0000008ab1500000)]
0x000001deeec4a800 JavaThread "Attach Listener" daemon [_thread_blocked, id=18076, stack(0x0000008ab1300000,0x0000008ab1400000)]
0x000001deeebf2800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=28564, stack(0x0000008ab1200000,0x0000008ab1300000)]
0x000001deecece800 JavaThread "Finalizer" daemon [_thread_blocked, id=6584, stack(0x0000008ab1100000,0x0000008ab1200000)]
0x000001deeebe2000 JavaThread "Reference Handler" daemon [_thread_blocked, id=30456, stack(0x0000008ab1000000,0x0000008ab1100000)]
Other Threads:
=>0x000001ded177d800 VMThread [stack: 0x0000008ab0f00000,0x0000008ab1000000] [id=11572]
0x000001def0c20000 WatcherThread [stack: 0x0000008ab2500000,0x0000008ab2600000] [id=22148]
VM state:at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
[0x000001ded16ed270] Threads_lock - owner thread: 0x000001ded177d800
heap address: 0x0000000081200000, size: 2030 MB, Compressed Oops mode: 32-bit
Narrow klass base: 0x0000000000000000, Narrow klass shift: 3
Compressed class space size: 1073741824 Address: 0x0000000100000000
Heap:
PSYoungGen total 244224K, used 129333K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 55% used [0x00000000d5b80000,0x00000000dd9cd438,0x00000000e3f80000)
from space 10752K, 0% used [0x00000000e4a00000,0x00000000e4a00000,0x00000000e5480000)
to space 10752K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4a00000)
ParOldGen total 136192K, used 28542K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082ddf8c8,0x0000000089700000)
Metaspace used 67607K, capacity 74680K, committed 75008K, reserved 1114112K
class space used 8711K, capacity 10132K, committed 10240K, reserved 1048576K
Card table byte_map: [0x000001dee77d0000,0x000001dee7bd0000] byte_map_base: 0x000001dee73c7000
Marking Bits: (ParMarkBitMap*) 0x00000000622fd980
Begin Bits: [0x000001dee7e80000, 0x000001dee9e38000)
End Bits: [0x000001dee9e38000, 0x000001deebdf0000)
Polling page: 0x000001ded33e0000
CodeCache: size=245760Kb used=25097Kb max_used=25097Kb free=220662Kb
bounds [0x000001ded8410000, 0x000001ded9ca0000, 0x000001dee7410000]
total_blobs=12855 nmethods=12196 adapters=574
compilation: enabled
Compilation events (10 events):
Event: 1499.885 Thread 0x000001deeecf7800 12345 1 org.apache.kafka.clients.consumer.KafkaConsumer::poll (16 bytes)
Event: 1499.885 Thread 0x000001deeecf8800 nmethod 12344 0x000001ded9c8fed0 code [0x000001ded9c90140, 0x000001ded9c90ba0]
Event: 1499.886 Thread 0x000001deeecf7800 nmethod 12345 0x000001ded9c91510 code [0x000001ded9c91680, 0x000001ded9c91800]
Event: 1499.886 Thread 0x000001deeecf8800 12346 1 org.apache.kafka.clients.consumer.internals.KafkaConsumerMetrics::recordPollStart (46 bytes)
Event: 1499.886 Thread 0x000001deeecf5800 nmethod 12343 0x000001ded9c91890 code [0x000001ded9c91b20, 0x000001ded9c92960]
Event: 1499.886 Thread 0x000001deeecf8800 nmethod 12346 0x000001ded9c93910 code [0x000001ded9c93a80, 0x000001ded9c93ce0]
Event: 1502.753 Thread 0x000001deeecf7800 12347 1 org.apache.coyote.Request::getRequestProcessor (5 bytes)
Event: 1502.753 Thread 0x000001deeecf7800 nmethod 12347 0x000001ded9c93f10 code [0x000001ded9c94060, 0x000001ded9c94178]
Event: 1502.758 Thread 0x000001deeecf6000 12348 1 org.springframework.core.MethodParameter::getParameterAnnotation (47 bytes)
Event: 1502.758 Thread 0x000001deeecf6000 nmethod 12348 0x000001ded9c941d0 code [0x000001ded9c94340, 0x000001ded9c94530]
GC Heap History (10 events):
Event: 1451.740 GC heap before
{Heap before GC invocations=49 (full 21):
PSYoungGen total 244224K, used 4991K [0x00000000d5b80000, 0x00000000e5580000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 10752K, 46% used [0x00000000e4b00000,0x00000000e4fdfc28,0x00000000e5580000)
to space 11264K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4a80000)
ParOldGen total 136192K, used 28180K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d85198,0x0000000089700000)
Metaspace used 66446K, capacity 73258K, committed 73472K, reserved 1112064K
class space used 8590K, capacity 9980K, committed 9984K, reserved 1048576K
Event: 1451.914 GC heap after
Heap after GC invocations=49 (full 21):
PSYoungGen total 244224K, used 0K [0x00000000d5b80000, 0x00000000e5580000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 10752K, 0% used [0x00000000e4b00000,0x00000000e4b00000,0x00000000e5580000)
to space 11264K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4a80000)
ParOldGen total 136192K, used 27964K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d4f130,0x0000000089700000)
Metaspace used 66435K, capacity 73240K, committed 73472K, reserved 1112064K
class space used 8589K, capacity 9976K, committed 9984K, reserved 1048576K
}
Event: 1483.530 GC heap before
{Heap before GC invocations=50 (full 21):
PSYoungGen total 244224K, used 149310K [0x00000000d5b80000, 0x00000000e5580000, 0x0000000100000000)
eden space 233472K, 63% used [0x00000000d5b80000,0x00000000ded4f900,0x00000000e3f80000)
from space 10752K, 0% used [0x00000000e4b00000,0x00000000e4b00000,0x00000000e5580000)
to space 11264K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4a80000)
ParOldGen total 136192K, used 27964K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d4f130,0x0000000089700000)
Metaspace used 66640K, capacity 73442K, committed 73600K, reserved 1112064K
class space used 8613K, capacity 10020K, committed 10112K, reserved 1048576K
Event: 1483.538 GC heap after
Heap after GC invocations=50 (full 21):
PSYoungGen total 238592K, used 5036K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 5120K, 98% used [0x00000000e3f80000,0x00000000e446b238,0x00000000e4480000)
to space 10752K, 0% used [0x00000000e4a00000,0x00000000e4a00000,0x00000000e5480000)
ParOldGen total 136192K, used 27972K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d51130,0x0000000089700000)
Metaspace used 66640K, capacity 73442K, committed 73600K, reserved 1112064K
class space used 8613K, capacity 10020K, committed 10112K, reserved 1048576K
}
Event: 1483.538 GC heap before
{Heap before GC invocations=51 (full 22):
PSYoungGen total 238592K, used 5036K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 5120K, 98% used [0x00000000e3f80000,0x00000000e446b238,0x00000000e4480000)
to space 10752K, 0% used [0x00000000e4a00000,0x00000000e4a00000,0x00000000e5480000)
ParOldGen total 136192K, used 27972K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d51130,0x0000000089700000)
Metaspace used 66640K, capacity 73442K, committed 73600K, reserved 1112064K
class space used 8613K, capacity 10020K, committed 10112K, reserved 1048576K
Event: 1483.667 GC heap after
Heap after GC invocations=51 (full 22):
PSYoungGen total 238592K, used 0K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 5120K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4480000)
to space 10752K, 0% used [0x00000000e4a00000,0x00000000e4a00000,0x00000000e5480000)
ParOldGen total 136192K, used 28127K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d77eb0,0x0000000089700000)
Metaspace used 66630K, capacity 73424K, committed 73600K, reserved 1112064K
class space used 8611K, capacity 10016K, committed 10112K, reserved 1048576K
}
Event: 1492.464 GC heap before
{Heap before GC invocations=52 (full 22):
PSYoungGen total 238592K, used 143859K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 61% used [0x00000000d5b80000,0x00000000de7fce18,0x00000000e3f80000)
from space 5120K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4480000)
to space 10752K, 0% used [0x00000000e4a00000,0x00000000e4a00000,0x00000000e5480000)
ParOldGen total 136192K, used 28127K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d77eb0,0x0000000089700000)
Metaspace used 66971K, capacity 73792K, committed 73856K, reserved 1114112K
class space used 8656K, capacity 10093K, committed 10112K, reserved 1048576K
Event: 1492.472 GC heap after
Heap after GC invocations=52 (full 22):
PSYoungGen total 244224K, used 5356K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 10752K, 49% used [0x00000000e4a00000,0x00000000e4f3b048,0x00000000e5480000)
to space 10752K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4a00000)
ParOldGen total 136192K, used 28135K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d79eb0,0x0000000089700000)
Metaspace used 66971K, capacity 73792K, committed 73856K, reserved 1114112K
class space used 8656K, capacity 10093K, committed 10112K, reserved 1048576K
}
Event: 1492.472 GC heap before
{Heap before GC invocations=53 (full 23):
PSYoungGen total 244224K, used 5356K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 10752K, 49% used [0x00000000e4a00000,0x00000000e4f3b048,0x00000000e5480000)
to space 10752K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4a00000)
ParOldGen total 136192K, used 28135K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082d79eb0,0x0000000089700000)
Metaspace used 66971K, capacity 73792K, committed 73856K, reserved 1114112K
class space used 8656K, capacity 10093K, committed 10112K, reserved 1048576K
Event: 1492.655 GC heap after
Heap after GC invocations=53 (full 23):
PSYoungGen total 244224K, used 0K [0x00000000d5b80000, 0x00000000e5480000, 0x0000000100000000)
eden space 233472K, 0% used [0x00000000d5b80000,0x00000000d5b80000,0x00000000e3f80000)
from space 10752K, 0% used [0x00000000e4a00000,0x00000000e4a00000,0x00000000e5480000)
to space 10752K, 0% used [0x00000000e3f80000,0x00000000e3f80000,0x00000000e4a00000)
ParOldGen total 136192K, used 28542K [0x0000000081200000, 0x0000000089700000, 0x00000000d5b80000)
object space 136192K, 20% used [0x0000000081200000,0x0000000082ddf8c8,0x0000000089700000)
Metaspace used 66961K, capacity 73774K, committed 73856K, reserved 1114112K
class space used 8654K, capacity 10089K, committed 10112K, reserved 1048576K
}
Deoptimization events (0 events):
No events
Classes redefined (10 events):
Event: 2170.327 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=15
Event: 2170.396 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=14
Event: 2170.460 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=13
Event: 2170.519 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=12
Event: 2170.577 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=11
Event: 2170.638 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=10
Event: 2170.704 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=9
Event: 2170.771 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=8
Event: 2170.841 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=7
Event: 2170.910 Thread 0x000001ded177d800 redefined class name=com.lh.controller.VoteController, count=6
Internal exceptions (10 events):
Event: 1491.925 Thread 0x000001def4151000 Exception <a 'java/net/SocketException': Software caused connection abort: socket write error> (0x00000000ddd1ee90) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 737]
Event: 1491.925 Thread 0x000001def4151000 Exception <a 'java/net/SocketException': Software caused connection abort: recv failed> (0x00000000ddd1f350) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 737]
Event: 1491.927 Thread 0x000001def4151000 Exception <a 'java/net/SocketException': Software caused connection abort: recv failed> (0x00000000ddd20b70) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 737]
Event: 1491.928 Thread 0x000001def4151000 Exception <a 'java/net/SocketException': Software caused connection abort: recv failed> (0x00000000ddd22390) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 737]
Event: 1491.929 Thread 0x000001def4151000 Exception <a 'java/net/SocketException': Software caused connection abort: socket write error> (0x00000000ddd23988) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 737]
Event: 1491.930 Thread 0x000001def4151000 Exception <a 'java/net/SocketException': Software caused connection abort: recv failed> (0x00000000ddd23e48) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 737]
Event: 1492.232 Thread 0x000001def3bcd000 Exception <a 'java/lang/InterruptedException': sleep interrupted> (0x00000000de6d90e0) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jvm.cpp, line 3359]
Event: 1493.074 Thread 0x000001def4155800 Exception <a 'java/io/FileNotFoundException'> (0x00000000d5d58770) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 1494.277 Thread 0x000001def4155800 Exception <a 'java/io/FileNotFoundException'> (0x00000000d8ce6df0) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 1494.321 Thread 0x000001def4155800 Exception <a 'java/io/FileNotFoundException'> (0x00000000d8e4edb8) thrown at [C:\jenkins\workspace\8-2-build-windows-x64-cygwin\jdk8u371\3355\hotspot\src\share\vm\prims\jni.cpp, line 710]
Events (10 events):
Event: 2170.640 Executing VM operation: RedefineClasses done
Event: 2170.641 Executing VM operation: RedefineClasses
Event: 2170.706 Executing VM operation: RedefineClasses done
Event: 2170.707 Executing VM operation: RedefineClasses
Event: 2170.773 Executing VM operation: RedefineClasses done
Event: 2170.774 Executing VM operation: RedefineClasses
Event: 2170.844 Executing VM operation: RedefineClasses done
Event: 2170.845 Executing VM operation: RedefineClasses
Event: 2170.912 Executing VM operation: RedefineClasses done
Event: 2170.915 Executing VM operation: GetOrSetLocal
Dynamic libraries:
0x00007ff739000000 - 0x00007ff73904a000 D:\Devapp\Java\jdk-1.8\bin\java.exe
0x00007ffb5d970000 - 0x00007ffb5db68000 C:\Windows\SYSTEM32\ntdll.dll
0x00007ffb5cd30000 - 0x00007ffb5cdf2000 C:\Windows\System32\KERNEL32.DLL
0x00007ffb5b310000 - 0x00007ffb5b60e000 C:\Windows\System32\KERNELBASE.dll
0x00007ffb443c0000 - 0x00007ffb443d7000 C:\InetPub\ftproot\Tipray\Ldterm\ghijt64.DLL
0x00007ffb5ca20000 - 0x00007ffb5cad1000 C:\Windows\System32\ADVAPI32.dll
0x00007ffb5d6d0000 - 0x00007ffb5d76e000 C:\Windows\System32\msvcrt.dll
0x00007ffb5d630000 - 0x00007ffb5d6cf000 C:\Windows\System32\sechost.dll
0x00007ffb5cae0000 - 0x00007ffb5cc03000 C:\Windows\System32\RPCRT4.dll
0x00007ffb5b1a0000 - 0x00007ffb5b1c7000 C:\Windows\System32\bcrypt.dll
0x00007ffb436b0000 - 0x00007ffb436f1000 C:\Inetpub\ftproot\Tipray\LdTerm\LdUserInjectDll64.dll
0x00007ffb5bd20000 - 0x00007ffb5bebd000 C:\Windows\System32\USER32.dll
0x00007ffb5b810000 - 0x00007ffb5b832000 C:\Windows\System32\win32u.dll
0x00007ffb5cf10000 - 0x00007ffb5cf3b000 C:\Windows\System32\GDI32.dll
0x00007ffb5b010000 - 0x00007ffb5b127000 C:\Windows\System32\gdi32full.dll
0x00007ffb5b610000 - 0x00007ffb5b6ad000 C:\Windows\System32\msvcp_win.dll
0x00007ffb5b890000 - 0x00007ffb5b990000 C:\Windows\System32\ucrtbase.dll
0x00007ffb4d2d0000 - 0x00007ffb4d56a000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_60b8b9eb71f62e16\COMCTL32.dll
0x00007ffb44140000 - 0x00007ffb443b7000 C:\InetPub\ftproot\Tipray\Ldterm\LdHook64.dll
0x00007ffb5bad0000 - 0x00007ffb5bbfb000 C:\Windows\System32\ole32.dll
0x00007ffb5bf50000 - 0x00007ffb5c2a3000 C:\Windows\System32\combase.dll
0x00007ffb5bc00000 - 0x00007ffb5bc08000 C:\Windows\System32\PSAPI.DLL
0x00007ffb49490000 - 0x00007ffb49534000 C:\Windows\SYSTEM32\WINSPOOL.DRV
0x00007ffb5ce60000 - 0x00007ffb5cf0d000 C:\Windows\System32\shcore.dll
0x00007ffb5a990000 - 0x00007ffb5a99c000 C:\Windows\SYSTEM32\CRYPTBASE.DLL
0x00007ffb5d190000 - 0x00007ffb5d1bf000 C:\Windows\System32\IMM32.DLL
0x00007ffb44470000 - 0x00007ffb444c7000 C:\Inetpub\ftproot\Tipray\LdTerm\ghhlp64.dll
0x00007ffb44460000 - 0x00007ffb44470000 C:\InetPub\ftproot\Tipray\Ldterm\HookDataInteractionx64.dll
0x00007ffb43e40000 - 0x00007ffb43eb2000 C:\InetPub\ftproot\Tipray\Ldterm\LdSmartEnc64.dll
0x00007ffb43e30000 - 0x00007ffb43e3b000 C:\Windows\SYSTEM32\FLTLIB.DLL
0x00007ffb43700000 - 0x00007ffb4371f000 C:\Inetpub\ftproot\Tipray\LdTerm\HookCreateProcessInternal64.dll
0x00007ffb4d020000 - 0x00007ffb4d076000 C:\Inetpub\ftproot\Tipray\LdTerm\MonFileOp64.dll
0x00007ffb5c2b0000 - 0x00007ffb5ca1d000 C:\Windows\System32\SHELL32.dll
0x00007ffb5cf40000 - 0x00007ffb5cf95000 C:\Windows\System32\SHLWAPI.dll
0x00007ffb4d600000 - 0x00007ffb4d61b000 D:\Devapp\Java\jdk-1.8\jre\bin\vcruntime140.dll
0x00007ffb54610000 - 0x00007ffb5461c000 D:\Devapp\Java\jdk-1.8\jre\bin\vcruntime140_1.dll
0x00007ffb31b80000 - 0x00007ffb31c0e000 D:\Devapp\Java\jdk-1.8\jre\bin\msvcp140.dll
0x0000000061ad0000 - 0x0000000062377000 D:\Devapp\Java\jdk-1.8\jre\bin\server\jvm.dll
0x00007ffb4d5f0000 - 0x00007ffb4d5f9000 C:\Windows\SYSTEM32\WSOCK32.dll
0x00007ffb546e0000 - 0x00007ffb546ea000 C:\Windows\SYSTEM32\VERSION.dll
0x00007ffb5ba60000 - 0x00007ffb5bacb000 C:\Windows\System32\WS2_32.dll
0x00007ffb4e450000 - 0x00007ffb4e477000 C:\Windows\SYSTEM32\WINMM.dll
0x00007ffb58f20000 - 0x00007ffb58f32000 C:\Windows\SYSTEM32\kernel.appcore.dll
0x00007ffb4d0d0000 - 0x00007ffb4d0e0000 D:\Devapp\Java\jdk-1.8\jre\bin\verify.dll
0x00007ffb4cda0000 - 0x00007ffb4cdcb000 D:\Devapp\Java\jdk-1.8\jre\bin\java.dll
0x00007ffb572f0000 - 0x00007ffb57326000 D:\Devapp\Java\jdk-1.8\jre\bin\jdwp.dll
0x00007ffb4a0c0000 - 0x00007ffb4a0c9000 D:\Devapp\Java\jdk-1.8\jre\bin\npt.dll
0x00007ffb3dfb0000 - 0x00007ffb3dfe4000 D:\Devapp\Java\jdk-1.8\jre\bin\instrument.dll
0x00007ffb4c960000 - 0x00007ffb4c978000 D:\Devapp\Java\jdk-1.8\jre\bin\zip.dll
0x00007ffb590b0000 - 0x00007ffb59854000 C:\Windows\SYSTEM32\windows.storage.dll
0x00007ffb5aa40000 - 0x00007ffb5aa6e000 C:\Windows\SYSTEM32\Wldp.dll
0x00007ffb5b990000 - 0x00007ffb5ba5d000 C:\Windows\System32\OLEAUT32.dll
0x00007ffb5af40000 - 0x00007ffb5af64000 C:\Windows\SYSTEM32\profapi.dll
0x00007ffb4a000000 - 0x00007ffb4a00a000 D:\Devapp\Java\jdk-1.8\jre\bin\dt_socket.dll
0x00007ffb5a7a0000 - 0x00007ffb5a80a000 C:\Windows\system32\mswsock.dll
0x00007ffb3cd30000 - 0x00007ffb3cd4c000 D:\Devapp\Java\jdk-1.8\jre\bin\net.dll
0x00007ffb5a480000 - 0x00007ffb5a54a000 C:\Windows\SYSTEM32\DNSAPI.dll
0x00007ffb5a430000 - 0x00007ffb5a46b000 C:\Windows\SYSTEM32\IPHLPAPI.DLL
0x00007ffb5bf40000 - 0x00007ffb5bf48000 C:\Windows\System32\NSI.dll
0x00007ffb53a80000 - 0x00007ffb53a8a000 C:\Windows\System32\rasadhlp.dll
0x00007ffb53060000 - 0x00007ffb530e0000 C:\Windows\System32\fwpuclnt.dll
0x00007ffb4ca50000 - 0x00007ffb4ca5d000 D:\Devapp\Java\jdk-1.8\jre\bin\management.dll
0x00007ffb34be0000 - 0x00007ffb34bf3000 D:\Devapp\Java\jdk-1.8\jre\bin\nio.dll
0x00007ffb5a9a0000 - 0x00007ffb5a9b8000 C:\Windows\SYSTEM32\CRYPTSP.dll
0x00007ffb5a050000 - 0x00007ffb5a084000 C:\Windows\system32\rsaenh.dll
0x00007ffb5af00000 - 0x00007ffb5af2e000 C:\Windows\SYSTEM32\USERENV.dll
0x00007ffb5b1d0000 - 0x00007ffb5b252000 C:\Windows\System32\bcryptprimitives.dll
0x00007ffb56ff0000 - 0x00007ffb57007000 C:\Windows\SYSTEM32\dhcpcsvc6.DLL
0x00007ffb56e10000 - 0x00007ffb56e2d000 C:\Windows\SYSTEM32\dhcpcsvc.DLL
0x00007ffb41fc0000 - 0x00007ffb41fd7000 C:\Windows\system32\napinsp.dll
0x00007ffb41fa0000 - 0x00007ffb41fbb000 C:\Windows\system32\pnrpnsp.dll
0x00007ffb41f80000 - 0x00007ffb41f95000 C:\Windows\system32\wshbth.dll
0x00007ffb571a0000 - 0x00007ffb571bd000 C:\Windows\system32\NLAapi.dll
0x00007ffb41f20000 - 0x00007ffb41f32000 C:\Windows\System32\winrnr.dll
0x00007ffb4a010000 - 0x00007ffb4a035000 D:\Devapp\Java\jdk-1.8\jre\bin\sunec.dll
0x00007ffb4ac40000 - 0x00007ffb4ac4d000 D:\Devapp\Java\jdk-1.8\jre\bin\sunmscapi.dll
0x00007ffb5b6b0000 - 0x00007ffb5b80c000 C:\Windows\System32\CRYPT32.dll
0x00007ffb5aab0000 - 0x00007ffb5aad7000 C:\Windows\SYSTEM32\ncrypt.dll
0x00007ffb5aa70000 - 0x00007ffb5aaab000 C:\Windows\SYSTEM32\NTASN1.dll
0x00007ffb58a80000 - 0x00007ffb58c64000 C:\Windows\SYSTEM32\dbghelp.dll
VM Arguments:
jvm_args: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:64387,suspend=y,server=n -XX:TieredStopAtLevel=1 -Xverify:none -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dmanagement.endpoints.jmx.exposure.include=* -javaagent:C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2023.2\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8
java_command: com.lh.VoteSystemApplication
java_class_path (initial): D:\Devapp\Java\jdk-1.8\jre\lib\charsets.jar;D:\Devapp\Java\jdk-1.8\jre\lib\deploy.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\access-bridge-64.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\cldrdata.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\dnsns.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\jaccess.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\jfxrt.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\localedata.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\nashorn.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\sunec.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\sunjce_provider.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\sunmscapi.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\sunpkcs11.jar;D:\Devapp\Java\jdk-1.8\jre\lib\ext\zipfs.jar;D:\Devapp\Java\jdk-1.8\jre\lib\javaws.jar;D:\Devapp\Java\jdk-1.8\jre\lib\jce.jar;D:\Devapp\Java\jdk-1.8\jre\lib\jfr.jar;D:\Devapp\Java\jdk-1.8\jre\lib\jfxswt.jar;D:\Devapp\Java\jdk-1.8\jre\lib\jsse.jar;D:\Devapp\Java\jdk-1.8\jre\lib\management-agent.jar;D:\Devapp\Java\jdk-1.8\jre\lib\plugin.jar;D:\Devapp\Java\jdk-1.8\jre\lib\resources.jar;D:\Devapp\Java\jdk-1.8\jre\lib\rt.jar;C:\Users\Administrator\Desktop\project\vote\vote_system\target\classes;D:\repository\org\springframework\boot\spring-boot-starter-web\2.4.2\spring-boot-starter-web-2.4.2.jar;D:\repository\org\springframework\boot\spring-boot-starter\2.4.2\spring-boot-starter-2.4.2.jar;D:\repository\org\springframework\boot\spring-boot-starter-logging\2.4.2\spring-boot-starter-logging-2.4.2.jar;D:\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;D:\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;D:\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;D:\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\repository\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;D:\repository
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=D:\Devapp\Java\jdk-1.8
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Devapp\Java\jdk-1.8\bin;D:\Devapp\go1.21.13.windows-amd64\go\bin;D:\Devapp\Git\cmd;D:\Devapp\node\;D:\Devapp\Bandizip\;D:\Devapp\Maven\apache-maven-3.9.2\bin;D:\Devapp\Memurai\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;D:\Devapp\VSCode\bin;C:\Users\Administrator\AppData\Roaming\npm
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 10 , 64 bit Build 19041 (10.0.19041.5198)
CPU:total 16 (initial active 16) (8 cores per cpu, 2 threads per core) family 6 model 45 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, aes, clmul, ht, tsc, tscinvbit, tscinv
Memory: 4k page, physical 8307720k(752056k free), swap 18891592k(3124708k free)
vm_info: Java HotSpot(TM) 64-Bit Server VM (25.371-b11) for windows-amd64 JRE (1.8.0_371-b11), built on Mar 17 2023 04:03:45 by "java_re" with MS VC++ 17.1 (VS2022)
time: Wed Dec 18 21:25:20 2024
timezone: Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
elapsed time: 2171.002354 seconds (0d 0h 36m 11s)

118
pom.xml

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lh</groupId>
<artifactId>vote_invest</artifactId>
<version>0.0.2</version>
<name>vote_invest</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.4.2</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!-- kafka -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- Apache HttpClient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

13
src/main/java/com/lh/VoteSystemApplication.java

@ -0,0 +1,13 @@
package com.lh;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = "com.lh")
public class VoteSystemApplication {
public static void main(String[] args) {
SpringApplication.run(VoteSystemApplication.class, args);
}
}

17
src/main/java/com/lh/bean/Candidate.java

@ -0,0 +1,17 @@
package com.lh.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Candidate {
private Long id;//ID
private String jwCode;//精网号
private String name;//候选人名称
private String avatar;//头像
private Integer votes = 0;//票数
private boolean isVoted;//是否被当前用户投票
}

82
src/main/java/com/lh/bean/RespBean.java

@ -0,0 +1,82 @@
package com.lh.bean;
public class RespBean {
//状态码 10000-成功 10001-失败
private Integer code;
//返回的附件信息
private String msg;
//返回的数据
private Object data;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public static RespBean ok() {
RespBean respBean = new RespBean();
respBean.setCode(10000);
return respBean;
}
public static RespBean ok(String msg) {
RespBean respBean = new RespBean();
respBean.setCode(10000);
respBean.setMsg(msg);
return respBean;
}
public static RespBean ok(String msg, Object data) {
RespBean respBean = new RespBean();
respBean.setCode(10000);
respBean.setMsg(msg);
respBean.setData(data);
return respBean;
}
public static RespBean error() {
RespBean respBean = new RespBean();
respBean.setCode(10001);
return respBean;
}
public static RespBean error(String msg) {
RespBean respBean = new RespBean();
respBean.setCode(10001);
respBean.setMsg(msg);
return respBean;
}
public static RespBean error(String msg, Object data) {
RespBean respBean = new RespBean();
respBean.setCode(10001);
respBean.setMsg(msg);
respBean.setData(data);
return respBean;
}
}

15
src/main/java/com/lh/bean/VoteMessage.java

@ -0,0 +1,15 @@
package com.lh.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VoteMessage {
private String voterJwcode; // 投票人IDJWCode
private String candidateJwcode; // 候选人IDJWCode
private String voterName; // 投票人姓名
private String voteTime; // 投票时间
}

18
src/main/java/com/lh/bean/Voter.java

@ -0,0 +1,18 @@
package com.lh.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Voter {
private Long id;//投票人ID
private String jwCode;//投票人Jwcode
private String name;//投票人姓名
private LocalDateTime voteTime;//投票时间
private String candidateJwCode;//被投票人JwCode
}

13
src/main/java/com/lh/bean/dto/TokenDTO.java

@ -0,0 +1,13 @@
package com.lh.bean.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TokenDTO {
private int jwcode;
private String username;
}

84
src/main/java/com/lh/config/CandidateCacheRepository.java

@ -0,0 +1,84 @@
package com.lh.config;
import com.lh.bean.Candidate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Repository;
import javax.annotation.PostConstruct;
import java.util.Set;
@Repository
public class CandidateCacheRepository {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@PostConstruct
public void init() {
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate.afterPropertiesSet();
}
// 保存候选人信息到 Redis
// 保存候选人信息到 Redis
public void saveCandidate(Candidate candidate) {
String key = "candidate:" + candidate.getJwCode();
// 确保所有值都是字符串类型
redisTemplate.opsForHash().put(key, "id", String.valueOf(candidate.getId()));
redisTemplate.opsForHash().put(key, "jwCode", candidate.getJwCode());
redisTemplate.opsForHash().put(key, "name", candidate.getName());
redisTemplate.opsForHash().put(key, "avatar", candidate.getAvatar());
redisTemplate.opsForHash().put(key, "votes", String.valueOf(candidate.getVotes()));
// 更新 ZSET
redisTemplate.opsForZSet().add("candidate:votes", candidate.getJwCode(), candidate.getVotes());
}
// 获取候选人详细信息
public Candidate getCandidate(String jwCode) {
String key = "candidate:" + jwCode;
Candidate candidate = new Candidate();
Object idObj = redisTemplate.opsForHash().get(key, "id");
if (idObj != null) {
candidate.setId(Long.parseLong(idObj.toString()));
}
candidate.setJwCode((String) redisTemplate.opsForHash().get(key, "jwCode"));
candidate.setName((String) redisTemplate.opsForHash().get(key, "name"));
candidate.setAvatar((String) redisTemplate.opsForHash().get(key, "avatar"));
Object votesObj = redisTemplate.opsForHash().get(key, "votes");
if (votesObj != null) {
candidate.setVotes(Integer.parseInt(votesObj.toString()));
}
//如果idjwCodenameavatarvotes都为空则返回null
if (candidate.getId() == null && candidate.getJwCode() == null && candidate.getName() == null && candidate.getAvatar() == null) {
return null;
}
return candidate;
}
// 获取所有候选人的 jwCode 按投票数排序
public Set<Object> getCandidateJwCodesByVotes() {
return redisTemplate.opsForZSet().reverseRange("candidate:votes", 0, -1);
}
// 删除 Redis 中所有候选人数据
public void deleteAllCandidatesFromCache() {
Set<Object> jwCodes = redisTemplate.opsForZSet().range("candidate:votes", 0, -1);
if (jwCodes != null) {
for (Object jwCode : jwCodes) {
redisTemplate.delete("candidate:" + jwCode);
}
}
redisTemplate.delete("candidate:votes");
}
}

22
src/main/java/com/lh/config/ExceptionHandler.java

@ -0,0 +1,22 @@
package com.lh.config;
import com.lh.bean.RespBean;
import com.lh.exception.MyException;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Configuration
@RestControllerAdvice
public class ExceptionHandler {
@org.springframework.web.bind.annotation.ExceptionHandler(MyException.class)
public RespBean myException(MyException e) {
e.printStackTrace();
return RespBean.error(e.getMessage());
}
@org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
public RespBean exception(Exception e) {
e.printStackTrace();
return RespBean.error("未知错误,请联系管理员");
}
}

37
src/main/java/com/lh/config/RedisConfig.java

@ -0,0 +1,37 @@
package com.lh.config;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@EnableCaching
public class RedisConfig {
@Bean
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory connectionFactory) {
return new StringRedisTemplate(connectionFactory);
}
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
// 设置 key 的序列化方式
template.setKeySerializer(new StringRedisSerializer());
// 设置 hash key hash value 的序列化方式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(new StringRedisSerializer());
// 设置 value 的序列化方式
template.setValueSerializer(new StringRedisSerializer());
return template;
}
}

49
src/main/java/com/lh/controller/VoteController.java

@ -0,0 +1,49 @@
package com.lh.controller;
import com.lh.bean.RespBean;
import com.lh.exception.MyException;
import com.lh.service.VoteService;
import com.lh.until.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.net.URLEncoder;
@CrossOrigin
@RestController
@RequestMapping
public class VoteController {
@Autowired
private VoteService voteService;
//投票.
@PostMapping("/vote")
public RespBean vote(@RequestParam("code") String candidateJwcode, @RequestParam("token") String token) throws Exception {
token = "token=" + URLEncoder.encode(token,"UTF-8");
Utils utils = new Utils();
String voterJwcode = String.valueOf(utils.getJwcode(token));
String voterName = utils.getUsername(token);
Integer result =voteService.insertVote(voterJwcode, candidateJwcode, voterName);
return RespBean.ok("投票成功!今日还可以投" + result + "次");
}
//获取所有候选人
@PostMapping ("/getCandidates")
public RespBean getCandidates(@RequestBody String token) throws IOException {
//System.out.println(token);
////将token的值分离出来
//int startIndex = token.indexOf('=') + 1; // 找到等号的位置并移动到等号后一位
//String tokenValue = token.substring(startIndex); // 提取等号后面的部分
token = "token=" + URLEncoder.encode(token.substring(10, token.length() - 2), "UTF-8");
System.out.println(token);
String voterJwcode = String.valueOf(new Utils().getJwcode(token));
return RespBean.ok("获取成功",voteService.getCandidates(voterJwcode));
}
//获取某个候选人的被投票记录
@GetMapping("/getVotesByCandidate/{candidateJwcode}")
public RespBean getVotesByCandidate(@PathVariable("candidateJwcode") String candidateJwcode) throws MyException {
return RespBean.ok("获取成功",voteService.getVotesByCandidate(candidateJwcode));
}
}

7
src/main/java/com/lh/exception/MyException.java

@ -0,0 +1,7 @@
package com.lh.exception;
public class MyException extends Exception{
public MyException(String msg){
super(msg);
}
}

17
src/main/java/com/lh/mapper/CandidatesMapper.java

@ -0,0 +1,17 @@
package com.lh.mapper;
import com.lh.bean.Candidate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CandidatesMapper {
//获取所有候选人
List<Candidate> getCandidates();
//通过精网号搜索候选人
Candidate getByCandidateJwcode(@Param("jwcode") String jwcode);
//候选人票数+1
boolean addVotes(@Param("jwcode") String jwcode);
}

17
src/main/java/com/lh/mapper/VoterMapper.java

@ -0,0 +1,17 @@
package com.lh.mapper;
import com.lh.bean.Voter;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface VoterMapper {
// 查询用户今日投票信息
List<Voter> countVotesToday(@Param("jwcode") String jwcode);
//插入投票记录
void insertVote(@Param("jwcode") String jwcode, @Param("candidateJwcode") String candidateJwcode,@Param("name") String namne);
//根据候选人的jwcode查询投票记录
List<Voter> getVotesByCandidate(@Param("candidateJwcode") String candidateJwcode);
}

74
src/main/java/com/lh/service/VoteConsumer.java

@ -0,0 +1,74 @@
package com.lh.service;
import com.lh.bean.Candidate;
import com.lh.exception.MyException;
import com.lh.mapper.CandidatesMapper;
import com.lh.mapper.VoterMapper;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;
@Service
@EnableKafka
public class VoteConsumer {
@Autowired
private VoterMapper voterMapper;
@Autowired
private CandidatesMapper candidatesMapper;
@Autowired
private StringRedisTemplate redisTemplate;
@KafkaListener(topics = "vote-topic", groupId = "vote-group")
public void handleVoteMessage(ConsumerRecord<String, String> record) throws MyException {
String message = record.value();
// 将消息分割为投票信息
String[] parts = message.split(",");
String voterJwcode = parts[0];
String candidateJwcode = parts[1];
String voterName = parts[2];
String voteTime = parts[3];
// 处理投票
processVote(voterJwcode, candidateJwcode, voterName, voteTime);
}
private boolean processVote(String voterJwcode, String candidateJwcode, String voterName, String voteTime) throws MyException {
// 获取候选人信息
Candidate candidate = candidatesMapper.getByCandidateJwcode(candidateJwcode);
// 2. 获取候选人信息
if (candidate == null) {
throw new MyException("候选人不存在!");
}
// 3. 检查用户是否已经为该候选人投过票
//List<Voter> hasVotes = voterMapper.countVotesToday(voterJwcode);
////遍历列表判断是否有记录
//boolean flag = true;
//for (Voter vote : hasVotes) {
// if (vote.getCandidateJwCode().equals(candidateJwcode)) {
// flag = false;
// }
//}
//if (!flag){
// throw new MyException("已投票,可以选择其他人试试哦~");
//}
// 4. 增加候选人票数
if (!candidatesMapper.addVotes(candidateJwcode)) {
throw new MyException ("候选人票数更新失败,请联系管理员!");
}
// 5. 插入投票记录
voterMapper.insertVote(voterJwcode, candidateJwcode, voterName);
System.out.println("投票成功!用户:" + voterJwcode + " 投给了 " + candidateJwcode);
return true;
}
}

26
src/main/java/com/lh/service/VoteProducer.java

@ -0,0 +1,26 @@
package com.lh.service;
import com.lh.bean.VoteMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
@Service
public class VoteProducer {
private static final String TOPIC = "vote-topic"; // Kafka topic
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
// 发送投票消息
public void sendVoteMessage(VoteMessage voteMessage) {
String message = String.format("%s,%s,%s,%s",
voteMessage.getVoterJwcode(),
voteMessage.getCandidateJwcode(),
voteMessage.getVoterName(),
voteMessage.getVoteTime());
kafkaTemplate.send(TOPIC, message); // 将投票信息发送到Kafka
}
}

16
src/main/java/com/lh/service/VoteService.java

@ -0,0 +1,16 @@
package com.lh.service;
import com.lh.bean.Candidate;
import com.lh.bean.Voter;
import com.lh.exception.MyException;
import java.util.List;
public interface VoteService {
//投票
Integer insertVote(String voterJwcode, String candidateJwcode, String voterName) throws MyException;
//获取所有候选人
List<Candidate> getCandidates(String VoterJwcode);
//获取某个候选人的被投票记录
List<Voter> getVotesByCandidate(String candidateJwcode) throws MyException;
}

164
src/main/java/com/lh/service/VoteServiceImpl.java

@ -0,0 +1,164 @@
package com.lh.service;
import com.lh.bean.Candidate;
import com.lh.bean.VoteMessage;
import com.lh.bean.Voter;
import com.lh.config.CandidateCacheRepository;
import com.lh.exception.MyException;
import com.lh.mapper.CandidatesMapper;
import com.lh.mapper.VoterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.sql.Timestamp;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Service
public class VoteServiceImpl implements VoteService {
private static final Logger logger = LoggerFactory.getLogger(VoteServiceImpl.class);
@Autowired
private VoterMapper voterMapper;
@Autowired
private CandidatesMapper candidatesMapper;
@Value("${vote.limit.daily}")
private int dailyVoteLimit; // 每日投票次数限制
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private VoteProducer voteProducer;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private CandidateCacheRepository candidateCacheRepository;
// 初始化时加载所有候选人数据并缓存到 Redis
@PostConstruct
public void initCandidatesCache() throws MyException {
try {
List<Candidate> candidates = candidatesMapper.getCandidates();
for (Candidate candidate : candidates) {
candidateCacheRepository.saveCandidate(candidate);
}
logger.info("Candidate cache initialized successfully.");
} catch (Exception e) {
logger.error("Failed to initialize candidate cache.", e);
throw new MyException("初始化候选人缓存失败");
}
}
// 投票
@Override
@Transactional(rollbackFor = Exception.class)
public Integer insertVote(String voterJwcode, String candidateJwcode, String voterName) throws MyException {
Candidate candidate = candidateCacheRepository.getCandidate(candidateJwcode);
System.out.println(candidate);
if (candidateCacheRepository.getCandidate(candidateJwcode) == null) {
throw new MyException("候选人不存在");
}
String redisKey = "vote_count:" + voterJwcode + ":" + LocalDateTime.now().toLocalDate();
String currentVoteCountStr = stringRedisTemplate.opsForValue().get(redisKey);
int voteCountToday = currentVoteCountStr == null ? 0 : Integer.parseInt(currentVoteCountStr);
if (voteCountToday >= dailyVoteLimit) {
throw new MyException("今日投票次数已达上限");
}
String voteStatusKey = "vote_status:" + voterJwcode + ":" + candidateJwcode;
Boolean hasVoted = stringRedisTemplate.hasKey(voteStatusKey);
if (hasVoted != null && hasVoted) {
throw new MyException("您已经为该候选人投票,不能重复投票");
}
String candidateKey = "candidate:" + candidateJwcode;
// 使用 Redis Hash 增加候选人投票数
redisTemplate.opsForHash().increment(candidateKey, "votes", 1);
// 使用 Redis ZSet 增加候选人投票数
redisTemplate.opsForZSet().incrementScore("candidate:votes", candidateJwcode, 1);
// 更新 Redis 中的投票次数
redisTemplate.opsForValue().increment(redisKey, 1);
// 设置 Redis 键的过期时间为当天的23:59:59
LocalDateTime now = LocalDateTime.now();
LocalDateTime endOfDay = now.toLocalDate().atTime(23, 59, 59);
long secondsUntilEndOfDay = Duration.between(now, endOfDay).getSeconds();
// 更新投票次数的过期时间
redisTemplate.expire(redisKey, secondsUntilEndOfDay, TimeUnit.SECONDS);
// 更新投票重复键
stringRedisTemplate.opsForValue().set(voteStatusKey, "true", secondsUntilEndOfDay, TimeUnit.SECONDS);
// 将投票请求发送到 Kafka 消息队列
voteProducer.sendVoteMessage(new VoteMessage(voterJwcode, candidateJwcode, voterName, Timestamp.valueOf(LocalDateTime.now()).toString()));
return dailyVoteLimit - voteCountToday - 1;
}
// 获取所有候选人
@Override
public List<Candidate> getCandidates(String voterJwcode) {
List<Candidate> candidateList = new ArrayList<>();
try {
Set<Object> jwCodes = candidateCacheRepository.getCandidateJwCodesByVotes();
List<String> jwCodeList = new ArrayList<>();
for (Object jwCode : jwCodes) {
jwCodeList.add(jwCode.toString());
}
for (String jwCode : jwCodeList) {
Candidate candidate = candidateCacheRepository.getCandidate(jwCode);
if (candidate != null) {
candidateList.add(candidate);
}
}
}catch(Exception e){
//如果缓存中获取候选人失败则从数据库中获取候选人列表
candidateList = candidatesMapper.getCandidates();
}
// 插入投票记录 List 插入当日是否投过票的状态
markVotedStatus(voterJwcode, candidateList);
return candidateList;
}
// 获取候选人被投票记录
@Override
public List<Voter> getVotesByCandidate(String candidateJwcode) throws MyException {
try {
return voterMapper.getVotesByCandidate(candidateJwcode);
} catch (Exception e) {
throw new MyException("获取候选人投票记录失败");
}
}
private void markVotedStatus(String voterJwcode, List<Candidate> candidateList) {
String voteStatusKeyPrefix = "vote_status:" + voterJwcode + ":";
Set<String> votedKeys = stringRedisTemplate.keys(voteStatusKeyPrefix + "*");
if (votedKeys != null) {
for (Candidate candidate : candidateList) {
String fullKey = voteStatusKeyPrefix + candidate.getJwCode();
if (votedKeys.contains(fullKey)) {
candidate.setVoted(true);
}
}
}
}
}

72
src/main/java/com/lh/until/Utils.java

@ -0,0 +1,72 @@
package com.lh.until;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.lh.bean.dto.TokenDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@Slf4j
@Component
public class Utils {
@Resource
private StringRedisTemplate stringRedisTemplate;
// 获取token中的信息
public TokenDTO analysisToken(String token) throws IOException {
// 编码Token
String url = "http://39.101.133.168:8828/hljw/api/v2/member/info";
// 创建HttpClient实例
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// 创建POST请求
HttpPost postRequest = new HttpPost(url);
postRequest.setHeader("Content-Type", "application/x-www-form-urlencoded");
System.out.println(token);
// 设置请求体参数
StringEntity entity = new StringEntity(token, ContentType.APPLICATION_FORM_URLENCODED);
postRequest.setEntity(entity);
// 发送请求并获取响应
try (CloseableHttpResponse response = httpClient.execute(postRequest)) {
int responseCode = response.getStatusLine().getStatusCode(); // 获取状态码
// 检查响应状态
if (responseCode == 200) {
// 读取响应体
String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
// 使用Jackson解析JSON响应体
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonResponse = objectMapper.readTree(responseBody);
JsonNode dataNode = jsonResponse.get("data");
TokenDTO tokenDTO = new TokenDTO();
tokenDTO.setJwcode(dataNode.get("jwcode").asInt());
tokenDTO.setUsername(dataNode.get("username").asText());
return tokenDTO;
}
else {
throw new RuntimeException("Failed : HTTP error code : " + responseCode);
}
}
}
}
// 获取token中的jwcode
public Integer getJwcode(String token) throws IOException {
TokenDTO dto = analysisToken(token);
return dto.getJwcode();
}
public String getUsername(String token) throws IOException {
TokenDTO dto = analysisToken(token);
return dto.getUsername();
}
}

39
src/main/resources/application.properties

@ -0,0 +1,39 @@
# 配置连接池
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/vote_invest_globally?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=123456
# HikariCP连接池配置
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.pool-name=HwgoldHikariCP
# mybatis配置
# 打印log信息
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
# 开启驼峰命名法,自动将数据库的命名方式,映射成Java中的命名方式
mybatis.configuration.map-underscore-to-camel-case: true
#下面这些内容是为了让MyBatis映射
#指定Mybatis的Mapper文件
mybatis.mapper-locations=classpath:mappers/*xml
#指定Mybatis的实体目录
mybatis.type-aliases-package=com.lh.mybatis.entity
# 应用服务 WEB 访问端口
server.port=8092
#Redis 配置
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=123456
spring.redis.timeout=2000
spring.redis.jedis.pool.max-active=10
spring.redis.jedis.pool.max-idle=5
spring.redis.jedis.pool.min-idle=1
# 每日最大投票次数
vote.limit.daily=3

13
src/main/resources/com/lh/mapper/CandidatesMapper.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.lh.mapper.CandidatesMapper">
<insert id="addVotes">
update candidates set votes = votes + 1 where jwcode = #{jwcode}
</insert>
<select id="getCandidates" resultType="com.lh.bean.Candidate">
select * from candidates order by votes desc
</select>
<select id="getByCandidateJwcode" resultType="com.lh.bean.Candidate">
select * from candidates where jwcode = #{jwcode}
</select>
</mapper>

14
src/main/resources/com/lh/mapper/VoterMapper.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.lh.mapper.VoterMapper">
<insert id="insertVote">
INSERT INTO voters(jwcode, candidate_jwcode, name)
VALUES(#{jwcode}, #{candidateJwcode}, #{name})
</insert>
<select id="countVotesToday" resultType="com.lh.bean.Voter">
SELECT * FROM voters WHERE jwcode = #{jwcode} AND DATE(vote_time) = CURDATE()
</select>
<select id="getVotesByCandidate" resultType="com.lh.bean.Voter">
SELECT * FROM voters WHERE candidate_jwcode = #{candidateJwcode}
</select>
</mapper>

6
src/main/resources/static/index.html

@ -0,0 +1,6 @@
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>

34
src/test/java/com/lh/VoteSystemApplicationTests.java

@ -0,0 +1,34 @@
package com.lh;
import com.lh.mapper.CandidatesMapper;
import com.lh.mapper.VoterMapper;
import com.lh.service.VoteService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class VoteSystemApplicationTests {
@Autowired
private CandidatesMapper candidatesMapper;
@Autowired
private VoterMapper voterMapper;
@Autowired
private VoteService voteService;
@Test
void contextLoads() {
candidatesMapper.getCandidates().forEach(System.out::println);
//System.out.print( voterMapper.countVotesToday("10010"));
voteService.getCandidates("90044599").forEach(System.out::println);
}
@Test
void contextLoads1() {
voterMapper.getVotesByCandidate("90044602").forEach(System.out::println);
}
@Test
void contextLoads2() {
voterMapper.insertVote("10010","20010","王五");
}
}
Loading…
Cancel
Save