├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── qingzhenyun-auto-config └── build.gradle ├── qingzhenyun-common-jooq ├── build.gradle └── src │ └── main │ └── kotlin │ └── com │ └── qingzhenyun │ └── common │ └── jooq │ ├── PostgresJSONGsonBinding.kt │ ├── binding │ ├── CommonJacksonBinding.kt │ └── CommonJsonBinding.kt │ └── service │ └── AbstractJooqDslRepository.kt ├── qingzhenyun-common-springboot ├── build.gradle └── src │ ├── main │ └── java │ │ └── TestClass.java │ └── test │ └── kotlin │ └── com │ └── qingzhenyun │ └── common │ └── util │ └── QStringUtilTest.kt ├── qingzhenyun-common ├── .DS_Store ├── build.gradle └── src │ ├── .DS_Store │ └── main │ ├── .DS_Store │ └── kotlin │ ├── .DS_Store │ └── com │ ├── .DS_Store │ └── qingzhenyun │ └── common │ ├── constants │ ├── CloudStoreConstants.kt │ └── UserFileConstants.kt │ ├── entity │ ├── RecordPage.kt │ ├── TrustedPath.kt │ └── usercenter │ │ └── LoginSsid.kt │ └── util │ ├── HASH.kt │ └── QStringUtil.kt ├── qingzhenyun-ice-sb-common ├── build.gradle └── src │ └── main │ ├── ice │ ├── cloudstore.ice │ ├── com │ │ └── qingzhenyun │ │ │ └── common │ │ │ └── ice │ │ │ ├── common │ │ │ ├── CommonPage.java │ │ │ ├── CommonRpcException.java │ │ │ └── _Marker.java │ │ │ └── userfile │ │ │ ├── FileOperationException.java │ │ │ ├── SimpleFile.java │ │ │ ├── SimpleFileListHelper.java │ │ │ ├── UserAsyncTask.java │ │ │ ├── UserFilePageResponse.java │ │ │ ├── UserFileResponse.java │ │ │ ├── UserFileResponseListHelper.java │ │ │ ├── UserFileServiceHandler.java │ │ │ ├── UserFileServiceHandlerPrx.java │ │ │ ├── UserOfflinePageResponse.java │ │ │ ├── UserOfflineResponse.java │ │ │ ├── UserOfflineResponseListHelper.java │ │ │ ├── _Marker.java │ │ │ └── _UserFileServiceHandlerPrxI.java │ ├── common.ice │ ├── convert.sh │ ├── csharp │ │ ├── common.cs │ │ └── userfile.cs │ ├── javascript │ │ ├── common.js │ │ └── userfile.js │ ├── offline.ice │ ├── python │ │ ├── common │ │ │ └── __init__.py │ │ ├── common_ice.py │ │ └── userfile │ │ │ └── __init__.py │ ├── usercenter.ice │ └── userfile.ice │ ├── java │ └── com │ │ └── qingzhenyun │ │ └── common │ │ └── ice │ │ ├── common │ │ ├── CommonPage.java │ │ ├── CommonRpcException.java │ │ └── _Marker.java │ │ └── userfile │ │ ├── FileOperationException.java │ │ ├── SimpleFile.java │ │ ├── SimpleFileListHelper.java │ │ ├── UserAsyncTask.java │ │ ├── UserFilePageResponse.java │ │ ├── UserFileResponse.java │ │ ├── UserFileResponseListHelper.java │ │ ├── UserFileServiceHandler.java │ │ ├── UserFileServiceHandlerPrx.java │ │ ├── UserOfflinePageResponse.java │ │ ├── UserOfflineResponse.java │ │ ├── UserOfflineResponseListHelper.java │ │ ├── _Marker.java │ │ └── _UserFileServiceHandlerPrxI.java │ └── kotlin │ └── com │ └── qingzhenyun │ └── common │ └── ice │ ├── IceBootstrapContext.kt │ └── IceHandler.kt ├── qingzhenyun-ice-test └── src │ └── main │ └── kotlin │ └── com │ └── qingzhenyun │ └── ice │ └── test │ └── IceTestApplication.kt ├── qingzhenyun-offline-download ├── .DS_Store ├── build.gradle └── src │ ├── .DS_Store │ ├── main │ ├── kotlin │ │ └── com │ │ │ └── qingzhenyun │ │ │ └── offline │ │ │ ├── OfflineDownloadApplication.kt │ │ │ ├── constants │ │ │ └── DownloadTaskConst.kt │ │ │ ├── context │ │ │ └── OfflineBootstrapContext.kt │ │ │ ├── handler │ │ │ └── OfflineDownloadServiceHandlerImpl.kt │ │ │ ├── repository │ │ │ └── DownloadTaskRepository.kt │ │ │ └── service │ │ │ ├── DownloadTaskService.kt │ │ │ ├── FakeCopyQueueService.kt │ │ │ ├── TaskDetailService.kt │ │ │ ├── UserTaskService.kt │ │ │ └── WaitingQueueService.kt │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ └── banner.txt │ └── test │ └── resources │ └── application.yml ├── qingzhenyun-user-center ├── build.gradle └── src │ ├── main │ ├── kotlin │ │ └── com │ │ │ └── qingzhenyun │ │ │ └── usercenter │ │ │ ├── UserCenterApplication.kt │ │ │ ├── context │ │ │ └── UserCenterBootstrapContext.kt │ │ │ ├── handler │ │ │ └── UserCenterServiceHandler.kt │ │ │ ├── repository │ │ │ └── UserCenterRepository.kt │ │ │ └── service │ │ │ └── UserCenterService.kt │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ └── banner.txt │ └── test │ ├── kotlin │ └── com │ │ └── qingzhenyun │ │ └── usercenter │ │ ├── UserCenterApplicationTests.kt │ │ └── UserCenterServiceTest.kt │ └── resources │ └── application.yml ├── qingzhenyun-user-file ├── .DS_Store ├── build.gradle └── src │ ├── .DS_Store │ ├── main │ ├── .DS_Store │ ├── META-INF │ │ └── README.md │ ├── java │ │ ├── .DS_Store │ │ └── com │ │ │ ├── .DS_Store │ │ │ └── qingzhenyun │ │ │ └── userfile │ │ │ └── configuration │ │ │ └── TestConfiguration.java │ ├── kotlin │ │ └── com │ │ │ └── qingzhenyun │ │ │ └── userfile │ │ │ ├── UserFileApplication.kt │ │ │ ├── configuration │ │ │ └── UserFileDataSourceConfiguration.kt │ │ │ ├── context │ │ │ └── UserFileBootstrapContext.kt │ │ │ ├── handler │ │ │ └── UserFileServiceHandlerImpl.kt │ │ │ ├── repository │ │ │ ├── FileOperationRepository.kt │ │ │ └── UserFileRepository.kt │ │ │ └── service │ │ │ ├── FileOperationService.java │ │ │ ├── UserFileService.kt │ │ │ └── UserFileService.kt.bak │ └── resources │ │ ├── application-dev.yml │ │ ├── application.yml │ │ └── banner.txt │ └── test │ ├── kotlin │ └── com │ │ └── qingzhenyun │ │ └── userfile │ │ ├── UserFileApplicationTests.kt │ │ └── UserFileServiceTest.kt │ └── resources │ └── application.yml └── settings.gradle /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 qingzhenyun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # qingzhenyun-core 2 | Qingzhenyun(6pan Core Service) 3 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.71' 3 | } 4 | 5 | group 'com.qingzhenyun' 6 | version '1.0-SNAPSHOT' 7 | 8 | subprojects{ 9 | ext { 10 | kotlin_version = '1.2.71' 11 | springBootVersion = '2.0.3.RELEASE' 12 | spring_version = '5.0.7.RELEASE' 13 | junit_version = '4.12' 14 | jvm_target = '1.8' 15 | ice_version = '3.7.1' 16 | slf4j_version = '1.7.25' 17 | hikaricp_version = '3.2.0' 18 | jooq_version = '3.11.2' 19 | postgres_version = '42.2.3' 20 | jooq_plugin_version = '3.0.1' 21 | jackson_version = '2.9.6' 22 | test_db_url = 'jdbc:postgresql://119.90.49.12:8999' 23 | test_db_user = 'postgres' 24 | test_db_password = 'e24a23c250246d795eaf08ddab6b0fa9' 25 | test_db_user_file = 'qingzhenyun_file' 26 | test_db_user_center = 'qingzhenyun_user_center' 27 | test_db_cloud_store = 'qingzhenyun_cloud_store' 28 | test_db_offline_download = 'qingzhenyun_offline_download' 29 | } 30 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jul 27 09:43:00 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /qingzhenyun-auto-config/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | // ext.kotlin_version = '1.2.30' 3 | 4 | repositories { 5 | mavenCentral() 6 | } 7 | //dependencies { 8 | // classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 9 | //} 10 | } 11 | 12 | group 'com.qingzhenyun' 13 | version '1.0-SNAPSHOT' 14 | 15 | apply plugin: 'java' 16 | //apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.8 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | //compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 26 | //testCompile group: 'junit', name: 'junit', version: '4.12' 27 | } 28 | 29 | /* 30 | compileKotlin { 31 | kotlinOptions.jvmTarget = "1.8" 32 | } 33 | compileTestKotlin { 34 | kotlinOptions.jvmTarget = "1.8" 35 | } 36 | */ -------------------------------------------------------------------------------- /qingzhenyun-common-jooq/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | //ext.kotlin_version = '1.2.30' 3 | 4 | repositories { 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 9 | } 10 | } 11 | 12 | group 'com.qingzhenyun' 13 | version '1.0-SNAPSHOT' 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.8 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile project(':qingzhenyun-ice-sb-common') 26 | compile group: 'com.zaxxer', name: 'HikariCP', version: hikaricp_version 27 | compile group: 'org.postgresql', name: 'postgresql', version: postgres_version 28 | compile group: 'org.jooq', name: 'jooq', version: jooq_version 29 | compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jackson_version 30 | 31 | } 32 | 33 | compileKotlin { 34 | kotlinOptions.jvmTarget = jvm_target 35 | } 36 | compileTestKotlin { 37 | kotlinOptions.jvmTarget = jvm_target 38 | } -------------------------------------------------------------------------------- /qingzhenyun-common-jooq/src/main/kotlin/com/qingzhenyun/common/jooq/PostgresJSONGsonBinding.kt: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | class PostgresJSONGsonBinding : Binding { 4 | override fun register(ctx: BindingRegisterContext) { 5 | ctx.statement().registerOutParameter(ctx.index(), Types.VARCHAR); 6 | } 7 | 8 | override fun sql(ctx: BindingSQLContext) { 9 | // Depending on how you generate your SQL, you may need to explicitly distinguish 10 | // between jOOQ generating bind variables or inlined literals. If so, use this check: 11 | // ctx.render().paramType() == INLINED 12 | ctx.render().visit(DSL.`val`(ctx.convert(converter()).value())).sql("::json") 13 | } 14 | 15 | override fun converter(): Converter { 16 | return object : Converter { 17 | override fun from(t: Any?): JsonNode? { 18 | if(t == null){ 19 | return null 20 | } 21 | return objectMapper.readValue(t.toString(),JsonNode::class.java) 22 | //return if (t == null) JsonNull.INSTANCE else Gson().fromJson("" + t, JsonElement::class.java) 23 | } 24 | 25 | override fun to(u: JsonNode?): String? { 26 | return if (u == null || u.isNull) null else objectMapper.writeValueAsString(u) 27 | } 28 | 29 | override fun fromType(): Class { 30 | return Any::class.java 31 | } 32 | 33 | override fun toType(): Class { 34 | return JsonNode::class.java 35 | } 36 | } 37 | } 38 | 39 | 40 | // Converting the JsonElement to a String value and setting that on a JDBC PreparedStatement 41 | @Throws(SQLException::class) 42 | override fun set(ctx: BindingSetStatementContext) { 43 | ctx.statement().setString(ctx.index(), Objects.toString(ctx.convert(converter()).value(), null)) 44 | } 45 | 46 | // Getting a String value from a JDBC ResultSet and converting that to a JsonElement 47 | @Throws(SQLException::class) 48 | override fun get(ctx: BindingGetResultSetContext) { 49 | ctx.convert(converter()).value(ctx.resultSet().getString(ctx.index())) 50 | } 51 | 52 | // Getting a String value from a JDBC CallableStatement and converting that to a JsonElement 53 | @Throws(SQLException::class) 54 | override fun get(ctx: BindingGetStatementContext) { 55 | ctx.convert(converter()).value(ctx.statement().getString(ctx.index())) 56 | } 57 | 58 | // Setting a value on a JDBC SQLOutput (useful for Oracle OBJECT types) 59 | @Throws(SQLException::class) 60 | override fun set(ctx: BindingSetSQLOutputContext) { 61 | throw SQLFeatureNotSupportedException() 62 | } 63 | 64 | // Getting a value from a JDBC SQLInput (useful for Oracle OBJECT types) 65 | @Throws(SQLException::class) 66 | override fun get(ctx: BindingGetSQLInputContext) { 67 | throw SQLFeatureNotSupportedException() 68 | } 69 | 70 | companion object { 71 | val objectMapper = ObjectMapper() 72 | } 73 | } 74 | 75 | */ 76 | -------------------------------------------------------------------------------- /qingzhenyun-common-jooq/src/main/kotlin/com/qingzhenyun/common/jooq/binding/CommonJacksonBinding.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.jooq.binding 2 | 3 | import com.fasterxml.jackson.databind.JsonNode 4 | import com.fasterxml.jackson.databind.ObjectMapper 5 | import org.jooq.* 6 | import org.jooq.impl.DSL 7 | import java.sql.SQLFeatureNotSupportedException 8 | import java.sql.Types 9 | import java.util.* 10 | 11 | class CommonJacksonBinding : Binding { 12 | override fun register(ctx: BindingRegisterContext) { 13 | ctx.statement().registerOutParameter(ctx.index(), Types.VARCHAR) 14 | } 15 | 16 | override fun sql(ctx: BindingSQLContext) { 17 | ctx.render().visit(DSL.`val`(ctx.convert(converter()).value())).sql("::json") 18 | } 19 | 20 | override fun converter(): Converter { 21 | return object : Converter { 22 | override fun from(t: Any?): JsonNode? { 23 | //logger.info("Convert data {}",t) 24 | /* 25 | if (t == null) { 26 | return null 27 | } 28 | val typeRef = object : TypeReference>() {} 29 | */ 30 | return objectMapper.readTree(t.toString()) 31 | } 32 | 33 | override fun to(u: JsonNode?): String? { 34 | return if (u == null || u.isNull) null else objectMapper.writeValueAsString(u) 35 | } 36 | 37 | override fun fromType(): Class { 38 | return Any::class.java 39 | } 40 | 41 | override fun toType(): Class { 42 | @Suppress("UNCHECKED_CAST") 43 | return JsonNode::class.java 44 | } 45 | } 46 | } 47 | 48 | override fun get(ctx: BindingGetResultSetContext) { 49 | ctx.convert(converter()).value(ctx.resultSet().getString(ctx.index())) 50 | } 51 | 52 | override fun get(ctx: BindingGetStatementContext) { 53 | ctx.convert(converter()).value(ctx.statement().getString(ctx.index())) 54 | } 55 | 56 | override fun get(ctx: BindingGetSQLInputContext?) { 57 | throw SQLFeatureNotSupportedException() 58 | } 59 | 60 | override fun set(ctx: BindingSetStatementContext) { 61 | ctx.statement().setString(ctx.index(), Objects.toString(ctx.convert(converter()).value(), null)) 62 | } 63 | 64 | override fun set(ctx: BindingSetSQLOutputContext?) { 65 | throw SQLFeatureNotSupportedException() 66 | } 67 | 68 | companion object { 69 | val objectMapper = ObjectMapper() 70 | // val logger = LoggerFactory.getLogger(CommonJsonBinding::class.java) 71 | } 72 | } -------------------------------------------------------------------------------- /qingzhenyun-common-jooq/src/main/kotlin/com/qingzhenyun/common/jooq/binding/CommonJsonBinding.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.jooq.binding 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference 4 | import com.fasterxml.jackson.databind.ObjectMapper 5 | import org.jooq.* 6 | import org.jooq.impl.DSL 7 | import java.sql.SQLException 8 | import java.sql.SQLFeatureNotSupportedException 9 | import java.sql.Types 10 | import java.util.* 11 | 12 | class CommonJsonBinding : Binding> { 13 | override fun register(ctx: BindingRegisterContext>) { 14 | ctx.statement().registerOutParameter(ctx.index(), Types.VARCHAR) 15 | } 16 | 17 | override fun sql(ctx: BindingSQLContext>) { 18 | // Depending on how you generate your SQL, you may need to explicitly distinguish 19 | // between jOOQ generating bind variables or inlined literals. If so, use this check: 20 | // ctx.render().paramType() == INLINED 21 | ctx.render().visit(DSL.`val`(ctx.convert(converter()).value())).sql("::json") 22 | } 23 | 24 | override fun converter(): Converter> { 25 | return object : Converter> { 26 | override fun from(t: Any?): Map? { 27 | //logger.info("Convert data {}",t) 28 | if (t == null) { 29 | return null 30 | } 31 | val typeRef = object : TypeReference>() {} 32 | return objectMapper.readValue(t.toString(), typeRef) 33 | } 34 | 35 | override fun to(u: Map?): String? { 36 | return if (u == null || u.isEmpty()) null else objectMapper.writeValueAsString(u) 37 | } 38 | 39 | override fun fromType(): Class { 40 | return Any::class.java 41 | } 42 | 43 | override fun toType(): Class> { 44 | @Suppress("UNCHECKED_CAST") 45 | return Map::class.java as Class> 46 | } 47 | } 48 | } 49 | 50 | 51 | // Converting the JsonElement to a String value and setting that on a JDBC PreparedStatement 52 | @Throws(SQLException::class) 53 | override fun set(ctx: BindingSetStatementContext>) { 54 | ctx.statement().setString(ctx.index(), Objects.toString(ctx.convert(converter()).value(), null)) 55 | } 56 | 57 | // Getting a String value from a JDBC ResultSet and converting that to a JsonElement 58 | @Throws(SQLException::class) 59 | override fun get(ctx: BindingGetResultSetContext>) { 60 | ctx.convert(converter()).value(ctx.resultSet().getString(ctx.index())) 61 | } 62 | 63 | // Getting a String value from a JDBC CallableStatement and converting that to a JsonElement 64 | @Throws(SQLException::class) 65 | override fun get(ctx: BindingGetStatementContext>) { 66 | ctx.convert(converter()).value(ctx.statement().getString(ctx.index())) 67 | } 68 | 69 | // Setting a value on a JDBC SQLOutput (useful for Oracle OBJECT types) 70 | @Throws(SQLException::class) 71 | override fun set(ctx: BindingSetSQLOutputContext>) { 72 | throw SQLFeatureNotSupportedException() 73 | } 74 | 75 | // Getting a value from a JDBC SQLInput (useful for Oracle OBJECT types) 76 | @Throws(SQLException::class) 77 | override fun get(ctx: BindingGetSQLInputContext>) { 78 | throw SQLFeatureNotSupportedException() 79 | } 80 | 81 | companion object { 82 | val objectMapper = ObjectMapper() 83 | // val logger = LoggerFactory.getLogger(CommonJsonBinding::class.java) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /qingzhenyun-common-springboot/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | repositories { 4 | mavenCentral() 5 | } 6 | dependencies { 7 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 8 | } 9 | } 10 | 11 | group 'com.qingzhenyun' 12 | version '1.0-SNAPSHOT' 13 | 14 | apply plugin: 'java' 15 | apply plugin: 'kotlin' 16 | 17 | sourceCompatibility = 1.8 18 | 19 | repositories { 20 | mavenCentral() 21 | } 22 | 23 | dependencies { 24 | compile project(':qingzhenyun-common') 25 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 26 | testCompile group: 'junit', name: 'junit', version: junit_version 27 | compile "org.springframework.boot:spring-boot:${springBootVersion}" 28 | } 29 | 30 | compileKotlin { 31 | kotlinOptions.jvmTarget = jvm_target 32 | } 33 | compileTestKotlin { 34 | kotlinOptions.jvmTarget = jvm_target 35 | } -------------------------------------------------------------------------------- /qingzhenyun-common-springboot/src/main/java/TestClass.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | import java.util.Map; 3 | 4 | public class TestClass { 5 | public void test() { 6 | Map ab = new HashMap(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /qingzhenyun-common-springboot/src/test/kotlin/com/qingzhenyun/common/util/QStringUtilTest.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.util 2 | 3 | import org.junit.Assert.assertEquals 4 | import org.junit.Assert.assertNotEquals 5 | import org.junit.Test 6 | 7 | class QStringUtilTest { 8 | 9 | @Test 10 | fun formatPath() { 11 | assertEquals("/", QStringUtil.formatPath("")) 12 | assertEquals("/", QStringUtil.formatPath("/")) 13 | assertEquals("/", QStringUtil.formatPath("//")) 14 | assertEquals("/", QStringUtil.formatPath("//\\")) 15 | assertEquals("/D", QStringUtil.formatPath("D")) 16 | assertEquals("/D", QStringUtil.formatPath("/D")) 17 | assertEquals("/D", QStringUtil.formatPath("/D ")) 18 | assertEquals("/D A", QStringUtil.formatPath("/D A")) 19 | assertEquals("/D", QStringUtil.formatPath("//D")) 20 | assertEquals("/D", QStringUtil.formatPath("//D\\")) 21 | assertEquals("/D", QStringUtil.formatPath("//\\D")) 22 | assertEquals("/D/S", QStringUtil.formatPath("D//\\S")) 23 | assertEquals("/D/S", QStringUtil.formatPath("//D/S")) 24 | assertEquals("/D/S", QStringUtil.formatPath("//D\\\\S")) 25 | assertEquals("/D/S", QStringUtil.formatPath("//\\D\\\\\\//\\S\\\\\\\\")) 26 | assertEquals("/D/S", QStringUtil.formatPath("//\\D\\\\/\\S\\\\\\\\")) 27 | assertEquals("/D/S", QStringUtil.formatPath("//\\D\\\\/\\S\\//\\\\")) 28 | assertEquals("/d/s", QStringUtil.formatPath("//D\\\\S", true)) 29 | assertEquals("/d/s", QStringUtil.formatPath("//\\D\\\\\\//\\S\\\\\\\\", true)) 30 | assertEquals("/d/s", QStringUtil.formatPath("//\\D\\\\/\\S\\\\\\\\", true)) 31 | assertEquals("/d/s", QStringUtil.formatPath("//\\D\\\\/\\S\\//\\\\", true)) 32 | } 33 | 34 | @Test 35 | fun getFileExt() { 36 | 37 | assertEquals("1.txt", QStringUtil.getFileName(QStringUtil.formatPath("1.txt"))) 38 | assertEquals("1.txt", QStringUtil.getFileName(QStringUtil.formatPath("/a/b/1.txt"))) 39 | assertNotEquals("1.txt", QStringUtil.getFileName(QStringUtil.formatPath("/a/b/1.pac"))) 40 | 41 | assertEquals(".txt", QStringUtil.getFileExt(QStringUtil.formatPath("1.txt"))) 42 | assertEquals(".txt", QStringUtil.getFileExt(QStringUtil.formatPath("/a/b/1.txt"))) 43 | assertNotEquals(".txt", QStringUtil.getFileExt(QStringUtil.formatPath("/a/b/1.pac"))) 44 | assertEquals(".txt", QStringUtil.getFileExt(QStringUtil.formatPath(".txt"))) 45 | assertEquals(".txt", QStringUtil.getFileExt(QStringUtil.formatPath(".txt"))) 46 | assertEquals("", QStringUtil.getFileExt(QStringUtil.formatPath("txt"))) 47 | assertEquals("", QStringUtil.getFileExt(QStringUtil.formatPath("a.b.c/txt"))) 48 | assertEquals("", QStringUtil.getFileExt(QStringUtil.formatPath("a.b.c/txt."))) 49 | 50 | assertEquals("", QStringUtil.getFileParentPath("")) 51 | assertEquals("", QStringUtil.getFileParentPath("/")) 52 | assertEquals("/a", QStringUtil.getFileParentPath("/a/c")) 53 | assertEquals("/a/c", QStringUtil.getFileParentPath("/a/c/d")) 54 | } 55 | } -------------------------------------------------------------------------------- /qingzhenyun-common/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-common/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-common/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | //ext.kotlin_version = '1.2.30' 3 | 4 | repositories { 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 9 | } 10 | } 11 | 12 | group 'com.qingzhenyun' 13 | version '1.0-SNAPSHOT' 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.8 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 26 | compile("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}") 27 | compile group: 'org.slf4j', name: 'slf4j-api', version: slf4j_version 28 | testCompile group: 'junit', name: 'junit', version: junit_version 29 | } 30 | 31 | compileKotlin { 32 | kotlinOptions.jvmTarget = jvm_target 33 | } 34 | compileTestKotlin { 35 | kotlinOptions.jvmTarget = jvm_target 36 | } -------------------------------------------------------------------------------- /qingzhenyun-common/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-common/src/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-common/src/main/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-common/src/main/kotlin/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-common/src/main/kotlin/com/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/qingzhenyun/common/constants/CloudStoreConstants.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.constants 2 | 3 | object CloudStoreConstants { 4 | const val WCS_TYPE = 0 5 | } -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/qingzhenyun/common/constants/UserFileConstants.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.constants 2 | 3 | object UserFileConstants { 4 | const val ROOT_NAME = "" 5 | 6 | const val DIRECTORY_TYPE = 1 7 | const val FILE_TYPE = 0 8 | } 9 | 10 | object UserFileOperate { 11 | const val ADD = 4 12 | const val DELETE = 1 13 | const val MOVE = 2 14 | const val RENAME = 3 15 | const val COPY = 5 16 | } -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/qingzhenyun/common/entity/RecordPage.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.entity 2 | 3 | import java.io.Serializable 4 | import java.util.* 5 | import java.util.function.Consumer 6 | 7 | class RecordPage : Serializable, Iterable { 8 | 9 | var page = 1 10 | 11 | var pageSize = 20 12 | private set 13 | 14 | // 总页面数 15 | var totalCount: Int = 0 16 | set(totalCount) { 17 | field = totalCount 18 | totalPage = Math 19 | .ceil(1.0 * this.totalCount / this.pageSize).toInt() 20 | 21 | if (totalPage == 0) { 22 | totalPage = 1 23 | } 24 | if (page > totalPage) { 25 | page = totalPage 26 | } 27 | } 28 | 29 | var totalPage = 0 30 | private set 31 | 32 | var list: List? = null 33 | 34 | val start: Int 35 | get() = (this.page - 1) * this.pageSize 36 | 37 | constructor(page: Int?, pageSize: Int?) { 38 | if (page != null && page > 0) { 39 | this.page = page 40 | } else { 41 | this.page = 1 42 | } 43 | this.pageSize = if (pageSize == null) 20 else if (pageSize > 9999) 9999 else if (pageSize < 1) 1 else pageSize 44 | } 45 | 46 | constructor(page: Int) { 47 | if (page > 0) { 48 | this.page = page 49 | } 50 | } 51 | 52 | constructor() 53 | 54 | fun setPageSize(pageSize: Int?) { 55 | this.pageSize = if (pageSize == null) 20 else if (pageSize > 9999) 9999 else if (pageSize < 1) 1 else pageSize 56 | } 57 | 58 | 59 | override fun iterator(): Iterator { 60 | return list!!.iterator() 61 | } 62 | 63 | override fun forEach(action: Consumer?) { 64 | list!!.forEach(action) 65 | } 66 | 67 | override fun spliterator(): Spliterator { 68 | return list!!.spliterator() 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/qingzhenyun/common/entity/TrustedPath.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.entity 2 | 3 | import com.qingzhenyun.common.util.QStringUtil 4 | 5 | class TrustedPath(sourcePath: String?) { 6 | val path: String = QStringUtil.formatPath(sourcePath) 7 | val uuid: String = QStringUtil.pathHash(path, false) 8 | fun isRoot(): Boolean { 9 | return path.isEmpty() || uuid.isEmpty() || "/" == path 10 | } 11 | } -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/qingzhenyun/common/entity/usercenter/LoginSsid.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.entity.usercenter 2 | 3 | class LoginSsid -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/qingzhenyun/common/util/HASH.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.util 2 | 3 | import java.io.UnsupportedEncodingException 4 | import java.security.MessageDigest 5 | import java.security.NoSuchAlgorithmException 6 | import java.security.SecureRandom 7 | import java.util.* 8 | 9 | private object Helper { 10 | 11 | fun getRandomString(): String = SecureRandom().nextLong().toString() 12 | 13 | fun getRandomBytes(size: Int): ByteArray { 14 | val random = SecureRandom() 15 | val bytes = ByteArray(size) 16 | random.nextBytes(bytes) 17 | return bytes 18 | } 19 | 20 | fun getRawBytes(text: String): ByteArray { 21 | return try { 22 | text.toByteArray(Charsets.UTF_8) 23 | } catch (e: UnsupportedEncodingException) { 24 | text.toByteArray() 25 | } 26 | } 27 | 28 | fun getString(data: ByteArray): String { 29 | try { 30 | return String(data, Charsets.UTF_8) 31 | } catch (e: UnsupportedEncodingException) { 32 | return String(data) 33 | } 34 | 35 | } 36 | 37 | fun base64Decode(text: String): ByteArray { 38 | return Base64.getDecoder().decode(text) 39 | //return Base64.decode(text, Base64.NO_WRAP) 40 | } 41 | 42 | fun base64Encode(data: ByteArray): String { 43 | return Base64.getEncoder().encodeToString(data) 44 | //return Base64.encodeToString(data, Base64.NO_WRAP) 45 | } 46 | } 47 | 48 | object HASH { 49 | private val MD5 = "MD5" 50 | private val SHA_1 = "SHA-1" 51 | private val SHA_256 = "SHA-256" 52 | private val DIGITS_LOWER = charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f') 53 | private val DIGITS_UPPER = charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F') 54 | 55 | fun md5(data: ByteArray): String { 56 | return String(encodeHex(md5Bytes(data))) 57 | } 58 | 59 | fun md5(text: String): String { 60 | return String(encodeHex(md5Bytes(Helper.getRawBytes(text)))) 61 | } 62 | 63 | fun md5Bytes(data: ByteArray): ByteArray { 64 | return getDigest(MD5).digest(data) 65 | } 66 | 67 | fun sha1(data: ByteArray): String { 68 | return String(encodeHex(sha1Bytes(data))) 69 | } 70 | 71 | fun sha1(text: String): String { 72 | return String(encodeHex(sha1Bytes(Helper.getRawBytes(text)))) 73 | } 74 | 75 | fun sha1Bytes(data: ByteArray): ByteArray { 76 | return getDigest(SHA_1).digest(data) 77 | } 78 | 79 | fun sha256(data: ByteArray): String { 80 | return String(encodeHex(sha256Bytes(data))) 81 | } 82 | 83 | fun sha256(text: String): String { 84 | return String(encodeHex(sha256Bytes(Helper.getRawBytes(text)))) 85 | } 86 | 87 | fun sha256Bytes(data: ByteArray): ByteArray { 88 | return getDigest(SHA_256).digest(data) 89 | } 90 | 91 | fun getDigest(algorithm: String): MessageDigest { 92 | try { 93 | return MessageDigest.getInstance(algorithm) 94 | } catch (e: NoSuchAlgorithmException) { 95 | throw IllegalArgumentException(e) 96 | } 97 | 98 | } 99 | 100 | private fun encodeHex(data: ByteArray, toLowerCase: Boolean = true): CharArray { 101 | return encodeHex(data, if (toLowerCase) DIGITS_LOWER else DIGITS_UPPER) 102 | } 103 | 104 | private fun encodeHex(data: ByteArray, toDigits: CharArray): CharArray { 105 | val l = data.size 106 | val out = CharArray(l shl 1) 107 | var i = 0 108 | var j = 0 109 | while (i < l) { 110 | out[j++] = toDigits[(240 and data[i].toInt()).ushr(4)] 111 | out[j++] = toDigits[15 and data[i].toInt()] 112 | i++ 113 | } 114 | return out 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /qingzhenyun-common/src/main/kotlin/com/qingzhenyun/common/util/QStringUtil.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.util 2 | 3 | import java.net.URLEncoder 4 | 5 | object QStringUtil { 6 | fun randomString(outputStrLength: Int): String { 7 | val len = if (outputStrLength > 1) outputStrLength - 1 else 1 8 | val chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 9 | var passWord = "" 10 | for (i in 0..len) { 11 | passWord += chars[Math.floor(Math.random() * chars.length).toInt()] 12 | } 13 | return passWord 14 | } 15 | 16 | // Like Javascript's encodeURI function 17 | fun encodeUri(str: String?): String? { 18 | if (str.isNullOrEmpty()) { 19 | return str 20 | } 21 | val sb = StringBuilder() 22 | str!!.split('/').forEach { v -> sb.append(URLEncoder.encode(v, "UTF-8")).append('/') } 23 | //val len = sb.length 24 | if (sb.isNotEmpty()) { 25 | return sb.substring(0, sb.length - 1) 26 | } 27 | return sb.toString() 28 | } 29 | 30 | fun getFileName(filePath: String): String { 31 | val xNameArr = filePath.split('/') 32 | return xNameArr[xNameArr.size - 1] 33 | } 34 | 35 | fun getFileParentPath(filePath: String): String { 36 | val pos = filePath.lastIndexOf('/') 37 | return if (pos == -1) { 38 | "" 39 | } else { 40 | filePath.substring(0, pos) 41 | } 42 | } 43 | 44 | fun getFileExt(filePath: String): String? { 45 | val xNameArr = getFileName(filePath).split('.') 46 | if (xNameArr.size < 2) { 47 | return "" 48 | } 49 | val ext = xNameArr[xNameArr.size - 1] 50 | return if (ext.isEmpty()) { 51 | ext 52 | } else { 53 | ".$ext" 54 | } 55 | } 56 | 57 | 58 | fun formatPath(path: String?, ignoreCase: Boolean = false): String { 59 | if (path == null) { 60 | return "/" 61 | } 62 | if (path.isNullOrEmpty()) { 63 | return "/" 64 | } 65 | var xPath = if (ignoreCase) path.trim().toLowerCase() else path.trim() 66 | while (xPath.contains("\\")) { 67 | xPath = xPath.replace('\\', '/') 68 | } 69 | /* 70 | while (xPath.contains("//")) { 71 | xPath = xPath.replace("//", "/") 72 | } 73 | */ 74 | 75 | xPath = xPath.split('/') 76 | .filter { c -> c.isNotEmpty() } 77 | .joinToString("/") { c -> if (c.length > 16384) c.substring(0, 16384) else c } 78 | 79 | if (xPath.endsWith('/')) { 80 | xPath = xPath.substring(0, xPath.length - 1) 81 | } 82 | if (xPath.isEmpty()) { 83 | return "/" 84 | } 85 | if (!xPath.startsWith('/')) { 86 | xPath = "/$xPath" 87 | } 88 | return xPath 89 | } 90 | 91 | fun pathHash(path: String?, clean: Boolean = true): String { 92 | val xPath = if (!clean) path ?: "" else formatPath(path) 93 | //HASH.md5() 94 | if (xPath.isEmpty()) { 95 | return "" 96 | } 97 | return HASH.md5(xPath) 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | //ext.kotlin_version = '1.2.30' 3 | 4 | repositories { 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 9 | } 10 | } 11 | 12 | group 'com.qingzhenyun' 13 | version '1.0-SNAPSHOT' 14 | 15 | apply plugin: 'java' 16 | apply plugin: 'kotlin' 17 | 18 | sourceCompatibility = 1.8 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | dependencies { 25 | compile project(':qingzhenyun-common-springboot') 26 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 27 | compile group: 'com.zeroc', name: 'ice', version: ice_version 28 | testCompile group: 'junit', name: 'junit', version: junit_version 29 | } 30 | 31 | compileKotlin { 32 | kotlinOptions.jvmTarget = jvm_target 33 | } 34 | compileTestKotlin { 35 | kotlinOptions.jvmTarget = jvm_target 36 | } -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/cloudstore.ice: -------------------------------------------------------------------------------- 1 | [["java:package:com.qingzhenyun.common.ice"]] 2 | module cloudstore { 3 | class CloudStoreResponse { 4 | string hash; 5 | long size; 6 | string mime; 7 | long uploadUser; 8 | long ctime; 9 | string originalFilename; 10 | string bucket; 11 | string key; 12 | int type; 13 | int preview; 14 | string uploadIp; 15 | int flag; 16 | bool hasPreview; 17 | }; 18 | class KnownMimeResponse { 19 | long uuid; 20 | string mime; 21 | int previewState; 22 | int level; 23 | int isReg; 24 | } 25 | 26 | class UnknownMimeResponse { 27 | long uuid; 28 | string mime; 29 | long createTime; 30 | } 31 | 32 | struct CloudStoreTokenResponse { 33 | string name; 34 | string parent; 35 | string path; 36 | string token; 37 | int type; 38 | string uploadUrl; 39 | int version; 40 | }; 41 | 42 | class SimpleDetailResponse { 43 | string hash; 44 | long size; 45 | int preview; 46 | string mime; 47 | int flag; 48 | bool hasPreview; 49 | }; 50 | 51 | class PreviewTaskResponse { 52 | string hash; 53 | int status; 54 | string info; 55 | long createTime; 56 | long updateTime; 57 | }; 58 | 59 | class CloudStoreResponseEx extends CloudStoreResponse { 60 | string downloadAddress; 61 | }; 62 | sequence IntList; 63 | 64 | sequence UnknownMimeResponseList; 65 | sequence KnownMimeResponseList; 66 | sequence StringSequence; 67 | sequence PreviewTaskResponseList; 68 | sequence SimpleDetailResponseSequence; 69 | 70 | 71 | interface CloudStoreServiceHandler{ 72 | KnownMimeResponseList getKnownMimeList(); 73 | UnknownMimeResponseList getUnknownMimeList(); 74 | bool addUnknownMime(string mime); 75 | CloudStoreTokenResponse createUploadToken(long userId,string parent,string path,string name, string originalFilename); 76 | CloudStoreResponse get(string hash); 77 | CloudStoreResponseEx getEx(string hash,long userId,bool internal); 78 | CloudStoreResponse uploadFile(string response); 79 | SimpleDetailResponseSequence getList(StringSequence hashList); 80 | SimpleDetailResponse getSimple(string hash); 81 | PreviewTaskResponseList fetchPreviewTask(string serverId,IntList status,int nextStatus, int size); 82 | PreviewTaskResponse updatePreviewTask(string serverId,string hash, PreviewTaskResponse data); 83 | PreviewTaskResponse updatePreviewTaskInfo(string serverId,string hash, int status, string info); 84 | bool finishPreviewTask(string serverId, string hash, int status); 85 | bool updateMimeAndKey(string serverId, string hash, string mime, bool finish, int status ,string bucket, string key); 86 | } 87 | } -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/common/CommonPage.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `common.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.common; 22 | 23 | public class CommonPage extends com.zeroc.Ice.Value 24 | { 25 | public CommonPage() 26 | { 27 | } 28 | 29 | public CommonPage(int page, int pageSize, int totalCount, int totalPage) 30 | { 31 | this.page = page; 32 | this.pageSize = pageSize; 33 | this.totalCount = totalCount; 34 | this.totalPage = totalPage; 35 | } 36 | 37 | public int page; 38 | 39 | public int pageSize; 40 | 41 | public int totalCount; 42 | 43 | public int totalPage; 44 | 45 | public CommonPage clone() 46 | { 47 | return (CommonPage)super.clone(); 48 | } 49 | 50 | public static String ice_staticId() 51 | { 52 | return "::common::CommonPage"; 53 | } 54 | 55 | @Override 56 | public String ice_id() 57 | { 58 | return ice_staticId(); 59 | } 60 | 61 | public static final long serialVersionUID = -3080956421140362601L; 62 | 63 | @Override 64 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) 65 | { 66 | ostr_.startSlice(ice_staticId(), -1, true); 67 | ostr_.writeInt(page); 68 | ostr_.writeInt(pageSize); 69 | ostr_.writeInt(totalCount); 70 | ostr_.writeInt(totalPage); 71 | ostr_.endSlice(); 72 | } 73 | 74 | @Override 75 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) 76 | { 77 | istr_.startSlice(); 78 | page = istr_.readInt(); 79 | pageSize = istr_.readInt(); 80 | totalCount = istr_.readInt(); 81 | totalPage = istr_.readInt(); 82 | istr_.endSlice(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/common/CommonRpcException.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `common.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.common; 22 | 23 | public class CommonRpcException extends com.zeroc.Ice.UserException 24 | { 25 | public CommonRpcException() 26 | { 27 | this.innerMessage = ""; 28 | } 29 | 30 | public CommonRpcException(Throwable cause) 31 | { 32 | super(cause); 33 | this.innerMessage = ""; 34 | } 35 | 36 | public CommonRpcException(int innerCode, String innerMessage) 37 | { 38 | this.innerCode = innerCode; 39 | this.innerMessage = innerMessage; 40 | } 41 | 42 | public CommonRpcException(int innerCode, String innerMessage, Throwable cause) 43 | { 44 | super(cause); 45 | this.innerCode = innerCode; 46 | this.innerMessage = innerMessage; 47 | } 48 | 49 | public String ice_id() 50 | { 51 | return "::common::CommonRpcException"; 52 | } 53 | 54 | public int innerCode; 55 | 56 | public String innerMessage; 57 | 58 | @Override 59 | protected void _writeImpl(com.zeroc.Ice.OutputStream ostr_) 60 | { 61 | ostr_.startSlice("::common::CommonRpcException", -1, true); 62 | ostr_.writeInt(innerCode); 63 | ostr_.writeString(innerMessage); 64 | ostr_.endSlice(); 65 | } 66 | 67 | @Override 68 | protected void _readImpl(com.zeroc.Ice.InputStream istr_) 69 | { 70 | istr_.startSlice(); 71 | innerCode = istr_.readInt(); 72 | innerMessage = istr_.readString(); 73 | istr_.endSlice(); 74 | } 75 | 76 | public static final long serialVersionUID = -6698224072596681125L; 77 | } 78 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/common/_Marker.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `common.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.common; 22 | 23 | interface _Marker 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/FileOperationException.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class FileOperationException extends com.qingzhenyun.common.ice.common.CommonRpcException 24 | { 25 | public FileOperationException() 26 | { 27 | super(); 28 | } 29 | 30 | public FileOperationException(Throwable cause) 31 | { 32 | super(cause); 33 | } 34 | 35 | public FileOperationException(int innerCode, String innerMessage, int fileType) 36 | { 37 | super(innerCode, innerMessage); 38 | this.fileType = fileType; 39 | } 40 | 41 | public FileOperationException(int innerCode, String innerMessage, int fileType, Throwable cause) 42 | { 43 | super(innerCode, innerMessage, cause); 44 | this.fileType = fileType; 45 | } 46 | 47 | public String ice_id() 48 | { 49 | return "::userfile::FileOperationException"; 50 | } 51 | 52 | public int fileType; 53 | 54 | @Override 55 | protected void _writeImpl(com.zeroc.Ice.OutputStream ostr_) 56 | { 57 | ostr_.startSlice("::userfile::FileOperationException", -1, false); 58 | ostr_.writeInt(fileType); 59 | ostr_.endSlice(); 60 | super._writeImpl(ostr_); 61 | } 62 | 63 | @Override 64 | protected void _readImpl(com.zeroc.Ice.InputStream istr_) 65 | { 66 | istr_.startSlice(); 67 | fileType = istr_.readInt(); 68 | istr_.endSlice(); 69 | super._readImpl(istr_); 70 | } 71 | 72 | public static final long serialVersionUID = -4385438827145581631L; 73 | } 74 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/SimpleFile.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class SimpleFile extends com.zeroc.Ice.Value 24 | { 25 | public SimpleFile() 26 | { 27 | this.uuid = ""; 28 | this.path = ""; 29 | } 30 | 31 | public SimpleFile(String uuid, String path) 32 | { 33 | this.uuid = uuid; 34 | this.path = path; 35 | } 36 | 37 | public String uuid; 38 | 39 | public String path; 40 | 41 | public SimpleFile clone() 42 | { 43 | return (SimpleFile)super.clone(); 44 | } 45 | 46 | public static String ice_staticId() 47 | { 48 | return "::userfile::SimpleFile"; 49 | } 50 | 51 | @Override 52 | public String ice_id() 53 | { 54 | return ice_staticId(); 55 | } 56 | 57 | public static final long serialVersionUID = 4537723145648043118L; 58 | 59 | @Override 60 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) 61 | { 62 | ostr_.startSlice(ice_staticId(), -1, true); 63 | ostr_.writeString(uuid); 64 | ostr_.writeString(path); 65 | ostr_.endSlice(); 66 | } 67 | 68 | @Override 69 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) 70 | { 71 | istr_.startSlice(); 72 | uuid = istr_.readString(); 73 | path = istr_.readString(); 74 | istr_.endSlice(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/SimpleFileListHelper.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public final class SimpleFileListHelper 24 | { 25 | public static void write(com.zeroc.Ice.OutputStream ostr, SimpleFile[] v) 26 | { 27 | if(v == null) 28 | { 29 | ostr.writeSize(0); 30 | } 31 | else 32 | { 33 | ostr.writeSize(v.length); 34 | for(int i0 = 0; i0 < v.length; i0++) 35 | { 36 | ostr.writeValue(v[i0]); 37 | } 38 | } 39 | } 40 | 41 | public static SimpleFile[] read(com.zeroc.Ice.InputStream istr) 42 | { 43 | final SimpleFile[] v; 44 | final int len0 = istr.readAndCheckSeqSize(1); 45 | v = new SimpleFile[len0]; 46 | for(int i0 = 0; i0 < len0; i0++) 47 | { 48 | final int fi0 = i0; 49 | istr.readValue(value -> v[fi0] = value, SimpleFile.class); 50 | } 51 | return v; 52 | } 53 | 54 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, java.util.Optional v) 55 | { 56 | if(v != null && v.isPresent()) 57 | { 58 | write(ostr, tag, v.get()); 59 | } 60 | } 61 | 62 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, SimpleFile[] v) 63 | { 64 | if(ostr.writeOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) 65 | { 66 | int pos = ostr.startSize(); 67 | SimpleFileListHelper.write(ostr, v); 68 | ostr.endSize(pos); 69 | } 70 | } 71 | 72 | public static java.util.Optional read(com.zeroc.Ice.InputStream istr, int tag) 73 | { 74 | if(istr.readOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) 75 | { 76 | istr.skip(4); 77 | SimpleFile[] v; 78 | v = SimpleFileListHelper.read(istr); 79 | return java.util.Optional.of(v); 80 | } 81 | else 82 | { 83 | return java.util.Optional.empty(); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/UserAsyncTask.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserAsyncTask extends com.zeroc.Ice.Value 24 | { 25 | public UserAsyncTask() 26 | { 27 | this.uuid = ""; 28 | this.destUuid = ""; 29 | } 30 | 31 | public UserAsyncTask(long userId, String uuid, String destUuid, int type, long createTime) 32 | { 33 | this.userId = userId; 34 | this.uuid = uuid; 35 | this.destUuid = destUuid; 36 | this.type = type; 37 | this.createTime = createTime; 38 | } 39 | 40 | public long userId; 41 | 42 | public String uuid; 43 | 44 | public String destUuid; 45 | 46 | public int type; 47 | 48 | public long createTime; 49 | 50 | public UserAsyncTask clone() 51 | { 52 | return (UserAsyncTask)super.clone(); 53 | } 54 | 55 | public static String ice_staticId() 56 | { 57 | return "::userfile::UserAsyncTask"; 58 | } 59 | 60 | @Override 61 | public String ice_id() 62 | { 63 | return ice_staticId(); 64 | } 65 | 66 | public static final long serialVersionUID = 3478657503434412904L; 67 | 68 | @Override 69 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) 70 | { 71 | ostr_.startSlice(ice_staticId(), -1, true); 72 | ostr_.writeLong(userId); 73 | ostr_.writeString(uuid); 74 | ostr_.writeString(destUuid); 75 | ostr_.writeInt(type); 76 | ostr_.writeLong(createTime); 77 | ostr_.endSlice(); 78 | } 79 | 80 | @Override 81 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) 82 | { 83 | istr_.startSlice(); 84 | userId = istr_.readLong(); 85 | uuid = istr_.readString(); 86 | destUuid = istr_.readString(); 87 | type = istr_.readInt(); 88 | createTime = istr_.readLong(); 89 | istr_.endSlice(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/UserFilePageResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserFilePageResponse extends com.qingzhenyun.common.ice.common.CommonPage 24 | { 25 | public UserFilePageResponse() 26 | { 27 | super(); 28 | } 29 | 30 | public UserFilePageResponse(int page, int pageSize, int totalCount, int totalPage, UserFileResponse[] list) 31 | { 32 | super(page, pageSize, totalCount, totalPage); 33 | this.list = list; 34 | } 35 | 36 | public UserFileResponse[] list; 37 | 38 | public UserFilePageResponse clone() 39 | { 40 | return (UserFilePageResponse)super.clone(); 41 | } 42 | 43 | public static String ice_staticId() 44 | { 45 | return "::userfile::UserFilePageResponse"; 46 | } 47 | 48 | @Override 49 | public String ice_id() 50 | { 51 | return ice_staticId(); 52 | } 53 | 54 | public static final long serialVersionUID = -7468370555184437513L; 55 | 56 | @Override 57 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) 58 | { 59 | ostr_.startSlice(ice_staticId(), -1, false); 60 | UserFileResponseListHelper.write(ostr_, list); 61 | ostr_.endSlice(); 62 | super._iceWriteImpl(ostr_); 63 | } 64 | 65 | @Override 66 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) 67 | { 68 | istr_.startSlice(); 69 | list = UserFileResponseListHelper.read(istr_); 70 | istr_.endSlice(); 71 | super._iceReadImpl(istr_); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/UserFileResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserFileResponse extends com.zeroc.Ice.Value 24 | { 25 | public UserFileResponse() 26 | { 27 | this.uuid = ""; 28 | this.storeId = ""; 29 | this.path = ""; 30 | this.name = ""; 31 | this.ext = ""; 32 | this.parent = ""; 33 | } 34 | 35 | public UserFileResponse(String uuid, String storeId, long userId, String path, String name, String ext, long size, String parent, int type, long atime, long ctime, long mtime, int version, boolean locking, int opt) 36 | { 37 | this.uuid = uuid; 38 | this.storeId = storeId; 39 | this.userId = userId; 40 | this.path = path; 41 | this.name = name; 42 | this.ext = ext; 43 | this.size = size; 44 | this.parent = parent; 45 | this.type = type; 46 | this.atime = atime; 47 | this.ctime = ctime; 48 | this.mtime = mtime; 49 | this.version = version; 50 | this.locking = locking; 51 | this.opt = opt; 52 | } 53 | 54 | public String uuid; 55 | 56 | public String storeId; 57 | 58 | public long userId; 59 | 60 | public String path; 61 | 62 | public String name; 63 | 64 | public String ext; 65 | 66 | public long size; 67 | 68 | public String parent; 69 | 70 | public int type; 71 | 72 | public long atime; 73 | 74 | public long ctime; 75 | 76 | public long mtime; 77 | 78 | public int version; 79 | 80 | public boolean locking; 81 | 82 | public int opt; 83 | 84 | public UserFileResponse clone() 85 | { 86 | return (UserFileResponse)super.clone(); 87 | } 88 | 89 | public static String ice_staticId() 90 | { 91 | return "::userfile::UserFileResponse"; 92 | } 93 | 94 | @Override 95 | public String ice_id() 96 | { 97 | return ice_staticId(); 98 | } 99 | 100 | public static final long serialVersionUID = 7397492762507671988L; 101 | 102 | @Override 103 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) 104 | { 105 | ostr_.startSlice(ice_staticId(), -1, true); 106 | ostr_.writeString(uuid); 107 | ostr_.writeString(storeId); 108 | ostr_.writeLong(userId); 109 | ostr_.writeString(path); 110 | ostr_.writeString(name); 111 | ostr_.writeString(ext); 112 | ostr_.writeLong(size); 113 | ostr_.writeString(parent); 114 | ostr_.writeInt(type); 115 | ostr_.writeLong(atime); 116 | ostr_.writeLong(ctime); 117 | ostr_.writeLong(mtime); 118 | ostr_.writeInt(version); 119 | ostr_.writeBool(locking); 120 | ostr_.writeInt(opt); 121 | ostr_.endSlice(); 122 | } 123 | 124 | @Override 125 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) 126 | { 127 | istr_.startSlice(); 128 | uuid = istr_.readString(); 129 | storeId = istr_.readString(); 130 | userId = istr_.readLong(); 131 | path = istr_.readString(); 132 | name = istr_.readString(); 133 | ext = istr_.readString(); 134 | size = istr_.readLong(); 135 | parent = istr_.readString(); 136 | type = istr_.readInt(); 137 | atime = istr_.readLong(); 138 | ctime = istr_.readLong(); 139 | mtime = istr_.readLong(); 140 | version = istr_.readInt(); 141 | locking = istr_.readBool(); 142 | opt = istr_.readInt(); 143 | istr_.endSlice(); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/UserFileResponseListHelper.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public final class UserFileResponseListHelper 24 | { 25 | public static void write(com.zeroc.Ice.OutputStream ostr, UserFileResponse[] v) 26 | { 27 | if(v == null) 28 | { 29 | ostr.writeSize(0); 30 | } 31 | else 32 | { 33 | ostr.writeSize(v.length); 34 | for(int i0 = 0; i0 < v.length; i0++) 35 | { 36 | ostr.writeValue(v[i0]); 37 | } 38 | } 39 | } 40 | 41 | public static UserFileResponse[] read(com.zeroc.Ice.InputStream istr) 42 | { 43 | final UserFileResponse[] v; 44 | final int len0 = istr.readAndCheckSeqSize(1); 45 | v = new UserFileResponse[len0]; 46 | for(int i0 = 0; i0 < len0; i0++) 47 | { 48 | final int fi0 = i0; 49 | istr.readValue(value -> v[fi0] = value, UserFileResponse.class); 50 | } 51 | return v; 52 | } 53 | 54 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, java.util.Optional v) 55 | { 56 | if(v != null && v.isPresent()) 57 | { 58 | write(ostr, tag, v.get()); 59 | } 60 | } 61 | 62 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, UserFileResponse[] v) 63 | { 64 | if(ostr.writeOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) 65 | { 66 | int pos = ostr.startSize(); 67 | UserFileResponseListHelper.write(ostr, v); 68 | ostr.endSize(pos); 69 | } 70 | } 71 | 72 | public static java.util.Optional read(com.zeroc.Ice.InputStream istr, int tag) 73 | { 74 | if(istr.readOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) 75 | { 76 | istr.skip(4); 77 | UserFileResponse[] v; 78 | v = UserFileResponseListHelper.read(istr); 79 | return java.util.Optional.of(v); 80 | } 81 | else 82 | { 83 | return java.util.Optional.empty(); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/UserOfflinePageResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserOfflinePageResponse extends com.qingzhenyun.common.ice.common.CommonPage 24 | { 25 | public UserOfflinePageResponse() 26 | { 27 | super(); 28 | } 29 | 30 | public UserOfflinePageResponse(int page, int pageSize, int totalCount, int totalPage, UserOfflineResponse[] list) 31 | { 32 | super(page, pageSize, totalCount, totalPage); 33 | this.list = list; 34 | } 35 | 36 | public UserOfflineResponse[] list; 37 | 38 | public UserOfflinePageResponse clone() 39 | { 40 | return (UserOfflinePageResponse)super.clone(); 41 | } 42 | 43 | public static String ice_staticId() 44 | { 45 | return "::userfile::UserOfflinePageResponse"; 46 | } 47 | 48 | @Override 49 | public String ice_id() 50 | { 51 | return ice_staticId(); 52 | } 53 | 54 | public static final long serialVersionUID = -7132854797303454448L; 55 | 56 | @Override 57 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) 58 | { 59 | ostr_.startSlice(ice_staticId(), -1, false); 60 | UserOfflineResponseListHelper.write(ostr_, list); 61 | ostr_.endSlice(); 62 | super._iceWriteImpl(ostr_); 63 | } 64 | 65 | @Override 66 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) 67 | { 68 | istr_.startSlice(); 69 | list = UserOfflineResponseListHelper.read(istr_); 70 | istr_.endSlice(); 71 | super._iceReadImpl(istr_); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/UserOfflineResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserOfflineResponse extends com.zeroc.Ice.Value 24 | { 25 | public UserOfflineResponse() 26 | { 27 | this.taskHash = ""; 28 | this.path = ""; 29 | this.mime = ""; 30 | this.name = ""; 31 | this.files = ""; 32 | this.copied = ""; 33 | this.uuid = ""; 34 | this.destUuid = ""; 35 | } 36 | 37 | public UserOfflineResponse(long userId, String taskHash, String path, long size, String mime, String name, String files, String copied, long createTime, String uuid, String destUuid, int progress, int status) 38 | { 39 | this.userId = userId; 40 | this.taskHash = taskHash; 41 | this.path = path; 42 | this.size = size; 43 | this.mime = mime; 44 | this.name = name; 45 | this.files = files; 46 | this.copied = copied; 47 | this.createTime = createTime; 48 | this.uuid = uuid; 49 | this.destUuid = destUuid; 50 | this.progress = progress; 51 | this.status = status; 52 | } 53 | 54 | public long userId; 55 | 56 | public String taskHash; 57 | 58 | public String path; 59 | 60 | public long size; 61 | 62 | public String mime; 63 | 64 | public String name; 65 | 66 | public String files; 67 | 68 | public String copied; 69 | 70 | public long createTime; 71 | 72 | public String uuid; 73 | 74 | public String destUuid; 75 | 76 | public int progress; 77 | 78 | public int status; 79 | 80 | public UserOfflineResponse clone() 81 | { 82 | return (UserOfflineResponse)super.clone(); 83 | } 84 | 85 | public static String ice_staticId() 86 | { 87 | return "::userfile::UserOfflineResponse"; 88 | } 89 | 90 | @Override 91 | public String ice_id() 92 | { 93 | return ice_staticId(); 94 | } 95 | 96 | public static final long serialVersionUID = -3873357766978096979L; 97 | 98 | @Override 99 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) 100 | { 101 | ostr_.startSlice(ice_staticId(), -1, true); 102 | ostr_.writeLong(userId); 103 | ostr_.writeString(taskHash); 104 | ostr_.writeString(path); 105 | ostr_.writeLong(size); 106 | ostr_.writeString(mime); 107 | ostr_.writeString(name); 108 | ostr_.writeString(files); 109 | ostr_.writeString(copied); 110 | ostr_.writeLong(createTime); 111 | ostr_.writeString(uuid); 112 | ostr_.writeString(destUuid); 113 | ostr_.writeInt(progress); 114 | ostr_.writeInt(status); 115 | ostr_.endSlice(); 116 | } 117 | 118 | @Override 119 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) 120 | { 121 | istr_.startSlice(); 122 | userId = istr_.readLong(); 123 | taskHash = istr_.readString(); 124 | path = istr_.readString(); 125 | size = istr_.readLong(); 126 | mime = istr_.readString(); 127 | name = istr_.readString(); 128 | files = istr_.readString(); 129 | copied = istr_.readString(); 130 | createTime = istr_.readLong(); 131 | uuid = istr_.readString(); 132 | destUuid = istr_.readString(); 133 | progress = istr_.readInt(); 134 | status = istr_.readInt(); 135 | istr_.endSlice(); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/UserOfflineResponseListHelper.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public final class UserOfflineResponseListHelper 24 | { 25 | public static void write(com.zeroc.Ice.OutputStream ostr, UserOfflineResponse[] v) 26 | { 27 | if(v == null) 28 | { 29 | ostr.writeSize(0); 30 | } 31 | else 32 | { 33 | ostr.writeSize(v.length); 34 | for(int i0 = 0; i0 < v.length; i0++) 35 | { 36 | ostr.writeValue(v[i0]); 37 | } 38 | } 39 | } 40 | 41 | public static UserOfflineResponse[] read(com.zeroc.Ice.InputStream istr) 42 | { 43 | final UserOfflineResponse[] v; 44 | final int len0 = istr.readAndCheckSeqSize(1); 45 | v = new UserOfflineResponse[len0]; 46 | for(int i0 = 0; i0 < len0; i0++) 47 | { 48 | final int fi0 = i0; 49 | istr.readValue(value -> v[fi0] = value, UserOfflineResponse.class); 50 | } 51 | return v; 52 | } 53 | 54 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, java.util.Optional v) 55 | { 56 | if(v != null && v.isPresent()) 57 | { 58 | write(ostr, tag, v.get()); 59 | } 60 | } 61 | 62 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, UserOfflineResponse[] v) 63 | { 64 | if(ostr.writeOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) 65 | { 66 | int pos = ostr.startSize(); 67 | UserOfflineResponseListHelper.write(ostr, v); 68 | ostr.endSize(pos); 69 | } 70 | } 71 | 72 | public static java.util.Optional read(com.zeroc.Ice.InputStream istr, int tag) 73 | { 74 | if(istr.readOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) 75 | { 76 | istr.skip(4); 77 | UserOfflineResponse[] v; 78 | v = UserOfflineResponseListHelper.read(istr); 79 | return java.util.Optional.of(v); 80 | } 81 | else 82 | { 83 | return java.util.Optional.empty(); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/_Marker.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | interface _Marker 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/com/qingzhenyun/common/ice/userfile/_UserFileServiceHandlerPrxI.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class _UserFileServiceHandlerPrxI extends com.zeroc.Ice._ObjectPrxI implements UserFileServiceHandlerPrx 24 | { 25 | public static final long serialVersionUID = 0L; 26 | } 27 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/common.ice: -------------------------------------------------------------------------------- 1 | [["java:package:com.qingzhenyun.common.ice"]] 2 | module common{ 3 | class CommonPage { 4 | int page; 5 | int pageSize; 6 | int totalCount; 7 | int totalPage; 8 | }; 9 | exception CommonRpcException{ 10 | int innerCode; 11 | string innerMessage; 12 | }; 13 | sequence StringList; 14 | } 15 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/convert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | java_dir=../../main/java 3 | python_dir=./python 4 | cs_dir=./csharp 5 | python_dest_dir=../../../../../../vscode/qingzhenyun-python-toolbox 6 | python_dest_rpc_dir=rpcs 7 | node_dest_dir=../../../../../../vscode/qingzhenyun-api-gateway/src/app/ice 8 | node_dir=./javascript 9 | python_split=${python_dest_rpc_dir}. 10 | rm -rf ${python_dir} 11 | rm -rf ${node_dir} 12 | rm -rf ${cs_dir} 13 | mkdir -p ${python_dir} 14 | mkdir -p ${python_dir}/${python_dest_rpc_dir} 15 | mkdir -p ${node_dir} 16 | mkdir -p ${cs_dir} 17 | for file in ./*.ice 18 | do 19 | if test -f ${file} 20 | then 21 | echo ${file} 22 | slice2java ${file} -I ./ 23 | slice2py ${file} --output-dir=${python_dir} -I ./ --prefix=${python_split} 24 | # convert java 25 | slice2js ${file} --output-dir=${node_dir} -I ./ 26 | slice2cs ${file} --output-dir=${cs_dir} -I ./ 27 | fi 28 | 29 | # cp -r ${python_dir}/ ${python_dest_dir} 30 | # cp -r ${node_dir}/ ${node_dest_dir} 31 | done 32 | cp -r ./com ${java_dir} 33 | # do js file 34 | echo "Checking javascript files..." 35 | for file in ${node_dir}/*.js 36 | do 37 | if test -f ${file} 38 | then 39 | echo ${file} 40 | sed -i "" "s#require(\"common\")#require(\".\/common\")#g" ${file} 41 | fi 42 | done 43 | cp -r ${node_dir}/ ${node_dest_dir} 44 | rsp=${python_dest_rpc_dir}/ 45 | for file in ${python_dir}/${python_split}* 46 | do 47 | if test -f ${file} 48 | then 49 | echo processing ${file} 50 | mv ${file} ${file/${python_split}/${rsp}} 51 | fi 52 | done 53 | cp -r ${python_dir}/${rsp}common_ice.py ${python_dir} 54 | cp -r ${python_dir}/ ${python_dest_dir} -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/javascript/common.js: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `common.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | (function (module, require, exports) { 22 | const Ice = require("ice").Ice; 23 | const _ModuleRegistry = Ice._ModuleRegistry; 24 | const Slice = Ice.Slice; 25 | 26 | let common = _ModuleRegistry.module("common"); 27 | 28 | const iceC_common_CommonPage_ids = [ 29 | "::Ice::Object", 30 | "::common::CommonPage" 31 | ]; 32 | 33 | common.CommonPage = class extends Ice.Value { 34 | constructor(page = 0, pageSize = 0, totalCount = 0, totalPage = 0) { 35 | super(); 36 | this.page = page; 37 | this.pageSize = pageSize; 38 | this.totalCount = totalCount; 39 | this.totalPage = totalPage; 40 | } 41 | 42 | _iceWriteMemberImpl(ostr) { 43 | ostr.writeInt(this.page); 44 | ostr.writeInt(this.pageSize); 45 | ostr.writeInt(this.totalCount); 46 | ostr.writeInt(this.totalPage); 47 | } 48 | 49 | _iceReadMemberImpl(istr) { 50 | this.page = istr.readInt(); 51 | this.pageSize = istr.readInt(); 52 | this.totalCount = istr.readInt(); 53 | this.totalPage = istr.readInt(); 54 | } 55 | }; 56 | 57 | Slice.defineValue(common.CommonPage, iceC_common_CommonPage_ids[1], false); 58 | 59 | common.CommonPageDisp = class extends Ice.Object { 60 | }; 61 | 62 | Slice.defineOperations(common.CommonPageDisp, undefined, iceC_common_CommonPage_ids, 1); 63 | 64 | common.CommonRpcException = class extends Ice.UserException { 65 | constructor(innerCode = 0, innerMessage = "", _cause = "") { 66 | super(_cause); 67 | this.innerCode = innerCode; 68 | this.innerMessage = innerMessage; 69 | } 70 | 71 | static get _parent() { 72 | return Ice.UserException; 73 | } 74 | 75 | static get _id() { 76 | return "::common::CommonRpcException"; 77 | } 78 | 79 | _mostDerivedType() { 80 | return common.CommonRpcException; 81 | } 82 | 83 | _writeMemberImpl(ostr) { 84 | ostr.writeInt(this.innerCode); 85 | ostr.writeString(this.innerMessage); 86 | } 87 | 88 | _readMemberImpl(istr) { 89 | this.innerCode = istr.readInt(); 90 | this.innerMessage = istr.readString(); 91 | } 92 | }; 93 | 94 | Slice.defineSequence(common, "StringListHelper", "Ice.StringHelper", false); 95 | exports.common = common; 96 | }; 97 | (typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined, 98 | typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? require : this.Ice._require, 99 | typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? exports : this) 100 | ) 101 | ; 102 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/offline.ice: -------------------------------------------------------------------------------- 1 | #include 2 | [["java:package:com.qingzhenyun.common.ice"]] 3 | module offline{ 4 | 5 | class SystemOfflineTaskResponse{ 6 | string taskId; 7 | int type; 8 | string name; 9 | int status; 10 | string serverId; 11 | long createTime; 12 | long updateTime; 13 | long createUser; 14 | string createIp; 15 | string detail; 16 | long size; 17 | int progress; 18 | long finishedSize; 19 | int errorCode; 20 | string mime; 21 | }; 22 | class SystemTaskDetailResponse{ 23 | string taskId; 24 | string path; 25 | long size; 26 | long completed; 27 | int progress; 28 | int order; 29 | string storeId; 30 | } 31 | sequence SystemTaskDetailResponseList; 32 | class SystemOfflineTaskWithDetailResponse{ 33 | SystemOfflineTaskResponse task; 34 | SystemTaskDetailResponseList detail; 35 | }; 36 | sequence SystemOfflineTaskResponseList; 37 | sequence IntList; 38 | class UserOfflineTaskResponse{ 39 | long userId; 40 | string taskId; 41 | string copyFile; 42 | string copiedFile; 43 | long createTime; 44 | string savePath; 45 | string filePath; 46 | long copied; 47 | int status; 48 | }; 49 | class CopyTaskResponse { 50 | string taskId; 51 | long userId; 52 | int progress; 53 | long updateTime; 54 | int status; 55 | long copied; 56 | long needCopySize; 57 | }; 58 | sequence UserOfflineTaskResponseList; 59 | sequence CopyTaskResponseList; 60 | class UserOfflinePageResponse extends common::CommonPage{ 61 | UserOfflineTaskResponseList list; 62 | }; 63 | sequence StringSequence; 64 | interface OfflineTaskServiceHandler{ 65 | SystemOfflineTaskResponse addSystemTask(string taskId,int type,string name, long createUser,string createIp, string detail); 66 | SystemOfflineTaskResponseList getSystemOfflineTaskList(StringSequence taskIdList); 67 | SystemOfflineTaskResponseList fetchTask(string serverId,IntList types,IntList status,int nextStatus, int size); 68 | bool updateDownloadingStatus(string taskId, string serverId,int status, string message, bool force); 69 | SystemOfflineTaskWithDetailResponse getSystemTask(string taskId); 70 | bool updateSystemTaskMetadata(SystemOfflineTaskWithDetailResponse data); 71 | bool updateSystemTaskDetail(SystemTaskDetailResponse data); 72 | bool finishOfflineTask(string taskId, int errorCode); 73 | bool updateTaskMime(string taskId, string mime); 74 | bool updateTaskProgress(string taskId, int status ,int progress, long size, long finishedSize); 75 | UserOfflineTaskResponse addUserTask(string taskId, long userId, string copyFile, string savePath); 76 | CopyTaskResponseList fetchCopyTask(int start, int size, int status, string taskId); 77 | UserOfflineTaskResponse fetchUserTask(string taskId, long userId); 78 | bool deleteCopyTask(string taskId); 79 | bool copyUserFile(string taskId, long userId, int status, int progress, long copied,long needCopySize, string copiedFile,string filePath); 80 | bool finishCopy(string taskId, long userId); 81 | UserOfflineTaskResponseList listOfflineTask(long userId,int start,int size,int order); 82 | UserOfflinePageResponse listOfflineTaskPage(long userId,int page,int pageSize,int order); 83 | 84 | //start:Int, size:Int, status: Int?, taskId: Skring 85 | /* 86 | UserResponse getNextUser(long userId); 87 | int sendMessage(string countryCode,string phone,int flag,string validateCode,int expireInSeconds) throws RegisterFailedException; 88 | bool validateMessage(string countryCode,string phone,int flag,string validateCode,bool deleteIfSuccess) throws RegisterFailedException; 89 | UserResponse getUserByUuid(long uuid); 90 | UserResponse getUserByPhone(string countryCode,string phone); 91 | bool checkUserExistsByName(string name); 92 | bool checkUserExistsByEmail(string email); 93 | bool checkUserExistsByPhone(string countryCode,string phone); 94 | bool changePassword(long uuid,string oldPassword,string newPassword); 95 | bool changePasswordByMessage(long userId,string countryCode,string phone,string newPassword); 96 | UserResponse loginByPhone(string countryCode,string phone,bool isMobile)throws LoginFailedException; 97 | bool logout(long userId,bool isMobile)throws LoginFailedException; 98 | UserResponse checkUserValidByName(string name,string password, bool isMobile) throws LoginFailedException; 99 | UserResponse checkUserValidByEmail(string email,string password,bool isMobile) throws LoginFailedException; 100 | UserResponse checkUserValidByPhone(string countryCode,string phone,string password,bool isMobile) throws LoginFailedException; 101 | */ 102 | }; 103 | }; -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/python/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by slice2py - DO NOT EDIT! 2 | # 3 | 4 | import Ice 5 | Ice.updateModule("common") 6 | 7 | # Modules: 8 | import rpcs.common_ice 9 | 10 | # Submodules: 11 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/python/common_ice.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ********************************************************************** 3 | # 4 | # Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 5 | # 6 | # This copy of Ice is licensed to you under the terms described in the 7 | # ICE_LICENSE file included in this distribution. 8 | # 9 | # ********************************************************************** 10 | # 11 | # Ice version 3.7.0 12 | # 13 | # 14 | # 15 | # Generated from file `common.ice' 16 | # 17 | # Warning: do not edit this file. 18 | # 19 | # 20 | # 21 | 22 | from sys import version_info as _version_info_ 23 | import Ice, IcePy 24 | 25 | # Start of module common 26 | _M_common = Ice.openModule('common') 27 | __name__ = 'common' 28 | 29 | if 'CommonPage' not in _M_common.__dict__: 30 | _M_common.CommonPage = Ice.createTempClass() 31 | class CommonPage(Ice.Value): 32 | def __init__(self, page=0, pageSize=0, totalCount=0, totalPage=0): 33 | self.page = page 34 | self.pageSize = pageSize 35 | self.totalCount = totalCount 36 | self.totalPage = totalPage 37 | 38 | def ice_id(self): 39 | return '::common::CommonPage' 40 | 41 | @staticmethod 42 | def ice_staticId(): 43 | return '::common::CommonPage' 44 | 45 | def __str__(self): 46 | return IcePy.stringify(self, _M_common._t_CommonPage) 47 | 48 | __repr__ = __str__ 49 | 50 | _M_common._t_CommonPage = IcePy.defineValue('::common::CommonPage', CommonPage, -1, (), False, False, None, ( 51 | ('page', (), IcePy._t_int, False, 0), 52 | ('pageSize', (), IcePy._t_int, False, 0), 53 | ('totalCount', (), IcePy._t_int, False, 0), 54 | ('totalPage', (), IcePy._t_int, False, 0) 55 | )) 56 | CommonPage._ice_type = _M_common._t_CommonPage 57 | 58 | _M_common.CommonPage = CommonPage 59 | del CommonPage 60 | 61 | if 'CommonRpcException' not in _M_common.__dict__: 62 | _M_common.CommonRpcException = Ice.createTempClass() 63 | class CommonRpcException(Ice.UserException): 64 | def __init__(self, innerCode=0, innerMessage=''): 65 | self.innerCode = innerCode 66 | self.innerMessage = innerMessage 67 | 68 | def __str__(self): 69 | return IcePy.stringifyException(self) 70 | 71 | __repr__ = __str__ 72 | 73 | _ice_id = '::common::CommonRpcException' 74 | 75 | _M_common._t_CommonRpcException = IcePy.defineException('::common::CommonRpcException', CommonRpcException, (), False, None, ( 76 | ('innerCode', (), IcePy._t_int, False, 0), 77 | ('innerMessage', (), IcePy._t_string, False, 0) 78 | )) 79 | CommonRpcException._ice_type = _M_common._t_CommonRpcException 80 | 81 | _M_common.CommonRpcException = CommonRpcException 82 | del CommonRpcException 83 | 84 | if '_t_StringList' not in _M_common.__dict__: 85 | _M_common._t_StringList = IcePy.defineSequence('::common::StringList', (), IcePy._t_string) 86 | 87 | # End of module common 88 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/python/userfile/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by slice2py - DO NOT EDIT! 2 | # 3 | 4 | import Ice 5 | Ice.updateModule("userfile") 6 | 7 | # Modules: 8 | import rpcs.userfile_ice 9 | 10 | # Submodules: 11 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/ice/usercenter.ice: -------------------------------------------------------------------------------- 1 | [["java:package:com.qingzhenyun.common.ice"]] 2 | module usercenter{ 3 | exception RegisterFailedException{ 4 | int innerCode; 5 | string innerMessage; 6 | }; 7 | exception LoginFailedException{ 8 | int innerCode; 9 | string innerMessage; 10 | }; 11 | //["java:type:java.util.HashMap"] 12 | dictionary SsidMap; 13 | class UserDataResponse{ 14 | long uuid; 15 | string name; 16 | // string password = 2; 17 | // private final String salt; 18 | string email; 19 | string countryCode; 20 | string phone; 21 | long createTime; 22 | // private final String createIp; 23 | string createIp; 24 | SsidMap ssid; 25 | string icon; 26 | long spaceUsed; 27 | long spaceCapacity; 28 | int type; 29 | int status; 30 | int version; 31 | /* 32 | int type; 33 | int ban; 34 | long banTime; 35 | long refreshTime; 36 | long lastLoginTime; 37 | string validateAddon; 38 | int validate; 39 | int version; 40 | */ 41 | }; 42 | sequence UserDataResponseList; 43 | interface UserCenterServiceHandler{ 44 | UserDataResponseList walkUser(long uuid, int size); 45 | UserDataResponse registerUser(string name,string password,string countryCode,string phone,string ip,string device) throws RegisterFailedException; 46 | UserDataResponse getUserByUuid(long uuid); 47 | UserDataResponse getUserByPhone(string countryCode,string phone); 48 | UserDataResponse loginByName(string name,string password, string device) throws LoginFailedException; 49 | UserDataResponse loginByPhone(string countryCode,string phone,string password, string device) throws LoginFailedException; 50 | UserDataResponse loginByMessage(string countryCode,string phone, string device) throws LoginFailedException; 51 | UserDataResponse logout(long uuid, string device); 52 | int updateUserSpaceUsage(long uuid, long spaceUsed); 53 | bool changePassword(long uuid,string oldPassword,string newPassword); 54 | bool changePasswordByUuid(long uuid,string newPassword); 55 | /* 56 | UserResponse getNextUser(long userId); 57 | int sendMessage(string countryCode,string phone,int flag,string validateCode,int expireInSeconds) throws RegisterFailedException; 58 | bool validateMessage(string countryCode,string phone,int flag,string validateCode,bool deleteIfSuccess) throws RegisterFailedException; 59 | UserResponse getUserByUuid(long uuid); 60 | UserResponse getUserByPhone(string countryCode,string phone); 61 | bool checkUserExistsByName(string name); 62 | bool checkUserExistsByEmail(string email); 63 | bool checkUserExistsByPhone(string countryCode,string phone); 64 | bool changePassword(long uuid,string oldPassword,string newPassword); 65 | bool changePasswordByMessage(long userId,string countryCode,string phone,string newPassword); 66 | UserResponse loginByPhone(string countryCode,string phone,bool isMobile)throws LoginFailedException; 67 | bool logout(long userId,bool isMobile)throws LoginFailedException; 68 | UserResponse checkUserValidByName(string name,string password, bool isMobile) throws LoginFailedException; 69 | UserResponse checkUserValidByEmail(string email,string password,bool isMobile) throws LoginFailedException; 70 | UserResponse checkUserValidByPhone(string countryCode,string phone,string password,bool isMobile) throws LoginFailedException; 71 | */ 72 | }; 73 | }; -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/common/CommonPage.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `common.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.common; 22 | 23 | public class CommonPage extends com.zeroc.Ice.Value { 24 | public static final long serialVersionUID = -3080956421140362601L; 25 | public int page; 26 | public int pageSize; 27 | public int totalCount; 28 | public int totalPage; 29 | 30 | public CommonPage() { 31 | } 32 | 33 | public CommonPage(int page, int pageSize, int totalCount, int totalPage) { 34 | this.page = page; 35 | this.pageSize = pageSize; 36 | this.totalCount = totalCount; 37 | this.totalPage = totalPage; 38 | } 39 | 40 | public static String ice_staticId() { 41 | return "::common::CommonPage"; 42 | } 43 | 44 | public CommonPage clone() { 45 | return (CommonPage) super.clone(); 46 | } 47 | 48 | @Override 49 | public String ice_id() { 50 | return ice_staticId(); 51 | } 52 | 53 | @Override 54 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) { 55 | ostr_.startSlice(ice_staticId(), -1, true); 56 | ostr_.writeInt(page); 57 | ostr_.writeInt(pageSize); 58 | ostr_.writeInt(totalCount); 59 | ostr_.writeInt(totalPage); 60 | ostr_.endSlice(); 61 | } 62 | 63 | @Override 64 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) { 65 | istr_.startSlice(); 66 | page = istr_.readInt(); 67 | pageSize = istr_.readInt(); 68 | totalCount = istr_.readInt(); 69 | totalPage = istr_.readInt(); 70 | istr_.endSlice(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/common/CommonRpcException.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `common.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.common; 22 | 23 | public class CommonRpcException extends com.zeroc.Ice.UserException { 24 | public static final long serialVersionUID = -6698224072596681125L; 25 | public int innerCode; 26 | public String innerMessage; 27 | 28 | public CommonRpcException() { 29 | this.innerMessage = ""; 30 | } 31 | 32 | public CommonRpcException(Throwable cause) { 33 | super(cause); 34 | this.innerMessage = ""; 35 | } 36 | 37 | public CommonRpcException(int innerCode, String innerMessage) { 38 | this.innerCode = innerCode; 39 | this.innerMessage = innerMessage; 40 | } 41 | 42 | public CommonRpcException(int innerCode, String innerMessage, Throwable cause) { 43 | super(cause); 44 | this.innerCode = innerCode; 45 | this.innerMessage = innerMessage; 46 | } 47 | 48 | public String ice_id() { 49 | return "::common::CommonRpcException"; 50 | } 51 | 52 | @Override 53 | protected void _writeImpl(com.zeroc.Ice.OutputStream ostr_) { 54 | ostr_.startSlice("::common::CommonRpcException", -1, true); 55 | ostr_.writeInt(innerCode); 56 | ostr_.writeString(innerMessage); 57 | ostr_.endSlice(); 58 | } 59 | 60 | @Override 61 | protected void _readImpl(com.zeroc.Ice.InputStream istr_) { 62 | istr_.startSlice(); 63 | innerCode = istr_.readInt(); 64 | innerMessage = istr_.readString(); 65 | istr_.endSlice(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/common/_Marker.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `common.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.common; 22 | 23 | interface _Marker { 24 | } 25 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/FileOperationException.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class FileOperationException extends com.qingzhenyun.common.ice.common.CommonRpcException { 24 | public static final long serialVersionUID = -4385438827145581631L; 25 | public int fileType; 26 | 27 | public FileOperationException() { 28 | super(); 29 | } 30 | 31 | public FileOperationException(Throwable cause) { 32 | super(cause); 33 | } 34 | 35 | public FileOperationException(int innerCode, String innerMessage, int fileType) { 36 | super(innerCode, innerMessage); 37 | this.fileType = fileType; 38 | } 39 | 40 | public FileOperationException(int innerCode, String innerMessage, int fileType, Throwable cause) { 41 | super(innerCode, innerMessage, cause); 42 | this.fileType = fileType; 43 | } 44 | 45 | public String ice_id() { 46 | return "::userfile::FileOperationException"; 47 | } 48 | 49 | @Override 50 | protected void _writeImpl(com.zeroc.Ice.OutputStream ostr_) { 51 | ostr_.startSlice("::userfile::FileOperationException", -1, false); 52 | ostr_.writeInt(fileType); 53 | ostr_.endSlice(); 54 | super._writeImpl(ostr_); 55 | } 56 | 57 | @Override 58 | protected void _readImpl(com.zeroc.Ice.InputStream istr_) { 59 | istr_.startSlice(); 60 | fileType = istr_.readInt(); 61 | istr_.endSlice(); 62 | super._readImpl(istr_); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/SimpleFile.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class SimpleFile extends com.zeroc.Ice.Value { 24 | public static final long serialVersionUID = 4537723145648043118L; 25 | public String uuid; 26 | public String path; 27 | 28 | public SimpleFile() { 29 | this.uuid = ""; 30 | this.path = ""; 31 | } 32 | 33 | public SimpleFile(String uuid, String path) { 34 | this.uuid = uuid; 35 | this.path = path; 36 | } 37 | 38 | public static String ice_staticId() { 39 | return "::userfile::SimpleFile"; 40 | } 41 | 42 | public SimpleFile clone() { 43 | return (SimpleFile) super.clone(); 44 | } 45 | 46 | @Override 47 | public String ice_id() { 48 | return ice_staticId(); 49 | } 50 | 51 | @Override 52 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) { 53 | ostr_.startSlice(ice_staticId(), -1, true); 54 | ostr_.writeString(uuid); 55 | ostr_.writeString(path); 56 | ostr_.endSlice(); 57 | } 58 | 59 | @Override 60 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) { 61 | istr_.startSlice(); 62 | uuid = istr_.readString(); 63 | path = istr_.readString(); 64 | istr_.endSlice(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/SimpleFileListHelper.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public final class SimpleFileListHelper { 24 | public static void write(com.zeroc.Ice.OutputStream ostr, SimpleFile[] v) { 25 | if (v == null) { 26 | ostr.writeSize(0); 27 | } else { 28 | ostr.writeSize(v.length); 29 | for (int i0 = 0; i0 < v.length; i0++) { 30 | ostr.writeValue(v[i0]); 31 | } 32 | } 33 | } 34 | 35 | public static SimpleFile[] read(com.zeroc.Ice.InputStream istr) { 36 | final SimpleFile[] v; 37 | final int len0 = istr.readAndCheckSeqSize(1); 38 | v = new SimpleFile[len0]; 39 | for (int i0 = 0; i0 < len0; i0++) { 40 | final int fi0 = i0; 41 | istr.readValue(value -> v[fi0] = value, SimpleFile.class); 42 | } 43 | return v; 44 | } 45 | 46 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, java.util.Optional v) { 47 | if (v != null && v.isPresent()) { 48 | write(ostr, tag, v.get()); 49 | } 50 | } 51 | 52 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, SimpleFile[] v) { 53 | if (ostr.writeOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) { 54 | int pos = ostr.startSize(); 55 | SimpleFileListHelper.write(ostr, v); 56 | ostr.endSize(pos); 57 | } 58 | } 59 | 60 | public static java.util.Optional read(com.zeroc.Ice.InputStream istr, int tag) { 61 | if (istr.readOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) { 62 | istr.skip(4); 63 | SimpleFile[] v; 64 | v = SimpleFileListHelper.read(istr); 65 | return java.util.Optional.of(v); 66 | } else { 67 | return java.util.Optional.empty(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/UserAsyncTask.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserAsyncTask extends com.zeroc.Ice.Value { 24 | public static final long serialVersionUID = 3478657503434412904L; 25 | public long userId; 26 | public String uuid; 27 | public String destUuid; 28 | public int type; 29 | public long createTime; 30 | 31 | public UserAsyncTask() { 32 | this.uuid = ""; 33 | this.destUuid = ""; 34 | } 35 | 36 | public UserAsyncTask(long userId, String uuid, String destUuid, int type, long createTime) { 37 | this.userId = userId; 38 | this.uuid = uuid; 39 | this.destUuid = destUuid; 40 | this.type = type; 41 | this.createTime = createTime; 42 | } 43 | 44 | public static String ice_staticId() { 45 | return "::userfile::UserAsyncTask"; 46 | } 47 | 48 | public UserAsyncTask clone() { 49 | return (UserAsyncTask) super.clone(); 50 | } 51 | 52 | @Override 53 | public String ice_id() { 54 | return ice_staticId(); 55 | } 56 | 57 | @Override 58 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) { 59 | ostr_.startSlice(ice_staticId(), -1, true); 60 | ostr_.writeLong(userId); 61 | ostr_.writeString(uuid); 62 | ostr_.writeString(destUuid); 63 | ostr_.writeInt(type); 64 | ostr_.writeLong(createTime); 65 | ostr_.endSlice(); 66 | } 67 | 68 | @Override 69 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) { 70 | istr_.startSlice(); 71 | userId = istr_.readLong(); 72 | uuid = istr_.readString(); 73 | destUuid = istr_.readString(); 74 | type = istr_.readInt(); 75 | createTime = istr_.readLong(); 76 | istr_.endSlice(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/UserFilePageResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserFilePageResponse extends com.qingzhenyun.common.ice.common.CommonPage { 24 | public static final long serialVersionUID = -7468370555184437513L; 25 | public UserFileResponse[] list; 26 | 27 | public UserFilePageResponse() { 28 | super(); 29 | } 30 | 31 | public UserFilePageResponse(int page, int pageSize, int totalCount, int totalPage, UserFileResponse[] list) { 32 | super(page, pageSize, totalCount, totalPage); 33 | this.list = list; 34 | } 35 | 36 | public static String ice_staticId() { 37 | return "::userfile::UserFilePageResponse"; 38 | } 39 | 40 | public UserFilePageResponse clone() { 41 | return (UserFilePageResponse) super.clone(); 42 | } 43 | 44 | @Override 45 | public String ice_id() { 46 | return ice_staticId(); 47 | } 48 | 49 | @Override 50 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) { 51 | ostr_.startSlice(ice_staticId(), -1, false); 52 | UserFileResponseListHelper.write(ostr_, list); 53 | ostr_.endSlice(); 54 | super._iceWriteImpl(ostr_); 55 | } 56 | 57 | @Override 58 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) { 59 | istr_.startSlice(); 60 | list = UserFileResponseListHelper.read(istr_); 61 | istr_.endSlice(); 62 | super._iceReadImpl(istr_); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/UserFileResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserFileResponse extends com.zeroc.Ice.Value { 24 | public static final long serialVersionUID = 7397492762507671988L; 25 | public String uuid; 26 | public String storeId; 27 | public long userId; 28 | public String path; 29 | public String name; 30 | public String ext; 31 | public long size; 32 | public String parent; 33 | public int type; 34 | public long atime; 35 | public long ctime; 36 | public long mtime; 37 | public int version; 38 | public boolean locking; 39 | public int opt; 40 | 41 | public UserFileResponse() { 42 | this.uuid = ""; 43 | this.storeId = ""; 44 | this.path = ""; 45 | this.name = ""; 46 | this.ext = ""; 47 | this.parent = ""; 48 | } 49 | 50 | public UserFileResponse(String uuid, String storeId, long userId, String path, String name, String ext, long size, String parent, int type, long atime, long ctime, long mtime, int version, boolean locking, int opt) { 51 | this.uuid = uuid; 52 | this.storeId = storeId; 53 | this.userId = userId; 54 | this.path = path; 55 | this.name = name; 56 | this.ext = ext; 57 | this.size = size; 58 | this.parent = parent; 59 | this.type = type; 60 | this.atime = atime; 61 | this.ctime = ctime; 62 | this.mtime = mtime; 63 | this.version = version; 64 | this.locking = locking; 65 | this.opt = opt; 66 | } 67 | 68 | public static String ice_staticId() { 69 | return "::userfile::UserFileResponse"; 70 | } 71 | 72 | public UserFileResponse clone() { 73 | return (UserFileResponse) super.clone(); 74 | } 75 | 76 | @Override 77 | public String ice_id() { 78 | return ice_staticId(); 79 | } 80 | 81 | @Override 82 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) { 83 | ostr_.startSlice(ice_staticId(), -1, true); 84 | ostr_.writeString(uuid); 85 | ostr_.writeString(storeId); 86 | ostr_.writeLong(userId); 87 | ostr_.writeString(path); 88 | ostr_.writeString(name); 89 | ostr_.writeString(ext); 90 | ostr_.writeLong(size); 91 | ostr_.writeString(parent); 92 | ostr_.writeInt(type); 93 | ostr_.writeLong(atime); 94 | ostr_.writeLong(ctime); 95 | ostr_.writeLong(mtime); 96 | ostr_.writeInt(version); 97 | ostr_.writeBool(locking); 98 | ostr_.writeInt(opt); 99 | ostr_.endSlice(); 100 | } 101 | 102 | @Override 103 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) { 104 | istr_.startSlice(); 105 | uuid = istr_.readString(); 106 | storeId = istr_.readString(); 107 | userId = istr_.readLong(); 108 | path = istr_.readString(); 109 | name = istr_.readString(); 110 | ext = istr_.readString(); 111 | size = istr_.readLong(); 112 | parent = istr_.readString(); 113 | type = istr_.readInt(); 114 | atime = istr_.readLong(); 115 | ctime = istr_.readLong(); 116 | mtime = istr_.readLong(); 117 | version = istr_.readInt(); 118 | locking = istr_.readBool(); 119 | opt = istr_.readInt(); 120 | istr_.endSlice(); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/UserFileResponseListHelper.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public final class UserFileResponseListHelper { 24 | public static void write(com.zeroc.Ice.OutputStream ostr, UserFileResponse[] v) { 25 | if (v == null) { 26 | ostr.writeSize(0); 27 | } else { 28 | ostr.writeSize(v.length); 29 | for (int i0 = 0; i0 < v.length; i0++) { 30 | ostr.writeValue(v[i0]); 31 | } 32 | } 33 | } 34 | 35 | public static UserFileResponse[] read(com.zeroc.Ice.InputStream istr) { 36 | final UserFileResponse[] v; 37 | final int len0 = istr.readAndCheckSeqSize(1); 38 | v = new UserFileResponse[len0]; 39 | for (int i0 = 0; i0 < len0; i0++) { 40 | final int fi0 = i0; 41 | istr.readValue(value -> v[fi0] = value, UserFileResponse.class); 42 | } 43 | return v; 44 | } 45 | 46 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, java.util.Optional v) { 47 | if (v != null && v.isPresent()) { 48 | write(ostr, tag, v.get()); 49 | } 50 | } 51 | 52 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, UserFileResponse[] v) { 53 | if (ostr.writeOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) { 54 | int pos = ostr.startSize(); 55 | UserFileResponseListHelper.write(ostr, v); 56 | ostr.endSize(pos); 57 | } 58 | } 59 | 60 | public static java.util.Optional read(com.zeroc.Ice.InputStream istr, int tag) { 61 | if (istr.readOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) { 62 | istr.skip(4); 63 | UserFileResponse[] v; 64 | v = UserFileResponseListHelper.read(istr); 65 | return java.util.Optional.of(v); 66 | } else { 67 | return java.util.Optional.empty(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/UserOfflinePageResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserOfflinePageResponse extends com.qingzhenyun.common.ice.common.CommonPage { 24 | public static final long serialVersionUID = -7132854797303454448L; 25 | public UserOfflineResponse[] list; 26 | 27 | public UserOfflinePageResponse() { 28 | super(); 29 | } 30 | 31 | public UserOfflinePageResponse(int page, int pageSize, int totalCount, int totalPage, UserOfflineResponse[] list) { 32 | super(page, pageSize, totalCount, totalPage); 33 | this.list = list; 34 | } 35 | 36 | public static String ice_staticId() { 37 | return "::userfile::UserOfflinePageResponse"; 38 | } 39 | 40 | public UserOfflinePageResponse clone() { 41 | return (UserOfflinePageResponse) super.clone(); 42 | } 43 | 44 | @Override 45 | public String ice_id() { 46 | return ice_staticId(); 47 | } 48 | 49 | @Override 50 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) { 51 | ostr_.startSlice(ice_staticId(), -1, false); 52 | UserOfflineResponseListHelper.write(ostr_, list); 53 | ostr_.endSlice(); 54 | super._iceWriteImpl(ostr_); 55 | } 56 | 57 | @Override 58 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) { 59 | istr_.startSlice(); 60 | list = UserOfflineResponseListHelper.read(istr_); 61 | istr_.endSlice(); 62 | super._iceReadImpl(istr_); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/UserOfflineResponse.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class UserOfflineResponse extends com.zeroc.Ice.Value { 24 | public static final long serialVersionUID = -3873357766978096979L; 25 | public long userId; 26 | public String taskHash; 27 | public String path; 28 | public long size; 29 | public String mime; 30 | public String name; 31 | public String files; 32 | public String copied; 33 | public long createTime; 34 | public String uuid; 35 | public String destUuid; 36 | public int progress; 37 | public int status; 38 | 39 | public UserOfflineResponse() { 40 | this.taskHash = ""; 41 | this.path = ""; 42 | this.mime = ""; 43 | this.name = ""; 44 | this.files = ""; 45 | this.copied = ""; 46 | this.uuid = ""; 47 | this.destUuid = ""; 48 | } 49 | 50 | public UserOfflineResponse(long userId, String taskHash, String path, long size, String mime, String name, String files, String copied, long createTime, String uuid, String destUuid, int progress, int status) { 51 | this.userId = userId; 52 | this.taskHash = taskHash; 53 | this.path = path; 54 | this.size = size; 55 | this.mime = mime; 56 | this.name = name; 57 | this.files = files; 58 | this.copied = copied; 59 | this.createTime = createTime; 60 | this.uuid = uuid; 61 | this.destUuid = destUuid; 62 | this.progress = progress; 63 | this.status = status; 64 | } 65 | 66 | public static String ice_staticId() { 67 | return "::userfile::UserOfflineResponse"; 68 | } 69 | 70 | public UserOfflineResponse clone() { 71 | return (UserOfflineResponse) super.clone(); 72 | } 73 | 74 | @Override 75 | public String ice_id() { 76 | return ice_staticId(); 77 | } 78 | 79 | @Override 80 | protected void _iceWriteImpl(com.zeroc.Ice.OutputStream ostr_) { 81 | ostr_.startSlice(ice_staticId(), -1, true); 82 | ostr_.writeLong(userId); 83 | ostr_.writeString(taskHash); 84 | ostr_.writeString(path); 85 | ostr_.writeLong(size); 86 | ostr_.writeString(mime); 87 | ostr_.writeString(name); 88 | ostr_.writeString(files); 89 | ostr_.writeString(copied); 90 | ostr_.writeLong(createTime); 91 | ostr_.writeString(uuid); 92 | ostr_.writeString(destUuid); 93 | ostr_.writeInt(progress); 94 | ostr_.writeInt(status); 95 | ostr_.endSlice(); 96 | } 97 | 98 | @Override 99 | protected void _iceReadImpl(com.zeroc.Ice.InputStream istr_) { 100 | istr_.startSlice(); 101 | userId = istr_.readLong(); 102 | taskHash = istr_.readString(); 103 | path = istr_.readString(); 104 | size = istr_.readLong(); 105 | mime = istr_.readString(); 106 | name = istr_.readString(); 107 | files = istr_.readString(); 108 | copied = istr_.readString(); 109 | createTime = istr_.readLong(); 110 | uuid = istr_.readString(); 111 | destUuid = istr_.readString(); 112 | progress = istr_.readInt(); 113 | status = istr_.readInt(); 114 | istr_.endSlice(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/UserOfflineResponseListHelper.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public final class UserOfflineResponseListHelper { 24 | public static void write(com.zeroc.Ice.OutputStream ostr, UserOfflineResponse[] v) { 25 | if (v == null) { 26 | ostr.writeSize(0); 27 | } else { 28 | ostr.writeSize(v.length); 29 | for (int i0 = 0; i0 < v.length; i0++) { 30 | ostr.writeValue(v[i0]); 31 | } 32 | } 33 | } 34 | 35 | public static UserOfflineResponse[] read(com.zeroc.Ice.InputStream istr) { 36 | final UserOfflineResponse[] v; 37 | final int len0 = istr.readAndCheckSeqSize(1); 38 | v = new UserOfflineResponse[len0]; 39 | for (int i0 = 0; i0 < len0; i0++) { 40 | final int fi0 = i0; 41 | istr.readValue(value -> v[fi0] = value, UserOfflineResponse.class); 42 | } 43 | return v; 44 | } 45 | 46 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, java.util.Optional v) { 47 | if (v != null && v.isPresent()) { 48 | write(ostr, tag, v.get()); 49 | } 50 | } 51 | 52 | public static void write(com.zeroc.Ice.OutputStream ostr, int tag, UserOfflineResponse[] v) { 53 | if (ostr.writeOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) { 54 | int pos = ostr.startSize(); 55 | UserOfflineResponseListHelper.write(ostr, v); 56 | ostr.endSize(pos); 57 | } 58 | } 59 | 60 | public static java.util.Optional read(com.zeroc.Ice.InputStream istr, int tag) { 61 | if (istr.readOptional(tag, com.zeroc.Ice.OptionalFormat.FSize)) { 62 | istr.skip(4); 63 | UserOfflineResponse[] v; 64 | v = UserOfflineResponseListHelper.read(istr); 65 | return java.util.Optional.of(v); 66 | } else { 67 | return java.util.Optional.empty(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/_Marker.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | interface _Marker { 24 | } 25 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/java/com/qingzhenyun/common/ice/userfile/_UserFileServiceHandlerPrxI.java: -------------------------------------------------------------------------------- 1 | // ********************************************************************** 2 | // 3 | // Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. 4 | // 5 | // This copy of Ice is licensed to you under the terms described in the 6 | // ICE_LICENSE file included in this distribution. 7 | // 8 | // ********************************************************************** 9 | // 10 | // Ice version 3.7.0 11 | // 12 | // 13 | // 14 | // Generated from file `userfile.ice' 15 | // 16 | // Warning: do not edit this file. 17 | // 18 | // 19 | // 20 | 21 | package com.qingzhenyun.common.ice.userfile; 22 | 23 | public class _UserFileServiceHandlerPrxI extends com.zeroc.Ice._ObjectPrxI implements UserFileServiceHandlerPrx { 24 | public static final long serialVersionUID = 0L; 25 | } 26 | -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/kotlin/com/qingzhenyun/common/ice/IceBootstrapContext.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.ice 2 | 3 | import com.zeroc.Ice.Communicator 4 | import com.zeroc.Ice.InitializationException 5 | import com.zeroc.Ice.Util 6 | import org.slf4j.LoggerFactory 7 | import org.springframework.beans.factory.DisposableBean 8 | import org.springframework.beans.factory.annotation.Autowired 9 | import org.springframework.boot.ApplicationArguments 10 | import org.springframework.boot.CommandLineRunner 11 | import org.springframework.context.support.AbstractApplicationContext 12 | import org.springframework.core.type.StandardMethodMetadata 13 | import java.util.* 14 | import java.util.stream.Stream 15 | 16 | abstract class IceBootstrapContext : CommandLineRunner, DisposableBean { 17 | @Autowired 18 | private val applicationArguments: ApplicationArguments? = null 19 | private var server: Communicator? = null 20 | @Autowired 21 | private val applicationContext: AbstractApplicationContext? = null 22 | 23 | @Throws(Exception::class) 24 | override fun run(args: Array) { 25 | 26 | var port = 8341 27 | var adapterName = "QingzhenyunAdapter" 28 | if (applicationArguments != null) { 29 | val options = applicationArguments.getOptionValues("adapter.name") 30 | if (options != null && options.size > 0 && options[0].isNotEmpty()) { 31 | adapterName = options[0] 32 | logger.info("Get adapter name {}", options[0]) 33 | } else { 34 | logger.warn("Can't parse adapter.name argument, using default value ({}).", adapterName) 35 | } 36 | } else { 37 | logger.warn("Missing adapter.name argument, using default value ({}).", adapterName) 38 | } 39 | 40 | val bootByIceGrid: Boolean = args.any { 41 | it.startsWith("--Ice.Config") 42 | } 43 | if (bootByIceGrid) { 44 | logger.info("Bootstrap ICE context using GRID...") 45 | } else { 46 | port = getPort() 47 | logger.warn("Bootstrap ICE context DIRECTLY...") 48 | } 49 | try { 50 | val initializedServer = Util.initialize(args) 51 | this.server = initializedServer 52 | val adapter = if (bootByIceGrid) server!!.createObjectAdapter(adapterName) else server!!.createObjectAdapterWithEndpoints(adapterName, "default -p $port") 53 | if (adapter != null) { 54 | if (bootByIceGrid) { 55 | logger.info("Start adapter by IceGrid...") 56 | } else { 57 | logger.info("Start adapter on $port...") 58 | } 59 | getBeanNamesByTypeWithAnnotation(IceHandler::class.java, com.zeroc.Ice.Object::class.java) 60 | .forEach { name -> 61 | val srv = applicationContext!!.beanFactory.getBean(name, com.zeroc.Ice.Object::class.java) 62 | logger.info("Adding ZeroC ICE rpc service {}", name) 63 | // 64 | val annotation = srv.javaClass.getAnnotation(IceHandler::class.java) 65 | if (annotation != null) { 66 | val handlerName = annotation.name 67 | adapter.add(srv, com.zeroc.Ice.Util.stringToIdentity(handlerName)) 68 | // server!!.addAdapter(srv,com.zeroc.Ice.Util.stringToIdentity(handlerName)) 69 | logger.info("Added ZeroC ICE rpc service {}", handlerName) 70 | } else { 71 | logger.warn("bean {} not have name.") 72 | } 73 | //val serviceDefinition = srv.bindService() 74 | //serverBuilder.addService(serviceDefinition) 75 | //logger.info("Is a",TProcessorFactory(srv.getIface()).isAsyncProcessor) 76 | // tArgs.processor(srv.getIface()); 77 | } 78 | adapter.activate() 79 | } 80 | 81 | } catch (initException: InitializationException) { 82 | logger.error(initException.reason) 83 | throw initException 84 | } 85 | } 86 | 87 | private fun getPort(): Int { 88 | var port = 8341 89 | if (applicationArguments != null) { 90 | val options = applicationArguments.getOptionValues("port") 91 | if (options != null && options.size > 0 && options[0].isNotEmpty()) { 92 | port = options[0].toInt() 93 | logger.info("Get listen port {}", port) 94 | } else { 95 | logger.warn("Can't parse port argument, using default value ({}).", port) 96 | } 97 | } else { 98 | logger.warn("Missing port argument, using default value ({}).", port) 99 | } 100 | return port 101 | } 102 | 103 | @Throws(Exception::class) 104 | private fun getBeanNamesByTypeWithAnnotation(annotationType: Class, beanType: Class): Stream { 105 | return Stream.of(*applicationContext!!.getBeanNamesForType(beanType)) 106 | .filter { name -> 107 | val beanDefinition = applicationContext.beanFactory.getBeanDefinition(name) 108 | val beansWithAnnotation = applicationContext.getBeansWithAnnotation(annotationType) 109 | if (!beansWithAnnotation.isEmpty()) { 110 | return@filter beansWithAnnotation.containsKey(name) 111 | } else if (beanDefinition.source is StandardMethodMetadata) { 112 | val metadata = beanDefinition.source as StandardMethodMetadata 113 | return@filter metadata.isAnnotated(annotationType.name) 114 | } 115 | false 116 | } 117 | } 118 | 119 | override fun destroy() { 120 | logger.info("Adapter closing...") 121 | Optional.ofNullable(server).ifPresent { it.shutdown() } 122 | } 123 | 124 | companion object { 125 | private val logger = LoggerFactory.getLogger(IceBootstrapContext::class.java) 126 | } 127 | } -------------------------------------------------------------------------------- /qingzhenyun-ice-sb-common/src/main/kotlin/com/qingzhenyun/common/ice/IceHandler.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.common.ice 2 | 3 | import org.springframework.stereotype.Service 4 | 5 | @Target(AnnotationTarget.CLASS, AnnotationTarget.FILE) 6 | @Retention(AnnotationRetention.RUNTIME) 7 | @MustBeDocumented 8 | @Service 9 | annotation class IceHandler(val name: String) -------------------------------------------------------------------------------- /qingzhenyun-ice-test/src/main/kotlin/com/qingzhenyun/ice/test/IceTestApplication.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.ice.test 2 | 3 | import com.qingzhenyun.common.ice.usercenter.UserCenterServiceHandlerPrx 4 | import org.slf4j.LoggerFactory 5 | import org.springframework.boot.autoconfigure.SpringBootApplication 6 | import org.springframework.boot.runApplication 7 | 8 | @SpringBootApplication 9 | open class IceTestApplication 10 | 11 | fun main(args: Array) { 12 | val logger = LoggerFactory.getLogger(IceTestApplication::class.java) 13 | runApplication(*args) 14 | logger.info("Init...") 15 | val communicator = com.zeroc.Ice.Util.initialize(args) 16 | val base = communicator.stringToProxy("UserCenterServiceHandler") 17 | val checked = UserCenterServiceHandlerPrx.checkedCast(base) 18 | if (checked != null) { 19 | logger.info("Checked!") 20 | val res = checked.test() 21 | logger.info(res.toString()) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /qingzhenyun-offline-download/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-offline-download/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-offline-download/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | //ext.kotlin_version = '1.2.30' 3 | 4 | repositories { 5 | mavenCentral() 6 | maven { url "https://repo.spring.io/snapshot" } 7 | maven { url "https://repo.spring.io/milestone" } 8 | maven { url 'https://plugins.gradle.org/m2/'} 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 13 | classpath("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}") 14 | classpath "nu.studer:gradle-jooq-plugin:$jooq_plugin_version" 15 | } 16 | } 17 | 18 | apply plugin: 'nu.studer.jooq' 19 | /* 20 | plugins { 21 | id 'nu.studer.jooq' version jooq_plugin_version 22 | } 23 | */ 24 | 25 | 26 | 27 | group 'com.qingzhenyun' 28 | version '1.0-SNAPSHOT' 29 | 30 | apply plugin: 'java' 31 | apply plugin: 'kotlin' 32 | apply plugin: 'org.springframework.boot' 33 | 34 | 35 | sourceCompatibility = 1.8 36 | 37 | repositories { 38 | mavenCentral() 39 | } 40 | 41 | dependencies { 42 | compile project(':qingzhenyun-ice-sb-common') 43 | compile project(':qingzhenyun-common-jooq') 44 | jooqRuntime group: 'org.postgresql', name: 'postgresql', version: postgres_version 45 | //compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 46 | compile("org.springframework.boot:spring-boot-starter:${springBootVersion}") 47 | testCompile group: 'junit', name: 'junit', version: junit_version 48 | compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}") 49 | compile("org.springframework.boot:spring-boot-starter-jooq:${springBootVersion}") 50 | compileOnly("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}") 51 | testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}") 52 | } 53 | 54 | compileKotlin { 55 | kotlinOptions.jvmTarget = jvm_target 56 | } 57 | compileTestKotlin { 58 | kotlinOptions.jvmTarget = jvm_target 59 | } 60 | 61 | compileJava.dependsOn(processResources) 62 | 63 | jooq { 64 | version = jooq_version // the default (can be omitted) 65 | offline(sourceSets.main) { 66 | jdbc { 67 | driver = 'org.postgresql.Driver' 68 | url = "${test_db_url}/${test_db_offline_download}" 69 | user = test_db_user 70 | password = test_db_password 71 | } 72 | generator { 73 | name = 'org.jooq.codegen.DefaultGenerator' 74 | strategy { 75 | name = 'org.jooq.codegen.DefaultGeneratorStrategy' 76 | } 77 | database { 78 | name = 'org.jooq.meta.postgres.PostgresDatabase' 79 | inputSchema = 'public' 80 | forcedTypes { 81 | forcedType { 82 | name = 'BOOLEAN' 83 | expression = '.*\\.HANDMADE' 84 | types = '.*' 85 | } 86 | } 87 | } 88 | 89 | generate { 90 | relations = true 91 | deprecated = false 92 | records = true 93 | immutablePojos = false 94 | fluentSetters = true 95 | pojos = true 96 | daos = false 97 | javaTimeTypes = true 98 | } 99 | target { 100 | packageName = 'com.qingzhenyun.generated.offline' 101 | //directory = 'src/main/java' 102 | encoding = 'UTF-8' 103 | } 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-offline-download/src/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/OfflineDownloadApplication.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | open class OfflineDownloadApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/constants/DownloadTaskConst.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.constants 2 | 3 | object DownloadTaskStatus { 4 | const val WAITING: Int = 0 5 | const val DOWNLOAD_UPLOAD_FINISHED: Int = 90 6 | const val DOWNLOAD_COPY_FINISHED: Int = 100 7 | //const val DOWNLOAD_FAILED: Int = -1 8 | } -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/context/OfflineBootstrapContext.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.context 2 | 3 | import com.qingzhenyun.common.ice.IceBootstrapContext 4 | import org.springframework.stereotype.Service 5 | 6 | @Service 7 | class OfflineBootstrapContext : IceBootstrapContext() -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/repository/DownloadTaskRepository.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.repository 2 | 3 | import com.qingzhenyun.common.jooq.service.AbstractJooqDslRepository 4 | import com.qingzhenyun.generated.offline.Tables 5 | import com.qingzhenyun.generated.offline.tables.pojos.DownloadTask 6 | import com.qingzhenyun.generated.offline.tables.records.DownloadTaskRecord 7 | import org.jooq.DSLContext 8 | import org.springframework.stereotype.Service 9 | 10 | @Service 11 | class DownloadTaskRepository(dslContext: DSLContext) : AbstractJooqDslRepository(dslContext, Tables.DOWNLOAD_TASK, DownloadTask::class.java) -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/service/DownloadTaskService.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.service 2 | 3 | import com.qingzhenyun.generated.offline.Tables 4 | import com.qingzhenyun.generated.offline.tables.records.DownloadTaskRecord 5 | import com.qingzhenyun.offline.repository.DownloadTaskRepository 6 | import org.jooq.DSLContext 7 | import org.jooq.impl.DSL 8 | import org.springframework.beans.factory.annotation.Autowired 9 | import org.springframework.stereotype.Service 10 | 11 | @Service 12 | class DownloadTaskService { 13 | 14 | 15 | @Autowired 16 | private lateinit var downloadTaskRepository: DownloadTaskRepository 17 | @Autowired 18 | private 19 | lateinit var defaultDSLContext: DSLContext 20 | 21 | // fun getList(hashList: Array?, clazz: Class): List { 22 | fun multiFetch(taskId: List, clazz: Class): List { 23 | /* 24 | val reqRow = row(Tables.DOWNLOAD_TASK.TASK_ID,Tables.DOWNLOAD_TASK.TYPE) 25 | val req:Array> = Array(task.size, init = { index -> 26 | val da = task[index] 27 | return@Array row(da.taskId,da.type) 28 | }) 29 | */ 30 | 31 | 32 | val dslContext = getDslContext(null) 33 | return dslContext.selectFrom(Tables.DOWNLOAD_TASK).where(Tables.DOWNLOAD_TASK.TASK_ID.`in`(taskId)) 34 | .fetch().into(clazz) 35 | 36 | } 37 | 38 | fun fetch(taskId: String?): DownloadTaskRecord? { 39 | val dslContext = getDslContext(taskId) 40 | val data = dslContext.selectFrom(Tables.DOWNLOAD_TASK).where(Tables.DOWNLOAD_TASK.TASK_ID.eq(taskId)) 41 | .fetch() 42 | if (data.isNotEmpty) { 43 | return data[0] 44 | } 45 | return null 46 | } 47 | 48 | fun updateTaskProgress(taskId: String?, status: Int, progress: Int, size: Long, finishedSize: Long): Boolean { 49 | val context = getDslContext(taskId) 50 | return context.transactionResult { configuration -> 51 | val dslContext = DSL.using(configuration) 52 | val data = dslContext.fetchOne(Tables.DOWNLOAD_TASK, Tables.DOWNLOAD_TASK.TASK_ID.eq(taskId)) 53 | ?: return@transactionResult false 54 | var changed = false 55 | if (status > 0 && data.status < status) { 56 | changed = true 57 | data.status = status 58 | } 59 | if (progress > 0 && data.progress < progress) { 60 | changed = true 61 | data.progress = progress 62 | } 63 | if (size > 0 && data.size < size) { 64 | changed = true 65 | data.size = size 66 | } 67 | if (finishedSize > 0 && data.finishedSize < finishedSize) { 68 | changed = true 69 | data.finishedSize = finishedSize 70 | } 71 | if (changed) { 72 | data.store() 73 | } 74 | return@transactionResult changed 75 | } 76 | 77 | } 78 | 79 | fun finishTask(taskId: String?, status: Int?, errorCode: Int?) { 80 | getDslContext(taskId).update(Tables.DOWNLOAD_TASK).set(Tables.DOWNLOAD_TASK.STATUS, status) 81 | .set(Tables.DOWNLOAD_TASK.ERROR_CODE, errorCode) 82 | .set(Tables.DOWNLOAD_TASK.UPDATE_TIME, System.currentTimeMillis()) 83 | .where((Tables.DOWNLOAD_TASK.TASK_ID.eq(taskId))) 84 | .execute() 85 | } 86 | 87 | fun updateMime(taskId: String?, mime: String?) { 88 | getDslContext(taskId).update(Tables.DOWNLOAD_TASK) 89 | .set(Tables.DOWNLOAD_TASK.MIME, mime) 90 | .set(Tables.DOWNLOAD_TASK.UPDATE_TIME, System.currentTimeMillis()) 91 | .where((Tables.DOWNLOAD_TASK.TASK_ID.eq(taskId))) 92 | .execute() 93 | } 94 | 95 | 96 | fun fetchAndUpdateMetadata(taskId: String?, name: String?, size: Long, serverId: String?, mime: String?): DownloadTaskRecord? { 97 | val data = fetch(taskId) ?: return null 98 | if (!name.isNullOrEmpty()) { 99 | data.name = name 100 | } 101 | if (size > 0) { 102 | data.size = size 103 | } 104 | data.updateTime = System.currentTimeMillis() 105 | if (!serverId.isNullOrEmpty()) { 106 | data.serverId = serverId 107 | } 108 | if (!mime.isNullOrEmpty()) { 109 | data.mime = mime 110 | } 111 | data.update() 112 | return data 113 | } 114 | 115 | fun addTask(taskId: String?, type: Int, name: String?, createUser: Long, createIp: String?, detail: String?): DownloadTaskRecord? { 116 | if (taskId.isNullOrEmpty()) { 117 | return null 118 | } 119 | return getDslContext(taskId).transactionResult { configuration -> 120 | val dslContext = DSL.using(configuration) 121 | val result = dslContext.selectFrom(Tables.DOWNLOAD_TASK).where(Tables.DOWNLOAD_TASK.TASK_ID.eq(taskId)) 122 | .forUpdate().fetch() 123 | if (result.isNotEmpty) { 124 | return@transactionResult result[0] 125 | } else { 126 | val res = dslContext.newRecord(Tables.DOWNLOAD_TASK) 127 | val current = System.currentTimeMillis() 128 | res.setTaskId(taskId).setType(type).setName(name).setCreateUser(createUser) 129 | .setCreateTime(current).setProgress(0).setSize(0).setStatus(0) 130 | .setUpdateTime(current).setFinishedSize(0) 131 | .setCreateIp(createIp).detail = detail 132 | res.store() 133 | return@transactionResult res 134 | } 135 | } 136 | } 137 | 138 | private fun getDslContext(taskId: String?, readOnly: Boolean = false): DSLContext { 139 | if (taskId.isNullOrEmpty()) { 140 | return defaultDSLContext 141 | } 142 | if (readOnly) { 143 | return defaultDSLContext 144 | } 145 | return defaultDSLContext 146 | } 147 | } -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/service/FakeCopyQueueService.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.service 2 | 3 | import com.qingzhenyun.common.jooq.service.AbstractJooqDslRepository 4 | import com.qingzhenyun.generated.offline.Tables 5 | import com.qingzhenyun.generated.offline.tables.pojos.FakeCopyQueue 6 | import com.qingzhenyun.generated.offline.tables.records.FakeCopyQueueRecord 7 | import org.jooq.Condition 8 | import org.jooq.DSLContext 9 | import org.springframework.stereotype.Service 10 | 11 | @Service 12 | class FakeCopyQueueService(dslContext: DSLContext) : AbstractJooqDslRepository(dslContext, Tables.FAKE_COPY_QUEUE, FakeCopyQueue::class.java) { 13 | fun addTask(taskId: String, userId: Long, progress: Int?, status: Int?) { 14 | val rec = FakeCopyQueueRecord().setTaskId(taskId) 15 | .setProgress(progress) 16 | .setUpdateTime(System.currentTimeMillis()) 17 | .setUserId(userId) 18 | .setStatus(status) 19 | .setCopied(0) 20 | .setNeedCopySize(0) 21 | getDslContext().insertInto(Tables.FAKE_COPY_QUEUE).set(rec).onDuplicateKeyUpdate() 22 | .set(Tables.FAKE_COPY_QUEUE.UPDATE_TIME, System.currentTimeMillis()) 23 | .set(Tables.FAKE_COPY_QUEUE.PROGRESS, progress) 24 | .set(Tables.FAKE_COPY_QUEUE.STATUS, status) 25 | .set(Tables.FAKE_COPY_QUEUE.COPIED, 0) 26 | .set(Tables.FAKE_COPY_QUEUE.NEED_COPY_SIZE, 0) 27 | .execute() 28 | } 29 | 30 | fun finishUploadTask(taskId: String?, status: Int?) { 31 | getDslContext().update(Tables.FAKE_COPY_QUEUE) 32 | .set(Tables.FAKE_COPY_QUEUE.STATUS, status) 33 | .set(Tables.FAKE_COPY_QUEUE.UPDATE_TIME, System.currentTimeMillis()) 34 | .where(Tables.FAKE_COPY_QUEUE.TASK_ID.eq(taskId)) 35 | .execute() 36 | } 37 | 38 | fun updateSingleTask(taskId: String?, userId: Long, copied: Long, needCopySize: Long): Boolean { 39 | return getDslContext().update(Tables.FAKE_COPY_QUEUE) 40 | .set(Tables.FAKE_COPY_QUEUE.UPDATE_TIME, System.currentTimeMillis()) 41 | .set(Tables.FAKE_COPY_QUEUE.USER_ID, userId) 42 | .set(Tables.FAKE_COPY_QUEUE.COPIED, copied) 43 | .set(Tables.FAKE_COPY_QUEUE.NEED_COPY_SIZE, needCopySize) 44 | .where(Tables.FAKE_COPY_QUEUE.TASK_ID.eq(taskId).and(Tables.FAKE_COPY_QUEUE.USER_ID.eq(userId))) 45 | .execute() > 0 46 | } 47 | 48 | fun deleteTask(taskId: String?): Boolean { 49 | return getDslContext().deleteFrom(Tables.FAKE_COPY_QUEUE) 50 | .where(Tables.FAKE_COPY_QUEUE.TASK_ID.eq(taskId)) 51 | .execute() > 0 52 | } 53 | 54 | fun finishSingleTask(taskId: String?, userId: Long): Boolean { 55 | return getDslContext().deleteFrom(Tables.FAKE_COPY_QUEUE) 56 | .where(Tables.FAKE_COPY_QUEUE.TASK_ID.eq(taskId).and(Tables.FAKE_COPY_QUEUE.USER_ID.eq(userId))) 57 | .execute() > 0 58 | } 59 | 60 | fun fetchTask(start: Int, size: Int, status: Int?, taskId: String?, clazz: Class): List { 61 | val dslContext = getDslContext() 62 | var condition: Condition? = null 63 | if (status != null && status > 0) { 64 | condition = Tables.FAKE_COPY_QUEUE.STATUS.eq(status) 65 | } 66 | if (!taskId.isNullOrEmpty()) { 67 | condition = if (condition != null) { 68 | condition.and(Tables.FAKE_COPY_QUEUE.TASK_ID.eq(taskId)) 69 | } else { 70 | Tables.FAKE_COPY_QUEUE.TASK_ID.eq(taskId) 71 | } 72 | } 73 | //val condition = Tables.FAKE_COPY_QUEUE.STATUS 74 | return this.getList(start, size, clazz, Tables.FAKE_COPY_QUEUE.UPDATE_TIME.asc(), condition, dslContext) 75 | } 76 | } -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/service/TaskDetailService.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.service 2 | 3 | import com.qingzhenyun.common.jooq.service.AbstractJooqDslRepository 4 | import com.qingzhenyun.generated.offline.Tables 5 | import com.qingzhenyun.generated.offline.tables.pojos.TaskDetail 6 | import com.qingzhenyun.generated.offline.tables.records.TaskDetailRecord 7 | import org.jooq.DSLContext 8 | import org.jooq.Query 9 | import org.jooq.impl.DSL 10 | import org.slf4j.LoggerFactory 11 | import org.springframework.stereotype.Service 12 | 13 | @Service 14 | class TaskDetailService(dslContext: DSLContext) : AbstractJooqDslRepository(dslContext, Tables.TASK_DETAIL, TaskDetail::class.java) { 15 | 16 | fun fetchAll(taskId: String?, clazz: Class): List { 17 | return this.getDslContext(taskId).selectFrom(Tables.TASK_DETAIL).where(Tables.TASK_DETAIL.TASK_ID.eq(taskId)).fetch().into(clazz) 18 | } 19 | 20 | private fun getDslContext(taskId: String?): DSLContext { 21 | if (taskId.isNullOrEmpty()) { 22 | return getDslContext() 23 | } 24 | return getDslContext() 25 | } 26 | 27 | fun updateMetadata(taskId: String?, list: List): Boolean { 28 | val dslContext = getDslContext(taskId) 29 | val queries = mutableListOf() 30 | list.forEach { data -> 31 | val rec = TaskDetailRecord() 32 | rec.from(data) 33 | if (rec.order > 0 && !rec.taskId.isNullOrEmpty()) { 34 | val query = dslContext.insertInto(Tables.TASK_DETAIL).set(rec).onDuplicateKeyUpdate().set(rec) 35 | queries.add(query) 36 | } 37 | } 38 | 39 | logger.info("Update {}:{} meta", list.size, queries.size) 40 | return dslContext.batch(queries).execute().sum() > 0 41 | } 42 | 43 | fun updateDetail(taskId: String, order: Int, path: String?, size: Long?, completed: Long?, progress: Int?, storeId: String?): Boolean { 44 | val dsl = getDslContext(taskId) 45 | return dsl.transactionResult { configuration -> 46 | val dslContext = DSL.using(configuration) 47 | val data = dslContext.fetchOne(Tables.TASK_DETAIL, Tables.TASK_DETAIL.TASK_ID.eq(taskId).and(Tables.TASK_DETAIL.ORDER.eq(order))) 48 | if (data == null) { 49 | val detail = dslContext.newRecord(Tables.TASK_DETAIL) 50 | detail.setCompleted(completed) 51 | .setOrder(order).setTaskId(taskId) 52 | .setPath(path).setProgress(progress).setSize(size).setStoreId(storeId).store() 53 | return@transactionResult true 54 | } else { 55 | var change = false 56 | if (!path.isNullOrEmpty() && path != data.path) { 57 | data.path = path 58 | change = true 59 | } 60 | if (completed != null && completed > 0 && completed != data.completed) { 61 | data.completed = completed 62 | change = true 63 | } 64 | if (size != null && size > 0 && size != data.size) { 65 | data.size = size 66 | change = true 67 | } 68 | if (progress != null && progress > 0 && progress != data.progress) { 69 | data.progress = progress 70 | change = true 71 | } 72 | if (!storeId.isNullOrEmpty() && storeId != data.storeId) { 73 | data.storeId = storeId 74 | change = true 75 | } 76 | if (change) { 77 | data.update() 78 | } 79 | return@transactionResult change 80 | } 81 | } 82 | 83 | 84 | //dslContext.insertInto(Tables.TASK_DETAIL).set(rec).onDuplicateKeyUpdate().set(rec) 85 | } 86 | 87 | companion object { 88 | private val logger = LoggerFactory.getLogger(TaskDetailService::class.java) 89 | } 90 | } -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/service/UserTaskService.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.service 2 | 3 | import com.qingzhenyun.common.entity.RecordPage 4 | import com.qingzhenyun.common.entity.TrustedPath 5 | import com.qingzhenyun.common.jooq.service.AbstractJooqDslRepository 6 | import com.qingzhenyun.generated.offline.Tables 7 | import com.qingzhenyun.generated.offline.tables.pojos.UserTask 8 | import com.qingzhenyun.generated.offline.tables.records.UserTaskRecord 9 | import org.jooq.DSLContext 10 | import org.jooq.SortField 11 | import org.springframework.stereotype.Service 12 | 13 | @Service 14 | class UserTaskService(dslContext: DSLContext) : AbstractJooqDslRepository(dslContext, Tables.USER_TASK, UserTask::class.java) { 15 | @Suppress("UNUSED") 16 | override fun getDslContext(): DSLContext { 17 | throw RuntimeException("Not single table") 18 | } 19 | 20 | private fun getDslContext(userId: Long?): DSLContext { 21 | if (userId == null) { 22 | return super.getDslContext() 23 | } 24 | return super.getDslContext() 25 | } 26 | 27 | 28 | fun updateUserTask(taskId: String?, userId: Long, copied: Long, copiedFile: String?, filePath: String?, statusX: Int? = null): Boolean { 29 | val dslContext = getDslContext(userId) 30 | var step = dslContext.update(Tables.USER_TASK).set(Tables.USER_TASK.COPIED, copied) 31 | if (!copiedFile.isNullOrEmpty()) { 32 | step = step.set(Tables.USER_TASK.COPIED_FILE, copiedFile) 33 | } 34 | if (!filePath.isNullOrEmpty()) { 35 | step = step.set(Tables.USER_TASK.FILE_PATH, TrustedPath(filePath).path) 36 | } 37 | if (statusX != null) { 38 | step = step.set(Tables.USER_TASK.STATUS, statusX) 39 | } 40 | 41 | return step.where(Tables.USER_TASK.TASK_ID.eq(taskId).and(Tables.USER_TASK.USER_ID.eq(userId))).execute() > 0 42 | } 43 | 44 | fun finishUserTask(taskId: String?, userId: Long, status: Int? = null): Boolean { 45 | val dslContext = getDslContext(userId) 46 | return dslContext.update(Tables.USER_TASK).set(Tables.USER_TASK.STATUS, status) 47 | .where(Tables.USER_TASK.TASK_ID.eq(taskId).and(Tables.USER_TASK.USER_ID.eq(userId))).execute() > 0 48 | } 49 | 50 | fun listOfflineTask(userId: Long, start: Int, size: Int, order: Int, clazz: Class): List { 51 | val dslContext = getDslContext(userId) 52 | val condition = Tables.USER_TASK.USER_ID.eq(userId) 53 | 54 | var orderByCondition: SortField<*> = Tables.USER_TASK.CREATE_TIME.desc() 55 | if (order == 1) { 56 | orderByCondition = Tables.USER_TASK.CREATE_TIME.asc() 57 | } 58 | return getList(start, size, clazz, orderByCondition, condition, dslContext) 59 | } 60 | 61 | fun listOfflineTaskPage(userId: Long, page: Int, pageSize: Int, order: Int, clazz: Class): RecordPage { 62 | val dslContext = getDslContext(userId) 63 | val condition = Tables.USER_TASK.USER_ID.eq(userId) 64 | 65 | var orderByCondition: SortField<*> = Tables.USER_TASK.CREATE_TIME.desc() 66 | if (order == 1) { 67 | orderByCondition = Tables.USER_TASK.CREATE_TIME.asc() 68 | } 69 | return getPage(page, pageSize, clazz, orderByCondition, condition, dslContext) 70 | } 71 | 72 | fun addUserTask(taskId: String?, userId: Long, copyFile: String?, savePath: String?): UserTaskRecord { 73 | val dslContext = getDslContext(userId) 74 | val trust = TrustedPath(savePath).path 75 | val rec = UserTaskRecord() 76 | .setTaskId(taskId) 77 | .setUserId(userId) 78 | .setCopyFile(copyFile) 79 | .setSavePath(trust) 80 | .setStatus(0) 81 | .setCopied(0) 82 | .setFilePath("") 83 | .setCopiedFile("{}") 84 | .setCreateTime(System.currentTimeMillis()) 85 | dslContext.insertInto(Tables.USER_TASK).set(rec).onDuplicateKeyUpdate() 86 | .set(Tables.USER_TASK.COPY_FILE, copyFile) 87 | .set(Tables.USER_TASK.COPIED_FILE, "{}") 88 | .set(Tables.USER_TASK.FILE_PATH, "") 89 | .set(Tables.USER_TASK.SAVE_PATH, trust) 90 | .set(Tables.USER_TASK.COPIED, 0) 91 | .set(Tables.USER_TASK.STATUS, 0) 92 | .set(Tables.USER_TASK.CREATE_TIME, System.currentTimeMillis()) 93 | .execute() 94 | return rec 95 | } 96 | 97 | fun get(taskId: String?, userId: Long): UserTaskRecord? { 98 | val dslContext = getDslContext(userId) 99 | return get(Tables.USER_TASK.TASK_ID.eq(taskId).and(Tables.USER_TASK.USER_ID.eq(userId)), dslContext) 100 | } 101 | } -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/kotlin/com/qingzhenyun/offline/service/WaitingQueueService.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.offline.service 2 | 3 | import com.qingzhenyun.common.jooq.service.AbstractJooqDslRepository 4 | import com.qingzhenyun.generated.offline.Tables 5 | import com.qingzhenyun.generated.offline.tables.pojos.WaitingQueue 6 | import com.qingzhenyun.generated.offline.tables.records.WaitingQueueRecord 7 | import com.qingzhenyun.offline.constants.DownloadTaskStatus 8 | import org.jooq.DSLContext 9 | import org.jooq.impl.DSL 10 | import org.slf4j.Logger 11 | import org.slf4j.LoggerFactory 12 | import org.springframework.stereotype.Service 13 | 14 | @Service 15 | class WaitingQueueService(dslContext: DSLContext) : AbstractJooqDslRepository(dslContext, Tables.WAITING_QUEUE, WaitingQueue::class.java) { 16 | fun addTask(taskId: String?, type: Int, name: String): WaitingQueueRecord? { 17 | if (taskId.isNullOrEmpty()) { 18 | return null 19 | } 20 | return getDslContext().transactionResult { configuration -> 21 | val dslContext = DSL.using(configuration) 22 | val result = dslContext.selectFrom(Tables.WAITING_QUEUE).where(Tables.WAITING_QUEUE.TYPE.eq(type).and(Tables.WAITING_QUEUE.TASK_ID.eq(taskId))) 23 | .forUpdate().fetch() 24 | if (result.isNotEmpty) { 25 | return@transactionResult result[0] 26 | } else { 27 | val res = dslContext.newRecord(Tables.WAITING_QUEUE) 28 | res.setTaskId(taskId).setType(type).setName(name) 29 | .setCreateTime(System.currentTimeMillis()).setStatus(DownloadTaskStatus.WAITING).updateTime = 0 30 | res.store() 31 | return@transactionResult res 32 | } 33 | } 34 | } 35 | 36 | fun finishTask(taskId: String?) { 37 | getDslContext().deleteFrom(Tables.WAITING_QUEUE).where(Tables.WAITING_QUEUE.TASK_ID.eq(taskId)).execute() 38 | } 39 | 40 | 41 | fun updateDownloadingStatus(taskId: String?, serverId: String?, status: Int, message: String?, force: Boolean): Boolean { 42 | if (force) { 43 | return getDslContext().update(Tables.WAITING_QUEUE) 44 | .set(Tables.WAITING_QUEUE.UPDATE_TIME, System.currentTimeMillis()) 45 | .set(Tables.WAITING_QUEUE.STATUS, status).set(Tables.WAITING_QUEUE.MESSAGE, message) 46 | .where(Tables.WAITING_QUEUE.TASK_ID.eq(taskId)) 47 | .execute() > 0 48 | } else { 49 | return getDslContext().transactionResult { configuration -> 50 | val dslContext = DSL.using(configuration) 51 | val result = dslContext.selectFrom(Tables.WAITING_QUEUE).where(Tables.WAITING_QUEUE.TASK_ID.eq(taskId)).limit(1) 52 | .forUpdate().fetch() 53 | if (result.isEmpty()) { 54 | logger.warn("Update {} failed. cannot find record.", taskId) 55 | return@transactionResult false 56 | } 57 | val data = result[0] 58 | 59 | if (data.serverId != serverId) { 60 | logger.warn("Update {} on different server id [{}] -> [{}]", data.serverId, serverId) 61 | data.serverId = serverId 62 | } 63 | val oldStatus = data.status 64 | if (oldStatus > 0) { 65 | if (status > oldStatus) { 66 | data.status = status 67 | } else { 68 | logger.warn("Update {} failed. cannot find record. cannot rollback {} to {}, use force.", taskId, oldStatus, status) 69 | } 70 | } else { 71 | data.status = status 72 | } 73 | if (!message.isNullOrEmpty()) { 74 | data.message = message 75 | } 76 | data.updateTime = System.currentTimeMillis() 77 | data.update() 78 | return@transactionResult true 79 | } 80 | } 81 | } 82 | 83 | fun fetchTask(serverId: String?, types: IntArray?, status: IntArray, nextStatus: Int, size: Int, clazz: Class): List { 84 | if (size < 1) { 85 | return emptyList() 86 | } 87 | val suitCondition = Tables.WAITING_QUEUE.TYPE.`in`(types!!.asList()).and(Tables.WAITING_QUEUE.STATUS.`in`(status.asList())) 88 | return getDslContext().transactionResult { configuration -> 89 | val dslContext = DSL.using(configuration) 90 | val result = dslContext.selectFrom(Tables.WAITING_QUEUE).where(suitCondition).limit(size) 91 | .forUpdate().fetch() 92 | result.forEach { data -> data.setUpdateTime(System.currentTimeMillis()).setStatus(nextStatus).serverId = serverId } 93 | dslContext.batchUpdate(result).execute() 94 | return@transactionResult result.into(clazz) 95 | } 96 | } 97 | 98 | fun fetchTaskRecord(serverId: String?, types: IntArray?, status: IntArray, nextStatus: Int, size: Int): List { 99 | if (size < 1) { 100 | return emptyList() 101 | } 102 | val suitCondition = Tables.WAITING_QUEUE.TYPE.`in`(types!!.asList()).and(Tables.WAITING_QUEUE.STATUS.`in`(status.asList())) 103 | return getDslContext().transactionResult { configuration -> 104 | val dslContext = DSL.using(configuration) 105 | val result = dslContext.selectFrom(Tables.WAITING_QUEUE).where(suitCondition).limit(size) 106 | .forUpdate().fetch() 107 | result.forEach { data -> data.setUpdateTime(System.currentTimeMillis()).setStatus(nextStatus).serverId = serverId } 108 | dslContext.batchUpdate(result).execute() 109 | return@transactionResult result 110 | } 111 | } 112 | 113 | companion object { 114 | private val logger: Logger = LoggerFactory.getLogger(WaitingQueueService::class.java) 115 | } 116 | } -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-offline-download/src/main/resources/application-dev.yml -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | com.qingzhenyun: info 4 | org.springfromework.web: info 5 | com.qingzhenyun.common: info 6 | # file: /var/log/qingzhenyun/qingzhenyun-user-file.log 7 | spring: 8 | #datasource: 9 | # continue-on-error: true 10 | # data-password: e24a23c250246d795eaf08ddab6b0fa9 11 | # data-username: postgres 12 | # driver-class-name: org.postgresql.Driver 13 | # url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun-file 14 | jooq: 15 | sql-dialect: postgres 16 | datasource: 17 | continue-on-error: true 18 | data-password: e24a23c250246d795eaf08ddab6b0fa9 19 | data-username: postgres 20 | password: e24a23c250246d795eaf08ddab6b0fa9 21 | username: postgres 22 | driver-class-name: org.postgresql.Driver 23 | url: jdbc:postgresql://192.168.250.11:5432/qingzhenyun_offline_download -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ******************************** 2 | * Offline Application * 3 | ******************************** -------------------------------------------------------------------------------- /qingzhenyun-offline-download/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | com.qingzhenyun: info 4 | org.springfromework.web: info 5 | com.qingzhenyun.common: info 6 | # file: /var/log/qingzhenyun/qingzhenyun-user-file.log 7 | spring: 8 | #datasource: 9 | # continue-on-error: true 10 | # data-password: e24a23c250246d795eaf08ddab6b0fa9 11 | # data-username: postgres 12 | # driver-class-name: org.postgresql.Driver 13 | # url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun-file 14 | jooq: 15 | sql-dialect: postgres 16 | datasource: 17 | continue-on-error: true 18 | data-password: e24a23c250246d795eaf08ddab6b0fa9 19 | data-username: postgres 20 | password: e24a23c250246d795eaf08ddab6b0fa9 21 | username: postgres 22 | driver-class-name: org.postgresql.Driver 23 | url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun_offline_download -------------------------------------------------------------------------------- /qingzhenyun-user-center/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | 3 | repositories { 4 | mavenCentral() 5 | maven { url "https://repo.spring.io/snapshot" } 6 | maven { url "https://repo.spring.io/milestone" } 7 | maven { url 'https://plugins.gradle.org/m2/'} 8 | } 9 | dependencies { 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 12 | classpath("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}") 13 | classpath "nu.studer:gradle-jooq-plugin:$jooq_plugin_version" 14 | } 15 | } 16 | 17 | group 'com.qingzhenyun' 18 | version '1.0-SNAPSHOT' 19 | 20 | apply plugin: 'nu.studer.jooq' 21 | apply plugin: 'java' 22 | apply plugin: 'kotlin' 23 | apply plugin: 'org.springframework.boot' 24 | 25 | sourceCompatibility = 1.8 26 | 27 | 28 | repositories { 29 | mavenCentral() 30 | } 31 | 32 | dependencies { 33 | compile project(':qingzhenyun-ice-sb-common') 34 | compile project(':qingzhenyun-common-jooq') 35 | jooqRuntime group: 'org.postgresql', name: 'postgresql', version: postgres_version 36 | //compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 37 | compile("org.springframework.boot:spring-boot-starter:${springBootVersion}") 38 | testCompile group: 'junit', name: 'junit', version: junit_version 39 | compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}") 40 | compile("org.springframework.boot:spring-boot-starter-jooq:${springBootVersion}") 41 | compileOnly("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}") 42 | testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}") 43 | } 44 | 45 | compileKotlin { 46 | kotlinOptions.jvmTarget = jvm_target 47 | } 48 | compileTestKotlin { 49 | kotlinOptions.jvmTarget = jvm_target 50 | } 51 | 52 | compileJava.dependsOn(processResources) 53 | 54 | jooq { 55 | version = jooq_version // the default (can be omitted) 56 | usercenter(sourceSets.main) { 57 | jdbc { 58 | driver = 'org.postgresql.Driver' 59 | url = "${test_db_url}/${test_db_user_center}" 60 | user = test_db_user 61 | password = test_db_password 62 | } 63 | generator { 64 | name = 'org.jooq.codegen.DefaultGenerator' 65 | strategy { 66 | name = 'org.jooq.codegen.DefaultGeneratorStrategy' 67 | } 68 | database { 69 | name = 'org.jooq.meta.postgres.PostgresDatabase' 70 | inputSchema = 'public' 71 | forcedTypes { 72 | /* 73 | forcedType { 74 | name = 'BOOLEAN' 75 | expression = '.*\\.HANDMADE' 76 | types = '.*' 77 | } 78 | */ 79 | forcedType { 80 | userType = 'java.util.Map' 81 | binding = 'com.qingzhenyun.common.jooq.binding.CommonJsonBinding' 82 | // name = 'JSON' 83 | expression = 'ssid' //.*JSON.* 84 | types = '.*' 85 | } 86 | } 87 | } 88 | 89 | generate { 90 | relations = true 91 | deprecated = false 92 | records = true 93 | immutablePojos = false 94 | fluentSetters = true 95 | pojos = true 96 | daos = false 97 | javaTimeTypes = true 98 | } 99 | target { 100 | packageName = 'com.qingzhenyun.generated.user' 101 | //directory = 'src/main/java' 102 | encoding = 'UTF-8' 103 | } 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/kotlin/com/qingzhenyun/usercenter/UserCenterApplication.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.usercenter 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | open class UserCenterApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/kotlin/com/qingzhenyun/usercenter/context/UserCenterBootstrapContext.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.usercenter.context 2 | 3 | import com.qingzhenyun.common.ice.IceBootstrapContext 4 | import org.springframework.stereotype.Service 5 | 6 | @Service 7 | class UserCenterBootstrapContext : IceBootstrapContext() -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/kotlin/com/qingzhenyun/usercenter/handler/UserCenterServiceHandler.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.usercenter.handler 2 | 3 | import com.qingzhenyun.common.ice.IceHandler 4 | import com.qingzhenyun.common.ice.usercenter.UserCenterServiceHandler 5 | import com.qingzhenyun.common.ice.usercenter.UserDataResponse 6 | import com.qingzhenyun.usercenter.service.UserCenterService 7 | import com.zeroc.Ice.Current 8 | import org.springframework.beans.factory.annotation.Autowired 9 | 10 | @IceHandler("UserCenterServiceHandler") 11 | class UserCenterServiceHandlerImpl : UserCenterServiceHandler { 12 | override fun updateUserSpaceUsage(uuid: Long, spaceUsed: Long, current: Current?): Int { 13 | return userCenterService.updateUserSpaceUsage(uuid, spaceUsed) 14 | } 15 | 16 | override fun walkUser(uuid: Long, size: Int, current: Current?): Array { 17 | return userCenterService.walkUser(uuid, size, UserDataResponse::class.java).toTypedArray() 18 | } 19 | 20 | override fun changePasswordByUuid(uuid: Long, newPassword: String?, current: Current?): Boolean { 21 | return userCenterService.changePasswordByUuid(uuid, newPassword) 22 | } 23 | 24 | override fun changePassword(uuid: Long, oldPassword: String?, newPassword: String?, current: Current?): Boolean { 25 | return userCenterService.changePassword(uuid, oldPassword, newPassword) 26 | } 27 | 28 | override fun logout(uuid: Long, device: String?, current: Current?): UserDataResponse? { 29 | return userCenterService.logout(uuid, device)?.into(UserDataResponse::class.java) 30 | } 31 | 32 | override fun loginByMessage(countryCode: String?, phone: String?, device: String?, current: Current?): UserDataResponse? { 33 | return userCenterService.loginByMessage(countryCode, phone, device)?.into(UserDataResponse::class.java) 34 | } 35 | 36 | override fun loginByName(name: String?, password: String?, device: String?, current: Current?): UserDataResponse? { 37 | return userCenterService.loginByName(name, password, device)?.into(UserDataResponse::class.java) 38 | } 39 | 40 | override fun loginByPhone(countryCode: String?, phone: String?, password: String?, device: String?, current: Current?): UserDataResponse? { 41 | return userCenterService.loginByPhone(countryCode, phone, password, device)?.into(UserDataResponse::class.java) 42 | } 43 | 44 | override fun registerUser(name: String?, password: String?, countryCode: String?, phone: String?, ip: String?, device: String?, current: Current?): UserDataResponse? { 45 | return userCenterService.registerUser(name, password, countryCode, phone, ip, device)?.into(UserDataResponse::class.java) 46 | } 47 | 48 | override fun getUserByPhone(countryCode: String?, phone: String?, current: Current?): UserDataResponse? { 49 | return userCenterService.getUserByPhone(countryCode, phone)?.into(UserDataResponse::class.java) 50 | } 51 | 52 | 53 | override fun getUserByUuid(uuid: Long, current: Current?): UserDataResponse? { 54 | return userCenterService.get(uuid)?.into(UserDataResponse::class.java) 55 | } 56 | 57 | @Autowired 58 | private lateinit var userCenterService: UserCenterService 59 | 60 | /* 61 | companion object { 62 | private val logger = LoggerFactory.getLogger(UserCenterServiceHandlerImpl::class.java) 63 | } 64 | */ 65 | } -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/kotlin/com/qingzhenyun/usercenter/repository/UserCenterRepository.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.usercenter.repository 2 | 3 | import com.qingzhenyun.common.jooq.service.AbstractJooqDslRepository 4 | import com.qingzhenyun.generated.user.Tables 5 | import com.qingzhenyun.generated.user.tables.pojos.UserData 6 | import com.qingzhenyun.generated.user.tables.records.UserDataRecord 7 | import org.jooq.DSLContext 8 | import org.springframework.stereotype.Service 9 | 10 | @Service 11 | class UserCenterRepository(dslContext: DSLContext) : AbstractJooqDslRepository(dslContext, Tables.USER_DATA, UserData::class.java) -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/kotlin/com/qingzhenyun/usercenter/service/UserCenterService.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.usercenter.service 2 | 3 | import com.qingzhenyun.common.ice.usercenter.LoginFailedException 4 | import com.qingzhenyun.common.ice.usercenter.RegisterFailedException 5 | import com.qingzhenyun.common.util.HASH 6 | import com.qingzhenyun.common.util.QStringUtil 7 | import com.qingzhenyun.generated.user.Tables 8 | import com.qingzhenyun.generated.user.tables.pojos.UserData 9 | import com.qingzhenyun.generated.user.tables.records.UserDataRecord 10 | import com.qingzhenyun.usercenter.repository.UserCenterRepository 11 | import org.springframework.beans.factory.annotation.Autowired 12 | import org.springframework.stereotype.Service 13 | 14 | @Service 15 | class UserCenterService { 16 | @Autowired 17 | private lateinit var userCenterRepository: UserCenterRepository 18 | 19 | 20 | fun addUser(): UserDataRecord { 21 | val userData = UserData() 22 | userData.setCreateIp("127.0.0.1").setName("papaya2").setPassword("1234").setSalt("5678").setCreateTime(System.currentTimeMillis()) 23 | .setEmail("papaya@dkexx.com").setCountryCode("86").setPhone("13800132000").ssid = hashMapOf("phone" to "fuck1238") 24 | return userCenterRepository.create(userData) 25 | } 26 | 27 | fun getUserByPhone(countryCode: String?, phone: String?): UserDataRecord? { 28 | val condition = Tables.USER_DATA.COUNTRY_CODE.eq(countryCode).and(Tables.USER_DATA.PHONE.eq(phone)) 29 | return userCenterRepository[condition] 30 | } 31 | 32 | fun getUserByName(name: String?): UserDataRecord? { 33 | val condition = Tables.USER_DATA.NAME.eq(name) 34 | return userCenterRepository[condition] 35 | } 36 | 37 | fun get(uuid: Long): UserDataRecord? { 38 | return userCenterRepository[uuid] 39 | } 40 | 41 | fun updateUserSpaceUsage(uuid: Long, spaceUsed: Long): Int { 42 | val user = get(uuid) ?: return 0 43 | if (user.spaceUsed != spaceUsed) { 44 | user.setSpaceUsed(spaceUsed).update() 45 | return 1 46 | } 47 | return 0 48 | } 49 | 50 | fun walkUser(uuid: Long, size: Int, clazz: Class): List { 51 | return userCenterRepository.getList(-1, size, clazz, Tables.USER_DATA.UUID.asc(), Tables.USER_DATA.UUID.gt(uuid)) 52 | } 53 | 54 | fun changePasswordByUuid(uuid: Long, newPassword: String?): Boolean { 55 | val user = get(uuid) ?: return false 56 | val salt = user.salt 57 | val version = USER_VERSION 58 | user.password = generateHashedPassword(newPassword ?: "", salt, version) 59 | user.update() 60 | return true 61 | } 62 | 63 | fun changePassword(uuid: Long, oldPassword: String?, newPassword: String?): Boolean { 64 | val user = get(uuid) ?: return false 65 | val password = user.password 66 | val salt = user.salt 67 | val version = USER_VERSION 68 | return if (generateHashedPassword(oldPassword ?: "", salt, version) == password) { 69 | user.password = generateHashedPassword(newPassword ?: "", salt, version) 70 | user.update() 71 | true 72 | } else { 73 | false 74 | } 75 | } 76 | 77 | fun logout(uuid: Long, device: String?): UserDataRecord? { 78 | val res = get(uuid) ?: return null 79 | res.ssid.remove(device ?: "pc") 80 | res.update() 81 | return res 82 | } 83 | 84 | fun loginByMessage(countryCode: String?, phone: String?, device: String?): UserDataRecord? { 85 | val res = getUserByPhone(countryCode, phone) 86 | if (res == null) { 87 | throw LoginFailedException(404, "USER_NOT_FOUND") 88 | } else { 89 | changeSsid(res, device).update() 90 | return res 91 | } 92 | } 93 | 94 | private fun changeSsid(res: UserDataRecord, device: String?): UserDataRecord { 95 | val map = mutableMapOf() 96 | map.putAll(res.ssid) 97 | map[device ?: "pc"] = QStringUtil.randomString(16) 98 | res.ssid = map 99 | return res 100 | } 101 | 102 | fun loginByName(name: String?, password: String?, device: String?): UserDataRecord? { 103 | return checkUser(this.getUserByName(name), password, device) 104 | } 105 | 106 | fun loginByPhone(countryCode: String?, phone: String?, password: String?, device: String?): UserDataRecord? { 107 | return checkUser(this.getUserByPhone(countryCode, phone), password, device) 108 | } 109 | 110 | private fun checkUser(user: UserDataRecord?, password: String?, device: String?): UserDataRecord { 111 | if (user != null) { 112 | if (generateHashedPassword(password!!, 113 | user.salt) == user.password) { 114 | //login success. 115 | changeSsid(user, device).update() 116 | return user 117 | } else { 118 | throw LoginFailedException(403, "USER_LOGIN_FAILED") 119 | } 120 | } else { 121 | throw LoginFailedException(404, "USER_NOT_FOUND") 122 | } 123 | } 124 | 125 | fun registerUser(name: String?, password: String?, countryCode: String?, phone: String?, ip: String?, device: String?): UserDataRecord? { 126 | val userInName = userCenterRepository[Tables.USER_DATA.NAME.eq(name)] 127 | if (userInName != null) { 128 | throw RegisterFailedException(101, "USER_NAME_EXIST") 129 | } 130 | val userInPhone = userCenterRepository[Tables.USER_DATA.PHONE.eq(phone).and(Tables.USER_DATA.COUNTRY_CODE.eq(countryCode))] 131 | if (userInPhone != null) { 132 | throw RegisterFailedException(102, "USER_PHONE_EXIST") 133 | } 134 | 135 | // User name,phone,email available, create random hash 136 | val salt = QStringUtil.randomString(8) 137 | //val uuid = UUID.randomUUID().toString() 138 | val user = UserData() 139 | val version = USER_VERSION 140 | 141 | // Auto set uuid 142 | user.setName(name).setPhone(phone).setCreateIp(ip).salt = salt 143 | // Hash 144 | val time = System.currentTimeMillis() 145 | user.setPassword(generateHashedPassword(password!!, salt, version)) 146 | .setSalt(salt) 147 | .setStatus(0) 148 | .setCountryCode(countryCode) 149 | .setPhone(phone) 150 | .setSsid(mapOf((device ?: "pc") to QStringUtil.randomString(12))) 151 | .setEmail("").setType(0) 152 | .setSpaceCapacity(8192).setSpaceUsed(0) 153 | .setCreateIp(ip) 154 | .setCreateTime(time) 155 | .setVersion(USER_VERSION) 156 | .setName(name) 157 | .icon = "default.jpg" 158 | return userCenterRepository.create(user) 159 | } 160 | 161 | private fun generateHashedPassword(password: String, salt: String, version: Int = 1): String { 162 | if (version == 1) { 163 | return HASH.sha256(password + "f@ck" + salt) //"f@ck is a magic number" 164 | } 165 | return HASH.sha256(password + "f@ck" + salt) //"f@ck is a magic number" 166 | } 167 | 168 | companion object { 169 | private const val USER_VERSION = 1 170 | } 171 | } -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-center/src/main/resources/application-dev.yml -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | com.qingzhenyun: info 4 | org.springfromework.web: info 5 | com.qingzhenyun.common: info 6 | # file: /var/log/qingzhenyun/qingzhenyun-user-file.log 7 | spring: 8 | #datasource: 9 | # continue-on-error: true 10 | # data-password: e24a23c250246d795eaf08ddab6b0fa9 11 | # data-username: postgres 12 | # driver-class-name: org.postgresql.Driver 13 | # url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun-file 14 | jooq: 15 | sql-dialect: postgres 16 | datasource: 17 | continue-on-error: true 18 | data-password: e24a23c250246d795eaf08ddab6b0fa9 19 | data-username: postgres 20 | password: e24a23c250246d795eaf08ddab6b0fa9 21 | username: postgres 22 | driver-class-name: org.postgresql.Driver 23 | url: jdbc:postgresql://192.168.250.11:5432/qingzhenyun_user_center -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ******************************** 2 | * User File Application * 3 | ******************************** -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/test/kotlin/com/qingzhenyun/usercenter/UserCenterApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.usercenter 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class UserCenterApplicationTests { 11 | @Test 12 | fun contextLoads() { 13 | } 14 | } -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/test/kotlin/com/qingzhenyun/usercenter/UserCenterServiceTest.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.usercenter 2 | 3 | import com.qingzhenyun.usercenter.service.UserCenterService 4 | import org.junit.Assert.assertNotNull 5 | import org.junit.Test 6 | import org.junit.runner.RunWith 7 | import org.springframework.beans.factory.annotation.Autowired 8 | import org.springframework.boot.test.context.SpringBootTest 9 | import org.springframework.test.context.junit4.SpringRunner 10 | 11 | @RunWith(SpringRunner::class) 12 | @SpringBootTest 13 | class UserCenterServiceTest { 14 | @Autowired 15 | private lateinit var userCenterService: UserCenterService 16 | 17 | @Test 18 | fun addUserTest() { 19 | assertNotNull(userCenterService.addUser()) 20 | } 21 | } -------------------------------------------------------------------------------- /qingzhenyun-user-center/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | com.qingzhenyun: info 4 | org.springfromework.web: info 5 | com.qingzhenyun.common: info 6 | # file: /var/log/qingzhenyun/qingzhenyun-user-file.log 7 | spring: 8 | #datasource: 9 | # continue-on-error: true 10 | # data-password: e24a23c250246d795eaf08ddab6b0fa9 11 | # data-username: postgres 12 | # driver-class-name: org.postgresql.Driver 13 | # url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun-file 14 | jooq: 15 | sql-dialect: postgres 16 | datasource: 17 | continue-on-error: true 18 | data-password: e24a23c250246d795eaf08ddab6b0fa9 19 | data-username: postgres 20 | password: e24a23c250246d795eaf08ddab6b0fa9 21 | username: postgres 22 | driver-class-name: org.postgresql.Driver 23 | url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun_user_center -------------------------------------------------------------------------------- /qingzhenyun-user-file/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-file/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-user-file/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | //ext.kotlin_version = '1.2.30' 3 | 4 | repositories { 5 | mavenCentral() 6 | maven { url "https://repo.spring.io/snapshot" } 7 | maven { url "https://repo.spring.io/milestone" } 8 | maven { url 'https://plugins.gradle.org/m2/'} 9 | } 10 | dependencies { 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 13 | classpath("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}") 14 | classpath "nu.studer:gradle-jooq-plugin:$jooq_plugin_version" 15 | } 16 | } 17 | 18 | apply plugin: 'nu.studer.jooq' 19 | /* 20 | plugins { 21 | id 'nu.studer.jooq' version jooq_plugin_version 22 | } 23 | */ 24 | 25 | 26 | 27 | group 'com.qingzhenyun' 28 | version '1.0-SNAPSHOT' 29 | 30 | apply plugin: 'java' 31 | apply plugin: 'kotlin' 32 | apply plugin: 'org.springframework.boot' 33 | 34 | 35 | sourceCompatibility = 1.8 36 | 37 | repositories { 38 | mavenCentral() 39 | } 40 | 41 | dependencies { 42 | compile project(':qingzhenyun-ice-sb-common') 43 | compile project(':qingzhenyun-common-jooq') 44 | jooqRuntime group: 'org.postgresql', name: 'postgresql', version: postgres_version 45 | //compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 46 | compile("org.springframework.boot:spring-boot-starter:${springBootVersion}") 47 | testCompile group: 'junit', name: 'junit', version: junit_version 48 | compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}") 49 | compile("org.springframework.boot:spring-boot-starter-jooq:${springBootVersion}") 50 | compileOnly("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}") 51 | testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}") 52 | } 53 | 54 | compileKotlin { 55 | kotlinOptions.jvmTarget = jvm_target 56 | } 57 | compileTestKotlin { 58 | kotlinOptions.jvmTarget = jvm_target 59 | } 60 | 61 | compileJava.dependsOn(processResources) 62 | 63 | jooq { 64 | version = jooq_version // the default (can be omitted) 65 | userfile(sourceSets.main) { 66 | jdbc { 67 | driver = 'org.postgresql.Driver' 68 | url = "${test_db_url}/${test_db_user_file}" 69 | user = test_db_user 70 | password = test_db_password 71 | } 72 | generator { 73 | name = 'org.jooq.codegen.DefaultGenerator' 74 | strategy { 75 | name = 'org.jooq.codegen.DefaultGeneratorStrategy' 76 | } 77 | database { 78 | name = 'org.jooq.meta.postgres.PostgresDatabase' 79 | inputSchema = 'public' 80 | forcedTypes { 81 | forcedType { 82 | name = 'BOOLEAN' 83 | expression = '.*\\.HANDMADE' 84 | types = '.*' 85 | } 86 | } 87 | } 88 | 89 | generate { 90 | relations = true 91 | deprecated = false 92 | records = true 93 | immutablePojos = false 94 | fluentSetters = true 95 | pojos = true 96 | daos = false 97 | javaTimeTypes = true 98 | } 99 | target { 100 | packageName = 'com.qingzhenyun.generated.file' 101 | //directory = 'src/main/java' 102 | encoding = 'UTF-8' 103 | } 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-file/src/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-file/src/main/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/META-INF/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-file/src/main/META-INF/README.md -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/java/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-file/src/main/java/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/java/com/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-file/src/main/java/com/.DS_Store -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/java/com/qingzhenyun/userfile/configuration/TestConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile.configuration; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class TestConfiguration { 8 | private String separator; 9 | 10 | public String getSeparator() { 11 | return this.separator; 12 | } 13 | 14 | @ConfigurationProperties("user.test.separator") 15 | public void setSeparator(String separator) { 16 | this.separator = separator; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/kotlin/com/qingzhenyun/userfile/UserFileApplication.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | open class UserFileApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/kotlin/com/qingzhenyun/userfile/configuration/UserFileDataSourceConfiguration.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile.configuration 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties 4 | import org.springframework.boot.context.properties.ConfigurationProperties 5 | import org.springframework.context.annotation.Bean 6 | import org.springframework.context.annotation.Configuration 7 | import org.springframework.context.annotation.Primary 8 | import javax.sql.DataSource 9 | 10 | @Configuration 11 | open class UserFileDataSourceConfiguration { 12 | // tag::configuration[] 13 | @Bean 14 | @Primary 15 | @ConfigurationProperties("user.datasource.main") 16 | open fun firstDataSourceProperties(): DataSourceProperties { 17 | return DataSourceProperties() 18 | } 19 | 20 | @Bean 21 | @Primary 22 | @ConfigurationProperties("user.datasource.main") 23 | open fun firstDataSource(): DataSource { 24 | return firstDataSourceProperties().initializeDataSourceBuilder().build() 25 | } 26 | 27 | /* 28 | @Bean 29 | @ConfigurationProperties("app.datasource.second") 30 | open fun secondDataSourceProperties(): DataSourceProperties { 31 | return DataSourceProperties() 32 | } 33 | 34 | @Bean 35 | @ConfigurationProperties("app.datasource.second") 36 | open fun secondDataSource(): DataSource { 37 | return secondDataSourceProperties().initializeDataSourceBuilder().build() 38 | } 39 | */ 40 | // end::configuration[] 41 | } -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/kotlin/com/qingzhenyun/userfile/context/UserFileBootstrapContext.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile.context 2 | 3 | import com.qingzhenyun.common.ice.IceBootstrapContext 4 | import org.springframework.stereotype.Service 5 | 6 | @Service 7 | class UserFileBootstrapContext : IceBootstrapContext() -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/kotlin/com/qingzhenyun/userfile/handler/UserFileServiceHandlerImpl.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile.handler 2 | 3 | import com.qingzhenyun.common.ice.IceHandler 4 | import com.qingzhenyun.common.ice.userfile.* 5 | import com.qingzhenyun.generated.file.tables.pojos.UserFile 6 | import com.qingzhenyun.userfile.repository.FileOperationRepository 7 | import com.qingzhenyun.userfile.service.UserFileService 8 | import com.zeroc.Ice.Current 9 | import org.springframework.beans.factory.annotation.Autowired 10 | 11 | @IceHandler("UserFileServiceHandler") 12 | class UserFileServiceHandlerImpl : UserFileServiceHandler { 13 | override fun updateDirectorySize(userId: Long, uuid: String?, fileSize: Long, current: Current?): Int { 14 | return userFileService.updateDirectorySize(userId, uuid, fileSize) 15 | } 16 | 17 | override fun deleteFile(userId: Long, uuid: String?, current: Current?): Int { 18 | return userFileService.deleteFile(userId, uuid) 19 | } 20 | 21 | override fun copy(userId: Long, uuid: String?, path: String?, destUuid: String?, destPath: String?, current: Current?): Int { 22 | return userFileService.preCopy(userId, uuid, path, destUuid, destPath) 23 | } 24 | 25 | override fun fetchFileOperation(size: Int, current: Current?): Array { 26 | return fileOperationRepository.fetchFileOperation(size, FileOperation::class.java).toTypedArray() 27 | } 28 | 29 | override fun getSimpleFileWithStoreIdList(userId: Long, pathList: Array, current: Current?): Array { 30 | return userFileService.getSimpleFileWithStoreIdList(userId, pathList, SimpleFileWithStoreId::class.java).toTypedArray() 31 | } 32 | 33 | 34 | override fun unlock(userId: Long, uuid: String?, current: Current?): Int { 35 | return userFileService.unlock(userId, uuid) 36 | } 37 | 38 | override fun listDirectory(userId: Long, uuid: String?, type: Int, start: Int, size: Int, orderBy: Int, current: Current?): Array { 39 | return userFileService.listDirectory(userId, uuid, type, start, size, orderBy, UserFileResponse::class.java).toTypedArray() 40 | } 41 | 42 | override fun remove(userId: Long, uuid: String?, path: String?, current: Current?): Int { 43 | return userFileService.preDelete(userId, uuid, path) 44 | } 45 | 46 | override fun rename(userId: Long, uuid: String?, path: String?, newName: String?, current: Current?): Int { 47 | return userFileService.preRename(userId, uuid, path, newName ?: "") 48 | } 49 | 50 | override fun move(userId: Long, uuid: String?, path: String?, destUuid: String?, destPath: String?, current: Current?): Int { 51 | return userFileService.preMove(userId, uuid, path, destUuid, destPath) 52 | } 53 | 54 | override fun createFile(userId: Long, parent: String?, path: String?, name: String?, size: Long, storeId: String?, current: Current?): UserFileResponse? { 55 | return userFileService 56 | .createFile(UserFile().setPath(path).setUserId(userId).setName(name).setParent(parent) 57 | .setSize(size).setStoreId(storeId)) 58 | ?.into(UserFileResponse::class.java) 59 | } 60 | 61 | override fun get(userId: Long, uuid: String?, path: String?, current: Current?): UserFileResponse? { 62 | return userFileService.get(userId, uuid, path)?.into(UserFileResponse::class.java) 63 | } 64 | 65 | override fun listDirectoryPage(userId: Long, uuid: String?, type: Int, page: Int, pageSize: Int, orderBy: Int, current: Current?): UserFilePageResponse { 66 | val data = this.userFileService.listDirectoryPage(userId, uuid, type, page, pageSize, orderBy, UserFileResponse::class.java) 67 | return UserFilePageResponse(data.page, data.pageSize, data.totalCount, data.totalPage, (data.list 68 | ?: emptyList()).toTypedArray()) 69 | } 70 | 71 | override fun createDirectory(userId: Long, parent: String?, path: String?, name: String?, current: Current?): UserFileResponse? { 72 | return userFileService 73 | .createDirectory(UserFile().setPath(path).setUserId(userId).setName(name).setParent(parent)) 74 | ?.into(UserFileResponse::class.java) 75 | } 76 | 77 | @Autowired 78 | private 79 | lateinit var fileOperationRepository: FileOperationRepository 80 | 81 | @Autowired 82 | private lateinit var userFileService: UserFileService 83 | companion object { 84 | // private val logger = LoggerFactory.getLogger(UserFileServiceHandlerImpl::class.java) 85 | } 86 | } -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/kotlin/com/qingzhenyun/userfile/repository/FileOperationRepository.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile.repository 2 | 3 | import com.qingzhenyun.common.jooq.service.AbstractJooqDslRepository 4 | import com.qingzhenyun.generated.file.Tables 5 | import com.qingzhenyun.generated.file.tables.pojos.FileOperation 6 | import com.qingzhenyun.generated.file.tables.records.FileOperationRecord 7 | import org.jooq.DSLContext 8 | import org.jooq.impl.DSL 9 | import org.springframework.stereotype.Service 10 | 11 | @Service 12 | class FileOperationRepository(dslContext: DSLContext) : AbstractJooqDslRepository(dslContext, Tables.FILE_OPERATION, FileOperation::class.java) { 13 | fun fetchFileOperation(size: Int, clazz: Class): List { 14 | return getDslContext().transactionResult { configuration -> 15 | val dslContext = DSL.using(configuration) 16 | val data = this.getRecordList(-1, size, Tables.FILE_OPERATION.TASK_ID.asc(), null, dslContext) 17 | if (data.isNotEmpty) { 18 | val t = data.into(clazz) 19 | dslContext.batchDelete(data).execute() 20 | return@transactionResult t 21 | } else { 22 | return@transactionResult emptyList() 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/kotlin/com/qingzhenyun/userfile/service/FileOperationService.java: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile.service; 2 | 3 | public class FileOperationService { 4 | } 5 | -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qingzhenyun/qingzhenyun-core/d52488bc41f3fb1f6451145674b45219b0762b44/qingzhenyun-user-file/src/main/resources/application-dev.yml -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | com.qingzhenyun: info 4 | org.springfromework.web: info 5 | com.qingzhenyun.common: info 6 | file: /var/log/qingzhenyun/qingzhenyun-user-file.log 7 | spring: 8 | #datasource: 9 | # continue-on-error: true 10 | # data-password: e24a23c250246d795eaf08ddab6b0fa9 11 | # data-username: postgres 12 | # driver-class-name: org.postgresql.Driver 13 | # url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun-file 14 | jooq: 15 | sql-dialect: postgres 16 | user: 17 | datasource: 18 | main: 19 | continue-on-error: true 20 | data-password: e24a23c250246d795eaf08ddab6b0fa9 21 | data-username: postgres 22 | password: e24a23c250246d795eaf08ddab6b0fa9 23 | username: postgres 24 | driver-class-name: org.postgresql.Driver 25 | url: jdbc:postgresql://192.168.250.11:5432/qingzhenyun_file -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ******************************** 2 | * User File Application * 3 | ******************************** -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/test/kotlin/com/qingzhenyun/userfile/UserFileApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class UserFileApplicationTests { 11 | @Test 12 | fun contextLoads() { 13 | } 14 | } -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/test/kotlin/com/qingzhenyun/userfile/UserFileServiceTest.kt: -------------------------------------------------------------------------------- 1 | package com.qingzhenyun.userfile 2 | 3 | import org.junit.runner.RunWith 4 | import org.springframework.boot.test.context.SpringBootTest 5 | import org.springframework.test.context.junit4.SpringRunner 6 | 7 | @RunWith(SpringRunner::class) 8 | @SpringBootTest 9 | //@SpringBootTest(classes = [UserFileApplicationTests::class,UserFileService::class]) 10 | class UserFileServiceTest { 11 | 12 | /* 13 | @Test 14 | fun findRoot() { 15 | userFileService.deleteUserSpace(testUserId) 16 | val userId = System.currentTimeMillis() 17 | val findRootFirst = userFileService.findRoot(userId) 18 | val findRootSecond = userFileService.findRoot(userId) 19 | assertEquals(findRootFirst.userId, findRootSecond.userId) 20 | assertEquals(findRootFirst.uuid, findRootSecond.uuid) 21 | val userIdSep = System.currentTimeMillis() 22 | val findRootThird = userFileService.findRoot(userIdSep) 23 | assertEquals(findRootFirst.uuid, findRootThird.uuid) 24 | } 25 | 26 | @Test 27 | fun validateRoot() { 28 | val success = userFileService.validateUserFile(5) 29 | assertTrue(success) 30 | } 31 | 32 | @Test 33 | fun lockUserTable() { 34 | val success = userFileService.lockUserTableTest(5) 35 | assertTrue(success) 36 | } 37 | 38 | @Test 39 | fun countUserPathTest() { 40 | userFileService.deleteUserSpace(testUserId) 41 | val oneFile = UserFile().setPath("/1/2/3/4/5/6") 42 | .setName("file.avi") 43 | .setSize(19890604).setUserId(testUserId) 44 | .setStoreId("engineeringDrawing").setType(UserFileConstants.FILE_TYPE) 45 | val twoFile = UserFile().setPath("/1/2/3/7/8/") 46 | .setName("file2.avi") 47 | .setSize(19890604).setUserId(testUserId) 48 | .setStoreId("engineeringDrawing").setType(UserFileConstants.FILE_TYPE) 49 | val fileOne = userFileService.createUserFileByPath(oneFile) 50 | val fileTwo = userFileService.createUserFileByPath(twoFile) 51 | 52 | assertNotNull(fileOne) 53 | assertNotNull(fileTwo) 54 | 55 | if (fileOne == null) { 56 | return 57 | } 58 | 59 | if (fileTwo == null) { 60 | return 61 | } 62 | // 63 | val fileThree = userFileService.get(testUserId, null, "/1/2/3") 64 | assertNotNull(fileThree) 65 | if (fileThree == null) { 66 | return 67 | } 68 | assertEquals(8, userFileService.countChildren(fileThree)) 69 | val seven = userFileService.get(testUserId, null, "/1/2/3/7") 70 | assertNotNull(seven) 71 | if (seven == null) { 72 | return 73 | } 74 | assertEquals("7", seven.name) 75 | val three = userFileService.get(testUserId, seven.parent) 76 | assertNotNull(three) 77 | if (three == null) { 78 | return 79 | } 80 | assertEquals(three.uuid, fileThree.uuid) 81 | val deleted = userFileService.preDelete(testUserId, three.uuid, null) 82 | assertEquals(8, deleted) 83 | } 84 | 85 | 86 | @Test 87 | fun createUserFileByPathTest() { 88 | userFileService.deleteUserSpace(testUserId) 89 | val oneSecond = UserFile().setPath("/Michael Wallace///a/v/") 90 | .setName("/interview/tank.avi") 91 | .setSize(19890604).setUserId(testUserId) 92 | .setStoreId("engineeringDrawing").setType(UserFileConstants.FILE_TYPE) 93 | val blackRimmedGlasses = userFileService.createUserFileByPath(oneSecond) 94 | assertNotNull(blackRimmedGlasses) 95 | if (blackRimmedGlasses != null) { 96 | assertEquals("/Michael Wallace/a/v/interview/tank.avi", oneSecond.path) 97 | assertEquals("/Michael Wallace/a/v/interview/tank.avi", blackRimmedGlasses.path) 98 | assertEquals(19890604, blackRimmedGlasses.size) 99 | assertEquals(UserFileConstants.FILE_TYPE, blackRimmedGlasses.type) 100 | assertEquals(".avi", blackRimmedGlasses.ext) 101 | assertEquals("tank.avi", blackRimmedGlasses.name) 102 | assertEquals("engineeringDrawing", blackRimmedGlasses.storeId) 103 | 104 | 105 | val redCloth = UserFile().setPath("/Michael Wallace///a/v/") 106 | .setName("/interview2/talk.avi") 107 | .setSize(19260817).setUserId(testUserId) 108 | .setStoreId("Tiananmen").setType(UserFileConstants.FILE_TYPE) 109 | val belt = userFileService.createUserFileByPath(redCloth) 110 | // get belt 111 | assertNotNull(belt) 112 | if (belt == null) { 113 | return 114 | } 115 | val frog = userFileService.get(testUserId, belt.parent, null) 116 | assertNotNull(frog) 117 | if (frog == null) { 118 | return 119 | } 120 | assertEquals("/Michael Wallace/a/v/interview2", frog.path) 121 | } 122 | } 123 | 124 | @Test 125 | fun moveOrCopyByPathTest() { 126 | userFileService.deleteUserSpace(testUserId) 127 | val oneFile = UserFile().setPath("/1/2/3/4/5/6") 128 | .setName("file.avi") 129 | .setSize(19890604).setUserId(testUserId) 130 | .setStoreId("engineeringDrawing").setType(UserFileConstants.FILE_TYPE) 131 | val twoFile = UserFile().setPath("/1/2/3/7/8/") 132 | .setName("file2.avi") 133 | .setSize(19260817).setUserId(testUserId) 134 | .setStoreId("engineeringDrawing2").setType(UserFileConstants.FILE_TYPE) 135 | val fileOne = userFileService.createUserFileByPath(oneFile) 136 | val fileTwo = userFileService.createUserFileByPath(twoFile) 137 | 138 | assertNotNull(fileOne) 139 | assertNotNull(fileTwo) 140 | 141 | if (fileOne == null) { 142 | return 143 | } 144 | 145 | if (fileTwo == null) { 146 | return 147 | } 148 | userFileService.moveOrCopyByPath(testUserId, "/1/2/3/7", "/1/2", false) 149 | } 150 | 151 | @Before 152 | fun before() { 153 | testUserId = System.currentTimeMillis() 154 | LOGGER.info("Create User: {}", testUserId) 155 | userFileService.deleteUserSpace(testUserId) 156 | 157 | } 158 | 159 | @After 160 | fun after() { 161 | LOGGER.info("Clean User: {}", testUserId) 162 | userFileService.deleteUserSpace(testUserId) 163 | LOGGER.info("Cleaned User: {}", testUserId) 164 | } 165 | 166 | private var testUserId: Long = 0 167 | @Autowired 168 | private lateinit var userFileService: UserFileService 169 | 170 | companion object { 171 | private val LOGGER = LoggerFactory.getLogger(this::class.java) 172 | } 173 | */ 174 | } -------------------------------------------------------------------------------- /qingzhenyun-user-file/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | com.qingzhenyun: info 4 | org.springfromework.web: info 5 | com.qingzhenyun.common: info 6 | file: /var/log/qingzhenyun/qingzhenyun-user-file.log 7 | spring: 8 | #datasource: 9 | # continue-on-error: true 10 | # data-password: e24a23c250246d795eaf08ddab6b0fa9 11 | # data-username: postgres 12 | # driver-class-name: org.postgresql.Driver 13 | # url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun-file 14 | jooq: 15 | sql-dialect: postgres 16 | user: 17 | datasource: 18 | main: 19 | continue-on-error: true 20 | data-password: e24a23c250246d795eaf08ddab6b0fa9 21 | data-username: postgres 22 | password: e24a23c250246d795eaf08ddab6b0fa9 23 | username: postgres 24 | driver-class-name: org.postgresql.Driver 25 | url: jdbc:postgresql://119.90.49.12:8999/qingzhenyun_file -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'qingzhenyun-core' 2 | include 'qingzhenyun-common' 3 | include 'qingzhenyun-common-springboot' 4 | include 'qingzhenyun-ice-sb-common' 5 | include 'qingzhenyun-user-file' 6 | include 'qingzhenyun-common-jooq' 7 | include 'qingzhenyun-auto-config' 8 | include 'qingzhenyun-user-center' 9 | include 'qingzhenyun-ice-test' 10 | include 'qingzhenyun-cloud-store' 11 | include 'qingzhenyun-offline-download' 12 | 13 | --------------------------------------------------------------------------------