├── .gitignore ├── .lgtm.yml ├── .travis.yml ├── LICENSE ├── README.md ├── appveyor.yml ├── docker ├── README.md ├── judger │ └── Dockerfile └── web │ ├── Dockerfile │ └── supervisord.conf ├── judger ├── Makefile ├── pom.xml └── src │ ├── main │ ├── cpp │ │ ├── org_verwandlung_voj_jni_hashmap.h │ │ ├── org_verwandlung_voj_jni_library.h │ │ ├── org_verwandlung_voj_judger_core_Runner.h │ │ ├── unix │ │ │ └── Judger.Core.Runner.cpp │ │ └── windows │ │ │ └── Judger.Core.Runner.cpp │ ├── java │ │ └── org │ │ │ └── verwandlung │ │ │ └── voj │ │ │ └── judger │ │ │ ├── application │ │ │ ├── ApplicationBootstrap.java │ │ │ ├── ApplicationDispatcher.java │ │ │ └── ApplicationHeartbeat.java │ │ │ ├── core │ │ │ ├── Comparator.java │ │ │ ├── Compiler.java │ │ │ ├── Dispatcher.java │ │ │ ├── Preprocessor.java │ │ │ └── Runner.java │ │ │ ├── exception │ │ │ ├── CreateDirectoryException.java │ │ │ └── IllgealSubmissionException.java │ │ │ ├── mapper │ │ │ ├── CheckpointMapper.java │ │ │ ├── JudgeResultMapper.java │ │ │ ├── LanguageMapper.java │ │ │ ├── ProblemMapper.java │ │ │ ├── SubmissionMapper.java │ │ │ ├── UserGroupMapper.java │ │ │ └── UserMapper.java │ │ │ ├── messenger │ │ │ ├── MessageReceiver.java │ │ │ └── MessageSender.java │ │ │ ├── model │ │ │ ├── Checkpoint.java │ │ │ ├── JudgeResult.java │ │ │ ├── Language.java │ │ │ ├── Problem.java │ │ │ ├── Submission.java │ │ │ ├── User.java │ │ │ └── UserGroup.java │ │ │ └── util │ │ │ ├── DigestUtils.java │ │ │ └── NativeLibraryLoader.java │ └── resources │ │ ├── application-context.xml │ │ ├── log4j2.xml │ │ └── voj.properties │ └── test │ ├── java │ └── org │ │ └── verwandlung │ │ └── voj │ │ └── judger │ │ ├── core │ │ ├── ComparatorTest.java │ │ ├── CompilerTest.java │ │ ├── PreprocessorTest.java │ │ └── RunnerTest.java │ │ └── mapper │ │ ├── CheckpointMapperTest.java │ │ ├── JudgeResultMapperTest.java │ │ ├── LanguageMapperTest.java │ │ ├── ProblemMapperTest.java │ │ ├── SubmissionMapperTest.java │ │ ├── UserGroupMapperTest.java │ │ └── UserMapperTest.java │ └── resources │ ├── log4j2-test.xml │ ├── test-spring-context.xml │ ├── voj-test-linux.properties │ └── voj-test-windows.properties ├── voj.sql └── web ├── .gitignore ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── verwandlung │ │ └── voj │ │ └── web │ │ ├── aspect │ │ ├── InterceptorAspect.java │ │ └── ViewAspect.java │ │ ├── controller │ │ ├── AccountsController.java │ │ ├── AdministrationController.java │ │ ├── ContestsController.java │ │ ├── DefaultController.java │ │ ├── DiscussionController.java │ │ ├── ExceptionHandlingController.java │ │ ├── ProblemsController.java │ │ └── SubmissionController.java │ │ ├── exception │ │ └── ResourceNotFoundException.java │ │ ├── mapper │ │ ├── BulletinBoardMessageMapper.java │ │ ├── CheckpointMapper.java │ │ ├── ContestContestantMapper.java │ │ ├── ContestMapper.java │ │ ├── ContestSubmissionMapper.java │ │ ├── DiscussionReplyMapper.java │ │ ├── DiscussionThreadMapper.java │ │ ├── DiscussionTopicMapper.java │ │ ├── EmailValidationMapper.java │ │ ├── JudgeResultMapper.java │ │ ├── LanguageMapper.java │ │ ├── OptionMapper.java │ │ ├── ProblemCategoryMapper.java │ │ ├── ProblemMapper.java │ │ ├── ProblemTagMapper.java │ │ ├── SubmissionMapper.java │ │ ├── UserGroupMapper.java │ │ ├── UserMapper.java │ │ └── UserMetaMapper.java │ │ ├── messenger │ │ ├── ApplicationEventListener.java │ │ ├── KeepAliveEvent.java │ │ ├── MessageReceiver.java │ │ ├── MessageSender.java │ │ └── SubmissionEvent.java │ │ ├── model │ │ ├── BulletinBoardMessage.java │ │ ├── Checkpoint.java │ │ ├── Contest.java │ │ ├── ContestContestant.java │ │ ├── ContestSubmission.java │ │ ├── DiscussionReply.java │ │ ├── DiscussionThread.java │ │ ├── DiscussionTopic.java │ │ ├── EmailValidation.java │ │ ├── JudgeResult.java │ │ ├── Language.java │ │ ├── Option.java │ │ ├── Problem.java │ │ ├── ProblemCategory.java │ │ ├── ProblemCategoryRelationship.java │ │ ├── ProblemTag.java │ │ ├── ProblemTagRelationship.java │ │ ├── Submission.java │ │ ├── User.java │ │ ├── UserGroup.java │ │ └── UserMeta.java │ │ ├── service │ │ ├── BulletinBoardService.java │ │ ├── ContestService.java │ │ ├── DiscussionService.java │ │ ├── LanguageService.java │ │ ├── OptionService.java │ │ ├── ProblemService.java │ │ ├── SubmissionService.java │ │ └── UserService.java │ │ └── util │ │ ├── CsrfProtector.java │ │ ├── DateUtils.java │ │ ├── DigestUtils.java │ │ ├── HtmlTextFilter.java │ │ ├── HttpRequestParser.java │ │ ├── HttpSessionParser.java │ │ ├── LocaleUtils.java │ │ ├── MailSender.java │ │ ├── OffensiveWordFilter.java │ │ ├── SessionListener.java │ │ └── SlugifyUtils.java ├── resources │ ├── localization │ │ ├── voj_en_US.properties │ │ └── voj_zh_CN.properties │ ├── log4j2.xml │ ├── mails │ │ └── reset-password.ftl │ ├── mappers │ │ ├── BulletinBoardMessageMapper.xml │ │ ├── CheckpointMapper.xml │ │ ├── ContestContestantMapper.xml │ │ ├── ContestMapper.xml │ │ ├── ContestSubmissionMapper.xml │ │ ├── DiscussionReplyMapper.xml │ │ ├── DiscussionThreadMapper.xml │ │ ├── DiscussionTopicMapper.xml │ │ ├── EmailValidationMapper.xml │ │ ├── JudgeResultMapper.xml │ │ ├── LanguageMapper.xml │ │ ├── OptionMapper.xml │ │ ├── ProblemCategoryMapper.xml │ │ ├── ProblemMapper.xml │ │ ├── ProblemTagMapper.xml │ │ ├── SubmissionMapper.xml │ │ ├── UserGroupMapper.xml │ │ ├── UserMapper.xml │ │ └── UserMetaMapper.xml │ └── voj.properties └── webapp │ ├── WEB-INF │ ├── dispatcher-servlet.xml │ ├── views │ │ ├── accounts │ │ │ ├── dashboard.jsp │ │ │ ├── login.jsp │ │ │ ├── register.jsp │ │ │ ├── reset-password.jsp │ │ │ └── user.jsp │ │ ├── administration │ │ │ ├── all-problems.jsp │ │ │ ├── all-submissions.jsp │ │ │ ├── all-users.jsp │ │ │ ├── edit-problem.jsp │ │ │ ├── edit-submission.jsp │ │ │ ├── edit-user.jsp │ │ │ ├── general-settings.jsp │ │ │ ├── include │ │ │ │ ├── footer-script.jsp │ │ │ │ ├── header.jsp │ │ │ │ └── sidebar.jsp │ │ │ ├── index.jsp │ │ │ ├── language-settings.jsp │ │ │ ├── new-problem.jsp │ │ │ ├── new-user.jsp │ │ │ └── problem-categories.jsp │ │ ├── contests │ │ │ ├── contest.jsp │ │ │ ├── contests.jsp │ │ │ ├── leaderboard-acm.jsp │ │ │ └── leaderboard-oi.jsp │ │ ├── discussion │ │ │ ├── new-thread.jsp │ │ │ ├── thread.jsp │ │ │ └── threads.jsp │ │ ├── errors │ │ │ ├── 404.jsp │ │ │ ├── 500.jsp │ │ │ └── not-supported.jsp │ │ ├── include │ │ │ ├── footer.jsp │ │ │ └── header.jsp │ │ ├── index.jsp │ │ ├── misc │ │ │ ├── about.jsp │ │ │ ├── help.jsp │ │ │ ├── judgers.jsp │ │ │ ├── privacy.jsp │ │ │ ├── terms.jsp │ │ │ └── worldwide.jsp │ │ ├── problems │ │ │ ├── problem.jsp │ │ │ └── problems.jsp │ │ └── submissions │ │ │ ├── submission.jsp │ │ │ └── submissions.jsp │ └── web.xml │ ├── assets │ ├── css │ │ ├── accounts │ │ │ ├── dashboard.css │ │ │ ├── login.css │ │ │ ├── register.css │ │ │ ├── reset-password.css │ │ │ └── user.css │ │ ├── administration │ │ │ ├── all-problems.css │ │ │ ├── all-submissions.css │ │ │ ├── all-users.css │ │ │ ├── dashboard.css │ │ │ ├── edit-submission.css │ │ │ ├── edit-user.css │ │ │ ├── general-settings.css │ │ │ ├── language-settings.css │ │ │ ├── new-problem.css │ │ │ ├── new-user.css │ │ │ ├── problem-categories.css │ │ │ └── style.css │ │ ├── bootstrap-responsive.min.css │ │ ├── bootstrap.min.css │ │ ├── codemirror.min.css │ │ ├── contests │ │ │ ├── contest.css │ │ │ ├── contests.css │ │ │ └── leaderboard.css │ │ ├── discussion │ │ │ ├── new-thread.css │ │ │ ├── thread.css │ │ │ └── threads.css │ │ ├── flat-ui.min.css │ │ ├── font-awesome-ie7.min.css │ │ ├── font-awesome.min.css │ │ ├── highlight.min.css │ │ ├── misc │ │ │ ├── about.css │ │ │ ├── error.css │ │ │ └── homepage.css │ │ ├── problems │ │ │ ├── problem.css │ │ │ └── problems.css │ │ ├── style.css │ │ └── submissions │ │ │ ├── submission.css │ │ │ └── submissions.css │ ├── fonts │ │ ├── Flat-UI-Icons.dev.svg │ │ ├── Flat-UI-Icons.eot │ │ ├── Flat-UI-Icons.svg │ │ ├── Flat-UI-Icons.ttf │ │ ├── Flat-UI-Icons.woff │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ └── fontawesome-webfont.woff │ ├── img │ │ ├── avatar.jpg │ │ ├── browsers │ │ │ ├── chrome.jpg │ │ │ ├── firefox.jpg │ │ │ ├── ie.jpg │ │ │ ├── opera.jpg │ │ │ └── safari.jpg │ │ ├── discussion.png │ │ ├── error.png │ │ ├── favicon.ico │ │ ├── favicon.png │ │ ├── glyphicons-halflings-white.png │ │ ├── glyphicons-halflings.png │ │ ├── loading.gif │ │ ├── logo-light.png │ │ ├── logo.jpg │ │ ├── logo.png │ │ ├── police-badge-of-china.png │ │ ├── sliders │ │ │ ├── slide-01.jpg │ │ │ ├── slide-02.jpg │ │ │ └── slide-03.jpg │ │ ├── switch-mask.png │ │ ├── upgrade-browser.png │ │ ├── wmd-buttons.svg │ │ └── wmd-draft.png │ ├── js │ │ ├── bootstrap.min.js │ │ ├── codemirror.min.js │ │ ├── date-en_US.min.js │ │ ├── date-zh_CN.min.js │ │ ├── flat-ui.min.js │ │ ├── highcharts.min.js │ │ ├── highlight.min.js │ │ ├── jquery-1.11.1.min.js │ │ ├── jquery.placeholder.min.js │ │ ├── markdown.min.js │ │ ├── md5.min.js │ │ ├── moment.min.js │ │ ├── pace.min.js │ │ └── site.js │ └── mode │ │ ├── clike.min.js │ │ ├── go.min.js │ │ ├── pascal.min.js │ │ ├── perl.min.js │ │ ├── php.min.js │ │ ├── python.min.js │ │ └── ruby.min.js │ └── index.jsp └── test ├── java └── org │ └── verwandlung │ └── voj │ └── web │ ├── mapper │ ├── CheckpointMapperTest.java │ ├── ContestContestantMapperTest.java │ ├── ContestMapperTest.java │ ├── DiscussionReplyMapperTest.java │ ├── DiscussionThreadMapperTest.java │ ├── DiscussionTopicMapperTest.java │ ├── EmailValidationMapperTest.java │ ├── JudgeResultMapperTest.java │ ├── LanguageMapperTest.java │ ├── OptionMapperTest.java │ ├── ProblemCategoryMapperTest.java │ ├── ProblemMapperTest.java │ ├── ProblemTagMapperTest.java │ ├── SubmissionMapperTest.java │ ├── UserGroupMapperTest.java │ ├── UserMapperTest.java │ └── UserMetaMapperTest.java │ └── util │ ├── DigestUtilsTest.java │ ├── HtmlTextFilterTest.java │ ├── MessageReceiverTest.java │ ├── MessageSenderTest.java │ ├── OffensiveWordFilterTest.java │ └── SlugifyUtilsTest.java └── resources ├── log4j2-test.xml ├── test-spring-context.xml └── voj-test.properties /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | bin/ 3 | logs/ 4 | cache/ 5 | 6 | # Maven 7 | target/ 8 | pom.xml.tag 9 | pom.xml.releaseBackup 10 | pom.xml.versionsBackup 11 | pom.xml.next 12 | release.properties 13 | dependency-reduced-pom.xml 14 | 15 | # Eclipse 16 | .classpath 17 | .project 18 | .settings/ 19 | 20 | # IntelliJ IDEA 21 | *.iml 22 | .idea/ 23 | META-INF/ 24 | 25 | # File Generated by Mac 26 | .DS_Store 27 | -------------------------------------------------------------------------------- /.lgtm.yml: -------------------------------------------------------------------------------- 1 | extraction: 2 | java: 3 | index: 4 | build_command: 5 | - "mvn package -DskipTests -f web/pom.xml" 6 | - "mvn package -DskipTests -f judger/pom.xml" 7 | 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: trusty 3 | 4 | services: mysql 5 | 6 | before_script: 7 | # Import Database 8 | - mysql -e 'CREATE DATABASE test;' 9 | - mysql test < voj.sql 10 | 11 | before_install: 12 | # Download JDK installer 13 | - wget https://github.com/sormuras/bach/raw/master/install-jdk.sh 14 | # Fix path error on JNI headers 15 | - sudo ln -nsf $JAVA_HOME/include/linux/jni_md.h $JAVA_HOME/include/jni_md.h 16 | - sudo ln -nsf $JAVA_HOME/include/linux/jawt_md.h $JAVA_HOME/include/jawt_md.h 17 | # Setup test environment for Linux 18 | - cp judger/src/test/resources/voj-test-linux.properties judger/src/test/resources/voj-test.properties 19 | # Find Maven Installation Path for root user 20 | - sudo find / -name mvn 21 | - export MVN_EXEC=`sudo find / -name mvn` 22 | # Setup Maven for Oracle JDK 9 23 | - export MAVEN_SKIP_RC=true 24 | 25 | matrix: 26 | fast_finish: true 27 | include: 28 | - env: JDK='Oracle JDK 8' 29 | jdk: oraclejdk8 30 | 31 | - env: JDK='Open JDK 8' 32 | jdk: openjdk8 33 | 34 | - env: JDK='Oracle JDK 11' 35 | install: . ./install-jdk.sh -F 11 -L BCL 36 | 37 | - env: JDK='Open JDK 11' 38 | jdk: openjdk11 39 | 40 | allow_failures: 41 | - env: JDK='Oracle JDK 11' 42 | 43 | script: 44 | - echo PATH = ${PATH} 45 | - echo JAVA_HOME = ${JAVA_HOME} 46 | - java -version 47 | - mvn test -f web/pom.xml 48 | - sudo $MVN_EXEC test -f judger/pom.xml 49 | 50 | after_script: 51 | - mysql -e 'DROP DATABASE test;' 52 | 53 | 54 | cache: 55 | directories: 56 | - $HOME/.m2 57 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # # version: "{branch} {build}" 2 | image: 3 | # Windows Server 2019 4 | - Visual Studio 2019 5 | 6 | environment: 7 | appveyor_build_worker_cloud: gce 8 | appveyor_rdp_password: Fx8eHPNesxhpmdru 9 | matrix: 10 | - JAVA_HOME: C:\Program Files\Java\jdk17 11 | - JAVA_HOME: C:\Program Files\Java\jdk21 12 | 13 | init: 14 | - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 15 | - ps: Start-Service MySQL80 16 | 17 | install: 18 | - set MINGW_HOME=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64 19 | - set PATH=%MINGW_HOME%\bin;C:\cygwin64\bin;C:\Program Files\MySql\MySQL Server 8.0\bin;%PATH% 20 | # Fix bug for mkdir in AppVeyor 21 | - del "C:\Program Files\Git\usr\bin\mkdir.exe" 22 | # Fix path error for make 23 | - copy "C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\mingw32-make.exe" "C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\make.exe" 24 | # Fix path error on JNI headers 25 | - copy "C:\Program Files\Java\jdk17\include\win32\jni_md.h" "C:\Program Files\Java\jdk17\include\jni_md.h" 26 | - copy "C:\Program Files\Java\jdk17\include\win32\jawt_md.h" "C:\Program Files\Java\jdk17\include\jawt_md.h" 27 | - copy "C:\Program Files\Java\jdk21\include\win32\jni_md.h" "C:\Program Files\Java\jdk21\include\jni_md.h" 28 | - copy "C:\Program Files\Java\jdk21\include\win32\jawt_md.h" "C:\Program Files\Java\jdk21\include\jawt_md.h" 29 | # Setup test environment for Windows 30 | - copy "judger\src\test\resources\voj-test-windows.properties" "judger\src\test\resources\voj-test.properties" 31 | 32 | build: off 33 | 34 | before_test: 35 | - mysql -e "SET PASSWORD FOR 'root'@'localhost' = '';" --user=root --password=Password12! 36 | - mysql -e "CREATE DATABASE test;" --user=root 37 | - mysql -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" --user=root 38 | - mysql test < voj.sql --user=root 39 | 40 | test_script: 41 | - mvn test -f web\pom.xml 42 | - mvn test -f judger\pom.xml 43 | 44 | after_test: 45 | - mysql -e "DROP DATABASE test;" --user=root 46 | 47 | on_finish: 48 | - ps: $blockRdp = $false; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 49 | 50 | matrix: 51 | fast_finish: false 52 | 53 | cache: 54 | - C:\maven\ 55 | - C:\Users\appveyor\.m2 56 | -------------------------------------------------------------------------------- /docker/README.md: -------------------------------------------------------------------------------- 1 | # Docker for Verwandlung Online Judge 2 | 3 | ## Build Docker Image for Web Application 4 | 5 | ``` 6 | cd web 7 | docker build -t "zjhzxhz/voj.web" . 8 | ``` 9 | 10 | You can also pull it from [Docker Hub](https://hub.docker.com/r/zjhzxhz/voj.web/). 11 | 12 | ``` 13 | docker pull zjhzxhz/voj.web 14 | ``` 15 | 16 | ## Run Web Application 17 | 18 | ``` 19 | docker run -d --name voj.web -p 8080:8080 zjhzxhz/voj.web 20 | ``` 21 | 22 | The web application is available at [http://localhost:8080/voj](http://localhost:8080/voj). 23 | 24 | ## Build Docker Image for Judger Application 25 | 26 | ``` 27 | cd judger 28 | docker build -t "zjhzxhz/voj.judger" . 29 | ``` 30 | 31 | You can also pull it from [Docker Hub](https://hub.docker.com/r/zjhzxhz/voj.judger/). 32 | 33 | ``` 34 | docker pull zjhzxhz/voj.judger 35 | ``` 36 | 37 | ## Run Judger Application 38 | 39 | ``` 40 | docker run -d --name voj.judger --link voj.web zjhzxhz/voj.judger 41 | ``` 42 | -------------------------------------------------------------------------------- /docker/judger/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for Verwandlung Online Judge - Judger 2 | FROM ubuntu:24.04 3 | MAINTAINER Haozhe Xie "root@haozhexie.com" 4 | 5 | # User Settings 6 | ARG MYSQL_USER_PASS=U3bEwhRHnD6xNVpb 7 | ARG MYSQL_HOST=voj.web 8 | ARG MYSQL_PORT=3306 9 | ARG ACTIVEMQ_HOST=voj.web 10 | ARG ACTIVEMQ_PORT=61616 11 | 12 | # Set environment variables. 13 | ENV HOME /root 14 | ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64 15 | ENV M2_HOME /opt/maven 16 | 17 | # Define working directory. 18 | WORKDIR /root 19 | 20 | # Install Java and Python 21 | RUN apt-get update && \ 22 | apt-get install -y git wget make g++ openjdk-17-jdk python3 && \ 23 | # Setup Python3 as the default Python 24 | ln -s /usr/bin/python3 /usr/bin/python && \ 25 | # Install Maven 26 | wget http://mirrors.tencent.com/apache/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz && \ 27 | tar -xf apache-maven-3.9.6-bin.tar.gz -C /opt && \ 28 | rm apache-maven-3.9.6-bin.tar.gz && \ 29 | mv /opt/apache-maven-3.9.6 /opt/maven 30 | 31 | # Setup Judger Project 32 | RUN git clone https://github.com/hzxie/voj.git && \ 33 | sed -i "s@jdbc.url = jdbc:mysql://localhost:3306@jdbc.url = jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}@g" voj/judger/src/main/resources/voj.properties && \ 34 | sed -i "s/jdbc.username = root/jdbc.username = voj/g" voj/judger/src/main/resources/voj.properties && \ 35 | sed -i "s/jdbc.password = /jdbc.password = ${MYSQL_USER_PASS}/g" voj/judger/src/main/resources/voj.properties && \ 36 | sed -i "s/localhost:61616/${ACTIVEMQ_HOST}:${ACTIVEMQ_PORT}/g" voj/judger/src/main/resources/voj.properties && \ 37 | mkdir -p voj/target/classes && \ 38 | $M2_HOME/bin/mvn package -DskipTests -f voj/judger/pom.xml 39 | 40 | # Run Judger 41 | CMD ["java", "-jar", "voj/judger/target/voj.judger.jar"] 42 | -------------------------------------------------------------------------------- /docker/web/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:mysqld] 5 | command=/etc/init.d/mariadb start 6 | 7 | [program:activemq] 8 | command=/opt/activemq/bin/activemq start 9 | 10 | [program:tomcat] 11 | command=bash -c 'sleep 15 && /opt/tomcat/bin/startup.sh' 12 | 13 | -------------------------------------------------------------------------------- /judger/Makefile: -------------------------------------------------------------------------------- 1 | CC=g++ 2 | CFLAGS=-c -std=c++11 -Wall -fPIC -I "${JAVA_HOME}/include" -I "${JAVA_HOME}/include/linux" 3 | LDFLAGS=-fPIC -shared 4 | EXTFLAGS= 5 | 6 | ifeq ($(OS), Windows_NT) 7 | SOURCES_DIR=src/main/cpp/windows 8 | OBJECTS_DIR=target/cpp 9 | EXECUTABLE=target/classes/JudgerCore.dll 10 | EXTFLAGS=-luserenv -lpsapi 11 | else 12 | UNAME_S := $(shell uname -s) 13 | ifeq ($(UNAME_S), Linux) 14 | SOURCES_DIR=src/main/cpp/unix 15 | OBJECTS_DIR=target/cpp 16 | EXECUTABLE=target/classes/libJudgerCore.so 17 | EXTFLAGS=-lpthread -lrt 18 | endif 19 | endif 20 | 21 | SOURCES=$(wildcard $(SOURCES_DIR)/*.cpp) 22 | OBJECTS=$(SOURCES:$(SOURCES_DIR)/%.cpp=$(OBJECTS_DIR)/%.o) 23 | 24 | all: $(EXECUTABLE) 25 | 26 | $(EXECUTABLE): $(OBJECTS) 27 | $(CC) $(LDFLAGS) $(OBJECTS) $(EXTFLAGS) -o $@ 28 | 29 | $(OBJECTS): $(SOURCES) 30 | mkdir -p $(OBJECTS_DIR) 31 | $(CC) $(CFLAGS) $< -o $@ 32 | 33 | clean: 34 | rm -rf $(OBJECTS_DIR) $(EXECUTABLE) 35 | -------------------------------------------------------------------------------- /judger/src/main/cpp/org_verwandlung_voj_jni_library.h: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | #include 41 | 42 | #include 43 | /* Header for class org_verwandlung_voj_jni_library */ 44 | 45 | #ifndef _Included_org_verwandlung_voj_jni_library 46 | #define _Included_org_verwandlung_voj_jni_library 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /** 52 | * 获取Java中String的值. 53 | * @param jniEnv - JNI 运行环境引用 54 | * @param jStr - 待获取值的Java字符串 55 | * @return Java字符串的值 56 | */ 57 | const char* getStringValue(JNIEnv* JniEnv, jstring jStr) { 58 | if ( jStr == nullptr || jStr == NULL ) { 59 | return ""; 60 | } 61 | const char* str = JniEnv->GetStringUTFChars(jStr, 0); 62 | return str; 63 | } 64 | 65 | /** 66 | * 抛出异常至Java运行环境. 67 | * @param jniEnv - JNI 运行环境引用 68 | * @param message - 异常信息 69 | * @return Java.lang.Error对象 70 | */ 71 | jint throwCStringException(JNIEnv* jniEnv, char* message) { 72 | jclass exClass; 73 | char* className = "java/lang/Error"; 74 | exClass = jniEnv->FindClass(className); 75 | 76 | return jniEnv->ThrowNew(exClass, message); 77 | } 78 | 79 | /** 80 | * 抛出异常至Java运行环境. 81 | * @param jniEnv - JNI 运行环境引用 82 | * @param message - 异常信息 83 | * @return Java.lang.Error对象 84 | */ 85 | jint throwStringException(JNIEnv* jniEnv, std::string message) { 86 | char* pMessage = const_cast(message.c_str()); 87 | return throwCStringException(jniEnv, pMessage); 88 | } 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif 94 | -------------------------------------------------------------------------------- /judger/src/main/cpp/org_verwandlung_voj_judger_core_Runner.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class org_verwandlung_voj_judger_core_Runner */ 4 | 5 | #ifndef _Included_org_verwandlung_voj_judger_core_Runner 6 | #define _Included_org_verwandlung_voj_judger_core_Runner 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: org_verwandlung_voj_judger_core_Runner 12 | * Method: getRuntimeResult 13 | * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)Ljava/util/Map; 14 | */ 15 | JNIEXPORT jobject JNICALL Java_org_verwandlung_voj_judger_core_Runner_getRuntimeResult 16 | (JNIEnv *, jobject, jstring, jstring, jstring, jstring, jstring, jint, jint); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /judger/src/main/java/org/verwandlung/voj/judger/exception/CreateDirectoryException.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.exception; 41 | 42 | /** 43 | * 创建文件夹失败的IO异常. 当java.io.File.File.mkdirs()返回false时被抛出. 44 | * 45 | * @author Haozhe Xie 46 | */ 47 | public class CreateDirectoryException extends Exception { 48 | /** 49 | * IOException的构造函数. 50 | * 51 | * @param message - 错误消息 52 | */ 53 | public CreateDirectoryException(String message) { 54 | super(message); 55 | } 56 | 57 | /** 唯一的序列化标识符. */ 58 | private static final long serialVersionUID = 7430055519184434330L; 59 | } 60 | -------------------------------------------------------------------------------- /judger/src/main/java/org/verwandlung/voj/judger/exception/IllgealSubmissionException.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.exception; 41 | 42 | /** 43 | * 无效的提交记录异常. 当getSubmission(long)操作返回null时被抛出. 44 | * 45 | * @author Haozhe Xie 46 | */ 47 | public class IllgealSubmissionException extends Exception { 48 | /** 49 | * IllgealSubmissionException的构造函数. 50 | * 51 | * @param message - 错误消息 52 | */ 53 | public IllgealSubmissionException(String message) { 54 | super(message); 55 | } 56 | 57 | /** 唯一的序列化标识符. */ 58 | private static final long serialVersionUID = -9019235951964656553L; 59 | } 60 | -------------------------------------------------------------------------------- /judger/src/main/java/org/verwandlung/voj/judger/mapper/CheckpointMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.mapper; 41 | 42 | import java.util.List; 43 | 44 | import org.apache.ibatis.annotations.CacheNamespace; 45 | import org.apache.ibatis.annotations.Options; 46 | import org.apache.ibatis.annotations.Param; 47 | import org.apache.ibatis.annotations.Result; 48 | import org.apache.ibatis.annotations.Results; 49 | import org.apache.ibatis.annotations.Select; 50 | 51 | import org.verwandlung.voj.judger.model.Checkpoint; 52 | 53 | /** 54 | * Checkpoint Data Access Object. 55 | * 56 | * @author Haozhe Xie 57 | */ 58 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 59 | public interface CheckpointMapper { 60 | /** 61 | * 获取某个试题的全部测试点. 62 | * 63 | * @param problemId - 试题的唯一标识符 64 | * @return 某个试题的全部测试点 65 | */ 66 | @Select("SELECT * FROM voj_problem_checkpoints WHERE problem_id = #{problemId}") 67 | @Options(useCache = true) 68 | @Results({ 69 | @Result(property = "problemId", column = "problem_id"), 70 | @Result(property = "checkpointId", column = "checkpoint_id"), 71 | @Result(property = "isExactlyMatch", column = "checkpoint_exactly_match"), 72 | @Result(property = "score", column = "checkpoint_score"), 73 | @Result(property = "input", column = "checkpoint_input"), 74 | @Result(property = "output", column = "checkpoint_output"), 75 | }) 76 | List getCheckpointsUsingProblemId(@Param("problemId") long problemId); 77 | } 78 | -------------------------------------------------------------------------------- /judger/src/main/java/org/verwandlung/voj/judger/mapper/UserGroupMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.mapper; 41 | 42 | import org.apache.ibatis.annotations.CacheNamespace; 43 | import org.apache.ibatis.annotations.Options; 44 | import org.apache.ibatis.annotations.Param; 45 | import org.apache.ibatis.annotations.Result; 46 | import org.apache.ibatis.annotations.Results; 47 | import org.apache.ibatis.annotations.Select; 48 | 49 | import org.verwandlung.voj.judger.model.UserGroup; 50 | 51 | /** 52 | * UserGroup Data Access Object. 53 | * 54 | * @author Haozhe Xie 55 | */ 56 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 57 | public interface UserGroupMapper { 58 | /** 59 | * 通过用户组的唯一标识符获取用户组对象. 60 | * 61 | * @param userGroupId - 用户组的唯一标识符 62 | * @return 预期的用户组对象或空引用 63 | */ 64 | @Select("SELECT * FROM voj_user_groups WHERE user_group_id = #{userGroupId}") 65 | @Options(useCache = true) 66 | @Results({ 67 | @Result(property = "userGroupId", column = "user_group_id"), 68 | @Result(property = "userGroupSlug", column = "user_group_slug"), 69 | @Result(property = "userGroupName", column = "user_group_name") 70 | }) 71 | UserGroup getUserGroupUsingId(@Param("userGroupId") int userGroupId); 72 | } 73 | -------------------------------------------------------------------------------- /judger/src/main/java/org/verwandlung/voj/judger/messenger/MessageSender.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.messenger; 41 | 42 | import java.util.Map; 43 | 44 | import org.springframework.beans.factory.annotation.Autowired; 45 | import org.springframework.jms.core.JmsTemplate; 46 | import org.springframework.stereotype.Component; 47 | 48 | /** 49 | * 消息发送服务. 50 | * 51 | * @author Haozhe Xie 52 | */ 53 | @Component 54 | public class MessageSender { 55 | /** 56 | * 发送消息至消息队列. 57 | * 58 | * @param mapMessage - Key-Value格式的消息 59 | */ 60 | public void sendMessage(final Map mapMessage) { 61 | jmsTemplate.convertAndSend(mapMessage); 62 | } 63 | 64 | /** 自动注入的JmsTemplate对象. 用于发送消息至消息队列. */ 65 | @Autowired private JmsTemplate jmsTemplate; 66 | } 67 | -------------------------------------------------------------------------------- /judger/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | logs/voj-judger.log 6 | logs/voj-judger-%d{yyyy-MM-dd}.log 7 | [%p] %d [%t] %c - %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /judger/src/main/resources/voj.properties: -------------------------------------------------------------------------------- 1 | # Database Configuration 2 | jdbc.driverClassName = com.mysql.cj.jdbc.Driver 3 | jdbc.url = jdbc:mysql://localhost:3306/voj?characterEncoding=UTF-8&serverTimezone=UTC 4 | jdbc.username = root 5 | jdbc.password = 6 | jdbc.initialSize = 5 7 | jdbc.maxActive = 30 8 | jdbc.minIdle = 3 9 | jdbc.maxIdle = 10 10 | jdbc.maxWait = 30000 11 | jdbc.timeBetweenEvictionRunsMillis = 60000 12 | jdbc.minEvictableIdleTimeMillis = 25200000 13 | jdbc.removeAbandoned = true 14 | jdbc.removeAbandonedTimeout = 1800 15 | 16 | # Message Service Configuration 17 | jms.broker.url = tcp://localhost:61616 18 | 19 | # Authentication for voj 20 | judger.username = voj@judger 21 | judger.password = zjhzxhz 22 | judger.description = 23 | 24 | # Working Directory 25 | judger.workDir = /tmp 26 | judger.checkpointDir = /tmp/voj-testpoints 27 | 28 | # System User with Lower Privileges 29 | system.username = hzxie 30 | system.password = @AppVeyor -------------------------------------------------------------------------------- /judger/src/test/java/org/verwandlung/voj/judger/mapper/JudgeResultMapperTest.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.mapper; 41 | 42 | import org.junit.jupiter.api.Assertions; 43 | import org.junit.jupiter.api.Test; 44 | import org.junit.jupiter.api.extension.ExtendWith; 45 | import org.springframework.beans.factory.annotation.Autowired; 46 | import org.springframework.test.context.ContextConfiguration; 47 | import org.springframework.test.context.junit.jupiter.SpringExtension; 48 | import org.springframework.transaction.annotation.Transactional; 49 | 50 | import org.verwandlung.voj.judger.model.JudgeResult; 51 | 52 | /** 53 | * JudgeResultMapper测试类. 54 | * 55 | * @author Haozhe Xie 56 | */ 57 | @ExtendWith(SpringExtension.class) 58 | @Transactional 59 | @ContextConfiguration({"classpath:test-spring-context.xml"}) 60 | public class JudgeResultMapperTest { 61 | /** 62 | * 测试用例: 测试getJudgeResultUsingSlug(String)方法 测试数据: 普通评测结果(JudgeResult)的评测结果组唯一英文缩写 预期结果: 63 | * 返回评测结果(JudgeResult)的评测结果组对象 64 | */ 65 | @Test 66 | public void testGetJudgeResultUsingSlugExists() { 67 | JudgeResult judgeResult = judgeResultMapper.getJudgeResultUsingSlug("AC"); 68 | Assertions.assertNotNull(judgeResult); 69 | 70 | int judgeResultId = judgeResult.getJudgeResultId(); 71 | Assertions.assertEquals(2, judgeResultId); 72 | } 73 | 74 | /** 测试用例: 测试getJudgeResultUsingSlug(String)方法 测试数据: 不存在的评测结果组唯一英文缩写 预期结果: 返回空引用 */ 75 | @Test 76 | public void testGetJudgeResultUsingSlugNotExists() { 77 | JudgeResult judgeResult = judgeResultMapper.getJudgeResultUsingSlug("Not-Exists"); 78 | Assertions.assertNull(judgeResult); 79 | } 80 | 81 | /** 待测试的JudgeResultMapper对象. */ 82 | @Autowired private JudgeResultMapper judgeResultMapper; 83 | } 84 | -------------------------------------------------------------------------------- /judger/src/test/java/org/verwandlung/voj/judger/mapper/ProblemMapperTest.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.mapper; 41 | 42 | import org.junit.jupiter.api.Assertions; 43 | import org.junit.jupiter.api.Test; 44 | import org.junit.jupiter.api.extension.ExtendWith; 45 | import org.springframework.beans.factory.annotation.Autowired; 46 | import org.springframework.test.context.ContextConfiguration; 47 | import org.springframework.test.context.junit.jupiter.SpringExtension; 48 | import org.springframework.transaction.annotation.Transactional; 49 | 50 | import org.verwandlung.voj.judger.model.Problem; 51 | 52 | /** 53 | * ProblemMapper测试类. 54 | * 55 | * @author Haozhe Xie 56 | */ 57 | @ExtendWith(SpringExtension.class) 58 | @Transactional 59 | @ContextConfiguration({"classpath:test-spring-context.xml"}) 60 | public class ProblemMapperTest { 61 | /** 测试用例: 测试getProblem()方法 测试数据: 使用A+B Problem的试题唯一标识符 预期结果: 返回预期的试题对象 */ 62 | @Test 63 | public void testGetProblemExists() { 64 | Problem problem = problemMapper.getProblem(1000); 65 | Assertions.assertNotNull(problem); 66 | 67 | String problemName = problem.getProblemName(); 68 | Assertions.assertEquals("A+B Problem", problemName); 69 | } 70 | 71 | /** 测试用例: 测试getProblem()方法 测试数据: 使用不存在的试题唯一标识符 预期结果: 返回空引用 */ 72 | @Test 73 | public void testGetProblemNotExists() { 74 | Problem problem = problemMapper.getProblem(0); 75 | Assertions.assertNull(problem); 76 | } 77 | 78 | /** 待测试的ProblemMapper对象. */ 79 | @Autowired private ProblemMapper problemMapper; 80 | } 81 | -------------------------------------------------------------------------------- /judger/src/test/java/org/verwandlung/voj/judger/mapper/SubmissionMapperTest.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.mapper; 41 | 42 | import org.junit.jupiter.api.Assertions; 43 | import org.junit.jupiter.api.Test; 44 | import org.junit.jupiter.api.extension.ExtendWith; 45 | import org.springframework.beans.factory.annotation.Autowired; 46 | import org.springframework.test.context.ContextConfiguration; 47 | import org.springframework.test.context.junit.jupiter.SpringExtension; 48 | import org.springframework.transaction.annotation.Transactional; 49 | 50 | import org.verwandlung.voj.judger.model.Submission; 51 | 52 | /** 53 | * SubmissionMapper测试类. 54 | * 55 | * @author Haozhe Xie 56 | */ 57 | @ExtendWith(SpringExtension.class) 58 | @Transactional 59 | @ContextConfiguration({"classpath:test-spring-context.xml"}) 60 | public class SubmissionMapperTest { 61 | /** 测试用例: 测试getSubmission(long)方法 测试数据: Problem#1000的提交记录的唯一标识符 预期结果: 返回预期的Submission对象 */ 62 | @Test 63 | public void testGetSubmissionExists() { 64 | Submission submission = submissionMapper.getSubmission(1000); 65 | Assertions.assertNotNull(submission); 66 | 67 | long problemId = submission.getProblem().getProblemId(); 68 | Assertions.assertEquals(1000, problemId); 69 | } 70 | 71 | /** 测试用例: 测试getSubmission(long)方法 测试数据: 不存在的的提交记录唯一标识符 预期结果: 返回空引用 */ 72 | @Test 73 | public void testGetSubmissionNotExists() { 74 | Submission submission = submissionMapper.getSubmission(0); 75 | Assertions.assertNull(submission); 76 | } 77 | 78 | /** 待测试的SubmissionMapper对象. */ 79 | @Autowired private SubmissionMapper submissionMapper; 80 | } 81 | -------------------------------------------------------------------------------- /judger/src/test/java/org/verwandlung/voj/judger/mapper/UserGroupMapperTest.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.mapper; 41 | 42 | import org.junit.jupiter.api.Assertions; 43 | import org.junit.jupiter.api.Test; 44 | import org.junit.jupiter.api.extension.ExtendWith; 45 | import org.springframework.beans.factory.annotation.Autowired; 46 | import org.springframework.test.context.ContextConfiguration; 47 | import org.springframework.test.context.junit.jupiter.SpringExtension; 48 | import org.springframework.transaction.annotation.Transactional; 49 | 50 | import org.verwandlung.voj.judger.model.UserGroup; 51 | 52 | /** 53 | * UserGroupMapper测试类. 54 | * 55 | * @author Haozhe Xie 56 | */ 57 | @ExtendWith(SpringExtension.class) 58 | @Transactional 59 | @ContextConfiguration({"classpath:test-spring-context.xml"}) 60 | public class UserGroupMapperTest { 61 | /** 测试用例: 测试getUserGroupUsingId(int)方法 测试数据: 普通用户(User)的用户组唯一标识符 预期结果: 返回用户(User)的用户组对象 */ 62 | @Test 63 | public void testGetUserGroupUsingIdExists() { 64 | UserGroup userGroup = userGroupMapper.getUserGroupUsingId(1); 65 | Assertions.assertNotNull(userGroup); 66 | 67 | String userGroupSlug = userGroup.getUserGroupSlug(); 68 | Assertions.assertEquals("forbidden", userGroupSlug); 69 | } 70 | 71 | /** 测试用例: 测试getUserGroupUsingId(int)方法 测试数据: 不存在的用户组唯一标识符 预期结果: 返回空引用 */ 72 | @Test 73 | public void testGetUserGroupUsingIdNotExists() { 74 | UserGroup userGroup = userGroupMapper.getUserGroupUsingId(0); 75 | Assertions.assertNull(userGroup); 76 | } 77 | 78 | /** 待测试的UserGroupMapper对象. */ 79 | @Autowired private UserGroupMapper userGroupMapper; 80 | } 81 | -------------------------------------------------------------------------------- /judger/src/test/java/org/verwandlung/voj/judger/mapper/UserMapperTest.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.judger.mapper; 41 | 42 | import org.junit.jupiter.api.Assertions; 43 | import org.junit.jupiter.api.Test; 44 | import org.junit.jupiter.api.extension.ExtendWith; 45 | import org.springframework.beans.factory.annotation.Autowired; 46 | import org.springframework.test.context.ContextConfiguration; 47 | import org.springframework.test.context.junit.jupiter.SpringExtension; 48 | import org.springframework.transaction.annotation.Transactional; 49 | 50 | import org.verwandlung.voj.judger.model.User; 51 | 52 | /** 53 | * UserMapper测试类. 54 | * 55 | * @author Haozhe Xie 56 | */ 57 | @ExtendWith(SpringExtension.class) 58 | @Transactional 59 | @ContextConfiguration({"classpath:test-spring-context.xml"}) 60 | public class UserMapperTest { 61 | /** 测试用例: 测试getUserUsingUsername(String)方法 测试数据: 使用用户名为zjhzxhz的用户 预期结果: 返回预期的用户对象 */ 62 | @Test 63 | public void testGetUserUsingUsernameExists() { 64 | User user = userMapper.getUserUsingUsername("Zjhzxhz"); 65 | Assertions.assertNotNull(user); 66 | 67 | long uid = user.getUid(); 68 | Assertions.assertEquals(1000, uid); 69 | } 70 | 71 | /** 测试用例: 测试getUserUsingUsername(String)方法 测试数据: 使用不存在的用户名 预期结果: 返回空引用 */ 72 | @Test 73 | public void testGetUserUsingUsernameNotExists() { 74 | User user = userMapper.getUserUsingUsername("Not-Exists"); 75 | Assertions.assertNull(user); 76 | } 77 | 78 | /** 待测试的UserMapper对象. */ 79 | @Autowired private UserMapper userMapper; 80 | } 81 | -------------------------------------------------------------------------------- /judger/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [%p] %d [%t] %c - %m%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /judger/src/test/resources/voj-test-linux.properties: -------------------------------------------------------------------------------- 1 | # Database Configuration 2 | jdbc.driverClassName = com.mysql.cj.jdbc.Driver 3 | jdbc.url = jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=UTC 4 | jdbc.username = root 5 | jdbc.password = 6 | jdbc.initialSize = 1 7 | jdbc.maxActive = 1 8 | jdbc.minIdle = 0 9 | jdbc.maxIdle = 1 10 | jdbc.maxWait = 1800 11 | jdbc.timeBetweenEvictionRunsMillis = 1800 12 | jdbc.minEvictableIdleTimeMillis = 1800 13 | jdbc.removeAbandoned = true 14 | jdbc.removeAbandonedTimeout = 1800 15 | 16 | # Message Service Configuration 17 | jms.broker.url = vm://localhost?broker.persistent=false 18 | 19 | # Authentication for voj 20 | judger.username = 21 | judger.password = 22 | judger.description = 23 | 24 | # Working Directory 25 | judger.workDir = /tmp 26 | judger.checkpointDir = /tmp/testpoints 27 | 28 | # System User with Lower Privileges 29 | system.username = appveyor 30 | system.password = Fx8eHPNesxhpmdru -------------------------------------------------------------------------------- /judger/src/test/resources/voj-test-windows.properties: -------------------------------------------------------------------------------- 1 | # Database Configuration 2 | jdbc.driverClassName = com.mysql.cj.jdbc.Driver 3 | jdbc.url = jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=UTC 4 | jdbc.username = root 5 | jdbc.password = 6 | jdbc.initialSize = 1 7 | jdbc.maxActive = 1 8 | jdbc.minIdle = 0 9 | jdbc.maxIdle = 1 10 | jdbc.maxWait = 1800 11 | jdbc.timeBetweenEvictionRunsMillis = 1800 12 | jdbc.minEvictableIdleTimeMillis = 1800 13 | jdbc.removeAbandoned = true 14 | jdbc.removeAbandonedTimeout = 1800 15 | 16 | # Message Service Configuration 17 | jms.broker.url = vm://localhost?broker.persistent=false 18 | 19 | # Authentication for voj 20 | judger.username = 21 | judger.password = 22 | judger.description = 23 | 24 | # Working Directory 25 | judger.workDir = C:/Windows/Temp 26 | judger.checkpointDir = C:/Windows/Temp/testpoints 27 | 28 | # System User with Lower Privileges 29 | system.username = appveyor 30 | system.password = Fx8eHPNesxhpmdru -------------------------------------------------------------------------------- /web/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/exception/ResourceNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.exception; 41 | 42 | import org.springframework.http.HttpStatus; 43 | import org.springframework.web.bind.annotation.ResponseStatus; 44 | 45 | @ResponseStatus(HttpStatus.NOT_FOUND) 46 | public class ResourceNotFoundException extends RuntimeException { 47 | /** 唯一的序列化标识符. */ 48 | private static final long serialVersionUID = -7683678924179048862L; 49 | } 50 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/CheckpointMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import java.util.List; 43 | 44 | import org.apache.ibatis.annotations.CacheNamespace; 45 | import org.apache.ibatis.annotations.Param; 46 | 47 | import org.verwandlung.voj.web.model.Checkpoint; 48 | 49 | /** 50 | * Checkpoint Data Access Object. 51 | * 52 | * @author Haozhe Xie 53 | */ 54 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 55 | public interface CheckpointMapper { 56 | /** 57 | * [此方法仅供管理员使用] 获取系统中试题测试点的总数. 58 | * 59 | * @return 系统中试题测试点的总数 60 | */ 61 | long getNumberOfCheckpoints(); 62 | 63 | /** 64 | * 获取某个试题的全部测试点. 65 | * 66 | * @param problemId - 试题的唯一标识符 67 | * @return 某个试题的全部测试点 68 | */ 69 | List getCheckpointsUsingProblemId(@Param("problemId") long problemId); 70 | 71 | /** 72 | * [此方法仅供管理员使用] 创建测试点. 73 | * 74 | * @param checkpoint - 测试点 75 | */ 76 | int createCheckpoint(Checkpoint checkpoint); 77 | 78 | /** 79 | * [此方法仅供管理员使用] 删除某个试题的全部测试点. 80 | * 81 | * @param problemId - 试题的唯一标识符 82 | */ 83 | int deleteCheckpoint(long problemId); 84 | } 85 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/ContestMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import org.apache.ibatis.annotations.Param; 43 | import org.verwandlung.voj.web.model.Contest; 44 | 45 | import java.util.List; 46 | 47 | /** 48 | * Contest Data Access Object. 49 | * 50 | * @author Haozhe Xie 51 | */ 52 | public interface ContestMapper { 53 | /** 54 | * [此方法仅供管理员使用] 获取竞赛的总数量. 55 | * 56 | * @param keyword - 竞赛的关键词 57 | * @return 竞赛的总数量 58 | */ 59 | long getNumberOfContests(@Param("keyword") String keyword); 60 | 61 | /** 62 | * 获取竞赛列表. 63 | * 64 | * @param keyword - 竞赛的关键词 65 | * @param offset - 起始竞赛的偏移量(offset) 66 | * @param limit - 需要获取竞赛的数量 67 | * @return 预期的竞赛对象 68 | */ 69 | List getContests( 70 | @Param("keyword") String keyword, @Param("offset") long offset, @Param("limit") int limit); 71 | 72 | /** 73 | * 根据竞赛的唯一标识符获取竞赛. 74 | * 75 | * @param contestId - 竞赛的唯一标识符 76 | * @return 预期的竞赛对象 77 | */ 78 | Contest getContest(long contestId); 79 | 80 | /** 81 | * 创建竞赛. 82 | * 83 | * @param contest - 待创建的竞赛对象 84 | */ 85 | int createContest(Contest contest); 86 | 87 | /** 88 | * 更新竞赛. 89 | * 90 | * @param contest - 待更新的竞赛对象 91 | */ 92 | int updateContest(Contest contest); 93 | 94 | /** 95 | * 删除竞赛. 96 | * 97 | * @param contestId - 竞赛的唯一标识符 98 | */ 99 | int deleteContest(long contestId); 100 | } 101 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/DiscussionReplyMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import org.apache.ibatis.annotations.Param; 43 | import org.verwandlung.voj.web.model.DiscussionReply; 44 | 45 | import java.util.List; 46 | 47 | /** 48 | * DiscussionReply Data Access Object. 49 | * 50 | * @author Haozhe Xie 51 | */ 52 | public interface DiscussionReplyMapper { 53 | /** 54 | * 根据讨论回复的唯一标识符获取DiscussionReply对象. 55 | * 56 | * @param discussionReplyId - 讨论回复的唯一标识符 57 | * @return 预期的DiscussionReply对象或空引用 58 | */ 59 | DiscussionReply getDiscussionReplyUsingReplyId( 60 | @Param("discussionReplyId") long discussionReplyId); 61 | 62 | /** 63 | * 获取某个讨论帖子下的全部回复, 并分页显示. 64 | * 65 | * @param discussionThreadId - 讨论帖子的唯一标识符 66 | * @param offset 起始回复的游标 67 | * @param limit 获取回复的数量 68 | * @return 包含讨论话题回复的List对象 69 | */ 70 | List getDiscussionRepliesUsingThreadId( 71 | @Param("discussionThreadId") long discussionThreadId, 72 | @Param("offset") long offset, 73 | @Param("limit") int limit); 74 | 75 | /** 76 | * 创建讨论回复. 77 | * 78 | * @param discussionReply - 待创建的DiscussionReply对象 79 | */ 80 | int createDiscussionReply(DiscussionReply discussionReply); 81 | 82 | /** 83 | * 更新讨论回复. 84 | * 85 | * @param discussionReply - 待更新的DiscussionReply对象 86 | */ 87 | int updateDiscussionReply(DiscussionReply discussionReply); 88 | 89 | /** 90 | * 删除讨论回复. 91 | * 92 | * @param discussionReplyId - 待删除回复的唯一标识符 93 | */ 94 | int deleteDiscussionReplyUsingReplyId(long discussionReplyId); 95 | } 96 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/DiscussionTopicMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import org.apache.ibatis.annotations.CacheNamespace; 43 | import org.verwandlung.voj.web.model.DiscussionTopic; 44 | 45 | import java.util.List; 46 | 47 | /** 48 | * DiscussionTopic Data Access Object. 49 | * 50 | * @author Haozhe Xie 51 | */ 52 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 53 | public interface DiscussionTopicMapper { 54 | /** 55 | * 获取全部的讨论话题. 56 | * 57 | * @return 包含全部讨论话题的List对象 58 | */ 59 | List getDiscussionTopics(); 60 | 61 | /** 62 | * 根据讨论话题的唯一标识符获取讨论话题对象. 63 | * 64 | * @param discussionTopicId - 讨论话题的唯一标识符 65 | * @return 一个讨论话题对象 66 | */ 67 | DiscussionTopic getDiscussionTopicUsingId(int discussionTopicId); 68 | 69 | /** 70 | * 根据讨论话题的唯一别名获取讨论话题对象. 71 | * 72 | * @param discussionTopicSlug - 讨论话题的别名 73 | * @return 一个讨论话题对象 74 | */ 75 | DiscussionTopic getDiscussionTopicUsingSlug(String discussionTopicSlug); 76 | 77 | /** 78 | * 创建讨论话题. 79 | * 80 | * @param discussionTopic - 待创建的讨论话题对象 81 | */ 82 | int createDiscussionTopic(DiscussionTopic discussionTopic); 83 | 84 | /** 85 | * 更新讨论话题. 86 | * 87 | * @param discussionTopic - 待更新的讨论话题对象 88 | */ 89 | int updateDiscussionTopic(DiscussionTopic discussionTopic); 90 | 91 | /** 92 | * 删除讨论话题. 93 | * 94 | * @param discussionTopicId - 待删除讨论话题的唯一标识符 95 | */ 96 | int deleteDiscussionTopicUsingId(int discussionTopicId); 97 | } 98 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/EmailValidationMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import org.apache.ibatis.annotations.CacheNamespace; 43 | import org.apache.ibatis.annotations.Param; 44 | 45 | import org.verwandlung.voj.web.model.EmailValidation; 46 | 47 | /** 48 | * EmailValidation Data Access Object. 49 | * 50 | * @author Haozhe Xie 51 | */ 52 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 53 | public interface EmailValidationMapper { 54 | /** 55 | * 获取某个电子邮件地址对应的EmailValidation对象. 56 | * 57 | * @param email - 电子邮件地址 58 | * @return 对应的EmailValidation对象 59 | */ 60 | EmailValidation getEmailValidation(@Param("email") String email); 61 | 62 | /** 63 | * 创建新的电子邮件验证凭据. 64 | * 65 | * @param emailValidation - 电子邮件验证凭据 66 | */ 67 | int createEmailValidation(EmailValidation emailValidation); 68 | 69 | /** 70 | * 删除电子邮件验证凭据. 71 | * 72 | * @param email - 电子邮件地址 73 | */ 74 | int deleteEmailValidation(@Param("email") String email); 75 | } 76 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/JudgeResultMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import org.apache.ibatis.annotations.CacheNamespace; 43 | import org.apache.ibatis.annotations.Param; 44 | 45 | import org.verwandlung.voj.web.model.JudgeResult; 46 | 47 | /** 48 | * JudgeResult Data Access Object. 49 | * 50 | * @author Haozhe Xie 51 | */ 52 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 53 | public interface JudgeResultMapper { 54 | /** 55 | * 通过评测结果的唯一标识符获取评测结果对象. 56 | * 57 | * @param judgeResultId - 评测结果的唯一标识符 58 | * @return 预期的评测结果对象或空引用 59 | */ 60 | JudgeResult getJudgeResultUsingId(@Param("judgeResultId") int judgeResultId); 61 | 62 | /** 63 | * 通过评测结果的别名获取评测结果对象. 64 | * 65 | * @param judgeResultSlug - 评测结果的别名 66 | * @return 预期的评测结果对象或空引用 67 | */ 68 | JudgeResult getJudgeResultUsingSlug(@Param("judgeResultSlug") String judgeResultSlug); 69 | } 70 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/LanguageMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import java.util.List; 43 | 44 | import org.apache.ibatis.annotations.CacheNamespace; 45 | import org.apache.ibatis.annotations.Param; 46 | 47 | import org.verwandlung.voj.web.model.Language; 48 | 49 | /** 50 | * Language Data Access Object. 51 | * 52 | * @author Haozhe Xie 53 | */ 54 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 55 | public interface LanguageMapper { 56 | /** 57 | * 通过编程语言的唯一标识符获取编程语言对象. 58 | * 59 | * @param languageId - 编程语言的唯一标识符 60 | * @return 预期的编程语言对象或空引用 61 | */ 62 | Language getLanguageUsingId(@Param("languageId") int languageId); 63 | 64 | /** 65 | * 通过编程语言的别名获取编程语言对象. 66 | * 67 | * @param languageSlug - 编程语言的别名 68 | * @return 预期的编程语言对象或空引用 69 | */ 70 | Language getLanguageUsingSlug(@Param("languageSlug") String languageSlug); 71 | 72 | /** 73 | * 获取支持的编程语言. 74 | * 75 | * @return 编程语言列表(List对象) 76 | */ 77 | List getAllLanguages(); 78 | 79 | /** 80 | * 添加编程语言对象. 81 | * 82 | * @param language - 待添加的编程语言对象 83 | */ 84 | int createLanguage(Language language); 85 | 86 | /** 87 | * 更新编程语言对象. 88 | * 89 | * @param language - 待更新的编程语言对象 90 | */ 91 | int updateLanguage(Language language); 92 | 93 | /** 94 | * 删除编程语言对象. 95 | * 96 | * @param languageId - 编程语言的唯一标识符 97 | */ 98 | int deleteLanguage(@Param("languageId") int languageId); 99 | } 100 | -------------------------------------------------------------------------------- /web/src/main/java/org/verwandlung/voj/web/mapper/OptionMapper.java: -------------------------------------------------------------------------------- 1 | /* Verwandlung Online Judge - A cross-platform judge online system 2 | * Copyright (C) 2018 Haozhe Xie 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | * 18 | * _ooOoo_ 19 | * o8888888o 20 | * 88" . "88 21 | * (| -_- |) 22 | * O\ = /O 23 | * ____/`---'\____ 24 | * .' \\| |// `. 25 | * / \\||| : |||// \ 26 | * / _||||| -:- |||||- \ 27 | * | | \\\ - /// | | 28 | * | \_| ''\---/'' | | 29 | * \ .-\__ `-` ___/-. / 30 | * ___`. .' /--.--\ `. . __ 31 | * ."" '< `.___\_<|>_/___.' >'"". 32 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 33 | * \ \ `-. \_ __\ /__ _/ .-` / / 34 | * ======`-.____`-.___\_____/___.-`____.-'====== 35 | * `=---=' 36 | * 37 | * HERE BE BUDDHA 38 | * 39 | */ 40 | package org.verwandlung.voj.web.mapper; 41 | 42 | import java.util.List; 43 | 44 | import org.apache.ibatis.annotations.CacheNamespace; 45 | import org.apache.ibatis.annotations.Param; 46 | 47 | import org.verwandlung.voj.web.model.Option; 48 | 49 | /** 50 | * Opton Data Access Object. 51 | * 52 | * @author Haozhe Xie 53 | */ 54 | @CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class) 55 | public interface OptionMapper { 56 | /** 57 | * 获取全部系统选项. 58 | * 59 | * @return 一个包含全部系统选项的列表 60 | */ 61 | List