diff --git a/.gitignore b/.gitignore index 317307aaf..60f5f562a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /target/ /.idea/ /logs/ +.DS_Store diff --git a/.idea/icon.png b/.idea/icon.png new file mode 100644 index 000000000..30c359909 Binary files /dev/null and b/.idea/icon.png differ diff --git a/.travis.yml b/.travis.yml index 1e6973704..08bc63950 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,10 @@ language: java before_install: - mvn install:install-file -Dfile=./lib/antlr-2.7.4.jar -DgroupId=net.sourceforge.cpdetector -DartifactId=antlr -Dpackaging=jar -Dversion=2.7.4 -DgeneratePom=true -DcreateChecksum=true - - mvn install:install-file -Dfile=./lib/beautyeye_lnf.jar -DgroupId=com.beautyeye -DartifactId=beautyeye-lnf -Dpackaging=jar -Dversion=1.0 -DgeneratePom=true -DcreateChecksum=true - mvn install:install-file -Dfile=./lib/chardet-1.0.jar -DgroupId=net.sourceforge.cpdetector -DartifactId=chardet -Dpackaging=jar -Dversion=1.0.0 -DgeneratePom=true -DcreateChecksum=true - mvn install:install-file -Dfile=./lib/cpdetector_1.0.10.jar -DgroupId=net.sourceforge.cpdetector -DartifactId=cpdetector -Dpackaging=jar -Dversion=1.0.10 -DgeneratePom=true -DcreateChecksum=true - - mvn install:install-file -Dfile=./lib/darcula.jar -DgroupId=com.darcula -DartifactId=darcula-lnf -Dpackaging=jar -Dversion=1.0 -DgeneratePom=true -DcreateChecksum=true - mvn install:install-file -Dfile=./lib/jargs-1.0.jar -DgroupId=net.sourceforge.cpdetector -DartifactId=jargs -Dpackaging=jar -Dversion=1.0.0 -DgeneratePom=true -DcreateChecksum=true - mvn install:install-file -Dfile=./lib/taobao-sdk-java-auto.jar -DgroupId=com.taobao -DartifactId=taobao-sdk-java-auto -Dpackaging=jar -Dversion=1.0.0 -DgeneratePom=true -DcreateChecksum=true - - mvn install:install-file -Dfile=./lib/weblaf-1.29.jar -DgroupId=com.weblaf -DartifactId=weblaf-lnf -Dpackaging=jar -Dversion=1.2.9 -DgeneratePom=true -DcreateChecksum=true jdk: - openjdk8 diff --git a/assets/files/download_links.json b/assets/files/download_links.json new file mode 100644 index 000000000..e3b36fdc0 --- /dev/null +++ b/assets/files/download_links.json @@ -0,0 +1,5 @@ +{ + "windows": "https://gitee.com/zhoubochina/WePush/releases/download/v5.0.4/WePush-5.0.4-windows.exe", + "mac": "https://gitee.com/zhoubochina/WePush/releases/download/v5.0.4/WePush_5.0.4.dmg", + "linux": "https://gitee.com/zhoubochina/WePush/releases/download/v5.0.4/WePush_5.0.4.deb" +} \ No newline at end of file diff --git a/src/main/resources/icon/introduce-wepush-qrcode.png b/assets/files/introduce-wepush-qrcode.png similarity index 100% rename from src/main/resources/icon/introduce-wepush-qrcode.png rename to assets/files/introduce-wepush-qrcode.png diff --git a/src/main/resources/user_case.json b/assets/files/user_case.json similarity index 100% rename from src/main/resources/user_case.json rename to assets/files/user_case.json diff --git a/assets/files/wx-zanshang.jpg b/assets/files/wx-zanshang.jpg new file mode 100644 index 000000000..9d663627d Binary files /dev/null and b/assets/files/wx-zanshang.jpg differ diff --git a/assets/linux/WePush.png b/assets/linux/WePush.png new file mode 100644 index 000000000..95e911a39 Binary files /dev/null and b/assets/linux/WePush.png differ diff --git a/assets/mac/WePush.icns b/assets/mac/WePush.icns new file mode 100644 index 000000000..55b68f19f Binary files /dev/null and b/assets/mac/WePush.icns differ diff --git a/assets/screen_shoot/1.png b/assets/screen_shoot/1.png new file mode 100644 index 000000000..c3b0cd52e Binary files /dev/null and b/assets/screen_shoot/1.png differ diff --git a/assets/screen_shoot/2.png b/assets/screen_shoot/2.png new file mode 100644 index 000000000..337b02732 Binary files /dev/null and b/assets/screen_shoot/2.png differ diff --git a/assets/screen_shoot/3.png b/assets/screen_shoot/3.png new file mode 100644 index 000000000..d49601be4 Binary files /dev/null and b/assets/screen_shoot/3.png differ diff --git a/assets/screen_shoot/4.png b/assets/screen_shoot/4.png new file mode 100644 index 000000000..8f8bd6c01 Binary files /dev/null and b/assets/screen_shoot/4.png differ diff --git a/assets/screen_shoot/5.png b/assets/screen_shoot/5.png new file mode 100644 index 000000000..d8c3a3fb8 Binary files /dev/null and b/assets/screen_shoot/5.png differ diff --git a/assets/screen_shoot/6.png b/assets/screen_shoot/6.png new file mode 100644 index 000000000..f43456fe3 Binary files /dev/null and b/assets/screen_shoot/6.png differ diff --git a/assets/screen_shoot/7.png b/assets/screen_shoot/7.png new file mode 100644 index 000000000..4a505f891 Binary files /dev/null and b/assets/screen_shoot/7.png differ diff --git a/assets/screen_shoot/theme.png b/assets/screen_shoot/theme.png new file mode 100644 index 000000000..f6fab1bde Binary files /dev/null and b/assets/screen_shoot/theme.png differ diff --git a/assets/windows/WePush.ico b/assets/windows/WePush.ico new file mode 100644 index 000000000..e02dd461d Binary files /dev/null and b/assets/windows/WePush.ico differ diff --git a/download.md b/download.md index 8c5a3921a..b3ce3e25f 100644 --- a/download.md +++ b/download.md @@ -3,6 +3,12 @@
Windows +[WePush-v4.4.0_210221-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.4.0_210221-x64-Setup.exe) +[WePush-v4.3.0_210123-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.3.0_210123-x64-Setup.exe) +[WePush-v4.2.5_210117-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.2.5_210117-x64-Setup.exe) +[WePush-v4.2.4_201222-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.2.4_201222-x64-Setup.exe) +[WePush-v4.2.3_201210-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.2.3_201210-x64-Setup.exe) +[WePush-v4.2.2_201208-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.2.2_201208-x64-Setup.exe) [WePush-v4.2.1_200308-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.2.1_200308-x64-Setup.exe) [WePush-v4.2.0_191129-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.2.0_191129-x64-Setup.exe) [WePush-v4.1.1_191027-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.1.1_191027-x64-Setup.exe) @@ -75,6 +81,12 @@
Mac OS +[v_4.4.0_210221.app](http://download.zhoubochina.com/mac/4.4.0.zip) +[v_4.3.0_210123.app](http://download.zhoubochina.com/mac/4.3.0.zip) +[v_4.2.5_210117.app](http://download.zhoubochina.com/mac/4.2.5.zip) +[v_4.2.4_201222.app](http://download.zhoubochina.com/mac/4.2.4.zip) +[v_4.2.3_201210.app](http://download.zhoubochina.com/mac/4.2.3.zip) +[v_4.2.2_201208.app](http://download.zhoubochina.com/mac/4.2.2.zip) [v_4.2.1_200308.app](http://download.zhoubochina.com/mac/4.2.1.zip) [v_4.1.1_191027.app](http://download.zhoubochina.com/mac/4.1.1.zip) [v_3.9.0_190915.app](http://download.zhoubochina.com/mac/3.9.0.zip) @@ -127,6 +139,12 @@
Portable(各系统通用绿色便携版32/64位) +[v4.4.0_210221](http://download.zhoubochina.com/linux/WePush-4.4.0.zip) +[v4.3.0_210123](http://download.zhoubochina.com/linux/WePush-4.3.0.zip) +[v4.2.5_210117](http://download.zhoubochina.com/linux/WePush-4.2.5.zip) +[v4.2.4_201222](http://download.zhoubochina.com/linux/WePush-4.2.4.zip) +[v4.2.3_201210](http://download.zhoubochina.com/linux/WePush-4.2.3.zip) +[v4.2.2_201208](http://download.zhoubochina.com/linux/WePush-4.2.2.zip) [v4.2.1_200308](http://download.zhoubochina.com/linux/WePush-4.2.1.zip) [v4.2.0_191129](http://download.zhoubochina.com/linux/WePush-4.2.0.zip) [v4.1.1_191027](http://download.zhoubochina.com/linux/WePush-4.1.1.zip) diff --git a/icons/.DS_Store b/icons/.DS_Store new file mode 100644 index 000000000..23cf2d6f2 Binary files /dev/null and b/icons/.DS_Store differ diff --git a/icons/android/play_store_512.png b/icons/android/play_store_512.png new file mode 100644 index 000000000..4156cc21a Binary files /dev/null and b/icons/android/play_store_512.png differ diff --git a/icons/android/res/mipmap-anydpi-v26/ic_launcher.xml b/icons/android/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 000000000..345888d26 --- /dev/null +++ b/icons/android/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/icons/android/res/mipmap-hdpi/ic_launcher.png b/icons/android/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..3e6e2f9db Binary files /dev/null and b/icons/android/res/mipmap-hdpi/ic_launcher.png differ diff --git a/icons/android/res/mipmap-hdpi/ic_launcher_background.png b/icons/android/res/mipmap-hdpi/ic_launcher_background.png new file mode 100644 index 000000000..19669488f Binary files /dev/null and b/icons/android/res/mipmap-hdpi/ic_launcher_background.png differ diff --git a/icons/android/res/mipmap-hdpi/ic_launcher_foreground.png b/icons/android/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 000000000..aa52eda1f Binary files /dev/null and b/icons/android/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/icons/android/res/mipmap-hdpi/ic_launcher_monochrome.png b/icons/android/res/mipmap-hdpi/ic_launcher_monochrome.png new file mode 100644 index 000000000..aa52eda1f Binary files /dev/null and b/icons/android/res/mipmap-hdpi/ic_launcher_monochrome.png differ diff --git a/icons/android/res/mipmap-mdpi/ic_launcher.png b/icons/android/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..a7acb58f4 Binary files /dev/null and b/icons/android/res/mipmap-mdpi/ic_launcher.png differ diff --git a/icons/android/res/mipmap-mdpi/ic_launcher_background.png b/icons/android/res/mipmap-mdpi/ic_launcher_background.png new file mode 100644 index 000000000..75025cfd5 Binary files /dev/null and b/icons/android/res/mipmap-mdpi/ic_launcher_background.png differ diff --git a/icons/android/res/mipmap-mdpi/ic_launcher_foreground.png b/icons/android/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 000000000..05b43eed0 Binary files /dev/null and b/icons/android/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/icons/android/res/mipmap-mdpi/ic_launcher_monochrome.png b/icons/android/res/mipmap-mdpi/ic_launcher_monochrome.png new file mode 100644 index 000000000..05b43eed0 Binary files /dev/null and b/icons/android/res/mipmap-mdpi/ic_launcher_monochrome.png differ diff --git a/icons/android/res/mipmap-xhdpi/ic_launcher.png b/icons/android/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..7fcfd4449 Binary files /dev/null and b/icons/android/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/icons/android/res/mipmap-xhdpi/ic_launcher_background.png b/icons/android/res/mipmap-xhdpi/ic_launcher_background.png new file mode 100644 index 000000000..9784f16c8 Binary files /dev/null and b/icons/android/res/mipmap-xhdpi/ic_launcher_background.png differ diff --git a/icons/android/res/mipmap-xhdpi/ic_launcher_foreground.png b/icons/android/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 000000000..b719cc74b Binary files /dev/null and b/icons/android/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/icons/android/res/mipmap-xhdpi/ic_launcher_monochrome.png b/icons/android/res/mipmap-xhdpi/ic_launcher_monochrome.png new file mode 100644 index 000000000..b719cc74b Binary files /dev/null and b/icons/android/res/mipmap-xhdpi/ic_launcher_monochrome.png differ diff --git a/icons/android/res/mipmap-xxhdpi/ic_launcher.png b/icons/android/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..976b16308 Binary files /dev/null and b/icons/android/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/icons/android/res/mipmap-xxhdpi/ic_launcher_background.png b/icons/android/res/mipmap-xxhdpi/ic_launcher_background.png new file mode 100644 index 000000000..04ef206c8 Binary files /dev/null and b/icons/android/res/mipmap-xxhdpi/ic_launcher_background.png differ diff --git a/icons/android/res/mipmap-xxhdpi/ic_launcher_foreground.png b/icons/android/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 000000000..69a0b95a7 Binary files /dev/null and b/icons/android/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/icons/android/res/mipmap-xxhdpi/ic_launcher_monochrome.png b/icons/android/res/mipmap-xxhdpi/ic_launcher_monochrome.png new file mode 100644 index 000000000..69a0b95a7 Binary files /dev/null and b/icons/android/res/mipmap-xxhdpi/ic_launcher_monochrome.png differ diff --git a/icons/android/res/mipmap-xxxhdpi/ic_launcher.png b/icons/android/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..da9c0eff0 Binary files /dev/null and b/icons/android/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/icons/android/res/mipmap-xxxhdpi/ic_launcher_background.png b/icons/android/res/mipmap-xxxhdpi/ic_launcher_background.png new file mode 100644 index 000000000..66a5487a2 Binary files /dev/null and b/icons/android/res/mipmap-xxxhdpi/ic_launcher_background.png differ diff --git a/icons/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/icons/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 000000000..b4879bbd7 Binary files /dev/null and b/icons/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/icons/android/res/mipmap-xxxhdpi/ic_launcher_monochrome.png b/icons/android/res/mipmap-xxxhdpi/ic_launcher_monochrome.png new file mode 100644 index 000000000..b4879bbd7 Binary files /dev/null and b/icons/android/res/mipmap-xxxhdpi/ic_launcher_monochrome.png differ diff --git a/icons/ios/AppIcon-20@2x.png b/icons/ios/AppIcon-20@2x.png new file mode 100644 index 000000000..0b38c91c4 Binary files /dev/null and b/icons/ios/AppIcon-20@2x.png differ diff --git a/icons/ios/AppIcon-20@2x~ipad.png b/icons/ios/AppIcon-20@2x~ipad.png new file mode 100644 index 000000000..0b38c91c4 Binary files /dev/null and b/icons/ios/AppIcon-20@2x~ipad.png differ diff --git a/icons/ios/AppIcon-20@3x.png b/icons/ios/AppIcon-20@3x.png new file mode 100644 index 000000000..9e43a2f61 Binary files /dev/null and b/icons/ios/AppIcon-20@3x.png differ diff --git a/icons/ios/AppIcon-20~ipad.png b/icons/ios/AppIcon-20~ipad.png new file mode 100644 index 000000000..9df1ae891 Binary files /dev/null and b/icons/ios/AppIcon-20~ipad.png differ diff --git a/icons/ios/AppIcon-29.png b/icons/ios/AppIcon-29.png new file mode 100644 index 000000000..1ea85538c Binary files /dev/null and b/icons/ios/AppIcon-29.png differ diff --git a/icons/ios/AppIcon-29@2x.png b/icons/ios/AppIcon-29@2x.png new file mode 100644 index 000000000..89a04ced9 Binary files /dev/null and b/icons/ios/AppIcon-29@2x.png differ diff --git a/icons/ios/AppIcon-29@2x~ipad.png b/icons/ios/AppIcon-29@2x~ipad.png new file mode 100644 index 000000000..89a04ced9 Binary files /dev/null and b/icons/ios/AppIcon-29@2x~ipad.png differ diff --git a/icons/ios/AppIcon-29@3x.png b/icons/ios/AppIcon-29@3x.png new file mode 100644 index 000000000..656fb13fc Binary files /dev/null and b/icons/ios/AppIcon-29@3x.png differ diff --git a/icons/ios/AppIcon-29~ipad.png b/icons/ios/AppIcon-29~ipad.png new file mode 100644 index 000000000..1ea85538c Binary files /dev/null and b/icons/ios/AppIcon-29~ipad.png differ diff --git a/icons/ios/AppIcon-40@2x.png b/icons/ios/AppIcon-40@2x.png new file mode 100644 index 000000000..de4ee76b2 Binary files /dev/null and b/icons/ios/AppIcon-40@2x.png differ diff --git a/icons/ios/AppIcon-40@2x~ipad.png b/icons/ios/AppIcon-40@2x~ipad.png new file mode 100644 index 000000000..de4ee76b2 Binary files /dev/null and b/icons/ios/AppIcon-40@2x~ipad.png differ diff --git a/icons/ios/AppIcon-40@3x.png b/icons/ios/AppIcon-40@3x.png new file mode 100644 index 000000000..de782800c Binary files /dev/null and b/icons/ios/AppIcon-40@3x.png differ diff --git a/icons/ios/AppIcon-40~ipad.png b/icons/ios/AppIcon-40~ipad.png new file mode 100644 index 000000000..0b38c91c4 Binary files /dev/null and b/icons/ios/AppIcon-40~ipad.png differ diff --git a/icons/ios/AppIcon-60@2x~car.png b/icons/ios/AppIcon-60@2x~car.png new file mode 100644 index 000000000..de782800c Binary files /dev/null and b/icons/ios/AppIcon-60@2x~car.png differ diff --git a/icons/ios/AppIcon-60@3x~car.png b/icons/ios/AppIcon-60@3x~car.png new file mode 100644 index 000000000..131a13252 Binary files /dev/null and b/icons/ios/AppIcon-60@3x~car.png differ diff --git a/icons/ios/AppIcon-83.5@2x~ipad.png b/icons/ios/AppIcon-83.5@2x~ipad.png new file mode 100644 index 000000000..c440764db Binary files /dev/null and b/icons/ios/AppIcon-83.5@2x~ipad.png differ diff --git a/icons/ios/AppIcon@2x.png b/icons/ios/AppIcon@2x.png new file mode 100644 index 000000000..de782800c Binary files /dev/null and b/icons/ios/AppIcon@2x.png differ diff --git a/icons/ios/AppIcon@2x~ipad.png b/icons/ios/AppIcon@2x~ipad.png new file mode 100644 index 000000000..8feef01b1 Binary files /dev/null and b/icons/ios/AppIcon@2x~ipad.png differ diff --git a/icons/ios/AppIcon@3x.png b/icons/ios/AppIcon@3x.png new file mode 100644 index 000000000..131a13252 Binary files /dev/null and b/icons/ios/AppIcon@3x.png differ diff --git a/icons/ios/AppIcon~ios-marketing.png b/icons/ios/AppIcon~ios-marketing.png new file mode 100644 index 000000000..d1808fc5f Binary files /dev/null and b/icons/ios/AppIcon~ios-marketing.png differ diff --git a/icons/ios/AppIcon~ipad.png b/icons/ios/AppIcon~ipad.png new file mode 100644 index 000000000..489d72aa7 Binary files /dev/null and b/icons/ios/AppIcon~ipad.png differ diff --git a/icons/ios/Contents.json b/icons/ios/Contents.json new file mode 100644 index 000000000..bd04914ae --- /dev/null +++ b/icons/ios/Contents.json @@ -0,0 +1,134 @@ +{ + "images": [ + { + "filename": "AppIcon@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "AppIcon@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "AppIcon~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" + }, + { + "filename": "AppIcon@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" + }, + { + "filename": "AppIcon-83.5@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" + }, + { + "filename": "AppIcon-40@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "AppIcon-40@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" + }, + { + "filename": "AppIcon-40~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" + }, + { + "filename": "AppIcon-40@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "AppIcon-20@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "AppIcon-20@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" + }, + { + "filename": "AppIcon-20~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" + }, + { + "filename": "AppIcon-20@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "AppIcon-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "AppIcon-29@2x.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "AppIcon-29@3x.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" + }, + { + "filename": "AppIcon-29~ipad.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "AppIcon-29@2x~ipad.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "AppIcon-60@2x~car.png", + "idiom": "car", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "AppIcon-60@3x~car.png", + "idiom": "car", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "AppIcon~ios-marketing.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" + } + ], + "info": { + "author": "iconkitchen", + "version": 1 + } +} \ No newline at end of file diff --git a/icons/macos/AppIcon.icns b/icons/macos/AppIcon.icns new file mode 100644 index 000000000..55b68f19f Binary files /dev/null and b/icons/macos/AppIcon.icns differ diff --git a/icons/web/README.txt b/icons/web/README.txt new file mode 100644 index 000000000..3bdd02f56 --- /dev/null +++ b/icons/web/README.txt @@ -0,0 +1,18 @@ +Add this to your HTML : + + + + +Add this to your app's manifest.json: + + ... + { + "icons": [ + { "src": "/favicon.ico", "type": "image/x-icon", "sizes": "16x16 32x32" }, + { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" }, + { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }, + { "src": "/icon-192-maskable.png", "type": "image/png", "sizes": "192x192", "purpose": "maskable" }, + { "src": "/icon-512-maskable.png", "type": "image/png", "sizes": "512x512", "purpose": "maskable" } + ] + } + ... diff --git a/icons/web/apple-touch-icon.png b/icons/web/apple-touch-icon.png new file mode 100644 index 000000000..131a13252 Binary files /dev/null and b/icons/web/apple-touch-icon.png differ diff --git a/icons/web/favicon.ico b/icons/web/favicon.ico new file mode 100644 index 000000000..6c0c76b30 Binary files /dev/null and b/icons/web/favicon.ico differ diff --git a/icons/web/icon-192-maskable.png b/icons/web/icon-192-maskable.png new file mode 100644 index 000000000..587ca3afb Binary files /dev/null and b/icons/web/icon-192-maskable.png differ diff --git a/icons/web/icon-192.png b/icons/web/icon-192.png new file mode 100644 index 000000000..dc57bdf20 Binary files /dev/null and b/icons/web/icon-192.png differ diff --git a/icons/web/icon-512-maskable.png b/icons/web/icon-512-maskable.png new file mode 100644 index 000000000..4156cc21a Binary files /dev/null and b/icons/web/icon-512-maskable.png differ diff --git a/icons/web/icon-512.png b/icons/web/icon-512.png new file mode 100644 index 000000000..6e3d8ad1a Binary files /dev/null and b/icons/web/icon-512.png differ diff --git a/lib/beautyeye_lnf.jar b/lib/beautyeye_lnf.jar deleted file mode 100644 index e4f81936b..000000000 Binary files a/lib/beautyeye_lnf.jar and /dev/null differ diff --git a/lib/darcula.jar b/lib/darcula.jar deleted file mode 100644 index 8178abd82..000000000 Binary files a/lib/darcula.jar and /dev/null differ diff --git a/lib/weblaf-1.29.jar b/lib/weblaf-1.29.jar deleted file mode 100644 index 55e9f9ba5..000000000 Binary files a/lib/weblaf-1.29.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index ca7f25875..bd402374a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,47 +6,71 @@ com.fangxuele.tool WePush - 1.0 + 5.0.5 jar WePush https://github.com/rememberber/WePush + + + alimaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + mvnrepository.com + https://mvnrepository.com + + + jitpack.io + https://jitpack.io + + + oss.sonatype.org + https://oss.sonatype.org/content/repositories/snapshots/ + + + UTF-8 UTF-8 - 1.8 - 1.8 + 21 + 21 - 1.8 + 21 1.2.3 - 3.7.0 - 3.7.0 - 3.7.0 - 4.0.0 - 4.6.2 - 4.6 + 4.6.0 + 4.6.0 + 4.6.0 + 5.1.1 + 5.6.4 + 5.2 5.1.47 7.0.3 - 1.2.58 + 1.2.74 1.6.2 4.4.2 - 4.1.0 + 4.1.2 1.4 1.0.6 1.2.7 - 2.1 - 1.18.8 - 3.5.3 - 3.28.0 - 4.12 + 2.3 + 1.18.30 + 3.5.13 + 3.43.0.0 + 4.13.1 4.1.4 - 3.3.1 - 2.3.1 - 4.0.1 + 3.4.5 + 2.3.2 + 4.9.1 1.1.0 - 0.10.75 - 7.2.25 + 0.10.134 + 7.3.0 + 3.5.2 + 3.5.2 + 3.5.2 + 2.6.0 + 3.1.847 @@ -220,18 +244,6 @@ - - com.darcula - darcula-lnf - 1.0 - - - - com.beautyeye - beautyeye-lnf - 1.0 - - net.sourceforge.cpdetector @@ -284,11 +296,11 @@ httpasyncclient ${httpasyncclient.version} - - com.zaxxer - HikariCP - ${HikariCP.version} - + + + + + org.quartz-scheduler quartz @@ -386,6 +398,14 @@ slf4j-log4j12 org.slf4j + + hbase-client + org.apache.hbase + + + bcprov-jdk15on + org.bouncycastle + @@ -395,54 +415,114 @@ ${qiniu-java-sdk.version} + + com.formdev + flatlaf + ${flatlaf.version} + + + + com.formdev + flatlaf-extras + ${flatlaf-extras.version} + + + + com.formdev + flatlaf-intellij-themes + ${flatlaf-intellij-themes.version} + + + + com.jayway.jsonpath + json-path + ${json-path.version} + + + slf4j-api + org.slf4j + + + + + + com.tencentcloudapi + tencentcloud-sdk-java + ${tencentcloud-sdk-java.version} + + - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - UTF-8 - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.0 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.2 + io.github.fvarrui + javapackager + 1.7.5 - - - true - lib/ - com.fangxuele.tool.push.App - - + true + com.fangxuele.tool.push.App + true - - - org.apache.maven.plugins - maven-dependency-plugin - 3.1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - copy-dependencies + bundling-for-mac package - copy-dependencies + package - ${project.build.directory}/lib + mac + true + + rememberber@163.com + UNIVERSAL + + jdk.crypto.ec,jdk.charsets + false @@ -453,36 +533,6 @@ maven-install-plugin 2.5.2 - - install-beautyeye - clean - - lib/beautyeye_lnf.jar - com.beautyeye - beautyeye-lnf - 1.0 - jar - true - - - install-file - - - - install-darcula - clean - - lib/darcula.jar - com.darcula - darcula-lnf - 1.0 - jar - true - - - install-file - - install-taobao-sdk-auto clean diff --git a/readme.md b/readme.md index e83cf3fcc..8e4c1ef72 100644 --- a/readme.md +++ b/readme.md @@ -1,16 +1,20 @@ - WePush-Logo + WePush-Logo # WePush > 专注批量推送的小而美的工具 -[![码云Gitee](https://gitee.com/zhoubochina/WePush/badge/star.svg?theme=blue)](https://gitee.com/zhoubochina/WePush) +[![star](https://gitee.com/zhoubochina/WePush/badge/star.svg?theme=gvp)](https://gitee.com/zhoubochina/WePush/stargazers) [![GitHub stars](https://img.shields.io/github/stars/rememberber/WePush.svg)](https://github.com/rememberber/WePush) -[![Build Status](https://travis-ci.org/rememberber/WePush.svg?branch=master)](https://travis-ci.org/rememberber/WePush) [![GitHub release](https://img.shields.io/github/release/rememberber/WePush.svg)](https://github.com/rememberber/WePush/releases) [![GitHub license](https://img.shields.io/github/license/rememberber/WePush.svg)](https://github.com/rememberber/WePush/blob/master/LICENSE.txt) +Featured|HelloGitHub + +## 支持的平台 +Windows • Linux • macOS + ### 目前已经支持的消息类型 + 模板消息-公众号 + 模板消息-小程序 @@ -55,84 +59,17 @@ …… ### 截图速览 -

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

-

- - WePush - -

- -### 更多外观 -

- - WePush - -

-

- - WePush - -

- +![Overview](assets/screen_shoot/1.png) +![Overview](assets/screen_shoot/2.png) +![Overview](assets/screen_shoot/3.png) +![Overview](assets/screen_shoot/4.png) +![Overview](assets/screen_shoot/5.png) +![Overview](assets/screen_shoot/7.png) +![Overview](assets/screen_shoot/6.png) +![Overview](assets/screen_shoot/theme.png) ### 安装文件下载 -[WePush下载地址](https://gitee.com/zhoubochina/WePush/wikis/download) - -安装之前请确认已经安装了jre1.8或者以上版本 -[jre下载地址](http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) - -### 环境依赖 -+ Java 8 -+ lombok +[WePush下载地址](https://gitee.com/zhoubochina/WePush/releases) ### 使用到的一些小技术点 + Java @@ -156,17 +93,7 @@ ### 特别感谢 [WxJava](https://gitee.com/binary/weixin-java-tools) [Hutool](http://hutool.cn/) -[Darcula](https://github.com/bulenkov/Darcula) -[BeautyEye](https://gitee.com/jackjiang/beautyeye) - -### 特别说明 -WePush所使用的图标来源于https://github.com/JetBrains/intellij-community项目 -版权、专利和许可都归其所有https://github.com/JetBrains/intellij-community/blob/master/LICENSE.txt -如有冒犯,请及时通知我删除 -Icons in WePush are from Project:https://github.com/JetBrains/intellij-community -Copy right,patent and license are belong to the "JetBrains/intellij-community" -https://github.com/JetBrains/intellij-community/blob/master/LICENSE.txt -If there is any offence, please inform me to delete them in time. +[FlatLaf](https://www.formdev.com/flatlaf/) ### 开发&构建 @@ -178,7 +105,7 @@ https://gitee.com/zhoubochina/WePush/wikis/help QQ交流群:

- WePush + WePush

@@ -188,6 +115,6 @@ QQ交流群: 您的赞赏将会给我带来更多动力**

- WePush + WePush

\ No newline at end of file diff --git a/screen_shoot/logo-128.png b/screen_shoot/logo-128.png new file mode 100644 index 000000000..b0cffe9fd Binary files /dev/null and b/screen_shoot/logo-128.png differ diff --git a/screen_shoot/wepush-qq-group.png b/screen_shoot/wepush-qq-group.png new file mode 100644 index 000000000..0623a034e Binary files /dev/null and b/screen_shoot/wepush-qq-group.png differ diff --git a/screen_shoot/wx-zanshang.jpg b/screen_shoot/wx-zanshang.jpg new file mode 100644 index 000000000..2c947449f Binary files /dev/null and b/screen_shoot/wx-zanshang.jpg differ diff --git a/src/main/java/com/fangxuele/tool/push/App.java b/src/main/java/com/fangxuele/tool/push/App.java index b10d45c91..4b6ab11d1 100644 --- a/src/main/java/com/fangxuele/tool/push/App.java +++ b/src/main/java/com/fangxuele/tool/push/App.java @@ -1,13 +1,21 @@ package com.fangxuele.tool.push; +import cn.hutool.core.thread.ThreadUtil; import com.fangxuele.tool.push.ui.Init; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.dialog.AboutDialog; +import com.fangxuele.tool.push.ui.dialog.SettingDialog; import com.fangxuele.tool.push.ui.form.LoadingForm; import com.fangxuele.tool.push.ui.form.MainWindow; import com.fangxuele.tool.push.ui.frame.MainFrame; +import com.fangxuele.tool.push.ui.listener.TaskListener; import com.fangxuele.tool.push.util.ConfigUtil; import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.UpgradeUtil; +import com.formdev.flatlaf.extras.FlatDesktop; +import com.formdev.flatlaf.util.SystemInfo; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.ibatis.session.SqlSession; import javax.swing.*; @@ -34,18 +42,51 @@ public class App { public static TrayIcon trayIcon; public static void main(String[] args) { + if (SystemInfo.isMacOS) { +// java -Xdock:name="WePush" -Xdock:icon=WePush.jpg ... (whatever else you normally specify here) +// java -Xms64m -Xmx256m -Dapple.awt.application.name="WePush" -Dcom.apple.mrj.application.apple.menu.about.name="WePush" -cp "./lib/*" com.luoboduner.moo.tool.App + System.setProperty("apple.laf.useScreenMenuBar", "true"); + System.setProperty("apple.awt.application.name", UiConsts.APP_NAME); + System.setProperty("com.apple.mrj.application.apple.menu.about.name", UiConsts.APP_NAME); + System.setProperty("apple.awt.application.appearance", "system"); + System.setProperty("flatlaf.useRoundedPopupBorder", "true"); + + FlatDesktop.setAboutHandler(() -> { + try { + AboutDialog dialog = new AboutDialog(); + + dialog.pack(); + dialog.setVisible(true); + } catch (Exception e2) { + log.error(ExceptionUtils.getStackTrace(e2)); + } + }); + FlatDesktop.setPreferencesHandler(() -> { + try { + SettingDialog dialog = new SettingDialog(); + + dialog.pack(); + dialog.setVisible(true); + } catch (Exception e2) { + log.error(ExceptionUtils.getStackTrace(e2)); + } + }); + FlatDesktop.setQuitHandler(FlatDesktop.QuitResponse::performQuit); + + } + Init.initTheme(); mainFrame = new MainFrame(); mainFrame.init(); JPanel loadingPanel = new LoadingForm().getLoadingPanel(); mainFrame.add(loadingPanel); + mainFrame.pack(); + mainFrame.setVisible(true); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - if (screenSize.getWidth() <= 1366) { + if (config.isDefaultMaxWindow() || screenSize.getWidth() <= 1366) { // 低分辨率下自动最大化窗口 mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); } - mainFrame.pack(); - mainFrame.setVisible(true); UpgradeUtil.smoothUpgrade(); mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); @@ -56,7 +97,11 @@ public static void main(String[] args) { Init.initOthers(); mainFrame.addListeners(); mainFrame.remove(loadingPanel); - Init.initFontSize(); + Init.fontSizeGuide(); Init.initTray(); + + // 重启应用时把所有定时任务重新加入到任务队列 + ThreadUtil.execute(TaskListener::addAllScheduledTask); + } } diff --git a/src/main/java/com/fangxuele/tool/push/bean/DingMsg.java b/src/main/java/com/fangxuele/tool/push/bean/DingMsg.java deleted file mode 100644 index 6804bc408..000000000 --- a/src/main/java/com/fangxuele/tool/push/bean/DingMsg.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.fangxuele.tool.push.bean; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.io.Serializable; - -/** - *
- * 钉钉消息
- * 
- * - * @author RememBerBer - * @since 2019/9/5. - */ -@Getter -@Setter -@ToString -public class DingMsg implements Serializable { - private static final long serialVersionUID = 1L; - - private String content; - - private String title; - - private String picUrl; - - private String url; - - private String btnTxt; - - private String btnUrl; -} diff --git a/src/main/java/com/fangxuele/tool/push/bean/TemplateData.java b/src/main/java/com/fangxuele/tool/push/bean/TemplateData.java index 6e469665a..40435f35e 100644 --- a/src/main/java/com/fangxuele/tool/push/bean/TemplateData.java +++ b/src/main/java/com/fangxuele/tool/push/bean/TemplateData.java @@ -3,8 +3,6 @@ import lombok.Getter; import lombok.Setter; -import java.io.Serializable; - /** *
  * 模板数据
@@ -15,7 +13,7 @@
  */
 @Getter
 @Setter
-public class TemplateData implements Serializable {
+public class TemplateData {
 
     private String name;
 
diff --git a/src/main/java/com/fangxuele/tool/push/bean/UserCase.java b/src/main/java/com/fangxuele/tool/push/bean/UserCase.java
index 0c4b849e6..43fa9b3dc 100644
--- a/src/main/java/com/fangxuele/tool/push/bean/UserCase.java
+++ b/src/main/java/com/fangxuele/tool/push/bean/UserCase.java
@@ -2,8 +2,6 @@
 
 import lombok.Data;
 
-import java.io.Serializable;
-
 /**
  * 
  * 用户案例
@@ -13,9 +11,7 @@
  * @since 2019/4/20.
  */
 @Data
-public class UserCase implements Serializable {
-
-    private static final long serialVersionUID = 2829237163275443844L;
+public class UserCase {
 
     private String qrCodeUrl;
 
diff --git a/src/main/java/com/fangxuele/tool/push/bean/VersionSummary.java b/src/main/java/com/fangxuele/tool/push/bean/VersionSummary.java
index eb1a88477..a4825aa8e 100644
--- a/src/main/java/com/fangxuele/tool/push/bean/VersionSummary.java
+++ b/src/main/java/com/fangxuele/tool/push/bean/VersionSummary.java
@@ -2,7 +2,6 @@
 
 import lombok.Data;
 
-import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -14,9 +13,7 @@
  * @since 2019/4/20.
  */
 @Data
-public class VersionSummary implements Serializable {
-
-    private static final long serialVersionUID = 4637273116136790267L;
+public class VersionSummary {
 
     /**
      * 当前版本
@@ -42,9 +39,7 @@ public class VersionSummary implements Serializable {
      * @since 2019/4/20.
      */
     @Data
-    public static class Version implements Serializable {
-
-        private static final long serialVersionUID = 4637273116136790268L;
+    public static class Version {
 
         private String version;
 
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/AliYunAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/AliYunAccountConfig.java
new file mode 100644
index 000000000..fe65a3ebf
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/AliYunAccountConfig.java
@@ -0,0 +1,13 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 阿里云账号配置
+ */
+@Data
+public class AliYunAccountConfig {
+    private String accessKeyId;
+    private String accessKeySecret;
+    private String sign;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/BdYunAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/BdYunAccountConfig.java
new file mode 100644
index 000000000..2db70ca16
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/BdYunAccountConfig.java
@@ -0,0 +1,14 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 百度云账号配置
+ */
+@Data
+public class BdYunAccountConfig {
+    private String bdEndPoint;
+    private String bdInvokeId;
+    private String bdSecretAccessKey;
+    private String bdAccessKeyId;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/DingAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/DingAccountConfig.java
new file mode 100644
index 000000000..f2cd5aa2e
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/DingAccountConfig.java
@@ -0,0 +1,14 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 钉钉账号配置
+ */
+@Data
+public class DingAccountConfig {
+    private String appSecret;
+    private String appName;
+    private String agentId;
+    private String appKey;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/EmailAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/EmailAccountConfig.java
new file mode 100644
index 000000000..81c91d308
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/EmailAccountConfig.java
@@ -0,0 +1,17 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * Email账号配置
+ */
+@Data
+public class EmailAccountConfig {
+    private boolean mailStartTLS;
+    private boolean mailSSL;
+    private String mailHost;
+    private String mailPort;
+    private String mailFrom;
+    private String mailUser;
+    private String mailPassword;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/HttpAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/HttpAccountConfig.java
new file mode 100644
index 000000000..ec3eeaf83
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/HttpAccountConfig.java
@@ -0,0 +1,15 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * Http账号配置
+ */
+@Data
+public class HttpAccountConfig {
+    private boolean useProxy;
+    private String proxyHost;
+    private String proxyPort;
+    private String proxyUserName;
+    private String proxyPassword;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/HwYunAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/HwYunAccountConfig.java
new file mode 100644
index 000000000..e6aca7237
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/HwYunAccountConfig.java
@@ -0,0 +1,15 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 华为云账号配置
+ */
+@Data
+public class HwYunAccountConfig {
+    private String accessUrl;
+    private String senderCode;
+    private String signature;
+    private String appSecret;
+    private String appKey;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/QiniuYunAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/QiniuYunAccountConfig.java
new file mode 100644
index 000000000..a58089bbf
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/QiniuYunAccountConfig.java
@@ -0,0 +1,12 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 七牛云账号配置
+ */
+@Data
+public class QiniuYunAccountConfig {
+    private String accessKey;
+    private String secretKey;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/TxYun3AccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/TxYun3AccountConfig.java
new file mode 100644
index 000000000..983416d68
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/TxYun3AccountConfig.java
@@ -0,0 +1,16 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 腾讯云3.0账号配置
+ */
+@Data
+public class TxYun3AccountConfig {
+    private String secretId;
+    private String secretKey;
+    private String endPoint;
+    private String region;
+    private String sign;
+    private String sdkAppId;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/TxYunAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/TxYunAccountConfig.java
new file mode 100644
index 000000000..27924f8aa
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/TxYunAccountConfig.java
@@ -0,0 +1,13 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 腾讯云账号配置
+ */
+@Data
+public class TxYunAccountConfig {
+    private String sign;
+    private String appKey;
+    private String appId;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/UpYunAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/UpYunAccountConfig.java
new file mode 100644
index 000000000..389282b80
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/UpYunAccountConfig.java
@@ -0,0 +1,11 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 又拍云账号配置
+ */
+@Data
+public class UpYunAccountConfig {
+    private String authorizationToken;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/WxCpAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/WxCpAccountConfig.java
new file mode 100644
index 000000000..452a046d1
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/WxCpAccountConfig.java
@@ -0,0 +1,16 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 微信企业号账号配置
+ */
+@Data
+public class WxCpAccountConfig {
+    private String corpId;
+    private String appName;
+    private String agentId;
+    private String secret;
+    private Boolean privateDep;
+    private String baseApiUrl;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/WxMaAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/WxMaAccountConfig.java
new file mode 100644
index 000000000..8f7f3a6b2
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/WxMaAccountConfig.java
@@ -0,0 +1,19 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 微信小程序账号配置
+ */
+@Data
+public class WxMaAccountConfig {
+    private String appId;
+    private String appSecret;
+    private String token;
+    private String aesKey;
+    private boolean maUseProxy;
+    private String maProxyHost;
+    private String maProxyPort;
+    private String maProxyUserName;
+    private String maProxyPassword;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/WxMpAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/WxMpAccountConfig.java
new file mode 100644
index 000000000..5a53a89f5
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/WxMpAccountConfig.java
@@ -0,0 +1,25 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 微信公众号账号配置
+ */
+@Data
+public class WxMpAccountConfig {
+    private String appId;
+    private String appSecret;
+    private String token;
+    private String aesKey;
+    private boolean mpUseProxy;
+    private String mpProxyHost;
+    private String mpProxyPort;
+    private String mpProxyUserName;
+    private String mpProxyPassword;
+    private boolean mpUseOutSideAt;
+    private boolean mpManualAt;
+    private boolean mpApiAt;
+    private String mpAt;
+    private String mpAtExpiresIn;
+    private String mpAtApiUrl;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/account/YunPianAccountConfig.java b/src/main/java/com/fangxuele/tool/push/bean/account/YunPianAccountConfig.java
new file mode 100644
index 000000000..169b293e7
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/bean/account/YunPianAccountConfig.java
@@ -0,0 +1,11 @@
+package com.fangxuele.tool.push.bean.account;
+
+import lombok.Data;
+
+/**
+ * 云片网账号配置
+ */
+@Data
+public class YunPianAccountConfig {
+    private String apiKey;
+}
diff --git a/src/main/java/com/fangxuele/tool/push/bean/HttpMsg.java b/src/main/java/com/fangxuele/tool/push/bean/msg/HttpMsg.java
similarity index 72%
rename from src/main/java/com/fangxuele/tool/push/bean/HttpMsg.java
rename to src/main/java/com/fangxuele/tool/push/bean/msg/HttpMsg.java
index 95f8f2b60..6a2d25384 100644
--- a/src/main/java/com/fangxuele/tool/push/bean/HttpMsg.java
+++ b/src/main/java/com/fangxuele/tool/push/bean/msg/HttpMsg.java
@@ -1,10 +1,9 @@
-package com.fangxuele.tool.push.bean;
+package com.fangxuele.tool.push.bean.msg;
 
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
 
-import java.io.Serializable;
 import java.net.HttpCookie;
 import java.util.List;
 import java.util.Map;
@@ -20,9 +19,7 @@
 @Getter
 @Setter
 @ToString
-public class HttpMsg implements Serializable {
-
-    private static final long serialVersionUID = 114436270588113296L;
+public class HttpMsg {
 
     private String url;
 
diff --git a/src/main/java/com/fangxuele/tool/push/bean/MailMsg.java b/src/main/java/com/fangxuele/tool/push/bean/msg/MailMsg.java
similarity index 67%
rename from src/main/java/com/fangxuele/tool/push/bean/MailMsg.java
rename to src/main/java/com/fangxuele/tool/push/bean/msg/MailMsg.java
index 58f926b3e..c935fab80 100644
--- a/src/main/java/com/fangxuele/tool/push/bean/MailMsg.java
+++ b/src/main/java/com/fangxuele/tool/push/bean/msg/MailMsg.java
@@ -1,10 +1,11 @@
-package com.fangxuele.tool.push.bean;
+package com.fangxuele.tool.push.bean.msg;
 
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
 
-import java.io.Serializable;
+import java.io.File;
+import java.util.List;
 
 /**
  * 
@@ -17,9 +18,7 @@
 @Getter
 @Setter
 @ToString
-public class MailMsg implements Serializable {
-
-    private static final long serialVersionUID = 7269816872586216264L;
+public class MailMsg {
 
     /**
      * 标题
@@ -34,7 +33,7 @@ public class MailMsg implements Serializable {
     /**
      * 附件
      */
-    private String mailFiles;
+    private List mailFiles;
 
     /**
      * 内容
diff --git a/src/main/java/com/fangxuele/tool/push/dao/InitMapper.java b/src/main/java/com/fangxuele/tool/push/dao/InitMapper.java
deleted file mode 100644
index d13595329..000000000
--- a/src/main/java/com/fangxuele/tool/push/dao/InitMapper.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.fangxuele.tool.push.dao;
-
-/**
- * 
- * 初始化数据库
- * 
- * - * @author RememBerBer - * @since 2019/5/9. - */ -public interface InitMapper { - /** - * 初始化创建所有表 - * - * @return - */ - int createAllTables(); -} diff --git a/src/main/java/com/fangxuele/tool/push/dao/TAccountMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TAccountMapper.java new file mode 100644 index 000000000..5cfcbd327 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TAccountMapper.java @@ -0,0 +1,28 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TAccount; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface TAccountMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TAccount record); + + int insertSelective(TAccount record); + + TAccount selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TAccount record); + + int updateByPrimaryKey(TAccount record); + + List selectByMsgType(int msgType); + + int deleteByMsgTypeAndAccountName(@Param("msgType") int msgType, @Param("accountName") String accountName); + + TAccount selectByMsgTypeAndAccountName(@Param("msgType") int msgType, @Param("accountName") String accountName); + + int updateByMsgTypeAndAccountName(TAccount tAccount1); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TDingAppMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TDingAppMapper.java deleted file mode 100644 index d0f4473c2..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TDingAppMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TDingApp; - -import java.util.List; - -public interface TDingAppMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TDingApp record); - - int insertSelective(TDingApp record); - - TDingApp selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TDingApp record); - - int updateByPrimaryKey(TDingApp record); - - List selectByAppName(String appName); - - List selectAll(); - - TDingApp selectByAgentId(String agentId); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgDingMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgDingMapper.java deleted file mode 100644 index e9dc67af9..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgDingMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgDing; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgDingMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgDing record); - - int insertSelective(TMsgDing record); - - TMsgDing selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgDing record); - - int updateByPrimaryKey(TMsgDing record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgDing tMsgDing); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgHttpMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgHttpMapper.java deleted file mode 100644 index 9b43dac0d..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgHttpMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgHttp; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgHttpMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgHttp record); - - int insertSelective(TMsgHttp record); - - TMsgHttp selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgHttp record); - - int updateByPrimaryKey(TMsgHttp record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgHttp tMsgHttp); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgKefuMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgKefuMapper.java deleted file mode 100644 index 7360affa9..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgKefuMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgKefu; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgKefuMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgKefu record); - - int insertSelective(TMsgKefu record); - - TMsgKefu selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgKefu record); - - int updateByPrimaryKey(TMsgKefu record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgKefu tMsgKefu); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgKefuPriorityMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgKefuPriorityMapper.java deleted file mode 100644 index 0057b9d32..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgKefuPriorityMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgKefuPriority; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgKefuPriorityMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgKefuPriority record); - - int insertSelective(TMsgKefuPriority record); - - TMsgKefuPriority selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgKefuPriority record); - - int updateByPrimaryKey(TMsgKefuPriority record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgKefuPriority tMsgKefuPriority); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgMaSubscribeMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgMaSubscribeMapper.java deleted file mode 100644 index ee3a8d816..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgMaSubscribeMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgMaSubscribe; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgMaSubscribeMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgMaSubscribe record); - - int insertSelective(TMsgMaSubscribe record); - - TMsgMaSubscribe selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgMaSubscribe record); - - int updateByPrimaryKey(TMsgMaSubscribe record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgMaSubscribe tMsgMaSubscribe); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgMaTemplateMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgMaTemplateMapper.java deleted file mode 100644 index 0088699de..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgMaTemplateMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgMaTemplate; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgMaTemplateMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgMaTemplate record); - - int insertSelective(TMsgMaTemplate record); - - TMsgMaTemplate selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgMaTemplate record); - - int updateByPrimaryKey(TMsgMaTemplate record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgMaTemplate tMsgMaTemplate); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgMailMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgMailMapper.java deleted file mode 100644 index b805dd10c..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgMailMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgMail; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgMailMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgMail record); - - int insertSelective(TMsgMail record); - - TMsgMail selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgMail record); - - int updateByPrimaryKey(TMsgMail record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgMail tMsgMail); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgMapper.java new file mode 100644 index 000000000..973361bb7 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TMsgMapper.java @@ -0,0 +1,24 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TMsg; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface TMsgMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TMsg record); + + int insertSelective(TMsg record); + + TMsg selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TMsg record); + + int updateByPrimaryKey(TMsg record); + + TMsg selectByUnique(@Param("msgType") int msgType, @Param("accountId") Integer accountId, @Param("msgName") String msgName); + + List selectByMsgTypeAndAccountId(@Param("msgType") int msgType, @Param("accountId") Integer accountId); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgMpTemplateMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgMpTemplateMapper.java deleted file mode 100644 index c26851cbe..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgMpTemplateMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgMpTemplate; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgMpTemplateMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgMpTemplate record); - - int insertSelective(TMsgMpTemplate record); - - TMsgMpTemplate selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgMpTemplate record); - - int updateByPrimaryKey(TMsgMpTemplate record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgMpTemplate tMsgMpTemplate); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgSmsMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgSmsMapper.java deleted file mode 100644 index f7af356e6..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgSmsMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgSms; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgSmsMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgSms record); - - int insertSelective(TMsgSms record); - - TMsgSms selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgSms record); - - int updateByPrimaryKey(TMsgSms record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgSms tMsgSms); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgWxCpMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgWxCpMapper.java deleted file mode 100644 index 18bfb5d34..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgWxCpMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgWxCp; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgWxCpMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgWxCp record); - - int insertSelective(TMsgWxCp record); - - TMsgWxCp selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgWxCp record); - - int updateByPrimaryKey(TMsgWxCp record); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgWxCp tMsgWxCp); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgWxUniformMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgWxUniformMapper.java deleted file mode 100644 index 21dfa1323..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TMsgWxUniformMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TMsgWxUniform; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TMsgWxUniformMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TMsgWxUniform record); - - int insertSelective(TMsgWxUniform record); - - TMsgWxUniform selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TMsgWxUniform record); - - int updateByPrimaryKey(TMsgWxUniform record); - - List selectByMsgType(int msgType); - - int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); - - int updateByMsgTypeAndMsgName(TMsgWxUniform tMsgWxUniform); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TPeopleDataMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TPeopleDataMapper.java new file mode 100644 index 000000000..2431ef5f6 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TPeopleDataMapper.java @@ -0,0 +1,30 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TPeopleData; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface TPeopleDataMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TPeopleData record); + + int insertSelective(TPeopleData record); + + TPeopleData selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TPeopleData record); + + int updateByPrimaryKey(TPeopleData record); + + List selectByPeopleIdLimit20(Integer peopleId); + + Long countByPeopleId(Integer peopleId); + + int deleteByPeopleId(Integer peopleId); + + List selectByPeopleId(Integer peopleId); + + List selectByPeopleIdAndKeyword(@Param("peopleId") Integer peopleId, @Param("keyWord") String keyWord); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TPeopleImportConfigMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TPeopleImportConfigMapper.java new file mode 100644 index 000000000..c3145616c --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TPeopleImportConfigMapper.java @@ -0,0 +1,20 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import org.apache.ibatis.annotations.Param; + +public interface TPeopleImportConfigMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TPeopleImportConfig record); + + int insertSelective(TPeopleImportConfig record); + + TPeopleImportConfig selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TPeopleImportConfig record); + + int updateByPrimaryKey(TPeopleImportConfig record); + + TPeopleImportConfig selectByPeopleId(@Param("peopleId") Integer selectedPeopleId); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TPeopleMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TPeopleMapper.java new file mode 100644 index 000000000..ee9a1d3de --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TPeopleMapper.java @@ -0,0 +1,24 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TPeople; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface TPeopleMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TPeople record); + + int insertSelective(TPeople record); + + TPeople selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TPeople record); + + int updateByPrimaryKey(TPeople record); + + TPeople selectByMsgTypeAndAccountIdAndName(@Param("msgType") String msgType, @Param("accountId") Integer selectedAccountId, @Param("peopleName") String peopleName); + + List selectByMsgTypeAndAccountId(@Param("msgType") String msgType, @Param("accountId") Integer selectedAccountId); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TPushHistoryMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TPushHistoryMapper.java deleted file mode 100644 index 09f0b222a..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TPushHistoryMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TPushHistory; - -import java.util.List; - -public interface TPushHistoryMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TPushHistory record); - - int insertSelective(TPushHistory record); - - TPushHistory selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TPushHistory record); - - int updateByPrimaryKey(TPushHistory record); - - List selectByMsgType(int msgType); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TTaskExtMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TTaskExtMapper.java new file mode 100644 index 000000000..409cbbf96 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TTaskExtMapper.java @@ -0,0 +1,12 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TTask; + +import java.util.List; + +public interface TTaskExtMapper { + + TTask selectByTitle(String title); + + List selectAll(); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TTaskHisMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TTaskHisMapper.java new file mode 100644 index 000000000..21d3a64e0 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TTaskHisMapper.java @@ -0,0 +1,21 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TTaskHis; + +import java.util.List; + +public interface TTaskHisMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TTaskHis record); + + int insertSelective(TTaskHis record); + + TTaskHis selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TTaskHis record); + + int updateByPrimaryKey(TTaskHis record); + + List selectByTaskId(Integer taskId); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TTaskMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TTaskMapper.java new file mode 100644 index 000000000..a226485b5 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TTaskMapper.java @@ -0,0 +1,21 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TTask; + +import java.util.List; + +public interface TTaskMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TTask record); + + int insertSelective(TTask record); + + TTask selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TTask record); + + int updateByPrimaryKey(TTask record); + + List selectAll(); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TTemplateDataMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TTemplateDataMapper.java deleted file mode 100644 index f8057e2b5..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TTemplateDataMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TTemplateData; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TTemplateDataMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TTemplateData record); - - int insertSelective(TTemplateData record); - - TTemplateData selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TTemplateData record); - - int updateByPrimaryKey(TTemplateData record); - - List selectByMsgTypeAndMsgId(@Param("msgType") int msgType, @Param("msgId") int msgId); - - int deleteByMsgTypeAndMsgId(@Param("msgType") int msgType, @Param("msgId") int msgId); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TWxAccountMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TWxAccountMapper.java deleted file mode 100644 index 4918f4208..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TWxAccountMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TWxAccount; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface TWxAccountMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TWxAccount record); - - int insertSelective(TWxAccount record); - - TWxAccount selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TWxAccount record); - - int updateByPrimaryKey(TWxAccount record); - - List selectByAccountTypeAndAccountName(@Param("accountType") String accountType, @Param("accountName") String accountName); - - List selectByAccountType(String wxAccountType); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/dao/TWxCpAppMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TWxCpAppMapper.java deleted file mode 100644 index 926b9128c..000000000 --- a/src/main/java/com/fangxuele/tool/push/dao/TWxCpAppMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fangxuele.tool.push.dao; - -import com.fangxuele.tool.push.domain.TWxCpApp; - -import java.util.List; - -public interface TWxCpAppMapper { - int deleteByPrimaryKey(Integer id); - - int insert(TWxCpApp record); - - int insertSelective(TWxCpApp record); - - TWxCpApp selectByPrimaryKey(Integer id); - - int updateByPrimaryKeySelective(TWxCpApp record); - - int updateByPrimaryKey(TWxCpApp record); - - List selectByAgentId(String agentId); - - List selectAll(); - - List selectByAppName(String appName); -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TAccount.java b/src/main/java/com/fangxuele/tool/push/domain/TAccount.java new file mode 100644 index 000000000..a61859bfb --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/domain/TAccount.java @@ -0,0 +1,73 @@ +package com.fangxuele.tool.push.domain; + +public class TAccount { + private Integer id; + + private Integer msgType; + + private String accountName; + + private String accountConfig; + + private String remark; + + private String createTime; + + private String modifiedTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getMsgType() { + return msgType; + } + + public void setMsgType(Integer msgType) { + this.msgType = msgType; + } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName == null ? null : accountName.trim(); + } + + public String getAccountConfig() { + return accountConfig; + } + + public void setAccountConfig(String accountConfig) { + this.accountConfig = accountConfig == null ? null : accountConfig.trim(); + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark == null ? null : remark.trim(); + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime == null ? null : createTime.trim(); + } + + public String getModifiedTime() { + return modifiedTime; + } + + public void setModifiedTime(String modifiedTime) { + this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TDingApp.java b/src/main/java/com/fangxuele/tool/push/domain/TDingApp.java deleted file mode 100644 index 6e2596434..000000000 --- a/src/main/java/com/fangxuele/tool/push/domain/TDingApp.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.fangxuele.tool.push.domain; - -import java.io.Serializable; - -public class TDingApp implements Serializable { - private Integer id; - - private String appName; - - private String agentId; - - private String appKey; - - private String appSecret; - - private String createTime; - - private String modifiedTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName == null ? null : appName.trim(); - } - - public String getAgentId() { - return agentId; - } - - public void setAgentId(String agentId) { - this.agentId = agentId == null ? null : agentId.trim(); - } - - public String getAppKey() { - return appKey; - } - - public void setAppKey(String appKey) { - this.appKey = appKey == null ? null : appKey.trim(); - } - - public String getAppSecret() { - return appSecret; - } - - public void setAppSecret(String appSecret) { - this.appSecret = appSecret == null ? null : appSecret.trim(); - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; - } - - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgMaTemplate.java b/src/main/java/com/fangxuele/tool/push/domain/TMsg.java similarity index 57% rename from src/main/java/com/fangxuele/tool/push/domain/TMsgMaTemplate.java rename to src/main/java/com/fangxuele/tool/push/domain/TMsg.java index 3914f85d8..1b64184d4 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgMaTemplate.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsg.java @@ -1,26 +1,24 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TMsgMaTemplate implements Serializable { +public class TMsg { private Integer id; private Integer msgType; + private Integer accountId; + private String msgName; - private String templateId; + private String content; - private String page; + private String previewUser; - private String emphasisKeyword; + private String remark; private String createTime; private String modifiedTime; - private static final long serialVersionUID = 1L; - public Integer getId() { return id; } @@ -37,6 +35,14 @@ public void setMsgType(Integer msgType) { this.msgType = msgType; } + public Integer getAccountId() { + return accountId; + } + + public void setAccountId(Integer accountId) { + this.accountId = accountId; + } + public String getMsgName() { return msgName; } @@ -45,28 +51,28 @@ public void setMsgName(String msgName) { this.msgName = msgName == null ? null : msgName.trim(); } - public String getTemplateId() { - return templateId; + public String getContent() { + return content; } - public void setTemplateId(String templateId) { - this.templateId = templateId == null ? null : templateId.trim(); + public void setContent(String content) { + this.content = content == null ? null : content.trim(); } - public String getPage() { - return page; + public String getPreviewUser() { + return previewUser; } - public void setPage(String page) { - this.page = page == null ? null : page.trim(); + public void setPreviewUser(String previewUser) { + this.previewUser = previewUser == null ? null : previewUser.trim(); } - public String getEmphasisKeyword() { - return emphasisKeyword; + public String getRemark() { + return remark; } - public void setEmphasisKeyword(String emphasisKeyword) { - this.emphasisKeyword = emphasisKeyword == null ? null : emphasisKeyword.trim(); + public void setRemark(String remark) { + this.remark = remark == null ? null : remark.trim(); } public String getCreateTime() { diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgDing.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgDing.java index 7944ec82d..cae1cc89c 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgDing.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgDing.java @@ -1,52 +1,31 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; +public class TMsgDing { -public class TMsgDing implements Serializable { - private Integer id; - - private Integer msgType; - - private String msgName; + private String radioType; private String dingMsgType; - private String agentId; - private String webHook; private String content; - private String createTime; - - private String modifiedTime; - - private String radioType; - - private static final long serialVersionUID = 1L; + private String msgTitle; - public Integer getId() { - return id; - } + private String picUrl; - public void setId(Integer id) { - this.id = id; - } + private String url; - public Integer getMsgType() { - return msgType; - } + private String btnTxt; - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } + private String btnUrl; - public String getMsgName() { - return msgName; + public String getRadioType() { + return radioType; } - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); + public void setRadioType(String radioType) { + this.radioType = radioType == null ? null : radioType.trim(); } public String getDingMsgType() { @@ -57,14 +36,6 @@ public void setDingMsgType(String dingMsgType) { this.dingMsgType = dingMsgType == null ? null : dingMsgType.trim(); } - public String getAgentId() { - return agentId; - } - - public void setAgentId(String agentId) { - this.agentId = agentId == null ? null : agentId.trim(); - } - public String getWebHook() { return webHook; } @@ -81,27 +52,43 @@ public void setContent(String content) { this.content = content == null ? null : content.trim(); } - public String getCreateTime() { - return createTime; + public String getMsgTitle() { + return msgTitle; } - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); + public void setMsgTitle(String msgTitle) { + this.msgTitle = msgTitle; } - public String getModifiedTime() { - return modifiedTime; + public String getPicUrl() { + return picUrl; } - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + public void setPicUrl(String picUrl) { + this.picUrl = picUrl; } - public String getRadioType() { - return radioType; + public String getUrl() { + return url; } - public void setRadioType(String radioType) { - this.radioType = radioType == null ? null : radioType.trim(); + public void setUrl(String url) { + this.url = url; + } + + public String getBtnTxt() { + return btnTxt; + } + + public void setBtnTxt(String btnTxt) { + this.btnTxt = btnTxt; + } + + public String getBtnUrl() { + return btnUrl; + } + + public void setBtnUrl(String btnUrl) { + this.btnUrl = btnUrl; } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgHttp.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgHttp.java index 5624365e1..d4a2927c5 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgHttp.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgHttp.java @@ -1,13 +1,6 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TMsgHttp implements Serializable { - private Integer id; - - private Integer msgType; - - private String msgName; +public class TMsgHttp { private String method; @@ -21,38 +14,8 @@ public class TMsgHttp implements Serializable { private String body; - private String createTime; - - private String modifiedTime; - private String bodyType; - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public String getMsgName() { - return msgName; - } - - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } - public String getMethod() { return method; } @@ -101,22 +64,6 @@ public void setBody(String body) { this.body = body == null ? null : body.trim(); } - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; - } - - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); - } - public String getBodyType() { return bodyType; } @@ -124,4 +71,5 @@ public String getBodyType() { public void setBodyType(String bodyType) { this.bodyType = bodyType == null ? null : bodyType.trim(); } + } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgKefu.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgKefu.java index cdc246e3d..f4c4742dc 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgKefu.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgKefu.java @@ -1,13 +1,6 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TMsgKefu implements Serializable { - private Integer id; - - private Integer msgType; - - private String msgName; +public class TMsgKefu { private String kefuMsgType; @@ -25,31 +18,13 @@ public class TMsgKefu implements Serializable { private String modifiedTime; - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } + private String previewUser; - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } + private String appId; - public String getMsgName() { - return msgName; - } + private String pagePath; - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } + private String thumbMediaId; public String getKefuMsgType() { return kefuMsgType; @@ -114,4 +89,36 @@ public String getModifiedTime() { public void setModifiedTime(String modifiedTime) { this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); } + + public String getPreviewUser() { + return previewUser; + } + + public void setPreviewUser(String previewUser) { + this.previewUser = previewUser == null ? null : previewUser.trim(); + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId == null ? null : appId.trim(); + } + + public String getPagePath() { + return pagePath; + } + + public void setPagePath(String pagePath) { + this.pagePath = pagePath == null ? null : pagePath.trim(); + } + + public String getThumbMediaId() { + return thumbMediaId; + } + + public void setThumbMediaId(String thumbMediaId) { + this.thumbMediaId = thumbMediaId == null ? null : thumbMediaId.trim(); + } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgKefuPriority.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgKefuPriority.java index fa3c90a64..0d9183489 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgKefuPriority.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgKefuPriority.java @@ -1,14 +1,10 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; +import com.fangxuele.tool.push.bean.TemplateData; -public class TMsgKefuPriority implements Serializable { - private Integer id; - - private Integer msgType; - - private String msgName; +import java.util.List; +public class TMsgKefuPriority { private String templateId; private String url; @@ -29,35 +25,13 @@ public class TMsgKefuPriority implements Serializable { private String kefuUrl; - private String createTime; - - private String modifiedTime; + private String appId; - private static final long serialVersionUID = 1L; + private String pagePath; - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } + private String thumbMediaId; - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public String getMsgName() { - return msgName; - } - - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } + private List templateDataList; public String getTemplateId() { return templateId; @@ -139,19 +113,35 @@ public void setKefuUrl(String kefuUrl) { this.kefuUrl = kefuUrl == null ? null : kefuUrl.trim(); } - public String getCreateTime() { - return createTime; + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId == null ? null : appId.trim(); + } + + public String getPagePath() { + return pagePath; + } + + public void setPagePath(String pagePath) { + this.pagePath = pagePath == null ? null : pagePath.trim(); + } + + public String getThumbMediaId() { + return thumbMediaId; } - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); + public void setThumbMediaId(String thumbMediaId) { + this.thumbMediaId = thumbMediaId == null ? null : thumbMediaId.trim(); } - public String getModifiedTime() { - return modifiedTime; + public List getTemplateDataList() { + return templateDataList; } - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + public void setTemplateDataList(List templateDataList) { + this.templateDataList = templateDataList; } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgMaSubscribe.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgMaSubscribe.java index 2b8b8aff6..4f16b8a38 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgMaSubscribe.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgMaSubscribe.java @@ -1,47 +1,15 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; +import com.fangxuele.tool.push.bean.TemplateData; -public class TMsgMaSubscribe implements Serializable { - private Integer id; - - private Integer msgType; - - private String msgName; +import java.util.List; +public class TMsgMaSubscribe { private String templateId; private String page; - private String createTime; - - private String modifiedTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public String getMsgName() { - return msgName; - } - - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } + List templateDataList; public String getTemplateId() { return templateId; @@ -59,19 +27,11 @@ public void setPage(String page) { this.page = page == null ? null : page.trim(); } - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; + public List getTemplateDataList() { + return templateDataList; } - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + public void setTemplateDataList(List templateDataList) { + this.templateDataList = templateDataList; } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgMail.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgMail.java index 8fed4bf51..21bca95f4 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgMail.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgMail.java @@ -1,51 +1,14 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TMsgMail implements Serializable { - private Integer id; - - private Integer msgType; - - private String msgName; +public class TMsgMail { private String title; - private String files; - - private String content; - - private String createTime; - - private String modifiedTime; - private String cc; - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public String getMsgName() { - return msgName; - } + private String files; - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } + private String content; public String getTitle() { return title; @@ -55,6 +18,14 @@ public void setTitle(String title) { this.title = title == null ? null : title.trim(); } + public String getCc() { + return cc; + } + + public void setCc(String cc) { + this.cc = cc == null ? null : cc.trim(); + } + public String getFiles() { return files; } @@ -71,27 +42,4 @@ public void setContent(String content) { this.content = content == null ? null : content.trim(); } - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; - } - - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); - } - - public String getCc() { - return cc; - } - - public void setCc(String cc) { - this.cc = cc == null ? null : cc.trim(); - } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.java new file mode 100644 index 000000000..2425b1f1a --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.java @@ -0,0 +1,58 @@ +package com.fangxuele.tool.push.domain; + +import com.fangxuele.tool.push.bean.TemplateData; + +import java.util.List; + +public class TMsgMpSubscribe { + + private String templateId; + + private String url; + + private String maAppid; + + private String maPagePath; + + List templateDataList; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId == null ? null : templateId.trim(); + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url == null ? null : url.trim(); + } + + public String getMaAppid() { + return maAppid; + } + + public void setMaAppid(String maAppid) { + this.maAppid = maAppid == null ? null : maAppid.trim(); + } + + public String getMaPagePath() { + return maPagePath; + } + + public void setMaPagePath(String maPagePath) { + this.maPagePath = maPagePath == null ? null : maPagePath.trim(); + } + + public List getTemplateDataList() { + return templateDataList; + } + + public void setTemplateDataList(List templateDataList) { + this.templateDataList = templateDataList; + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgMpTemplate.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgMpTemplate.java index c981b0faf..6ab2b61cc 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgMpTemplate.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgMpTemplate.java @@ -1,13 +1,10 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; +import com.fangxuele.tool.push.bean.TemplateData; -public class TMsgMpTemplate implements Serializable { - private Integer id; +import java.util.List; - private Integer msgType; - - private String msgName; +public class TMsgMpTemplate { private String templateId; @@ -17,35 +14,7 @@ public class TMsgMpTemplate implements Serializable { private String maPagePath; - private String createTime; - - private String modifiedTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public String getMsgName() { - return msgName; - } - - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } + private List templateDataList; public String getTemplateId() { return templateId; @@ -79,19 +48,11 @@ public void setMaPagePath(String maPagePath) { this.maPagePath = maPagePath == null ? null : maPagePath.trim(); } - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; + public List getTemplateDataList() { + return templateDataList; } - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + public void setTemplateDataList(List templateDataList) { + this.templateDataList = templateDataList; } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgSms.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgSms.java index f6c9745df..01250949e 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgSms.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgSms.java @@ -1,47 +1,16 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; +import com.fangxuele.tool.push.bean.TemplateData; -public class TMsgSms implements Serializable { - private Integer id; +import java.util.List; - private Integer msgType; - - private String msgName; +public class TMsgSms { private String templateId; private String content; - private String createTime; - - private String modifiedTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public String getMsgName() { - return msgName; - } - - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } + private List templateDataList; public String getTemplateId() { return templateId; @@ -59,19 +28,11 @@ public void setContent(String content) { this.content = content == null ? null : content.trim(); } - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; + public List getTemplateDataList() { + return templateDataList; } - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + public void setTemplateDataList(List templateDataList) { + this.templateDataList = templateDataList; } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgWxCp.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgWxCp.java index 378fb471d..da03a67f3 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgWxCp.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgWxCp.java @@ -1,18 +1,9 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TMsgWxCp implements Serializable { - private Integer id; - - private Integer msgType; - - private String msgName; +public class TMsgWxCp { private String cpMsgType; - private String agentId; - private String content; private String title; @@ -23,38 +14,8 @@ public class TMsgWxCp implements Serializable { private String url; - private String createTime; - - private String modifiedTime; - private String btnTxt; - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } - - public String getMsgName() { - return msgName; - } - - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } - public String getCpMsgType() { return cpMsgType; } @@ -63,14 +24,6 @@ public void setCpMsgType(String cpMsgType) { this.cpMsgType = cpMsgType == null ? null : cpMsgType.trim(); } - public String getAgentId() { - return agentId; - } - - public void setAgentId(String agentId) { - this.agentId = agentId == null ? null : agentId.trim(); - } - public String getContent() { return content; } @@ -111,22 +64,6 @@ public void setUrl(String url) { this.url = url == null ? null : url.trim(); } - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; - } - - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); - } - public String getBtnTxt() { return btnTxt; } @@ -134,4 +71,5 @@ public String getBtnTxt() { public void setBtnTxt(String btnTxt) { this.btnTxt = btnTxt == null ? null : btnTxt.trim(); } + } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgWxUniform.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgWxUniform.java index f9fa474e9..851cd09e9 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TMsgWxUniform.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgWxUniform.java @@ -1,13 +1,10 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; +import com.fangxuele.tool.push.bean.TemplateData; -public class TMsgWxUniform implements Serializable { - private Integer id; +import java.util.List; - private Integer msgType; - - private String msgName; +public class TMsgWxUniform { private String mpTemplateId; @@ -23,35 +20,9 @@ public class TMsgWxUniform implements Serializable { private String emphasisKeyword; - private String createTime; - - private String modifiedTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getMsgType() { - return msgType; - } - - public void setMsgType(Integer msgType) { - this.msgType = msgType; - } + List templateDataListMp; - public String getMsgName() { - return msgName; - } - - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); - } + List templateDataListMa; public String getMpTemplateId() { return mpTemplateId; @@ -109,19 +80,19 @@ public void setEmphasisKeyword(String emphasisKeyword) { this.emphasisKeyword = emphasisKeyword == null ? null : emphasisKeyword.trim(); } - public String getCreateTime() { - return createTime; + public List getTemplateDataListMp() { + return templateDataListMp; } - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); + public void setTemplateDataListMp(List templateDataListMp) { + this.templateDataListMp = templateDataListMp; } - public String getModifiedTime() { - return modifiedTime; + public List getTemplateDataListMa() { + return templateDataListMa; } - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + public void setTemplateDataListMa(List templateDataListMa) { + this.templateDataListMa = templateDataListMa; } } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TPushHistory.java b/src/main/java/com/fangxuele/tool/push/domain/TPeople.java similarity index 51% rename from src/main/java/com/fangxuele/tool/push/domain/TPushHistory.java rename to src/main/java/com/fangxuele/tool/push/domain/TPeople.java index ef6d17a09..edd9153f6 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TPushHistory.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TPeople.java @@ -1,26 +1,22 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TPushHistory implements Serializable { +public class TPeople { private Integer id; - private Integer msgId; - private Integer msgType; - private String msgName; + private Integer accountId; + + private String peopleName; - private String result; + private String appVersion; - private String csvFile; + private String remark; private String createTime; private String modifiedTime; - private static final long serialVersionUID = 1L; - public Integer getId() { return id; } @@ -29,14 +25,6 @@ public void setId(Integer id) { this.id = id; } - public Integer getMsgId() { - return msgId; - } - - public void setMsgId(Integer msgId) { - this.msgId = msgId; - } - public Integer getMsgType() { return msgType; } @@ -45,28 +33,36 @@ public void setMsgType(Integer msgType) { this.msgType = msgType; } - public String getMsgName() { - return msgName; + public Integer getAccountId() { + return accountId; + } + + public void setAccountId(Integer accountId) { + this.accountId = accountId; + } + + public String getPeopleName() { + return peopleName; } - public void setMsgName(String msgName) { - this.msgName = msgName == null ? null : msgName.trim(); + public void setPeopleName(String peopleName) { + this.peopleName = peopleName == null ? null : peopleName.trim(); } - public String getResult() { - return result; + public String getAppVersion() { + return appVersion; } - public void setResult(String result) { - this.result = result == null ? null : result.trim(); + public void setAppVersion(String appVersion) { + this.appVersion = appVersion == null ? null : appVersion.trim(); } - public String getCsvFile() { - return csvFile; + public String getRemark() { + return remark; } - public void setCsvFile(String csvFile) { - this.csvFile = csvFile == null ? null : csvFile.trim(); + public void setRemark(String remark) { + this.remark = remark == null ? null : remark.trim(); } public String getCreateTime() { diff --git a/src/main/java/com/fangxuele/tool/push/domain/TPeopleData.java b/src/main/java/com/fangxuele/tool/push/domain/TPeopleData.java new file mode 100644 index 000000000..d42e165a1 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/domain/TPeopleData.java @@ -0,0 +1,93 @@ +package com.fangxuele.tool.push.domain; + +public class TPeopleData { + private Integer id; + + private Integer peopleId; + + private String pin; + + private String varData; + + private String appVersion; + + private String dataVersion; + + private String remark; + + private String createTime; + + private String modifiedTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getPeopleId() { + return peopleId; + } + + public void setPeopleId(Integer peopleId) { + this.peopleId = peopleId; + } + + public String getPin() { + return pin; + } + + public void setPin(String pin) { + this.pin = pin == null ? null : pin.trim(); + } + + public String getVarData() { + return varData; + } + + public void setVarData(String varData) { + this.varData = varData == null ? null : varData.trim(); + } + + public String getAppVersion() { + return appVersion; + } + + public void setAppVersion(String appVersion) { + this.appVersion = appVersion == null ? null : appVersion.trim(); + } + + public String getDataVersion() { + return dataVersion; + } + + public void setDataVersion(String dataVersion) { + this.dataVersion = dataVersion; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark == null ? null : remark.trim(); + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime == null ? null : createTime.trim(); + } + + public String getModifiedTime() { + return modifiedTime; + } + + public void setModifiedTime(String modifiedTime) { + this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TPeopleImportConfig.java b/src/main/java/com/fangxuele/tool/push/domain/TPeopleImportConfig.java new file mode 100644 index 000000000..814247695 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/domain/TPeopleImportConfig.java @@ -0,0 +1,113 @@ +package com.fangxuele.tool.push.domain; + +public class TPeopleImportConfig { + private Integer id; + + private Integer peopleId; + + private String lastWay; + + private String lastFilePath; + + private String lastSql; + + private String appVersion; + + private String lastWayConfig; + + private String lastDataVersion; + + private String remark; + + private String createTime; + + private String modifiedTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getPeopleId() { + return peopleId; + } + + public void setPeopleId(Integer peopleId) { + this.peopleId = peopleId; + } + + public String getLastWay() { + return lastWay; + } + + public void setLastWay(String lastWay) { + this.lastWay = lastWay == null ? null : lastWay.trim(); + } + + public String getLastFilePath() { + return lastFilePath; + } + + public void setLastFilePath(String lastFilePath) { + this.lastFilePath = lastFilePath == null ? null : lastFilePath.trim(); + } + + public String getLastSql() { + return lastSql; + } + + public void setLastSql(String lastSql) { + this.lastSql = lastSql == null ? null : lastSql.trim(); + } + + public String getAppVersion() { + return appVersion; + } + + public void setAppVersion(String appVersion) { + this.appVersion = appVersion == null ? null : appVersion.trim(); + } + + public String getLastWayConfig() { + return lastWayConfig; + } + + public void setLastWayConfig(String lastWayConfig) { + this.lastWayConfig = lastWayConfig; + } + + public String getLastDataVersion() { + return lastDataVersion; + } + + public void setLastDataVersion(String lastDataVersion) { + this.lastDataVersion = lastDataVersion; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark == null ? null : remark.trim(); + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime == null ? null : createTime.trim(); + } + + public String getModifiedTime() { + return modifiedTime; + } + + public void setModifiedTime(String modifiedTime) { + this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TTask.java b/src/main/java/com/fangxuele/tool/push/domain/TTask.java new file mode 100644 index 000000000..930b2297b --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/domain/TTask.java @@ -0,0 +1,223 @@ +package com.fangxuele.tool.push.domain; + +public class TTask { + private Integer id; + + private String title; + + private Integer msgType; + + private Integer accountId; + + private Integer messageId; + + private Integer peopleId; + + private Integer taskMode; + + private Integer taskPeriod; + + private Integer periodType; + + private String periodTime; + + private String cron; + + private Integer threadCnt; + + private Integer maxThreadCnt; + + private Integer reimportPeople; + + private Integer resultAlert; + + private String alertEmails; + + private Integer saveResult; + + private Integer intervalPush; + + private Integer intervalTime; + + private String remark; + + private String createTime; + + private String modifiedTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title == null ? null : title.trim(); + } + + public Integer getMsgType() { + return msgType; + } + + public void setMsgType(Integer msgType) { + this.msgType = msgType; + } + + public Integer getAccountId() { + return accountId; + } + + public void setAccountId(Integer accountId) { + this.accountId = accountId; + } + + public Integer getMessageId() { + return messageId; + } + + public void setMessageId(Integer messageId) { + this.messageId = messageId; + } + + public Integer getPeopleId() { + return peopleId; + } + + public void setPeopleId(Integer peopleId) { + this.peopleId = peopleId; + } + + public Integer getTaskMode() { + return taskMode; + } + + public void setTaskMode(Integer taskMode) { + this.taskMode = taskMode; + } + + public Integer getTaskPeriod() { + return taskPeriod; + } + + public void setTaskPeriod(Integer taskPeriod) { + this.taskPeriod = taskPeriod; + } + + public Integer getPeriodType() { + return periodType; + } + + public void setPeriodType(Integer periodType) { + this.periodType = periodType; + } + + public String getPeriodTime() { + return periodTime; + } + + public void setPeriodTime(String periodTime) { + this.periodTime = periodTime == null ? null : periodTime.trim(); + } + + public String getCron() { + return cron; + } + + public void setCron(String cron) { + this.cron = cron == null ? null : cron.trim(); + } + + public Integer getThreadCnt() { + return threadCnt; + } + + public void setThreadCnt(Integer threadCnt) { + this.threadCnt = threadCnt; + } + + public Integer getMaxThreadCnt() { + return maxThreadCnt; + } + + public void setMaxThreadCnt(Integer maxThreadCnt) { + this.maxThreadCnt = maxThreadCnt; + } + + public Integer getReimportPeople() { + return reimportPeople; + } + + public void setReimportPeople(Integer reimportPeople) { + this.reimportPeople = reimportPeople; + } + + public Integer getResultAlert() { + return resultAlert; + } + + public void setResultAlert(Integer resultAlert) { + this.resultAlert = resultAlert; + } + + public String getAlertEmails() { + return alertEmails; + } + + public void setAlertEmails(String alertEmails) { + this.alertEmails = alertEmails == null ? null : alertEmails.trim(); + } + + public Integer getSaveResult() { + return saveResult; + } + + public void setSaveResult(Integer saveResult) { + this.saveResult = saveResult; + } + + public Integer getIntervalPush() { + return intervalPush; + } + + public void setIntervalPush(Integer intervalPush) { + this.intervalPush = intervalPush; + } + + public Integer getIntervalTime() { + return intervalTime; + } + + public void setIntervalTime(Integer intervalTime) { + this.intervalTime = intervalTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark == null ? null : remark.trim(); + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime == null ? null : createTime.trim(); + } + + public String getModifiedTime() { + return modifiedTime; + } + + public void setModifiedTime(String modifiedTime) { + this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TTaskHis.java b/src/main/java/com/fangxuele/tool/push/domain/TTaskHis.java new file mode 100644 index 000000000..e261edf74 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/domain/TTaskHis.java @@ -0,0 +1,173 @@ +package com.fangxuele.tool.push.domain; + +public class TTaskHis { + private Integer id; + + private Integer taskId; + + private String startTime; + + private String endTime; + + private Integer totalCnt; + + private Integer successCnt; + + private Integer failCnt; + + private Integer status; + + private Integer dryRun; + + private String successFilePath; + + private String failFilePath; + + private String noSendFilePath; + + private String logFilePath; + + private Integer taskMode; + + private String remark; + + private String createTime; + + private String modifiedTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getTaskId() { + return taskId; + } + + public void setTaskId(Integer taskId) { + this.taskId = taskId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime == null ? null : startTime.trim(); + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime == null ? null : endTime.trim(); + } + + public Integer getTotalCnt() { + return totalCnt; + } + + public void setTotalCnt(Integer totalCnt) { + this.totalCnt = totalCnt; + } + + public Integer getSuccessCnt() { + return successCnt; + } + + public void setSuccessCnt(Integer successCnt) { + this.successCnt = successCnt; + } + + public Integer getFailCnt() { + return failCnt; + } + + public void setFailCnt(Integer failCnt) { + this.failCnt = failCnt; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getDryRun() { + return dryRun; + } + + public void setDryRun(Integer dryRun) { + this.dryRun = dryRun; + } + + public String getSuccessFilePath() { + return successFilePath; + } + + public void setSuccessFilePath(String successFilePath) { + this.successFilePath = successFilePath == null ? null : successFilePath.trim(); + } + + public String getFailFilePath() { + return failFilePath; + } + + public void setFailFilePath(String failFilePath) { + this.failFilePath = failFilePath == null ? null : failFilePath.trim(); + } + + public String getNoSendFilePath() { + return noSendFilePath; + } + + public void setNoSendFilePath(String noSendFilePath) { + this.noSendFilePath = noSendFilePath == null ? null : noSendFilePath.trim(); + } + + public String getLogFilePath() { + return logFilePath; + } + + public void setLogFilePath(String logFilePath) { + this.logFilePath = logFilePath == null ? null : logFilePath.trim(); + } + + public Integer getTaskMode() { + return taskMode; + } + + public void setTaskMode(Integer taskMode) { + this.taskMode = taskMode; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark == null ? null : remark.trim(); + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime == null ? null : createTime.trim(); + } + + public String getModifiedTime() { + return modifiedTime; + } + + public void setModifiedTime(String modifiedTime) { + this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TTemplateData.java b/src/main/java/com/fangxuele/tool/push/domain/TTemplateData.java index fd07a7d0d..1c871ec37 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TTemplateData.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TTemplateData.java @@ -1,8 +1,6 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TTemplateData implements Serializable { +public class TTemplateData { private Integer id; private Integer msgType; @@ -19,8 +17,6 @@ public class TTemplateData implements Serializable { private String modifiedTime; - private static final long serialVersionUID = 1L; - public Integer getId() { return id; } diff --git a/src/main/java/com/fangxuele/tool/push/domain/TWxAccount.java b/src/main/java/com/fangxuele/tool/push/domain/TWxAccount.java deleted file mode 100644 index cc844345f..000000000 --- a/src/main/java/com/fangxuele/tool/push/domain/TWxAccount.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.fangxuele.tool.push.domain; - -import java.io.Serializable; - -public class TWxAccount implements Serializable { - private Integer id; - - private String accountType; - - private String accountName; - - private String appId; - - private String appSecret; - - private String token; - - private String aesKey; - - private String createTime; - - private String modifiedTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getAccountType() { - return accountType; - } - - public void setAccountType(String accountType) { - this.accountType = accountType == null ? null : accountType.trim(); - } - - public String getAccountName() { - return accountName; - } - - public void setAccountName(String accountName) { - this.accountName = accountName == null ? null : accountName.trim(); - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId == null ? null : appId.trim(); - } - - public String getAppSecret() { - return appSecret; - } - - public void setAppSecret(String appSecret) { - this.appSecret = appSecret == null ? null : appSecret.trim(); - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token == null ? null : token.trim(); - } - - public String getAesKey() { - return aesKey; - } - - public void setAesKey(String aesKey) { - this.aesKey = aesKey == null ? null : aesKey.trim(); - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; - } - - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TWxCpApp.java b/src/main/java/com/fangxuele/tool/push/domain/TWxCpApp.java deleted file mode 100644 index 78294b928..000000000 --- a/src/main/java/com/fangxuele/tool/push/domain/TWxCpApp.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.fangxuele.tool.push.domain; - -import java.io.Serializable; - -public class TWxCpApp implements Serializable { - private Integer id; - - private String corpid; - - private String appName; - - private String agentId; - - private String secret; - - private String token; - - private String aesKey; - - private String createTime; - - private String modifiedTime; - - private static final long serialVersionUID = 1L; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getCorpid() { - return corpid; - } - - public void setCorpid(String corpid) { - this.corpid = corpid == null ? null : corpid.trim(); - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName == null ? null : appName.trim(); - } - - public String getAgentId() { - return agentId; - } - - public void setAgentId(String agentId) { - this.agentId = agentId == null ? null : agentId.trim(); - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret == null ? null : secret.trim(); - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token == null ? null : token.trim(); - } - - public String getAesKey() { - return aesKey; - } - - public void setAesKey(String aesKey) { - this.aesKey = aesKey == null ? null : aesKey.trim(); - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime == null ? null : createTime.trim(); - } - - public String getModifiedTime() { - return modifiedTime; - } - - public void setModifiedTime(String modifiedTime) { - this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); - } -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TWxMpUser.java b/src/main/java/com/fangxuele/tool/push/domain/TWxMpUser.java index 5b63d7727..35f8c4c51 100644 --- a/src/main/java/com/fangxuele/tool/push/domain/TWxMpUser.java +++ b/src/main/java/com/fangxuele/tool/push/domain/TWxMpUser.java @@ -1,8 +1,6 @@ package com.fangxuele.tool.push.domain; -import java.io.Serializable; - -public class TWxMpUser implements Serializable { +public class TWxMpUser { private String openId; private String nickname; @@ -39,8 +37,6 @@ public class TWxMpUser implements Serializable { private String modifiedTime; - private static final long serialVersionUID = 1L; - public String getOpenId() { return openId; } diff --git a/src/main/java/com/fangxuele/tool/push/logic/BoostPushRunThread.java b/src/main/java/com/fangxuele/tool/push/logic/BoostPushRunThread.java deleted file mode 100644 index 670bbf7d9..000000000 --- a/src/main/java/com/fangxuele/tool/push/logic/BoostPushRunThread.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.fangxuele.tool.push.logic; - -import cn.hutool.core.date.BetweenFormater; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.cron.pattern.CronPattern; -import cn.hutool.cron.pattern.CronPatternUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.msgsender.IMsgSender; -import com.fangxuele.tool.push.logic.msgsender.MsgSenderFactory; -import com.fangxuele.tool.push.logic.msgthread.MsgAsyncSendThread; -import com.fangxuele.tool.push.ui.form.BoostForm; -import com.fangxuele.tool.push.util.ConsoleUtil; -import org.apache.commons.compress.utils.Lists; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.http.HttpResponse; - -import javax.swing.*; -import java.io.IOException; -import java.util.Date; -import java.util.List; -import java.util.concurrent.Future; - -/** - *
- * 性能模式推送执行控制线程
- * 
- * - * @author RememBerBer - * @since 2019/7/7. - */ -public class BoostPushRunThread extends Thread { - - private static final Log logger = LogFactory.get(); - - public static List> futureList = Lists.newArrayList(); - - @Override - public void run() { - BoostForm boostForm = BoostForm.getInstance(); - boostForm.getProcessedProgressBar().setIndeterminate(true); - boostForm.getCompletedProgressBar().setIndeterminate(true); - // 准备推送 - preparePushRun(); - boostForm.getProcessedProgressBar().setIndeterminate(false); - boostForm.getCompletedProgressBar().setIndeterminate(false); - ConsoleUtil.boostConsoleWithLog("推送开始……"); - // 消息数据分片以及线程纷发 - shardingAndMsgThread(); - // 时间监控 - timeMonitor(); - } - - /** - * 准备推送 - */ - private void preparePushRun() { - BoostForm boostForm = BoostForm.getInstance(); - - // 按钮状态 - boostForm.getScheduledRunButton().setEnabled(false); - boostForm.getStartButton().setEnabled(false); - boostForm.getStopButton().setEnabled(true); - - boostForm.getStopButton().setText("停止"); - // 初始化 - boostForm.getProcessedCountLabel().setText("0"); - boostForm.getSuccessCountLabel().setText("0"); - boostForm.getFailCountLabel().setText("0"); - - // 设置是否空跑 - PushControl.dryRun = boostForm.getDryRunCheckBox().isSelected(); - - // 执行前重新导入目标用户 - PushControl.reimportMembers(); - - // 重置推送数据 - PushData.reset(); - PushData.startTime = System.currentTimeMillis(); - - // 拷贝准备的目标用户 - PushData.toSendList.addAll(PushData.allUser); - PushData.TO_SEND_COUNT.set(PushData.allUser.size()); - // 总记录数 - PushData.totalRecords = PushData.toSendList.size(); - - boostForm.getMemberCountLabel().setText("消息总数:" + PushData.totalRecords); - boostForm.getProcessedProgressBar().setMaximum((int) PushData.totalRecords); - boostForm.getCompletedProgressBar().setMaximum((int) PushData.totalRecords); - ConsoleUtil.boostConsoleWithLog("消息总数:" + PushData.totalRecords); - // 可用处理器核心数量 - boostForm.getProcessorCountLabel().setText("可用处理器核心:" + Runtime.getRuntime().availableProcessors()); - ConsoleUtil.boostConsoleWithLog("可用处理器核心:" + Runtime.getRuntime().availableProcessors()); - - // 准备消息构造器 - PushControl.prepareMsgMaker(); - } - - /** - * 消息数据分片以及线程纷发 - */ - private static void shardingAndMsgThread() { - - MsgAsyncSendThread msgAsyncSendThread; - - IMsgSender msgSender = MsgSenderFactory.getMsgSender(); - msgAsyncSendThread = new MsgAsyncSendThread(msgSender); - - ThreadUtil.execute(msgAsyncSendThread); - ConsoleUtil.boostConsoleWithLog("线程启动完毕……"); - } - - /** - * 时间监控 - */ - private void timeMonitor() { - BoostForm boostForm = BoostForm.getInstance(); - - long startTimeMillis = System.currentTimeMillis(); - // 计时 - while (true) { - if (PushData.TO_SEND_COUNT.get() <= PushData.successRecords.longValue() + PushData.failRecords.longValue()) { - if (!PushData.fixRateScheduling) { - boostForm.getStopButton().setEnabled(false); - boostForm.getStopButton().updateUI(); - boostForm.getStartButton().setEnabled(true); - boostForm.getStartButton().updateUI(); - boostForm.getScheduledRunButton().setEnabled(true); - boostForm.getScheduledRunButton().updateUI(); - boostForm.getScheduledTaskLabel().setText(""); - String finishTip = "发送完毕!\n"; - JOptionPane.showMessageDialog(boostForm.getBoostPanel(), finishTip, "提示", - JOptionPane.INFORMATION_MESSAGE); - boostForm.getScheduledTaskLabel().setVisible(false); - } else { - if (App.config.isRadioCron()) { - Date nextDate = CronPatternUtil.nextDateAfter(new CronPattern(App.config.getTextCron()), new Date(), true); - boostForm.getScheduledTaskLabel().setText("计划任务执行中,下一次执行时间:" + DateFormatUtils.format(nextDate, "yyyy-MM-dd HH:mm:ss")); - } - boostForm.getStopButton().setText("停止计划任务"); - } - - PushData.endTime = System.currentTimeMillis(); - - // 保存停止前的数据 - try { - // 空跑控制 - if (!boostForm.getDryRunCheckBox().isSelected()) { - ConsoleUtil.boostConsoleWithLog("正在保存结果数据……"); - boostForm.getCompletedProgressBar().setIndeterminate(true); - PushControl.savePushData(); - ConsoleUtil.boostConsoleWithLog("结果数据保存完毕!"); - } - } catch (IOException e) { - logger.error(e); - } finally { - boostForm.getCompletedProgressBar().setIndeterminate(false); - } - break; - } - - long currentTimeMillis = System.currentTimeMillis(); - long lastTimeMillis = currentTimeMillis - startTimeMillis; - long leftTimeMillis = (long) ((double) lastTimeMillis / (PushData.sendSuccessList.size() + PushData.sendFailList.size()) * (PushData.allUser.size() - PushData.sendSuccessList.size() - PushData.sendFailList.size())); - - // 耗时 - String formatBetweenLast = DateUtil.formatBetween(lastTimeMillis, BetweenFormater.Level.SECOND); - boostForm.getLastTimeLabel().setText("".equals(formatBetweenLast) ? "0s" : formatBetweenLast); - - // 预计剩余 - String formatBetweenLeft = DateUtil.formatBetween(leftTimeMillis, BetweenFormater.Level.SECOND); - boostForm.getLeftTimeLabel().setText("".equals(formatBetweenLeft) ? "0s" : formatBetweenLeft); - - boostForm.getJvmMemoryLabel().setText("JVM内存占用:" + FileUtil.readableFileSize(Runtime.getRuntime().totalMemory()) + "/" + FileUtil.readableFileSize(Runtime.getRuntime().maxMemory())); - - ThreadUtil.safeSleep(100); - } - } - -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/logic/InfinityTaskRunThread.java b/src/main/java/com/fangxuele/tool/push/logic/InfinityTaskRunThread.java new file mode 100644 index 000000000..44aa983a3 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/InfinityTaskRunThread.java @@ -0,0 +1,597 @@ +package com.fangxuele.tool.push.logic; + +import cn.hutool.core.date.BetweenFormatter; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.domain.*; +import com.fangxuele.tool.push.logic.msgsender.IMsgSender; +import com.fangxuele.tool.push.logic.msgsender.MailMsgSender; +import com.fangxuele.tool.push.logic.msgsender.MsgSenderFactory; +import com.fangxuele.tool.push.logic.msgthread.MsgInfinitySendThread; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.dialog.importway.*; +import com.fangxuele.tool.push.ui.form.TaskForm; +import com.fangxuele.tool.push.util.ConsoleUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.opencsv.CSVWriter; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.time.DateFormatUtils; + +import java.awt.*; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.*; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.atomic.LongAdder; +import java.util.stream.Collectors; + +/** + *
+ * 性能模式推送执行控制线程
+ * 
+ * + * @author RememBerBer + * @since 2023/8/9 + */ +@Getter +@Setter +public class InfinityTaskRunThread extends Thread { + + private static final Log logger = LogFactory.get(); + + private Integer taskId; + + private Integer dryRun; + + /** + * 发送成功数 + */ + public LongAdder successRecords = new LongAdder(); + + /** + * 发送失败数 + */ + public LongAdder failRecords = new LongAdder(); + + /** + * 停止标志 + */ + public volatile boolean running = false; + + private Long startTime; + + /** + * 结束时间 + */ + public static long endTime = 0; + + private List toSendList; + + /** + * 总记录数 + */ + static long totalRecords; + + /** + * 线程总数 + */ + public int threadCount; + + /** + * 固定频率计划任务执行中 + */ + public boolean fixRateScheduling = false; + + /** + * 发送成功的列表 + */ + public List sendSuccessList; + + /** + * 发送失败的列表 + */ + public List sendFailList; + + + /** + * 线程安全队列,非阻塞,用于存放待发送的消息,多线程消费该队列 + */ + public ConcurrentLinkedQueue toSendConcurrentLinkedQueue = new ConcurrentLinkedQueue<>(); + + /** + * 线程安全队列,非阻塞,用于存放活跃的线程名称 + */ + public ConcurrentLinkedQueue activeThreadConcurrentLinkedQueue = new ConcurrentLinkedQueue<>(); + + /** + * (异步发送)已处理数 + */ + public LongAdder processedRecords = new LongAdder(); + + /** + * 线程状态Map,key:线程名称,value:true运行,false停止 + */ + public Map threadStatusMap = new ConcurrentHashMap<>(100); + + private TTask tTask; + + public Integer getTaskId() { + return taskId; + } + + public void setTaskId(Integer taskId) { + this.taskId = taskId; + } + + public Integer getDryRun() { + return dryRun; + } + + public void setDryRun(Integer dryRun) { + this.dryRun = dryRun; + } + + private static TTaskMapper taskMapper = MybatisUtil.getSqlSession().getMapper(TTaskMapper.class); + private static TTaskHisMapper taskHisMapper = MybatisUtil.getSqlSession().getMapper(TTaskHisMapper.class); + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + private TTaskHis taskHis; + + private TMsg tMsg; + + private String logFilePath; + + private BufferedWriter logWriter; + + public static Map infinityTaskRunThreadMap = new ConcurrentHashMap<>(); + + private ThreadPoolExecutor threadPoolExecutor; + + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + public InfinityTaskRunThread(Integer taskId, Integer dryRun) { + this.taskId = taskId; + this.dryRun = dryRun; + } + + @Override + public void run() { + // 准备推送 + this.tTask = taskMapper.selectByPrimaryKey(taskId); + + try { + String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_"); + + logFilePath = SystemUtil.CONFIG_HOME + "data" + File.separator + + "push_log" + File.separator + tTask.getTitle() + "_" + nowTime + + ".log"; + FileUtil.touch(logFilePath); + logWriter = new BufferedWriter(new FileWriter(logFilePath)); + } catch (IOException e) { + logger.error(e); + } + + preparePushRun(); + + running = true; + + taskHis.setStatus(TaskStatusEnum.RUNNING_CODE); + taskHisMapper.updateByPrimaryKey(taskHis); + + ConsoleUtil.pushLog(logWriter, "推送开始……"); + ConsoleUtil.pushLog(logWriter, "推送过程中可随时拖拽下方滑动条调整线程数量,以达到最佳推送速度。"); + // 线程池初始化 + tMsg = msgMapper.selectByPrimaryKey(tTask.getMessageId()); + + int initCorePoolSize = tTask.getThreadCnt(); + threadPoolExecutor = ThreadUtil.newExecutor(initCorePoolSize, tTask.getMaxThreadCnt()); + adjustThreadCount(threadPoolExecutor, initCorePoolSize); + + infinityTaskRunThreadMap.put(taskHis.getId(), this); + // 时间监控 + timeMonitor(threadPoolExecutor); + + resetLocalData(); + + infinityTaskRunThreadMap.remove(taskHis.getId()); + } + + /** + * 准备推送 + */ + private void preparePushRun() { + + // 初始化任务历史表 + taskHis = new TTaskHis(); + + taskHis.setTaskId(tTask.getId()); + + // 设置是否空跑 + taskHis.setDryRun(dryRun); + + taskHis.setTaskMode(tTask.getTaskMode()); + + taskHis.setLogFilePath(logFilePath); + + if (tTask.getTaskPeriod() == TaskTypeEnum.SCHEDULE_TASK_CODE && tTask.getReimportPeople() == 1) { + // 获取上一次导入方式 + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(tTask.getPeopleId()); + String lastWay = tPeopleImportConfig.getLastWay(); + switch (Integer.valueOf(lastWay)) { + case PeopleImportWayEnum.BY_FILE_CODE: + ImportByFile importByFile = new ImportByFile(tTask.getPeopleId()); + importByFile.reImport(); + break; + case PeopleImportWayEnum.BY_SQL_CODE: + ImportBySQL importBySQL = new ImportBySQL(tTask.getPeopleId()); + importBySQL.reImport(); + break; + case PeopleImportWayEnum.BY_NUM_CODE: + ImportByNum importByNum = new ImportByNum(tTask.getPeopleId()); + importByNum.reImport(); + break; + case PeopleImportWayEnum.BY_WX_MP_CODE: + ImportByWxMp importByWxMp = new ImportByWxMp(tTask.getPeopleId()); + importByWxMp.reImport(); + break; + case PeopleImportWayEnum.BY_WX_CP_CODE: + ImportByWxCp importByWxCp = new ImportByWxCp(tTask.getPeopleId()); + importByWxCp.reImport(); + break; + case PeopleImportWayEnum.BY_DING_CODE: + ImportByDing importByDing = new ImportByDing(tTask.getPeopleId()); + importByDing.reImport(); + break; + default: + break; + } + } + + // 重置推送数据 + resetLocalData(); + + startTime = System.currentTimeMillis(); + + // 拷贝准备的目标用户 + List tPeopleData = peopleDataMapper.selectByPeopleId(tTask.getPeopleId()); + + tPeopleData.forEach(peopleData -> { + String varData = peopleData.getVarData(); + String[] strings = JSON.parseObject(varData, new TypeReference() { + }); + toSendConcurrentLinkedQueue.add(strings); + }); + // 总记录数 + totalRecords = toSendConcurrentLinkedQueue.size(); + taskHis.setTotalCnt((int) totalRecords); + + ConsoleUtil.pushLog(logWriter, "消息总数:" + totalRecords); + ConsoleUtil.pushLog(logWriter, "可用处理器核心:" + Runtime.getRuntime().availableProcessors()); + + taskHis.setStatus(TaskStatusEnum.INIT_CODE); + + String nowDateForSqlite = SqliteUtil.nowDateForSqlite(); + taskHis.setStartTime(nowDateForSqlite); + taskHis.setCreateTime(nowDateForSqlite); + taskHis.setModifiedTime(nowDateForSqlite); + + taskHisMapper.insert(taskHis); + + TaskForm taskForm = TaskForm.getInstance(); + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow > -1) { + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + if (selectedTaskId.equals(taskId)) { + TaskForm.initTaskHisListTable(taskId); + } + } + } + + + synchronized public void adjustThreadCount(ThreadPoolExecutor threadPoolExecutor, int targetCount) { + IMsgSender msgSender; + MsgInfinitySendThread msgInfinitySendThread; + while (activeThreadConcurrentLinkedQueue.size() < targetCount) { + msgSender = MsgSenderFactory.getMsgSender(tMsg.getId(), dryRun); + msgInfinitySendThread = new MsgInfinitySendThread(msgSender, this); + threadPoolExecutor.execute(msgInfinitySendThread); + } + while (activeThreadConcurrentLinkedQueue.size() > targetCount) { + String threadName = activeThreadConcurrentLinkedQueue.poll(); + threadStatusMap.put(threadName, false); + } + threadPoolExecutor.setCorePoolSize(targetCount); + } + + /** + * 时间监控 + * + * @param threadPoolExecutor + */ + private void timeMonitor(ThreadPoolExecutor threadPoolExecutor) { + // 计时 + while (true) { + if ((!running && activeThreadConcurrentLinkedQueue.isEmpty()) || toSendConcurrentLinkedQueue.isEmpty()) { + endTime = System.currentTimeMillis(); + taskHis.setEndTime(SqliteUtil.nowDateForSqlite()); + taskHis.setSuccessCnt(successRecords.intValue()); + taskHis.setFailCnt(failRecords.intValue()); + taskHis.setStatus(TaskStatusEnum.FINISH_CODE); + + taskHisMapper.updateByPrimaryKey(taskHis); + + TaskForm taskForm = TaskForm.getInstance(); + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow > -1) { + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + if (selectedTaskId.equals(taskId)) { + // 遍历TaskListTable找到taskHisId对应的行号 + int taskHisId = taskHis.getId(); + int taskHisListTableRows = taskForm.getTaskHisListTable().getRowCount(); + int taskHisListTableRow = -1; + for (int i = 0; i < taskHisListTableRows; i++) { + int taskHisIdInTable = (int) taskForm.getTaskHisListTable().getValueAt(i, 0); + if (taskHisId == taskHisIdInTable) { + taskHisListTableRow = i; + break; + } + } + if (taskHisListTableRow != -1) { + taskForm.getTaskHisListTable().setValueAt(TaskStatusEnum.getDescByCode(taskHis.getStatus()), taskHisListTableRow, 7); + taskForm.getTaskHisListTable().setValueAt(taskHis.getSuccessCnt(), taskHisListTableRow, 5); + taskForm.getTaskHisListTable().setValueAt(taskHis.getFailCnt(), taskHisListTableRow, 6); + taskForm.getTaskHisListTable().setValueAt(taskHis.getEndTime(), taskHisListTableRow, 3); + } + } + } + + if (App.trayIcon != null && SystemUtil.isWindowsOs()) { + App.trayIcon.displayMessage("WePush", tTask.getTitle() + " 发送完毕!", TrayIcon.MessageType.INFO); + } + + // 保存停止前的数据 + try { + // 空跑控制 + if (dryRun == 0) { + ConsoleUtil.pushLog(logWriter, "正在保存结果数据……"); + savePushData(); + ConsoleUtil.pushLog(logWriter, "结果数据保存完毕!"); + } + } catch (IOException e) { + logger.error(e); + } finally { + threadPoolExecutor.shutdown(); + ConsoleUtil.pushLog(logWriter, "推送结束!"); + } + + // 关闭logWriter + if (logWriter != null) { + try { + logWriter.flush(); + logWriter.close(); + } catch (IOException e) { + logger.error(e); + } + } + + running = false; + break; + } + + taskHis.setSuccessCnt(successRecords.intValue()); + taskHis.setFailCnt(failRecords.intValue()); + + TaskForm taskForm = TaskForm.getInstance(); + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow > -1) { + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + if (selectedTaskId.equals(taskId)) { + // 遍历TaskListTable找到taskHisId对应的行号 + int taskHisId = taskHis.getId(); + int taskHisListTableRows = taskForm.getTaskHisListTable().getRowCount(); + int taskHisListTableRow = -1; + for (int i = 0; i < taskHisListTableRows; i++) { + int taskHisIdInTable = (int) taskForm.getTaskHisListTable().getValueAt(i, 0); + if (taskHisId == taskHisIdInTable) { + taskHisListTableRow = i; + break; + } + } + if (taskHisListTableRow != -1) { + taskForm.getTaskHisListTable().setValueAt(taskHis.getSuccessCnt(), taskHisListTableRow, 5); + taskForm.getTaskHisListTable().setValueAt(taskHis.getFailCnt(), taskHisListTableRow, 6); + taskForm.getTaskHisListTable().setValueAt(TaskStatusEnum.getDescByCode(taskHis.getStatus()), taskHisListTableRow, 7); + } + } + } + ThreadUtil.safeSleep(500); + } + } + + /** + * 成功数+1 + */ + public void increaseSuccess() { + successRecords.add(1); + } + + /** + * 失败数+1 + */ + public void increaseFail() { + failRecords.add(1); + } + + /** + * 已处理数+1 + */ + public void increaseProcessed() { + processedRecords.add(1); + } + + private void savePushData() throws IOException { + if (!toSendConcurrentLinkedQueue.isEmpty()) { + toSendList = new ArrayList<>(toSendConcurrentLinkedQueue); + } + + File pushHisDir = new File(SystemUtil.CONFIG_HOME + "data" + File.separator + "push_his"); + if (!pushHisDir.exists()) { + boolean mkdirs = pushHisDir.mkdirs(); + } + + String taskName = tTask.getTitle(); + String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_"); + CSVWriter writer; + int msgType = tTask.getMsgType(); + + List fileList = new ArrayList<>(); + // 保存已发送 + if (sendSuccessList.size() > 0) { + File sendSuccessFile = new File(SystemUtil.CONFIG_HOME + "data" + + File.separator + "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + taskName + + "-发送成功-" + nowTime + ".csv"); + FileUtil.touch(sendSuccessFile); + writer = new CSVWriter(new FileWriter(sendSuccessFile)); + + for (String[] str : sendSuccessList) { + writer.writeNext(str); + } + writer.close(); + + taskHis.setSuccessFilePath(sendSuccessFile.getAbsolutePath()); + taskHisMapper.updateByPrimaryKey(taskHis); + fileList.add(sendSuccessFile); + // 保存累计推送总数 + App.config.setPushTotal(App.config.getPushTotal() + sendSuccessList.size()); + App.config.save(); + } + + // 保存未发送 + for (String[] str : sendSuccessList) { + if (msgType == MessageTypeEnum.HTTP_CODE && tTask.getSaveResult() == 1) { + str = ArrayUtils.remove(str, str.length - 1); + String[] finalStr = str; + toSendList = toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList()); + } else { + toSendList.remove(str); + } + } + for (String[] str : sendFailList) { + if (msgType == MessageTypeEnum.HTTP_CODE && tTask.getSaveResult() == 1) { + str = ArrayUtils.remove(str, str.length - 1); + String[] finalStr = str; + toSendList = toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList()); + } else { + toSendList.remove(str); + } + } + + if (toSendList.size() > 0) { + File unSendFile = new File(SystemUtil.CONFIG_HOME + "data" + File.separator + + "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + taskName + "-未发送-" + nowTime + + ".csv"); + FileUtil.touch(unSendFile); + writer = new CSVWriter(new FileWriter(unSendFile)); + for (String[] str : toSendList) { + writer.writeNext(str); + } + writer.close(); + + taskHis.setNoSendFilePath(unSendFile.getAbsolutePath()); + taskHisMapper.updateByPrimaryKey(taskHis); + fileList.add(unSendFile); + } + + // 保存发送失败 + if (sendFailList.size() > 0) { + File failSendFile = new File(SystemUtil.CONFIG_HOME + "data" + File.separator + + "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + taskName + "-发送失败-" + nowTime + ".csv"); + FileUtil.touch(failSendFile); + writer = new CSVWriter(new FileWriter(failSendFile)); + for (String[] str : sendFailList) { + writer.writeNext(str); + } + writer.close(); + + taskHis.setFailFilePath(failSendFile.getAbsolutePath()); + taskHisMapper.updateByPrimaryKey(taskHis); + fileList.add(failSendFile); + } + + // 发送推送结果邮件 + if (tTask.getResultAlert() == 1) { + ConsoleUtil.pushLog(logWriter, "发送推送结果邮件开始"); + String mailResultTo = tTask.getAlertEmails().replace(";", ";").replace(" ", ""); + String[] mailTos = mailResultTo.split(";"); + ArrayList mailToList = new ArrayList<>(Arrays.asList(mailTos)); + + MailMsgSender mailMsgSender = new MailMsgSender(); + String title = "WePush推送结果:【" + taskName + + "】" + sendSuccessList.size() + "成功;" + sendFailList.size() + "失败;" + + toSendList.size() + "未发送"; + StringBuilder contentBuilder = new StringBuilder(); + contentBuilder.append("

WePush推送结果

"); + contentBuilder.append("

消息类型:").append(MessageTypeEnum.getName(tTask.getMsgType())).append("

"); + contentBuilder.append("

消息名称:").append(taskName).append("

"); + contentBuilder.append("
"); + + contentBuilder.append("

成功数:").append(sendSuccessList.size()).append("

"); + contentBuilder.append("

失败数:").append(sendFailList.size()).append("

"); + contentBuilder.append("

未推送数:").append(toSendList.size()).append("

"); + contentBuilder.append("
"); + + contentBuilder.append("

开始时间:").append(DateFormatUtils.format(new Date(startTime), "yyyy-MM-dd HH:mm:ss")).append("

"); + contentBuilder.append("

完毕时间:").append(DateFormatUtils.format(new Date(endTime), "yyyy-MM-dd HH:mm:ss")).append("

"); + contentBuilder.append("

总耗时:").append(DateUtil.formatBetween(endTime - startTime, BetweenFormatter.Level.SECOND)).append("

"); + contentBuilder.append("
"); + + contentBuilder.append("

详情请查看附件

"); + + contentBuilder.append("
"); + contentBuilder.append("
"); + contentBuilder.append("

来自WePush,一款专注于批量推送的小而美的工具

"); + contentBuilder.append("\"WePush\""); + + File[] files = new File[fileList.size()]; + fileList.toArray(files); + mailMsgSender.sendPushResultMail(mailToList, title, contentBuilder.toString(), files); + ConsoleUtil.pushLog(logWriter, "发送推送结果邮件结束"); + } + } + + void resetLocalData() { + running = false; + processedRecords.reset(); + successRecords.reset(); + failRecords.reset(); + threadCount = 0; + toSendList = Collections.synchronizedList(new LinkedList<>()); + toSendConcurrentLinkedQueue = new ConcurrentLinkedQueue<>(); + activeThreadConcurrentLinkedQueue = new ConcurrentLinkedQueue<>(); + threadStatusMap = new ConcurrentHashMap<>(100); + sendSuccessList = Collections.synchronizedList(new LinkedList<>()); + sendFailList = Collections.synchronizedList(new LinkedList<>()); + startTime = 0L; + endTime = 0; + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java b/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java index 0c2444513..56dec0501 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java +++ b/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java @@ -28,7 +28,9 @@ public enum MessageTypeEnum { BD_YUN(15, "百度云短信"), QI_NIU_YUN(16, "七牛云短信"), WX_UNIFORM_MESSAGE(17, "小程序-统一服务消息"), - MA_SUBSCRIBE(18, "小程序-订阅消息"); + MA_SUBSCRIBE(18, "小程序-订阅消息"), + MP_SUBSCRIBE(19, "公众号-订阅通知"), + TX_YUN_3(20, "腾讯云短信3.0"); private int code; @@ -51,12 +53,18 @@ public enum MessageTypeEnum { public static final int QI_NIU_YUN_CODE = 16; public static final int WX_UNIFORM_MESSAGE_CODE = 17; public static final int MA_SUBSCRIBE_CODE = 18; + public static final int MP_SUBSCRIBE_CODE = 19; + public static final int TX_YUN_3_CODE = 20; MessageTypeEnum(int code, String name) { this.code = code; this.name = name; } + public static String getName(MessageTypeEnum messageTypeEnum) { + return messageTypeEnum.name; + } + public static String getName(int code) { String name = ""; switch (code) { @@ -111,9 +119,36 @@ public static String getName(int code) { case 18: name = MA_SUBSCRIBE.name; break; + case 19: + name = MP_SUBSCRIBE.name; + break; + case 20: + name = TX_YUN_3.name; + break; default: name = ""; } return name; } + + public static boolean isWxMpType(int msgType) { + return msgType == MessageTypeEnum.KEFU_CODE + || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE + || msgType == MessageTypeEnum.MP_TEMPLATE_CODE + || msgType == MessageTypeEnum.MP_SUBSCRIBE_CODE + ; + } + + public static boolean isWxMaType(int msgType) { + return msgType == MessageTypeEnum.MA_TEMPLATE_CODE + || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE + || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE + ; + } + + public static boolean isWxMaOrMpType(int msgType) { + return isWxMaType(msgType) + || isWxMpType(msgType); + } + } diff --git a/src/main/java/com/fangxuele/tool/push/logic/PeopleImportWayEnum.java b/src/main/java/com/fangxuele/tool/push/logic/PeopleImportWayEnum.java new file mode 100644 index 000000000..c4c206dc0 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/PeopleImportWayEnum.java @@ -0,0 +1,69 @@ +package com.fangxuele.tool.push.logic; + +/** + *
+ * 人群导入方式枚举
+ * 
+ * + * @author Zhou Bo + * @since 2021/4/29. + */ +public enum PeopleImportWayEnum { + /** + * 导入方式 + */ + BY_FILE(1, "通过文件导入"), + BY_SQL(2, "通过SQL导入"), + BY_WX_MP(3, "通过微信公众平台导入"), + BY_WX_CP(4, "通过微信企业通讯录导入"), + BY_DING(5, "通过钉钉通讯录导入"), + BY_NUM(6, "通过数量导入"); + + private int code; + + private String name; + + public static final int BY_FILE_CODE = 1; + public static final int BY_SQL_CODE = 2; + public static final int BY_WX_MP_CODE = 3; + public static final int BY_WX_CP_CODE = 4; + public static final int BY_DING_CODE = 5; + public static final int BY_NUM_CODE = 6; + + PeopleImportWayEnum(int code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(int code) { + String name = ""; + switch (code) { + case 1: + name = BY_FILE.name; + break; + case 2: + name = BY_SQL.name; + break; + case 3: + name = BY_WX_MP.name; + break; + case 4: + name = BY_WX_CP.name; + break; + case 5: + name = BY_DING.name; + break; + case 6: + name = BY_NUM.name; + break; + default: + name = ""; + } + return name; + } + + public static String getName(PeopleImportWayEnum wayEnum) { + return wayEnum.name; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/PeriodTypeEnum.java b/src/main/java/com/fangxuele/tool/push/logic/PeriodTypeEnum.java new file mode 100644 index 000000000..aac242b5d --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/PeriodTypeEnum.java @@ -0,0 +1,46 @@ +package com.fangxuele.tool.push.logic; + +/** + *
+ * 周期类型常量
+ * 
+ * + * @author Zhou Bo + * @since 2023/8/2 + */ +public enum PeriodTypeEnum { + /** + * 周期类型 + */ + RUN_AT_THIS_TIME_TASK(1, "在此时间开始推送"), + RUN_PER_DAY_TASK(2, "每天定时推送"), + RUN_PER_WEEK_TASK(3, "每周定时推送"), + CRON_TASK(4, "Cron表达式定时推送"); + + private int code; + + private String name; + + public static final int RUN_AT_THIS_TIME_TASK_CODE = 1; + public static final int RUN_PER_DAY_TASK_CODE = 2; + public static final int RUN_PER_WEEK_TASK_CODE = 3; + public static final int CRON_TASK_CODE = 4; + + PeriodTypeEnum(int code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(PeriodTypeEnum messageTypeEnum) { + return messageTypeEnum.name; + } + + public static String getDesc(Integer periodType) { + for (PeriodTypeEnum periodTypeEnum : PeriodTypeEnum.values()) { + if (periodTypeEnum.code == periodType) { + return periodTypeEnum.name; + } + } + return null; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/PushControl.java b/src/main/java/com/fangxuele/tool/push/logic/PushControl.java index 063716c01..34e5cd03c 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/PushControl.java +++ b/src/main/java/com/fangxuele/tool/push/logic/PushControl.java @@ -1,45 +1,15 @@ package com.fangxuele.tool.push.logic; -import cn.hutool.core.date.BetweenFormater; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.json.JSONUtil; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TPushHistoryMapper; -import com.fangxuele.tool.push.domain.TPushHistory; -import com.fangxuele.tool.push.logic.msgmaker.MsgMakerFactory; -import com.fangxuele.tool.push.logic.msgmaker.WxMaTemplateMsgMaker; -import com.fangxuele.tool.push.logic.msgmaker.WxMpTemplateMsgMaker; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; import com.fangxuele.tool.push.logic.msgsender.IMsgSender; -import com.fangxuele.tool.push.logic.msgsender.MailMsgSender; import com.fangxuele.tool.push.logic.msgsender.MsgSenderFactory; import com.fangxuele.tool.push.logic.msgsender.SendResult; -import com.fangxuele.tool.push.ui.UiConsts; -import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.ui.dialog.importway.ImportByFile; import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.PushForm; -import com.fangxuele.tool.push.ui.form.PushHisForm; -import com.fangxuele.tool.push.ui.form.ScheduleForm; -import com.fangxuele.tool.push.ui.form.SettingForm; -import com.fangxuele.tool.push.ui.listener.MemberListener; -import com.fangxuele.tool.push.util.ConsoleUtil; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.fangxuele.tool.push.util.SqliteUtil; -import com.fangxuele.tool.push.util.SystemUtil; -import com.opencsv.CSVWriter; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateFormatUtils; -import javax.swing.*; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; import java.util.List; -import java.util.stream.Collectors; /** *
@@ -50,39 +20,23 @@
  * @since 2017/6/19.
  */
 public class PushControl {
-
-    /**
-     * 是否空跑
-     */
-    public static boolean dryRun;
-
-    public volatile static boolean saveResponseBody = false;
-
-    private static TPushHistoryMapper pushHistoryMapper = MybatisUtil.getSqlSession().getMapper(TPushHistoryMapper.class);
+    private static final Log logger = LogFactory.get();
 
     /**
      * 模板变量前缀
      */
     public static final String TEMPLATE_VAR_PREFIX = "var";
 
-    /**
-     * 预览消息
-     */
-    public static List preview() {
+    public static List preview(Integer tMsgId) {
         List sendResultList = new ArrayList<>();
-        if (!configCheck()) {
-            return null;
-        }
         List msgDataList = new ArrayList<>();
         for (String data : MessageEditForm.getInstance().getPreviewUserField().getText().split(";")) {
-            msgDataList.add(data.split(MemberListener.TXT_FILE_DATA_SEPERATOR_REGEX));
+            msgDataList.add(data.split(ImportByFile.TXT_FILE_DATA_SEPERATOR_REGEX));
         }
 
         // 准备消息构造器
-        prepareMsgMaker();
-        IMsgSender msgSender = MsgSenderFactory.getMsgSender();
+        IMsgSender msgSender = MsgSenderFactory.getMsgSender(tMsgId, 0);
 
-        dryRun = false;
         if (msgSender != null) {
             for (String[] msgData : msgDataList) {
                 sendResultList.add(msgSender.send(msgData));
@@ -93,376 +47,4 @@ public static List preview() {
 
         return sendResultList;
     }
-
-    /**
-     * 推送前检查
-     *
-     * @return boolean
-     */
-    public static boolean pushCheck() {
-        MainWindow mainWindow = MainWindow.getInstance();
-        PushForm pushForm = PushForm.getInstance();
-
-        if (StringUtils.isEmpty(MessageEditForm.getInstance().getMsgNameField().getText())) {
-            JOptionPane.showMessageDialog(mainWindow.getMainPanel(), "请先选择一条消息!", "提示",
-                    JOptionPane.INFORMATION_MESSAGE);
-            mainWindow.getTabbedPane().setSelectedIndex(2);
-
-            return false;
-        }
-        if (PushData.allUser == null || PushData.allUser.size() == 0) {
-            int msgType = App.config.getMsgType();
-            String tipsTitle = "请先准备目标用户!";
-            if (msgType == MessageTypeEnum.HTTP_CODE) {
-                tipsTitle = "请先准备消息变量!";
-            }
-            JOptionPane.showMessageDialog(mainWindow.getMainPanel(), tipsTitle, "提示",
-                    JOptionPane.INFORMATION_MESSAGE);
-
-            return false;
-        }
-        if (!PushData.boostMode) {
-            if ("0".equals(pushForm.getMaxThreadPoolTextField().getText()) || StringUtils.isEmpty(pushForm.getMaxThreadPoolTextField().getText())) {
-                JOptionPane.showMessageDialog(pushForm.getPushPanel(), "请设置每页分配用户数!", "提示",
-                        JOptionPane.INFORMATION_MESSAGE);
-
-                return false;
-            }
-            if ("0".equals(pushForm.getThreadCountTextField().getText()) || StringUtils.isEmpty(pushForm.getThreadCountTextField().getText())) {
-                JOptionPane.showMessageDialog(pushForm.getPushPanel(), "请设置每个线程分配的页数!", "提示",
-                        JOptionPane.INFORMATION_MESSAGE);
-
-                return false;
-            }
-        }
-
-        return configCheck();
-    }
-
-    /**
-     * 配置检查
-     *
-     * @return
-     */
-    public static boolean configCheck() {
-        SettingForm settingForm = SettingForm.getInstance();
-
-        int msgType = App.config.getMsgType();
-        switch (msgType) {
-            case MessageTypeEnum.MP_TEMPLATE_CODE:
-            case MessageTypeEnum.KEFU_CODE:
-            case MessageTypeEnum.KEFU_PRIORITY_CODE:
-            case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE: {
-                if (App.config.isMpUseOutSideAt()) {
-                    if (App.config.isMpManualAt() &&
-                            (StringUtils.isEmpty(App.config.getMpAt()) || StringUtils.isEmpty(App.config.getMpAtExpiresIn()))) {
-                        JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存手动输入的外部accessToken信息!", "提示",
-                                JOptionPane.INFORMATION_MESSAGE);
-                        return false;
-                    }
-                    if (App.config.isMpApiAt() && StringUtils.isEmpty(App.config.getMpAtApiUrl())) {
-                        JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存用于获取外部accessToken的URL!", "提示",
-                                JOptionPane.INFORMATION_MESSAGE);
-                        return false;
-                    }
-                    return true;
-                }
-                if (StringUtils.isEmpty(App.config.getWechatAppId()) || StringUtils.isEmpty(App.config.getWechatAppSecret())) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存公众号相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            }
-            case MessageTypeEnum.MA_TEMPLATE_CODE:
-            case MessageTypeEnum.MA_SUBSCRIBE_CODE:
-                if (StringUtils.isEmpty(App.config.getMiniAppAppId()) || StringUtils.isEmpty(App.config.getMiniAppAppSecret())) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存小程序相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.ALI_YUN_CODE:
-                String aliyunAccessKeyId = App.config.getAliyunAccessKeyId();
-                String aliyunAccessKeySecret = App.config.getAliyunAccessKeySecret();
-
-                if (StringUtils.isEmpty(aliyunAccessKeyId) || StringUtils.isEmpty(aliyunAccessKeySecret)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存阿里云短信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.TX_YUN_CODE:
-                String txyunAppId = App.config.getTxyunAppId();
-                String txyunAppKey = App.config.getTxyunAppKey();
-
-                if (StringUtils.isEmpty(txyunAppId) || StringUtils.isEmpty(txyunAppKey)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存腾讯云短信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.QI_NIU_YUN_CODE:
-                String qiniuAccessKey = App.config.getQiniuAccessKey();
-                String qiniuSecretKey = App.config.getQiniuSecretKey();
-
-                if (StringUtils.isEmpty(qiniuAccessKey) || StringUtils.isEmpty(qiniuSecretKey)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存七牛云短信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.UP_YUN_CODE:
-                String upAuthorizationToken = App.config.getUpAuthorizationToken();
-
-                if (StringUtils.isEmpty(upAuthorizationToken)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存又拍云短信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.BD_YUN_CODE:
-                String bdAccessKeyId = App.config.getBdAccessKeyId();
-                String bdSecretAccessKey = App.config.getBdSecretAccessKey();
-
-                if (StringUtils.isEmpty(bdAccessKeyId) || StringUtils.isEmpty(bdSecretAccessKey)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存百度云短信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.HW_YUN_CODE:
-                String hwAppKey = App.config.getHwAppKey();
-                String hwAppSecretPassword = App.config.getHwAppSecretPassword();
-
-                if (StringUtils.isEmpty(hwAppKey) || StringUtils.isEmpty(hwAppSecretPassword)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存华为云短信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.YUN_PIAN_CODE:
-                String yunpianApiKey = App.config.getYunpianApiKey();
-                if (StringUtils.isEmpty(yunpianApiKey)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存云片网短信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.EMAIL_CODE:
-                String mailHost = App.config.getMailHost();
-                String mailFrom = App.config.getMailFrom();
-                if (StringUtils.isBlank(mailHost) || StringUtils.isBlank(mailFrom)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存E-Mail相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            case MessageTypeEnum.WX_CP_CODE:
-                String wxCpCorpId = App.config.getWxCpCorpId();
-                if (StringUtils.isBlank(wxCpCorpId)) {
-                    JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
-                            "请先在设置中填写并保存微信企业号/企业微信相关配置!", "提示",
-                            JOptionPane.INFORMATION_MESSAGE);
-                    return false;
-                }
-                break;
-            default:
-        }
-        return true;
-    }
-
-    /**
-     * 推送停止或结束后保存数据
-     */
-    static void savePushData() throws IOException {
-        MessageEditForm messageEditForm = MessageEditForm.getInstance();
-        File pushHisDir = new File(SystemUtil.configHome + "data" + File.separator + "push_his");
-        if (!pushHisDir.exists()) {
-            pushHisDir.mkdirs();
-        }
-
-        String msgName = messageEditForm.getMsgNameField().getText();
-        String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_");
-        CSVWriter writer;
-        int msgType = App.config.getMsgType();
-
-        List fileList = new ArrayList<>();
-        // 保存已发送
-        if (PushData.sendSuccessList.size() > 0) {
-            File sendSuccessFile = new File(SystemUtil.configHome + "data" +
-                    File.separator + "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + msgName +
-                    "-发送成功-" + nowTime + ".csv");
-            FileUtil.touch(sendSuccessFile);
-            writer = new CSVWriter(new FileWriter(sendSuccessFile));
-
-            for (String[] str : PushData.sendSuccessList) {
-                writer.writeNext(str);
-            }
-            writer.close();
-
-            savePushResult(msgName, "发送成功", sendSuccessFile);
-            fileList.add(sendSuccessFile);
-            // 保存累计推送总数
-            App.config.setPushTotal(App.config.getPushTotal() + PushData.sendSuccessList.size());
-            App.config.save();
-        }
-
-        // 保存未发送
-        for (String[] str : PushData.sendSuccessList) {
-            if (msgType == MessageTypeEnum.HTTP_CODE && PushControl.saveResponseBody) {
-                str = ArrayUtils.remove(str, str.length - 1);
-                String[] finalStr = str;
-                PushData.toSendList = PushData.toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList());
-            } else {
-                PushData.toSendList.remove(str);
-            }
-        }
-        for (String[] str : PushData.sendFailList) {
-            if (msgType == MessageTypeEnum.HTTP_CODE && PushControl.saveResponseBody) {
-                str = ArrayUtils.remove(str, str.length - 1);
-                String[] finalStr = str;
-                PushData.toSendList = PushData.toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList());
-            } else {
-                PushData.toSendList.remove(str);
-            }
-        }
-
-        if (PushData.toSendList.size() > 0) {
-            File unSendFile = new File(SystemUtil.configHome + "data" + File.separator +
-                    "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + msgName + "-未发送-" + nowTime +
-                    ".csv");
-            FileUtil.touch(unSendFile);
-            writer = new CSVWriter(new FileWriter(unSendFile));
-            for (String[] str : PushData.toSendList) {
-                writer.writeNext(str);
-            }
-            writer.close();
-
-            savePushResult(msgName, "未发送", unSendFile);
-            fileList.add(unSendFile);
-        }
-
-        // 保存发送失败
-        if (PushData.sendFailList.size() > 0) {
-            File failSendFile = new File(SystemUtil.configHome + "data" + File.separator +
-                    "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + msgName + "-发送失败-" + nowTime + ".csv");
-            FileUtil.touch(failSendFile);
-            writer = new CSVWriter(new FileWriter(failSendFile));
-            for (String[] str : PushData.sendFailList) {
-                writer.writeNext(str);
-            }
-            writer.close();
-
-            savePushResult(msgName, "发送失败", failSendFile);
-            fileList.add(failSendFile);
-        }
-
-        PushHisForm.init();
-
-        // 发送推送结果邮件
-        if ((PushData.scheduling || PushData.fixRateScheduling)
-                && ScheduleForm.getInstance().getSendPushResultCheckBox().isSelected()) {
-            ConsoleUtil.consoleWithLog("发送推送结果邮件开始");
-            String mailResultTo = ScheduleForm.getInstance().getMailResultToTextField().getText().replace(";", ";").replace(" ", "");
-            String[] mailTos = mailResultTo.split(";");
-            ArrayList mailToList = new ArrayList<>(Arrays.asList(mailTos));
-
-            MailMsgSender mailMsgSender = new MailMsgSender();
-            String title = "WePush推送结果:【" + messageEditForm.getMsgNameField().getText()
-                    + "】" + PushData.sendSuccessList.size() + "成功;" + PushData.sendFailList.size() + "失败;"
-                    + PushData.toSendList.size() + "未发送";
-            StringBuilder contentBuilder = new StringBuilder();
-            contentBuilder.append("

WePush推送结果

"); - contentBuilder.append("

消息类型:" + MessageTypeEnum.getName(App.config.getMsgType()) + "

"); - contentBuilder.append("

消息名称:" + messageEditForm.getMsgNameField().getText() + "

"); - contentBuilder.append("
"); - - contentBuilder.append("

成功数:" + PushData.sendSuccessList.size() + "

"); - contentBuilder.append("

失败数:" + PushData.sendFailList.size() + "

"); - contentBuilder.append("

未推送数:" + PushData.toSendList.size() + "

"); - contentBuilder.append("
"); - - contentBuilder.append("

开始时间:" + DateFormatUtils.format(new Date(PushData.startTime), "yyyy-MM-dd HH:mm:ss") + "

"); - contentBuilder.append("

完毕时间:" + DateFormatUtils.format(new Date(PushData.endTime), "yyyy-MM-dd HH:mm:ss") + "

"); - contentBuilder.append("

总耗时:" + DateUtil.formatBetween(PushData.endTime - PushData.startTime, BetweenFormater.Level.SECOND) + "

"); - contentBuilder.append("
"); - - contentBuilder.append("

详情请查看附件

"); - - contentBuilder.append("
"); - contentBuilder.append("
"); - contentBuilder.append("

来自WePush,一款专注于批量推送的小而美的工具

"); - contentBuilder.append("\"WePush\""); - - File[] files = new File[fileList.size()]; - fileList.toArray(files); - mailMsgSender.sendPushResultMail(mailToList, title, contentBuilder.toString(), files); - ConsoleUtil.consoleWithLog("发送推送结果邮件结束"); - } - } - - /** - * 保存结果到DB - * - * @param msgName - * @param resultInfo - * @param file - */ - private static void savePushResult(String msgName, String resultInfo, File file) { - TPushHistory tPushHistory = new TPushHistory(); - String now = SqliteUtil.nowDateForSqlite(); - tPushHistory.setMsgType(App.config.getMsgType()); - tPushHistory.setMsgName(msgName); - tPushHistory.setResult(resultInfo); - tPushHistory.setCsvFile(file.getAbsolutePath()); - tPushHistory.setCreateTime(now); - tPushHistory.setModifiedTime(now); - - pushHistoryMapper.insertSelective(tPushHistory); - } - - /** - * 准备消息构造器 - */ - static void prepareMsgMaker() { - if (App.config.getMsgType() == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE) { - new WxMpTemplateMsgMaker().prepare(); - new WxMaTemplateMsgMaker().prepare(); - } else { - MsgMakerFactory.getMsgMaker().prepare(); - } - } - - /** - * 重新导入目标用户(定时任务) - */ - public static void reimportMembers() { - if (PushData.fixRateScheduling && ScheduleForm.getInstance().getReimportCheckBox().isSelected()) { - switch ((String) ScheduleForm.getInstance().getReimportComboBox().getSelectedItem()) { - case "通过SQL导入": - MemberListener.importFromSql(); - break; - case "通过文件导入": - MemberListener.importFromFile(); - break; - case "导入所有关注公众号的用户": - MemberListener.importWxAll(); - break; - case "导入企业通讯录中所有用户": - MemberListener.importWxCpAll(); - break; - default: - } - } - } - } \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/logic/PushData.java b/src/main/java/com/fangxuele/tool/push/logic/PushData.java deleted file mode 100644 index 9838924fb..000000000 --- a/src/main/java/com/fangxuele/tool/push/logic/PushData.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.fangxuele.tool.push.logic; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.LongAdder; - -/** - *
- * 推送数据 报表相关等使用
- * 
- * - * @author RememBerBer - * @since 2017/6/19. - */ -public class PushData { - - /** - * 导入的用户 - */ - public static List allUser = Collections.synchronizedList(new ArrayList<>()); - - /** - * 总记录数 - */ - static long totalRecords; - - /** - * (异步发送)已处理数 - */ - public static LongAdder processedRecords = new LongAdder(); - - /** - * 发送成功数 - */ - public static LongAdder successRecords = new LongAdder(); - - /** - * 发送失败数 - */ - public static LongAdder failRecords = new LongAdder(); - - /** - * 准备发送的列表 - */ - public static List toSendList; - - /** - * 准备发送的数量 - */ - public static final AtomicInteger TO_SEND_COUNT = new AtomicInteger(); - - /** - * 发送成功的列表 - */ - public static List sendSuccessList; - - /** - * 发送失败的列表 - */ - public static List sendFailList; - - /** - * 停止标志 - */ - public volatile static boolean running = false; - - /** - * 计划任务执行中标志 - */ - public static boolean scheduling = false; - - /** - * 固定频率计划任务执行中 - */ - public static boolean fixRateScheduling = false; - - /** - * 线程总数 - */ - static int threadCount; - - /** - * 已经停止了的线程总数 - */ - static LongAdder stoppedThreadCount = new LongAdder(); - - /** - * 已处理数+1 - */ - public static void increaseProcessed() { - processedRecords.add(1); - } - - /** - * 成功数+1 - */ - public static void increaseSuccess() { - successRecords.add(1); - } - - /** - * 失败数+1 - */ - public static void increaseFail() { - failRecords.add(1); - } - - /** - * 停止线程数+1 - */ - public static void increaseStoppedThread() { - stoppedThreadCount.add(1); - } - - /** - * 开始时间 - */ - public static long startTime = 0; - - /** - * 结束时间 - */ - public static long endTime = 0; - - /** - * 是否为性能模式 - */ - public static boolean boostMode = false; - - /** - * 重置推送数据 - */ - static void reset() { - running = true; - processedRecords.reset(); - successRecords.reset(); - failRecords.reset(); - stoppedThreadCount.reset(); - threadCount = 0; - toSendList = Collections.synchronizedList(new LinkedList<>()); - sendSuccessList = Collections.synchronizedList(new LinkedList<>()); - sendFailList = Collections.synchronizedList(new LinkedList<>()); - startTime = 0; - endTime = 0; - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/logic/PushRunThread.java b/src/main/java/com/fangxuele/tool/push/logic/PushRunThread.java deleted file mode 100644 index b3ab51570..000000000 --- a/src/main/java/com/fangxuele/tool/push/logic/PushRunThread.java +++ /dev/null @@ -1,248 +0,0 @@ -package com.fangxuele.tool.push.logic; - -import cn.hutool.core.date.BetweenFormater; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.cron.pattern.CronPattern; -import cn.hutool.cron.pattern.CronPatternUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.msgsender.IMsgSender; -import com.fangxuele.tool.push.logic.msgsender.MsgSenderFactory; -import com.fangxuele.tool.push.logic.msgthread.BaseMsgThread; -import com.fangxuele.tool.push.logic.msgthread.MsgSendThread; -import com.fangxuele.tool.push.ui.component.TableInCellProgressBarRenderer; -import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.PushForm; -import com.fangxuele.tool.push.util.ConsoleUtil; -import org.apache.commons.lang3.time.DateFormatUtils; - -import javax.swing.*; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.io.IOException; -import java.util.Date; -import java.util.concurrent.ThreadPoolExecutor; - -/** - *
- * 推送执行控制线程
- * 
- * - * @author RememBerBer - * @since 2017/6/28. - */ -public class PushRunThread extends Thread { - - private static final Log logger = LogFactory.get(); - - @Override - public void run() { - PushForm pushForm = PushForm.getInstance(); - pushForm.getPushTotalProgressBar().setIndeterminate(true); - // 准备推送 - preparePushRun(); - pushForm.getPushTotalProgressBar().setIndeterminate(false); - ConsoleUtil.consoleWithLog("推送开始……"); - // 消息数据分片以及线程纷发 - shardingAndMsgThread(); - // 时间监控 - timeMonitor(); - } - - /** - * 准备推送 - */ - private void preparePushRun() { - PushForm pushForm = PushForm.getInstance(); - // 按钮状态 - pushForm.getScheduleRunButton().setEnabled(false); - pushForm.getPushStartButton().setEnabled(false); - pushForm.getPushStopButton().setEnabled(true); - - pushForm.getPushStopButton().setText("停止"); - // 初始化 - pushForm.getPushSuccessCount().setText("0"); - pushForm.getPushFailCount().setText("0"); - - // 设置是否空跑 - PushControl.dryRun = pushForm.getDryRunCheckBox().isSelected(); - - PushControl.saveResponseBody = pushForm.getSaveResponseBodyCheckBox().isSelected(); - - // 执行前重新导入目标用户 - PushControl.reimportMembers(); - - // 重置推送数据 - PushData.reset(); - PushData.startTime = System.currentTimeMillis(); - - // 拷贝准备的目标用户 - PushData.toSendList.addAll(PushData.allUser); - // 总记录数 - PushData.totalRecords = PushData.toSendList.size(); - - pushForm.getPushTotalCountLabel().setText("消息总数:" + PushData.totalRecords); - pushForm.getPushTotalProgressBar().setMaximum((int) PushData.totalRecords); - ConsoleUtil.consoleWithLog("消息总数:" + PushData.totalRecords); - // 可用处理器核心数量 - pushForm.getAvailableProcessorLabel().setText("可用处理器核心:" + Runtime.getRuntime().availableProcessors()); - ConsoleUtil.consoleWithLog("可用处理器核心:" + Runtime.getRuntime().availableProcessors()); - - // 线程数 - App.config.setThreadCount(Integer.parseInt(pushForm.getThreadCountTextField().getText())); - App.config.save(); - ConsoleUtil.consoleWithLog("线程数:" + pushForm.getThreadCountTextField().getText()); - - // 线程池大小 - App.config.setMaxThreadPool(Integer.parseInt(pushForm.getMaxThreadPoolTextField().getText())); - App.config.save(); - ConsoleUtil.consoleWithLog("线程池大小:" + pushForm.getMaxThreadPoolTextField().getText()); - - // 准备消息构造器 - PushControl.prepareMsgMaker(); - - // 线程数 - PushData.threadCount = Integer.parseInt(pushForm.getThreadCountTextField().getText()); - - // 初始化线程table - String[] headerNames = {"线程", "分片区间", "成功", "失败", "总数", "当前进度"}; - DefaultTableModel tableModel = new DefaultTableModel(null, headerNames); - pushForm.getPushThreadTable().setModel(tableModel); - pushForm.getPushThreadTable().getColumn("当前进度").setCellRenderer(new TableInCellProgressBarRenderer()); - - DefaultTableCellRenderer hr = (DefaultTableCellRenderer) pushForm.getPushThreadTable().getTableHeader() - .getDefaultRenderer(); - // 表头列名居左 - hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); - pushForm.getPushThreadTable().updateUI(); - } - - /** - * 消息数据分片以及线程纷发 - */ - private static void shardingAndMsgThread() { - PushForm pushForm = PushForm.getInstance(); - Object[] data; - - int maxThreadPoolSize = App.config.getMaxThreadPool(); - ThreadPoolExecutor threadPoolExecutor = ThreadUtil.newExecutor(maxThreadPoolSize, maxThreadPoolSize); - MsgSendThread msgSendThread; - // 每个线程分配 - int perThread = (int) (PushData.totalRecords / PushData.threadCount) + 1; - DefaultTableModel tableModel = (DefaultTableModel) pushForm.getPushThreadTable().getModel(); - BaseMsgThread.msgType = App.config.getMsgType(); - for (int i = 0; i < PushData.threadCount; i++) { - int startIndex = i * perThread; - if (startIndex > PushData.totalRecords - 1) { - PushData.threadCount = i; - break; - } - int endIndex = i * perThread + perThread; - if (endIndex > PushData.totalRecords - 1) { - endIndex = (int) (PushData.totalRecords); - } - - IMsgSender msgSender = MsgSenderFactory.getMsgSender(); - msgSendThread = new MsgSendThread(startIndex, endIndex, msgSender); - - msgSendThread.setTableRow(i); - msgSendThread.setName("T-" + i); - - data = new Object[6]; - data[0] = msgSendThread.getName(); - data[1] = startIndex + "-" + endIndex; - data[5] = 0; - tableModel.addRow(data); - - threadPoolExecutor.execute(msgSendThread); - } - ConsoleUtil.consoleWithLog("所有线程宝宝启动完毕……"); - } - - /** - * 时间监控 - */ - private void timeMonitor() { - PushForm pushForm = PushForm.getInstance(); - long startTimeMillis = System.currentTimeMillis(); - // 计时 - while (true) { - if (PushData.stoppedThreadCount.intValue() == PushData.threadCount) { - if (!PushData.fixRateScheduling) { - pushForm.getPushStopButton().setEnabled(false); - pushForm.getPushStopButton().updateUI(); - pushForm.getPushStartButton().setEnabled(true); - pushForm.getPushStartButton().updateUI(); - pushForm.getScheduleRunButton().setEnabled(true); - pushForm.getScheduleRunButton().updateUI(); - pushForm.getScheduleDetailLabel().setText(""); - - if (App.trayIcon != null) { - MessageEditForm messageEditForm = MessageEditForm.getInstance(); - String msgName = messageEditForm.getMsgNameField().getText(); - App.trayIcon.displayMessage("WePush", msgName + " 发送完毕!", TrayIcon.MessageType.INFO); - } - - String finishTip = "发送完毕!\n"; - JOptionPane.showMessageDialog(pushForm.getPushPanel(), finishTip, "提示", - JOptionPane.INFORMATION_MESSAGE); - pushForm.getScheduleDetailLabel().setVisible(false); - } else { - if (App.config.isRadioCron()) { - Date nextDate = CronPatternUtil.nextDateAfter(new CronPattern(App.config.getTextCron()), new Date(), true); - pushForm.getScheduleDetailLabel().setText("计划任务执行中,下一次执行时间:" + DateFormatUtils.format(nextDate, "yyyy-MM-dd HH:mm:ss")); - } - pushForm.getPushStopButton().setText("停止计划任务"); - } - - PushData.endTime = System.currentTimeMillis(); - - // 保存停止前的数据 - try { - // 空跑控制 - if (!pushForm.getDryRunCheckBox().isSelected()) { - ConsoleUtil.consoleWithLog("正在保存结果数据……"); - pushForm.getPushTotalProgressBar().setIndeterminate(true); - PushControl.savePushData(); - ConsoleUtil.consoleWithLog("结果数据保存完毕!"); - } - } catch (IOException e) { - logger.error(e); - } finally { - pushForm.getPushTotalProgressBar().setIndeterminate(false); - } - break; - } - - int successCount = PushData.sendSuccessList.size(); - int failCount = PushData.sendFailList.size(); - int totalSentCount = successCount + failCount; - long currentTimeMillis = System.currentTimeMillis(); - long lastTimeMillis = currentTimeMillis - startTimeMillis; - long leftTimeMillis = (long) ((double) lastTimeMillis / (totalSentCount) * (PushData.allUser.size() - totalSentCount)); - - // 耗时 - String formatBetweenLast = DateUtil.formatBetween(lastTimeMillis, BetweenFormater.Level.SECOND); - pushForm.getPushLastTimeLabel().setText("".equals(formatBetweenLast) ? "0s" : formatBetweenLast); - - // 预计剩余 - String formatBetweenLeft = DateUtil.formatBetween(leftTimeMillis, BetweenFormater.Level.SECOND); - pushForm.getPushLeftTimeLabel().setText("".equals(formatBetweenLeft) ? "0s" : formatBetweenLeft); - - pushForm.getJvmMemoryLabel().setText("JVM内存占用:" + FileUtil.readableFileSize(Runtime.getRuntime().totalMemory()) + "/" + FileUtil.readableFileSize(Runtime.getRuntime().maxMemory())); - - // TPS - if (lastTimeMillis == 0) { - lastTimeMillis = 1; - } - int tps = (int) (totalSentCount * 1000 / lastTimeMillis); - pushForm.getTpsLabel().setText(String.valueOf(tps)); - ThreadUtil.safeSleep(100); - } - } - -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/logic/TaskModeEnum.java b/src/main/java/com/fangxuele/tool/push/logic/TaskModeEnum.java new file mode 100644 index 000000000..d949f5a4a --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/TaskModeEnum.java @@ -0,0 +1,42 @@ +package com.fangxuele.tool.push.logic; + +/** + *
+ * 任务模式常量
+ * 
+ * + * @author Zhou Bo + * @since 2023/8/2 + */ +public enum TaskModeEnum { + /** + * 任务模式 + */ + FIX_THREAD_TASK(1, "固定线程"), + INFINITY_TASK(2, "变速模式"); + + private int code; + + private String name; + + public static final int FIX_THREAD_TASK_CODE = 1; + public static final int INFINITY_TASK_CODE = 2; + + TaskModeEnum(int code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(TaskModeEnum messageTypeEnum) { + return messageTypeEnum.name; + } + + public static String getDescByCode(Integer code) { + for (TaskModeEnum taskModeEnum : TaskModeEnum.values()) { + if (taskModeEnum.code == code) { + return taskModeEnum.name; + } + } + return null; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/TaskRunThread.java b/src/main/java/com/fangxuele/tool/push/logic/TaskRunThread.java new file mode 100644 index 000000000..215f504ca --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/TaskRunThread.java @@ -0,0 +1,575 @@ +package com.fangxuele.tool.push.logic; + +import cn.hutool.core.date.BetweenFormatter; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.domain.*; +import com.fangxuele.tool.push.logic.msgsender.IMsgSender; +import com.fangxuele.tool.push.logic.msgsender.MailMsgSender; +import com.fangxuele.tool.push.logic.msgsender.MsgSenderFactory; +import com.fangxuele.tool.push.logic.msgthread.MsgSendThread; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.dialog.importway.*; +import com.fangxuele.tool.push.ui.form.TaskForm; +import com.fangxuele.tool.push.util.ConsoleUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.opencsv.CSVWriter; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.time.DateFormatUtils; + +import java.awt.*; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.LongAdder; +import java.util.stream.Collectors; + +/** + *
+ * 推送执行控制线程
+ * 
+ * + * @author RememBerBer + * @since 2023/8/03 + */ +@Getter +@Setter +public class TaskRunThread extends Thread { + + private static final Log logger = LogFactory.get(); + + private Integer taskId; + + private Integer dryRun; + + /** + * 发送成功数 + */ + public LongAdder successRecords = new LongAdder(); + + /** + * 发送失败数 + */ + public LongAdder failRecords = new LongAdder(); + + /** + * 处理完毕的线程数 + */ + public AtomicInteger finishedThreadCount = new AtomicInteger(0); + + /** + * 停止标志 + */ + public volatile boolean running = false; + + private Long startTime; + + /** + * 结束时间 + */ + public static long endTime = 0; + + private List toSendList; + + /** + * 总记录数 + */ + static long totalRecords; + + /** + * 线程总数 + */ + public int threadCount; + + /** + * 固定频率计划任务执行中 + */ + public boolean fixRateScheduling = false; + + /** + * 发送成功的列表 + */ + public List sendSuccessList; + + /** + * 发送失败的列表 + */ + public List sendFailList; + + private TTask tTask; + + public Integer getTaskId() { + return taskId; + } + + public void setTaskId(Integer taskId) { + this.taskId = taskId; + } + + public Integer getDryRun() { + return dryRun; + } + + public void setDryRun(Integer dryRun) { + this.dryRun = dryRun; + } + + private static TTaskMapper taskMapper = MybatisUtil.getSqlSession().getMapper(TTaskMapper.class); + private static TTaskHisMapper taskHisMapper = MybatisUtil.getSqlSession().getMapper(TTaskHisMapper.class); + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + private TTaskHis taskHis; + + private TMsg tMsg; + + private String logFilePath; + + private BufferedWriter logWriter; + + public static Map taskRunThreadMap = new ConcurrentHashMap<>(); + + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + public TaskRunThread(Integer taskId, Integer dryRun) { + this.taskId = taskId; + this.dryRun = dryRun; + } + + @Override + public void run() { + // 准备推送 + this.tTask = taskMapper.selectByPrimaryKey(taskId); + + try { + String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_"); + + logFilePath = SystemUtil.CONFIG_HOME + "data" + File.separator + + "push_log" + File.separator + tTask.getTitle() + "_" + nowTime + + ".log"; + FileUtil.touch(logFilePath); + logWriter = new BufferedWriter(new FileWriter(logFilePath)); + } catch (IOException e) { + logger.error(e); + } + + preparePushRun(); + + running = true; + + taskHis.setStatus(TaskStatusEnum.RUNNING_CODE); + taskHisMapper.updateByPrimaryKey(taskHis); + + ConsoleUtil.pushLog(logWriter, "推送开始……"); + // 消息数据分片以及线程纷发 + tMsg = msgMapper.selectByPrimaryKey(tTask.getMessageId()); + shardingAndMsgThread(tMsg); + + taskRunThreadMap.put(taskHis.getId(), this); + // 时间监控 + timeMonitor(); + + resetLocalData(); + + taskRunThreadMap.remove(taskHis.getId()); + } + + /** + * 准备推送 + */ + private void preparePushRun() { + + // 初始化任务历史表 + taskHis = new TTaskHis(); + + taskHis.setTaskId(tTask.getId()); + + // 设置是否空跑 + taskHis.setDryRun(dryRun); + + taskHis.setTaskMode(tTask.getTaskMode()); + + taskHis.setLogFilePath(logFilePath); + + if (tTask.getTaskPeriod() == TaskTypeEnum.SCHEDULE_TASK_CODE && tTask.getReimportPeople() == 1) { + // 获取上一次导入方式 + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(tTask.getPeopleId()); + String lastWay = tPeopleImportConfig.getLastWay(); + switch (Integer.valueOf(lastWay)) { + case PeopleImportWayEnum.BY_FILE_CODE: + ImportByFile importByFile = new ImportByFile(tTask.getPeopleId()); + importByFile.reImport(); + break; + case PeopleImportWayEnum.BY_SQL_CODE: + ImportBySQL importBySQL = new ImportBySQL(tTask.getPeopleId()); + importBySQL.reImport(); + break; + case PeopleImportWayEnum.BY_NUM_CODE: + ImportByNum importByNum = new ImportByNum(tTask.getPeopleId()); + importByNum.reImport(); + break; + case PeopleImportWayEnum.BY_WX_MP_CODE: + ImportByWxMp importByWxMp = new ImportByWxMp(tTask.getPeopleId()); + importByWxMp.reImport(); + break; + case PeopleImportWayEnum.BY_WX_CP_CODE: + ImportByWxCp importByWxCp = new ImportByWxCp(tTask.getPeopleId()); + importByWxCp.reImport(); + break; + case PeopleImportWayEnum.BY_DING_CODE: + ImportByDing importByDing = new ImportByDing(tTask.getPeopleId()); + importByDing.reImport(); + break; + default: + break; + } + } + + // 重置推送数据 + resetLocalData(); + + startTime = System.currentTimeMillis(); + + // 拷贝准备的目标用户 + List tPeopleData = peopleDataMapper.selectByPeopleId(tTask.getPeopleId()); + + tPeopleData.forEach(peopleData -> { + String varData = peopleData.getVarData(); + String[] strings = JSON.parseObject(varData, new TypeReference() { + }); + toSendList.add(strings); + }); + // 总记录数 + totalRecords = toSendList.size(); + + taskHis.setTotalCnt((int) totalRecords); + ConsoleUtil.pushLog(logWriter, "消息总数:" + totalRecords); + ConsoleUtil.pushLog(logWriter, "可用处理器核心:" + Runtime.getRuntime().availableProcessors()); + + // 线程数 + ConsoleUtil.pushLog(logWriter, "线程数:" + tTask.getThreadCnt()); + ConsoleUtil.pushLog(logWriter, "线程池大小:" + tTask.getThreadCnt()); + + // 线程数 + threadCount = tTask.getThreadCnt(); + + taskHis.setStatus(TaskStatusEnum.INIT_CODE); + + String nowDateForSqlite = SqliteUtil.nowDateForSqlite(); + taskHis.setStartTime(nowDateForSqlite); + taskHis.setCreateTime(nowDateForSqlite); + taskHis.setModifiedTime(nowDateForSqlite); + + taskHisMapper.insert(taskHis); + + TaskForm taskForm = TaskForm.getInstance(); + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow > -1) { + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + if (selectedTaskId.equals(taskId)) { + TaskForm.initTaskHisListTable(taskId); + } + } + } + + /** + * 消息数据分片以及线程纷发 + */ + private void shardingAndMsgThread(TMsg tMsg) { + MsgSendThread msgSendThread; + // 每个线程分配 + int perThread = (int) (totalRecords / threadCount) + 1; + for (int i = 0; i < threadCount; i++) { + int startIndex = i * perThread; + if (startIndex > totalRecords - 1) { + threadCount = i; + break; + } + int endIndex = i * perThread + perThread; + if (endIndex > totalRecords - 1) { + endIndex = (int) (totalRecords); + } + + IMsgSender msgSender = MsgSenderFactory.getMsgSender(tMsg.getId(), dryRun); + msgSendThread = new MsgSendThread(startIndex, endIndex, msgSender, this); + + Thread.ofVirtual().name("T-" + i).start(msgSendThread); + } + ConsoleUtil.pushLog(logWriter, "所有线程宝宝启动完毕……"); + } + + /** + * 时间监控 + */ + private void timeMonitor() { + // 计时 + while (true) { + if (finishedThreadCount.get() == threadCount) { + taskHis.setEndTime(SqliteUtil.nowDateForSqlite()); + + int successCount = sendSuccessList.size(); + int failCount = sendFailList.size(); + taskHis.setSuccessCnt(successCount); + taskHis.setFailCnt(failCount); + taskHis.setStatus(TaskStatusEnum.FINISH_CODE); + + taskHisMapper.updateByPrimaryKey(taskHis); + + TaskForm taskForm = TaskForm.getInstance(); + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow > -1) { + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + if (selectedTaskId.equals(taskId)) { + // 遍历TaskListTable找到taskHisId对应的行号 + int taskHisId = taskHis.getId(); + int taskHisListTableRows = taskForm.getTaskHisListTable().getRowCount(); + int taskHisListTableRow = -1; + for (int i = 0; i < taskHisListTableRows; i++) { + int taskHisIdInTable = (int) taskForm.getTaskHisListTable().getValueAt(i, 0); + if (taskHisId == taskHisIdInTable) { + taskHisListTableRow = i; + break; + } + } + if (taskHisListTableRow != -1) { + taskForm.getTaskHisListTable().setValueAt(TaskStatusEnum.getDescByCode(taskHis.getStatus()), taskHisListTableRow, 7); + taskForm.getTaskHisListTable().setValueAt(taskHis.getSuccessCnt(), taskHisListTableRow, 5); + taskForm.getTaskHisListTable().setValueAt(taskHis.getFailCnt(), taskHisListTableRow, 6); + taskForm.getTaskHisListTable().setValueAt(taskHis.getEndTime(), taskHisListTableRow, 3); + } + } + } + + if (App.trayIcon != null && SystemUtil.isWindowsOs()) { + App.trayIcon.displayMessage("WePush", tTask.getTitle() + " 发送完毕!", TrayIcon.MessageType.INFO); + } + + // 保存停止前的数据 + try { + // 空跑控制 + if (dryRun == 0) { + ConsoleUtil.pushLog(logWriter, "正在保存结果数据……"); + savePushData(); + ConsoleUtil.pushLog(logWriter, "结果数据保存完毕!"); + } + } catch (IOException e) { + logger.error(e); + } + + // 关闭logWriter + if (logWriter != null) { + try { + logWriter.flush(); + logWriter.close(); + } catch (IOException e) { + logger.error(e); + } + } + + running = false; + break; + } + + taskHis.setSuccessCnt(successRecords.intValue()); + taskHis.setFailCnt(failRecords.intValue()); + + TaskForm taskForm = TaskForm.getInstance(); + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow > -1) { + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + if (selectedTaskId.equals(taskId)) { + // 遍历TaskListTable找到taskHisId对应的行号 + int taskHisId = taskHis.getId(); + int taskHisListTableRows = taskForm.getTaskHisListTable().getRowCount(); + int taskHisListTableRow = -1; + for (int i = 0; i < taskHisListTableRows; i++) { + int taskHisIdInTable = (int) taskForm.getTaskHisListTable().getValueAt(i, 0); + if (taskHisId == taskHisIdInTable) { + taskHisListTableRow = i; + break; + } + } + if (taskHisListTableRow != -1) { + taskForm.getTaskHisListTable().setValueAt(taskHis.getSuccessCnt(), taskHisListTableRow, 5); + taskForm.getTaskHisListTable().setValueAt(taskHis.getFailCnt(), taskHisListTableRow, 6); + taskForm.getTaskHisListTable().setValueAt(TaskStatusEnum.getDescByCode(taskHis.getStatus()), taskHisListTableRow, 7); + } + } + } + ThreadUtil.safeSleep(500); + } + } + + /** + * 成功数+1 + */ + public void increaseSuccess() { + successRecords.add(1); + } + + /** + * 失败数+1 + */ + public void increaseFail() { + failRecords.add(1); + } + + private void resetLocalData() { + running = false; + successRecords.reset(); + failRecords.reset(); + finishedThreadCount.set(0); + threadCount = 0; + toSendList = Collections.synchronizedList(new LinkedList<>()); + sendSuccessList = Collections.synchronizedList(new LinkedList<>()); + sendFailList = Collections.synchronizedList(new LinkedList<>()); + startTime = 0L; + endTime = 0; + } + + private void savePushData() throws IOException { + File pushHisDir = new File(SystemUtil.CONFIG_HOME + "data" + File.separator + "push_his"); + if (!pushHisDir.exists()) { + boolean mkdirs = pushHisDir.mkdirs(); + } + + String taskName = tTask.getTitle(); + String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_"); + CSVWriter writer; + int msgType = tTask.getMsgType(); + + List fileList = new ArrayList<>(); + // 保存已发送 + if (sendSuccessList.size() > 0) { + File sendSuccessFile = new File(SystemUtil.CONFIG_HOME + "data" + + File.separator + "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + taskName + + "-发送成功-" + nowTime + ".csv"); + FileUtil.touch(sendSuccessFile); + writer = new CSVWriter(new FileWriter(sendSuccessFile)); + + for (String[] str : sendSuccessList) { + writer.writeNext(str); + } + writer.close(); + + taskHis.setSuccessFilePath(sendSuccessFile.getAbsolutePath()); + taskHisMapper.updateByPrimaryKey(taskHis); + fileList.add(sendSuccessFile); + // 保存累计推送总数 + App.config.setPushTotal(App.config.getPushTotal() + sendSuccessList.size()); + App.config.save(); + } + + // 保存未发送 + for (String[] str : sendSuccessList) { + if (msgType == MessageTypeEnum.HTTP_CODE && tTask.getSaveResult() == 1) { + str = ArrayUtils.remove(str, str.length - 1); + String[] finalStr = str; + toSendList = toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList()); + } else { + toSendList.remove(str); + } + } + for (String[] str : sendFailList) { + if (msgType == MessageTypeEnum.HTTP_CODE && tTask.getSaveResult() == 1) { + str = ArrayUtils.remove(str, str.length - 1); + String[] finalStr = str; + toSendList = toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList()); + } else { + toSendList.remove(str); + } + } + + if (toSendList.size() > 0) { + File unSendFile = new File(SystemUtil.CONFIG_HOME + "data" + File.separator + + "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + taskName + "-未发送-" + nowTime + + ".csv"); + FileUtil.touch(unSendFile); + writer = new CSVWriter(new FileWriter(unSendFile)); + for (String[] str : toSendList) { + writer.writeNext(str); + } + writer.close(); + + taskHis.setNoSendFilePath(unSendFile.getAbsolutePath()); + taskHisMapper.updateByPrimaryKey(taskHis); + fileList.add(unSendFile); + } + + // 保存发送失败 + if (sendFailList.size() > 0) { + File failSendFile = new File(SystemUtil.CONFIG_HOME + "data" + File.separator + + "push_his" + File.separator + MessageTypeEnum.getName(msgType) + "-" + taskName + "-发送失败-" + nowTime + ".csv"); + FileUtil.touch(failSendFile); + writer = new CSVWriter(new FileWriter(failSendFile)); + for (String[] str : sendFailList) { + writer.writeNext(str); + } + writer.close(); + + taskHis.setFailFilePath(failSendFile.getAbsolutePath()); + taskHisMapper.updateByPrimaryKey(taskHis); + fileList.add(failSendFile); + } + + // 发送推送结果邮件 + if (tTask.getResultAlert() == 1) { + ConsoleUtil.pushLog(logWriter, "发送推送结果邮件开始"); + String mailResultTo = tTask.getAlertEmails().replace(";", ";").replace(" ", ""); + String[] mailTos = mailResultTo.split(";"); + ArrayList mailToList = new ArrayList<>(Arrays.asList(mailTos)); + + MailMsgSender mailMsgSender = new MailMsgSender(); + String title = "WePush推送结果:【" + taskName + + "】" + sendSuccessList.size() + "成功;" + sendFailList.size() + "失败;" + + toSendList.size() + "未发送"; + StringBuilder contentBuilder = new StringBuilder(); + contentBuilder.append("

WePush推送结果

"); + contentBuilder.append("

消息类型:").append(MessageTypeEnum.getName(tTask.getMsgType())).append("

"); + contentBuilder.append("

消息名称:").append(taskName).append("

"); + contentBuilder.append("
"); + + contentBuilder.append("

成功数:").append(sendSuccessList.size()).append("

"); + contentBuilder.append("

失败数:").append(sendFailList.size()).append("

"); + contentBuilder.append("

未推送数:").append(toSendList.size()).append("

"); + contentBuilder.append("
"); + + contentBuilder.append("

开始时间:").append(DateFormatUtils.format(new Date(startTime), "yyyy-MM-dd HH:mm:ss")).append("

"); + contentBuilder.append("

完毕时间:").append(DateFormatUtils.format(new Date(endTime), "yyyy-MM-dd HH:mm:ss")).append("

"); + contentBuilder.append("

总耗时:").append(DateUtil.formatBetween(endTime - startTime, BetweenFormatter.Level.SECOND)).append("

"); + contentBuilder.append("
"); + + contentBuilder.append("

详情请查看附件

"); + + contentBuilder.append("
"); + contentBuilder.append("
"); + contentBuilder.append("

来自WePush,一款专注于批量推送的小而美的工具

"); + contentBuilder.append("\"WePush\""); + + File[] files = new File[fileList.size()]; + fileList.toArray(files); + mailMsgSender.sendPushResultMail(mailToList, title, contentBuilder.toString(), files); + ConsoleUtil.pushLog(logWriter, "发送推送结果邮件结束"); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/logic/TaskStatusEnum.java b/src/main/java/com/fangxuele/tool/push/logic/TaskStatusEnum.java new file mode 100644 index 000000000..4597b99e8 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/TaskStatusEnum.java @@ -0,0 +1,50 @@ +package com.fangxuele.tool.push.logic; + +/** + *
+ * 任务状态常量
+ * 
+ * + * @author Zhou Bo + * @since 2023/8/14. + */ +public enum TaskStatusEnum { + /** + * 任务状态 + */ + INIT(10, "初始化"), + RUNNING(20, "运行中"), + FINISH(30, "完成"), + STOP(40, "停止"); + + private int code; + + private String name; + + public static final int INIT_CODE = 10; + public static final int RUNNING_CODE = 20; + public static final int FINISH_CODE = 30; + public static final int STOP_CODE = 40; + + TaskStatusEnum(int code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(TaskStatusEnum taskStatusEnum) { + return taskStatusEnum.name; + } + + public static String getDescByCode(Integer taskPeriod) { + for (TaskStatusEnum taskStatusEnum : TaskStatusEnum.values()) { + if (taskStatusEnum.code == taskPeriod) { + return taskStatusEnum.name; + } + } + return null; + } + + public int getCode() { + return code; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/TaskTypeEnum.java b/src/main/java/com/fangxuele/tool/push/logic/TaskTypeEnum.java new file mode 100644 index 000000000..0d82c4250 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/TaskTypeEnum.java @@ -0,0 +1,48 @@ +package com.fangxuele.tool.push.logic; + +/** + *
+ * 任务类型常量
+ * 
+ * + * @author Zhou Bo + * @since 2021/6/4. + */ +public enum TaskTypeEnum { + /** + * 任务类型 + */ + MANUAL_TASK(1, "手动任务"), + SCHEDULE_TASK(2, "定时任务"), + TRIGGER_TASK(3, "触发任务"); + + private int code; + + private String name; + + public static final int MANUAL_TASK_CODE = 1; + public static final int SCHEDULE_TASK_CODE = 2; + public static final int TRIGGER_TASK_CODE = 3; + + TaskTypeEnum(int code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(TaskTypeEnum taskTypeEnum) { + return taskTypeEnum.name; + } + + public static String getDescByCode(Integer taskPeriod) { + for (TaskTypeEnum taskTypeEnum : TaskTypeEnum.values()) { + if (taskTypeEnum.code == taskPeriod) { + return taskTypeEnum.name; + } + } + return null; + } + + public int getCode() { + return code; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/AliyunMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/AliyunMsgMaker.java index c40a2f014..722905e6f 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/AliyunMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/AliyunMsgMaker.java @@ -1,16 +1,19 @@ package com.fangxuele.tool.push.logic.msgmaker; import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; import com.aliyuncs.http.MethodType; -import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.bean.TemplateData; -import com.fangxuele.tool.push.ui.form.msg.AliYunMsgForm; +import com.fangxuele.tool.push.bean.account.AliYunAccountConfig; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgSms; +import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.TemplateUtil; -import org.apache.commons.compress.utils.Lists; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,34 +28,22 @@ */ public class AliyunMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String templateId; + private String templateId; - public static List templateDataList; + private List templateDataList; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = AliYunMsgForm.getInstance().getMsgTemplateIdTextField().getText(); + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); - if (AliYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - AliYunMsgForm.initTemplateDataTable(); - } + private AliYunAccountConfig aliYunAccountConfig; - DefaultTableModel tableModel = (DefaultTableModel) AliYunMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - TemplateData templateData; - templateDataList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String name = ((String) tableModel.getValueAt(i, 0)).trim(); - String value = ((String) tableModel.getValueAt(i, 1)).trim(); - templateData = new TemplateData(); - templateData.setName(name); - templateData.setValue(value); - templateDataList.add(templateData); - } + public AliyunMsgMaker(TMsg tMsg) { + TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class); + this.templateId = tMsgSms.getTemplateId(); + this.templateDataList = tMsgSms.getTemplateDataList(); + TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId()); + String accountConfig = tAccount.getAccountConfig(); + aliYunAccountConfig = JSON.parseObject(accountConfig, AliYunAccountConfig.class); } /** @@ -67,7 +58,7 @@ public SendSmsRequest makeMsg(String[] msgData) { //使用post提交 request.setSysMethod(MethodType.POST); //必填:短信签名-可在短信控制台中找到 - request.setSignName(App.config.getAliyunSign()); + request.setSignName(aliYunAccountConfig.getSign()); // 模板参数 Map paramMap = new HashMap<>(10); diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/BdYunMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/BdYunMsgMaker.java index 57ae049d3..b76cf2fef 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/BdYunMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/BdYunMsgMaker.java @@ -1,11 +1,14 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.ui.form.msg.BdYunMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgSms; import com.fangxuele.tool.push.util.TemplateUtil; -import com.google.common.collect.Maps; +import lombok.Getter; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; +import java.util.HashMap; import java.util.Map; /** @@ -16,30 +19,19 @@ * @author Zhou Bo * @since 2019/6/14. */ +@Getter public class BdYunMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String templateId; + private String templateId; - public static Map paramMap; + private Map paramMap; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = BdYunMsgForm.getInstance().getMsgTemplateIdTextField().getText(); - - if (BdYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - BdYunMsgForm.initTemplateDataTable(); - } - - DefaultTableModel tableModel = (DefaultTableModel) BdYunMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - paramMap = Maps.newHashMap(); - for (int i = 0; i < rowCount; i++) { - String key = ((String) tableModel.getValueAt(i, 0)); - String value = ((String) tableModel.getValueAt(i, 1)); - paramMap.put(key, value); + public BdYunMsgMaker(TMsg tMsg) { + TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class); + templateId = tMsgSms.getTemplateId(); + paramMap = new HashMap<>(); + for (TemplateData templateData : tMsgSms.getTemplateDataList()) { + paramMap.put(templateData.getName(), templateData.getValue()); } } diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/DingMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/DingMsgMaker.java index 58812f2d2..3b02bac48 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/DingMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/DingMsgMaker.java @@ -1,8 +1,8 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.bean.DingMsg; -import com.fangxuele.tool.push.logic.msgsender.DingMsgSender; -import com.fangxuele.tool.push.ui.form.msg.DingMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgDing; import com.fangxuele.tool.push.util.TemplateUtil; import org.apache.velocity.VelocityContext; @@ -16,61 +16,36 @@ */ public class DingMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String agentId; + private String msgType; - public static String msgType; + private String msgTitle; - private static String msgTitle; + private String picUrl; - private static String picUrl; + private String url; - public static String desc; + private String btnTxt; - public static String url; + private String btnUrl; - private static String btnTxt; + private String msgContent; - private static String btnUrl; + private String radioType; - private static String msgContent; + private String webHook; - public static String radioType; + public DingMsgMaker(TMsg tMsg) { + TMsgDing tMsgDing = JSON.parseObject(tMsg.getContent(), TMsgDing.class); - public static String webHook; - - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - String agentIdBefore = agentId; - String agentIdNow = DingMsgForm.appNameToAgentIdMap.get(DingMsgForm.getInstance().getAppNameComboBox().getSelectedItem()); - - String webHookBefore = webHook; - String webHookNow = DingMsgForm.getInstance().getWebHookTextField().getText().trim(); - synchronized (this) { - if (agentIdBefore == null || !agentIdBefore.equals(agentIdNow)) { - agentId = agentIdNow; - DingMsgSender.accessTokenTimedCache = null; - DingMsgSender.defaultDingTalkClient = null; - } - if (webHookBefore == null || !webHookBefore.equals(webHookNow)) { - DingMsgSender.robotClient = null; - } - } - msgType = (String) DingMsgForm.getInstance().getMsgTypeComboBox().getSelectedItem(); - msgTitle = DingMsgForm.getInstance().getTitleTextField().getText(); - picUrl = DingMsgForm.getInstance().getPicUrlTextField().getText().trim(); - url = DingMsgForm.getInstance().getUrlTextField().getText().trim(); - btnTxt = DingMsgForm.getInstance().getBtnTxtTextField().getText().trim(); - btnUrl = DingMsgForm.getInstance().getBtnURLTextField().getText().trim(); - msgContent = DingMsgForm.getInstance().getContentTextArea().getText(); - if (DingMsgForm.getInstance().getWorkRadioButton().isSelected()) { - radioType = "work"; - } else { - radioType = "robot"; - } - webHook = DingMsgForm.getInstance().getWebHookTextField().getText(); + msgType = tMsgDing.getDingMsgType(); + msgTitle = tMsgDing.getMsgTitle(); + picUrl = tMsgDing.getPicUrl(); + url = tMsgDing.getUrl(); + btnTxt = tMsgDing.getBtnTxt(); + btnUrl = tMsgDing.getBtnUrl(); + msgContent = tMsgDing.getContent(); + radioType = tMsgDing.getRadioType(); + webHook = tMsgDing.getWebHook(); } /** @@ -80,16 +55,16 @@ public void prepare() { * @return WxMpTemplateMessage */ @Override - public DingMsg makeMsg(String[] msgData) { + public TMsgDing makeMsg(String[] msgData) { - DingMsg dingMsg = new DingMsg(); + TMsgDing dingMsg = new TMsgDing(); VelocityContext velocityContext = getVelocityContext(msgData); if ("markdown消息".equals(msgType)) { dingMsg.setContent(msgContent); } else { dingMsg.setContent(TemplateUtil.evaluate(msgContent, velocityContext)); } - dingMsg.setTitle(TemplateUtil.evaluate(msgTitle, velocityContext)); + dingMsg.setMsgTitle(TemplateUtil.evaluate(msgTitle, velocityContext)); dingMsg.setPicUrl(TemplateUtil.evaluate(picUrl, velocityContext)); dingMsg.setUrl(TemplateUtil.evaluate(url, velocityContext)); dingMsg.setBtnTxt(TemplateUtil.evaluate(btnTxt, velocityContext)); diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HttpMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HttpMsgMaker.java index 7f01a9332..835cc94d0 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HttpMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HttpMsgMaker.java @@ -1,15 +1,19 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.bean.HttpMsg; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.fangxuele.tool.push.bean.msg.HttpMsg; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgHttp; import com.fangxuele.tool.push.ui.form.msg.HttpMsgForm; import com.fangxuele.tool.push.util.TemplateUtil; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.DateUtils; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; import java.net.HttpCookie; import java.text.ParseException; import java.util.HashMap; @@ -24,76 +28,31 @@ * @since 2019/7/16. */ @Slf4j +@Getter public class HttpMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String method; - public static String url; - public static String body; - public static String bodyType; - public static List paramList; - public static List headerList; - public static List cookieList; + private String method; + private String url; + private String body; + private String bodyType; + private List paramList; + private List headerList; + private List cookieList; - @Override - public void prepare() { - method = (String) HttpMsgForm.getInstance().getMethodComboBox().getSelectedItem(); - url = HttpMsgForm.getInstance().getUrlTextField().getText().trim(); - body = HttpMsgForm.getInstance().getBodyTextArea().getText(); - bodyType = (String) HttpMsgForm.getInstance().getBodyTypeComboBox().getSelectedItem(); + public HttpMsgMaker(TMsg tMsg) { + TMsgHttp tMsgHttp = JSON.parseObject(tMsg.getContent(), TMsgHttp.class); - // Params========================= - if (HttpMsgForm.getInstance().getParamTable().getModel().getRowCount() == 0) { - HttpMsgForm.initParamTable(); - } - DefaultTableModel paramTableModel = (DefaultTableModel) HttpMsgForm.getInstance().getParamTable().getModel(); - int rowCount = paramTableModel.getRowCount(); - HttpMsgForm.NameValueObject nameValueObject; - paramList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String name = ((String) paramTableModel.getValueAt(i, 0)).trim(); - String value = ((String) paramTableModel.getValueAt(i, 1)).trim(); - nameValueObject = new HttpMsgForm.NameValueObject(); - nameValueObject.setName(name); - nameValueObject.setValue(value); - paramList.add(nameValueObject); - } - // Headers========================= - if (HttpMsgForm.getInstance().getHeaderTable().getModel().getRowCount() == 0) { - HttpMsgForm.initHeaderTable(); - } - DefaultTableModel headerTableModel = (DefaultTableModel) HttpMsgForm.getInstance().getHeaderTable().getModel(); - rowCount = headerTableModel.getRowCount(); - headerList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String name = ((String) headerTableModel.getValueAt(i, 0)).trim(); - String value = ((String) headerTableModel.getValueAt(i, 1)).trim(); - nameValueObject = new HttpMsgForm.NameValueObject(); - nameValueObject.setName(name); - nameValueObject.setValue(value); - headerList.add(nameValueObject); - } - // Cookies========================= - if (HttpMsgForm.getInstance().getCookieTable().getModel().getRowCount() == 0) { - HttpMsgForm.initCookieTable(); - } - DefaultTableModel cookieTableModel = (DefaultTableModel) HttpMsgForm.getInstance().getCookieTable().getModel(); - rowCount = cookieTableModel.getRowCount(); - cookieList = Lists.newArrayList(); - HttpMsgForm.CookieObject cookieObject; - for (int i = 0; i < rowCount; i++) { - String name = ((String) cookieTableModel.getValueAt(i, 0)).trim(); - String value = ((String) cookieTableModel.getValueAt(i, 1)).trim(); - String domain = ((String) cookieTableModel.getValueAt(i, 2)).trim(); - String path = ((String) cookieTableModel.getValueAt(i, 3)).trim(); - String expiry = ((String) cookieTableModel.getValueAt(i, 4)).trim(); - cookieObject = new HttpMsgForm.CookieObject(); - cookieObject.setName(name); - cookieObject.setValue(value); - cookieObject.setDomain(domain); - cookieObject.setPath(path); - cookieObject.setExpiry(expiry); - cookieList.add(cookieObject); - } + method = tMsgHttp.getMethod(); + url = tMsgHttp.getUrl(); + body = tMsgHttp.getBody(); + bodyType = tMsgHttp.getBodyType(); + + paramList = JSON.parseObject(tMsgHttp.getParams(), new TypeReference>() { + }); + headerList = JSON.parseObject(tMsgHttp.getHeaders(), new TypeReference>() { + }); + cookieList = JSON.parseObject(tMsgHttp.getCookies(), new TypeReference>() { + }); } @Override diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HwYunMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HwYunMsgMaker.java index 81d321ed9..40953b0c7 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HwYunMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/HwYunMsgMaker.java @@ -1,11 +1,14 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.ui.form.msg.HwYunMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgSms; import com.fangxuele.tool.push.util.TemplateUtil; -import org.apache.commons.compress.utils.Lists; +import lombok.Getter; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; +import java.util.ArrayList; import java.util.List; /** @@ -16,29 +19,19 @@ * @author Zhou Bo * @since 2019/6/14. */ -public class HwYunMsgMaker extends BaseMsgMaker implements IMsgMaker{ +@Getter +public class HwYunMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String templateId; + private String templateId; - public static List paramList; + private List paramList; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = HwYunMsgForm.getInstance().getMsgTemplateIdTextField().getText(); - - if (HwYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - HwYunMsgForm.initTemplateDataTable(); - } - - DefaultTableModel tableModel = (DefaultTableModel) HwYunMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - paramList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String value = ((String) tableModel.getValueAt(i, 1)); - paramList.add(value); + public HwYunMsgMaker(TMsg tMsg) { + TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class); + this.templateId = tMsgSms.getTemplateId(); + paramList = new ArrayList<>(); + for (TemplateData templateData : tMsgSms.getTemplateDataList()) { + paramList.add(templateData.getValue()); } } diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/IMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/IMsgMaker.java index df172713b..bd887db45 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/IMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/IMsgMaker.java @@ -1,10 +1,6 @@ package com.fangxuele.tool.push.logic.msgmaker; public interface IMsgMaker { - /** - * 准备(界面字段等) - */ - void prepare(); /** * 消息加工器接口 diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MailMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MailMsgMaker.java index 2a8674afe..a41f0573a 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MailMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MailMsgMaker.java @@ -1,10 +1,17 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.bean.MailMsg; -import com.fangxuele.tool.push.ui.form.msg.MailMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.msg.MailMsg; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgMail; import com.fangxuele.tool.push.util.TemplateUtil; +import org.apache.commons.lang3.StringUtils; import org.apache.velocity.VelocityContext; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + /** *
  * E-Mail加工器
@@ -15,20 +22,26 @@
  */
 public class MailMsgMaker extends BaseMsgMaker implements IMsgMaker {
 
-    public static String mailTitle;
-    public static String mailCc;
-    public static String mailFiles;
-    public static String mailContent;
+    private String mailTitle;
+    private String mailCc;
+    private List mailFiles;
+    private String mailContent;
 
-    /**
-     * 准备(界面字段等)
-     */
-    @Override
-    public void prepare() {
-        mailTitle = MailMsgForm.getInstance().getMailTitleTextField().getText();
-        mailCc = MailMsgForm.getInstance().getMailCcTextField().getText();
-        mailFiles = MailMsgForm.getInstance().getMailFilesTextField().getText();
-        mailContent = MailMsgForm.getInstance().getMailContentPane().getText();
+    public MailMsgMaker(TMsg tMsg) {
+        TMsgMail tMsgMail = JSON.parseObject(tMsg.getContent(), TMsgMail.class);
+        mailTitle = tMsgMail.getTitle();
+        mailCc = tMsgMail.getCc();
+        List files = new ArrayList<>();
+        String text = tMsgMail.getFiles();
+        String[] strings = text.split("\\n");
+        for (String string : strings) {
+            string = string.trim();
+            if (StringUtils.isNotEmpty(string)) {
+                files.add(new File(string));
+            }
+        }
+        mailFiles = files;
+        mailContent = tMsgMail.getContent();
     }
 
     /**
@@ -43,11 +56,10 @@ public MailMsg makeMsg(String[] msgData) {
         VelocityContext velocityContext = getVelocityContext(msgData);
         String title = TemplateUtil.evaluate(mailTitle, velocityContext);
         String cc = TemplateUtil.evaluate(mailCc, velocityContext);
-        String files = TemplateUtil.evaluate(mailFiles, velocityContext);
         String content = TemplateUtil.evaluate(mailContent, velocityContext);
         mailMsg.setMailTitle(title);
         mailMsg.setMailCc(cc);
-        mailMsg.setMailFiles(files);
+        mailMsg.setMailFiles(mailFiles);
         mailMsg.setMailContent(content);
         return mailMsg;
     }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java
index 1695c8155..82a8081b0 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java
@@ -1,6 +1,7 @@
 package com.fangxuele.tool.push.logic.msgmaker;
 
 import com.fangxuele.tool.push.App;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 
 /**
@@ -18,53 +19,56 @@ public class MsgMakerFactory {
      *
      * @return IMsgMaker
      */
-    public static IMsgMaker getMsgMaker() {
+    public static IMsgMaker getMsgMaker(TMsg tMsg) {
         IMsgMaker iMsgMaker = null;
         switch (App.config.getMsgType()) {
             case MessageTypeEnum.MP_TEMPLATE_CODE:
-                iMsgMaker = new WxMpTemplateMsgMaker();
-                break;
-            case MessageTypeEnum.MA_TEMPLATE_CODE:
-                iMsgMaker = new WxMaTemplateMsgMaker();
+                iMsgMaker = new WxMpTemplateMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.MA_SUBSCRIBE_CODE:
-                iMsgMaker = new WxMaSubscribeMsgMaker();
+                iMsgMaker = new WxMaSubscribeMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.KEFU_CODE:
-                iMsgMaker = new WxKefuMsgMaker();
+                iMsgMaker = new WxKefuMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.ALI_YUN_CODE:
-                iMsgMaker = new AliyunMsgMaker();
+                iMsgMaker = new AliyunMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.TX_YUN_CODE:
-                iMsgMaker = new TxYunMsgMaker();
+                iMsgMaker = new TxYunMsgMaker(tMsg);
+                break;
+            case MessageTypeEnum.TX_YUN_3_CODE:
+                iMsgMaker = new TxYun3MsgMaker(tMsg);
                 break;
             case MessageTypeEnum.HW_YUN_CODE:
-                iMsgMaker = new HwYunMsgMaker();
+                iMsgMaker = new HwYunMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.YUN_PIAN_CODE:
-                iMsgMaker = new YunPianMsgMaker();
+                iMsgMaker = new YunPianMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.EMAIL_CODE:
-                iMsgMaker = new MailMsgMaker();
+                iMsgMaker = new MailMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.WX_CP_CODE:
-                iMsgMaker = new WxCpMsgMaker();
+                iMsgMaker = new WxCpMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.HTTP_CODE:
-                iMsgMaker = new HttpMsgMaker();
+                iMsgMaker = new HttpMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.DING_CODE:
-                iMsgMaker = new DingMsgMaker();
+                iMsgMaker = new DingMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.BD_YUN_CODE:
-                iMsgMaker = new BdYunMsgMaker();
+                iMsgMaker = new BdYunMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.UP_YUN_CODE:
-                iMsgMaker = new UpYunMsgMaker();
+                iMsgMaker = new UpYunMsgMaker(tMsg);
                 break;
             case MessageTypeEnum.QI_NIU_YUN_CODE:
-                iMsgMaker = new QiNiuYunMsgMaker();
+                iMsgMaker = new QiNiuYunMsgMaker(tMsg);
+                break;
+            case MessageTypeEnum.MP_SUBSCRIBE_CODE:
+                iMsgMaker = new WxMpSubscribeMsgMaker(tMsg);
                 break;
             default:
         }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/QiNiuYunMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/QiNiuYunMsgMaker.java
index 89025a74c..cc92a74fb 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/QiNiuYunMsgMaker.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/QiNiuYunMsgMaker.java
@@ -1,11 +1,14 @@
 package com.fangxuele.tool.push.logic.msgmaker;
 
-import com.fangxuele.tool.push.ui.form.msg.QiNiuYunMsgForm;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.domain.TMsg;
+import com.fangxuele.tool.push.domain.TMsgSms;
 import com.fangxuele.tool.push.util.TemplateUtil;
-import com.google.common.collect.Maps;
+import lombok.Getter;
 import org.apache.velocity.VelocityContext;
 
-import javax.swing.table.DefaultTableModel;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -16,30 +19,21 @@
  * @author Zhou Bo
  * @since 2019/6/14.
  */
+@Getter
 public class QiNiuYunMsgMaker extends BaseMsgMaker implements IMsgMaker {
 
-    public static String templateId;
+    private String templateId;
 
-    public static Map paramMap;
+    private Map paramMap;
 
-    /**
-     * 准备(界面字段等)
-     */
-    @Override
-    public void prepare() {
-        templateId = QiNiuYunMsgForm.getInstance().getMsgTemplateIdTextField().getText();
+    public QiNiuYunMsgMaker(TMsg tMsg) {
+        TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class);
+        this.templateId = tMsgSms.getTemplateId();
 
-        if (QiNiuYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
-            QiNiuYunMsgForm.initTemplateDataTable();
-        }
+        paramMap = new HashMap<>();
 
-        DefaultTableModel tableModel = (DefaultTableModel) QiNiuYunMsgForm.getInstance().getTemplateMsgDataTable().getModel();
-        int rowCount = tableModel.getRowCount();
-        paramMap = Maps.newHashMap();
-        for (int i = 0; i < rowCount; i++) {
-            String key = ((String) tableModel.getValueAt(i, 0));
-            String value = ((String) tableModel.getValueAt(i, 1));
-            paramMap.put(key, value);
+        for (TemplateData templateData : tMsgSms.getTemplateDataList()) {
+            paramMap.put(templateData.getName(), templateData.getValue());
         }
     }
 
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/TxYun3MsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/TxYun3MsgMaker.java
new file mode 100644
index 000000000..d1d1e6798
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/TxYun3MsgMaker.java
@@ -0,0 +1,54 @@
+package com.fangxuele.tool.push.logic.msgmaker;
+
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.domain.TMsg;
+import com.fangxuele.tool.push.domain.TMsgSms;
+import com.fangxuele.tool.push.util.TemplateUtil;
+import lombok.Getter;
+import org.apache.velocity.VelocityContext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 
+ * 腾讯云3.0模板短信加工器
+ * 
+ * + * @author Zhou Bo + * @since 2023/9/4. + */ +@Getter +public class TxYun3MsgMaker extends BaseMsgMaker implements IMsgMaker { + + private String templateId; + + private List paramList; + + public TxYun3MsgMaker(TMsg tMsg) { + TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class); + this.templateId = tMsgSms.getTemplateId(); + paramList = new ArrayList<>(); + for (TemplateData templateData : tMsgSms.getTemplateDataList()) { + paramList.add(templateData.getValue()); + } + } + + /** + * 组织腾讯云短信消息 + * + * @param msgData 消息信息 + * @return String[] + */ + @Override + public String[] makeMsg(String[] msgData) { + + VelocityContext velocityContext = getVelocityContext(msgData); + for (int i = 0; i < paramList.size(); i++) { + paramList.set(i, TemplateUtil.evaluate(paramList.get(i), velocityContext)); + } + String[] paramArray = new String[paramList.size()]; + return paramList.toArray(paramArray); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/TxYunMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/TxYunMsgMaker.java index 458f54a24..194fe9e5e 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/TxYunMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/TxYunMsgMaker.java @@ -1,11 +1,14 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.ui.form.msg.TxYunMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgSms; import com.fangxuele.tool.push.util.TemplateUtil; -import org.apache.commons.compress.utils.Lists; +import lombok.Getter; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; +import java.util.ArrayList; import java.util.List; /** @@ -16,29 +19,19 @@ * @author Zhou Bo * @since 2019/6/14. */ -public class TxYunMsgMaker extends BaseMsgMaker implements IMsgMaker{ +@Getter +public class TxYunMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static int templateId; + private int templateId; - public static List paramList; + private List paramList; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = Integer.parseInt(TxYunMsgForm.getInstance().getMsgTemplateIdTextField().getText()); - - if (TxYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - TxYunMsgForm.initTemplateDataTable(); - } - - DefaultTableModel tableModel = (DefaultTableModel) TxYunMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - paramList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String value = ((String) tableModel.getValueAt(i, 1)); - paramList.add(value); + public TxYunMsgMaker(TMsg tMsg) { + TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class); + this.templateId = Integer.parseInt(tMsgSms.getTemplateId()); + paramList = new ArrayList<>(); + for (TemplateData templateData : tMsgSms.getTemplateDataList()) { + paramList.add(templateData.getValue()); } } diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/UpYunMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/UpYunMsgMaker.java index 9131a09e8..65b96afa1 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/UpYunMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/UpYunMsgMaker.java @@ -1,11 +1,14 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.ui.form.msg.UpYunMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgSms; import com.fangxuele.tool.push.util.TemplateUtil; -import org.apache.commons.compress.utils.Lists; +import lombok.Getter; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; +import java.util.ArrayList; import java.util.List; /** @@ -16,29 +19,20 @@ * @author Zhou Bo * @since 2019/6/14. */ -public class UpYunMsgMaker extends BaseMsgMaker implements IMsgMaker{ +@Getter +public class UpYunMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String templateId; + private String templateId; - public static List paramList; + private List paramList; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = UpYunMsgForm.getInstance().getMsgTemplateIdTextField().getText(); - - if (UpYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - UpYunMsgForm.initTemplateDataTable(); - } + public UpYunMsgMaker(TMsg tMsg) { + TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class); + this.templateId = tMsgSms.getTemplateId(); - DefaultTableModel tableModel = (DefaultTableModel) UpYunMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - paramList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String value = ((String) tableModel.getValueAt(i, 1)); - paramList.add(value); + paramList = new ArrayList<>(); + for (TemplateData templateData : tMsgSms.getTemplateDataList()) { + paramList.add(templateData.getValue()); } } diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxCpMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxCpMsgMaker.java index 65240d2a1..e3a355543 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxCpMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxCpMsgMaker.java @@ -1,10 +1,15 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.logic.msgsender.WxCpMsgSender; -import com.fangxuele.tool.push.ui.form.msg.WxCpMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.account.WxCpAccountConfig; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgWxCp; +import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.TemplateUtil; -import me.chanjar.weixin.cp.bean.WxCpMessage; import me.chanjar.weixin.cp.bean.article.NewArticle; +import me.chanjar.weixin.cp.bean.message.WxCpMessage; import org.apache.velocity.VelocityContext; /** @@ -17,43 +22,41 @@ */ public class WxCpMsgMaker extends BaseMsgMaker implements IMsgMaker { - private static String agentId; + private String agentId; - public static String msgType; + private String msgType; - private static String msgTitle; + private String msgTitle; - private static String picUrl; + private String picUrl; - public static String desc; + private String desc; - public static String url; + private String url; - private static String btnTxt; + private String btnTxt; - private static String msgContent; + private String msgContent; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - String agentIdBefore = agentId; - String agentIdNow = WxCpMsgForm.appNameToAgentIdMap.get(WxCpMsgForm.getInstance().getAppNameComboBox().getSelectedItem()); - synchronized (this) { - if (agentIdBefore == null || !agentIdBefore.equals(agentIdNow)) { - agentId = agentIdNow; - WxCpMsgSender.wxCpConfigStorage = null; - WxCpMsgSender.wxCpService = null; - } - } - msgType = (String) WxCpMsgForm.getInstance().getMsgTypeComboBox().getSelectedItem(); - msgTitle = WxCpMsgForm.getInstance().getTitleTextField().getText(); - picUrl = WxCpMsgForm.getInstance().getPicUrlTextField().getText().trim(); - desc = WxCpMsgForm.getInstance().getDescTextField().getText(); - url = WxCpMsgForm.getInstance().getUrlTextField().getText().trim(); - btnTxt = WxCpMsgForm.getInstance().getBtnTxtTextField().getText().trim(); - msgContent = WxCpMsgForm.getInstance().getContentTextArea().getText(); + private WxCpAccountConfig wxCpAccountConfig; + + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + + public WxCpMsgMaker(TMsg tMsg) { + TMsgWxCp tMsgWxCp = JSON.parseObject(tMsg.getContent(), TMsgWxCp.class); + + TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId()); + String accountConfig = tAccount.getAccountConfig(); + wxCpAccountConfig = JSON.parseObject(accountConfig, WxCpAccountConfig.class); + agentId = wxCpAccountConfig.getAgentId(); + + msgType = tMsgWxCp.getCpMsgType(); + msgTitle = tMsgWxCp.getTitle(); + picUrl = tMsgWxCp.getImgUrl(); + desc = tMsgWxCp.getDescribe(); + url = tMsgWxCp.getUrl(); + btnTxt = tMsgWxCp.getBtnTxt(); + msgContent = tMsgWxCp.getContent(); } /** diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxKefuMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxKefuMsgMaker.java index a70d90e57..2426bada8 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxKefuMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxKefuMsgMaker.java @@ -1,6 +1,8 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.ui.form.msg.KefuMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgKefu; import com.fangxuele.tool.push.util.TemplateUtil; import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; import org.apache.velocity.VelocityContext; @@ -15,29 +17,36 @@ */ public class WxKefuMsgMaker extends BaseMsgMaker implements IMsgMaker { - private static String msgKefuMsgType; + private String msgKefuMsgType; - private static String msgKefuMsgTitle; + private String msgKefuMsgTitle; - private static String msgKefuMsgContent; + private String msgKefuMsgContent; - private static String msgKefuPicUrl; + private String msgKefuPicUrl; - private static String msgKefuDesc; + private String msgKefuDesc; - private static String msgKefuUrl; + private String msgKefuUrl; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - msgKefuMsgType = KefuMsgForm.getInstance().getMsgKefuMsgTypeComboBox().getSelectedItem().toString(); - msgKefuMsgTitle = KefuMsgForm.getInstance().getMsgKefuMsgTitleTextField().getText(); - msgKefuPicUrl = KefuMsgForm.getInstance().getMsgKefuPicUrlTextField().getText(); - msgKefuDesc = KefuMsgForm.getInstance().getMsgKefuDescTextField().getText(); - msgKefuUrl = KefuMsgForm.getInstance().getMsgKefuUrlTextField().getText(); - msgKefuMsgContent = KefuMsgForm.getInstance().getContentTextArea().getText(); + private String msgKefuAppid; + + private String msgKefuPagepath; + + private String msgKefuThumbMediaId; + + public WxKefuMsgMaker(TMsg tMsg) { + TMsgKefu tMsgKefu = JSON.parseObject(tMsg.getContent(), TMsgKefu.class); + + msgKefuMsgType = tMsgKefu.getKefuMsgType(); + msgKefuMsgTitle = tMsgKefu.getTitle(); + msgKefuPicUrl = tMsgKefu.getImgUrl(); + msgKefuDesc = tMsgKefu.getDescribe(); + msgKefuUrl = tMsgKefu.getUrl(); + msgKefuMsgContent = tMsgKefu.getContent(); + msgKefuAppid = tMsgKefu.getAppId(); + msgKefuPagepath = tMsgKefu.getPagePath(); + msgKefuThumbMediaId = tMsgKefu.getThumbMediaId(); } /** @@ -73,6 +82,11 @@ public WxMpKefuMessage makeMsg(String[] msgData) { } else if ("文本消息".equals(msgKefuMsgType)) { String content = TemplateUtil.evaluate(msgKefuMsgContent, velocityContext); kefuMessage = WxMpKefuMessage.TEXT().content(content).build(); + } else if ("小程序卡片消息".equals(msgKefuMsgType)) { + String title = TemplateUtil.evaluate(msgKefuMsgTitle, velocityContext); + String pagePath = TemplateUtil.evaluate(msgKefuPagepath, velocityContext); + String thumbMediaId = TemplateUtil.evaluate(msgKefuThumbMediaId, velocityContext); + kefuMessage = WxMpKefuMessage.MINIPROGRAMPAGE().title(title).appId(msgKefuAppid).pagePath(pagePath).thumbMediaId(thumbMediaId).build(); } return kefuMessage; diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java index 4c1b2c491..4545f1ee7 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java @@ -1,13 +1,13 @@ package com.fangxuele.tool.push.logic.msgmaker; import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; +import com.alibaba.fastjson.JSON; import com.fangxuele.tool.push.bean.TemplateData; -import com.fangxuele.tool.push.ui.form.msg.MaSubscribeMsgForm; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgMaSubscribe; import com.fangxuele.tool.push.util.TemplateUtil; -import org.apache.commons.compress.utils.Lists; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; import java.util.List; /** @@ -20,36 +20,15 @@ */ public class WxMaSubscribeMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String templateId; - private static String templateUrl; - public static List templateDataList; + private String templateId; + private String page; + private List templateDataList; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = MaSubscribeMsgForm.getInstance().getMsgTemplateIdTextField().getText().trim(); - templateUrl = MaSubscribeMsgForm.getInstance().getMsgTemplateUrlTextField().getText().trim(); - - if (MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - MaSubscribeMsgForm.initTemplateDataTable(); - } - - DefaultTableModel tableModel = (DefaultTableModel) MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - TemplateData templateData; - templateDataList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String name = ((String) tableModel.getValueAt(i, 0)).trim(); - String value = ((String) tableModel.getValueAt(i, 1)).trim(); - String color = ((String) tableModel.getValueAt(i, 2)).trim(); - templateData = new TemplateData(); - templateData.setName(name); - templateData.setValue(value); - templateData.setColor(color); - templateDataList.add(templateData); - } + public WxMaSubscribeMsgMaker(TMsg tMsg) { + TMsgMaSubscribe tMsgMaSubscribe = JSON.parseObject(tMsg.getContent(), TMsgMaSubscribe.class); + this.templateId = tMsgMaSubscribe.getTemplateId(); + this.page = tMsgMaSubscribe.getPage(); + this.templateDataList = tMsgMaSubscribe.getTemplateDataList(); } /** @@ -64,12 +43,12 @@ public WxMaSubscribeMessage makeMsg(String[] msgData) { WxMaSubscribeMessage wxMaSubscribeMessage = new WxMaSubscribeMessage(); wxMaSubscribeMessage.setTemplateId(templateId); VelocityContext velocityContext = getVelocityContext(msgData); - String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext); + String templateUrlEvaluated = TemplateUtil.evaluate(page, velocityContext); wxMaSubscribeMessage.setPage(templateUrlEvaluated); - WxMaSubscribeMessage.Data wxMaSubscribeData; + WxMaSubscribeMessage.MsgData wxMaSubscribeData; for (TemplateData templateData : templateDataList) { - wxMaSubscribeData = new WxMaSubscribeMessage.Data(); + wxMaSubscribeData = new WxMaSubscribeMessage.MsgData(); wxMaSubscribeData.setName(templateData.getName()); wxMaSubscribeData.setValue(TemplateUtil.evaluate(templateData.getValue(), velocityContext)); wxMaSubscribeMessage.addData(wxMaSubscribeData); diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaTemplateMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaTemplateMsgMaker.java deleted file mode 100644 index 2a06efa25..000000000 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaTemplateMsgMaker.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.fangxuele.tool.push.logic.msgmaker; - -import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; -import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; -import com.fangxuele.tool.push.bean.TemplateData; -import com.fangxuele.tool.push.ui.form.msg.MaTemplateMsgForm; -import com.fangxuele.tool.push.util.TemplateUtil; -import org.apache.commons.compress.utils.Lists; -import org.apache.velocity.VelocityContext; - -import javax.swing.table.DefaultTableModel; -import java.util.List; - -/** - *
- * 小程序模板消息加工器
- * 
- * - * @author Zhou Bo - * @since 2019/6/14. - */ -public class WxMaTemplateMsgMaker extends BaseMsgMaker implements IMsgMaker { - - public static String templateId; - private static String templateUrl; - private static String templateKeyWord; - public static List templateDataList; - - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = MaTemplateMsgForm.getInstance().getMsgTemplateIdTextField().getText().trim(); - templateUrl = MaTemplateMsgForm.getInstance().getMsgTemplateUrlTextField().getText().trim(); - templateKeyWord = MaTemplateMsgForm.getInstance().getMsgTemplateKeyWordTextField().getText().trim() + ".DATA"; - - if (MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - MaTemplateMsgForm.initTemplateDataTable(); - } - - DefaultTableModel tableModel = (DefaultTableModel) MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - TemplateData templateData; - templateDataList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String name = ((String) tableModel.getValueAt(i, 0)).trim(); - String value = ((String) tableModel.getValueAt(i, 1)).trim(); - String color = ((String) tableModel.getValueAt(i, 2)).trim(); - templateData = new TemplateData(); - templateData.setName(name); - templateData.setValue(value); - templateData.setColor(color); - templateDataList.add(templateData); - } - } - - /** - * 组织模板消息-小程序 - * - * @param msgData 消息信息 - * @return WxMaTemplateMessage - */ - @Override - public WxMaTemplateMessage makeMsg(String[] msgData) { - // 拼模板 - WxMaTemplateMessage wxMessageTemplate = new WxMaTemplateMessage(); - wxMessageTemplate.setTemplateId(templateId); - VelocityContext velocityContext = getVelocityContext(msgData); - String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext); - wxMessageTemplate.setPage(templateUrlEvaluated); - wxMessageTemplate.setEmphasisKeyword(templateKeyWord); - - WxMaTemplateData wxMaTemplateData; - for (TemplateData templateData : templateDataList) { - wxMaTemplateData = new WxMaTemplateData(); - wxMaTemplateData.setName(templateData.getName()); - wxMaTemplateData.setValue(TemplateUtil.evaluate(templateData.getValue(), velocityContext)); - wxMaTemplateData.setColor(templateData.getColor()); - wxMessageTemplate.addData(wxMaTemplateData); - } - - return wxMessageTemplate; - } -} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpSubscribeMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpSubscribeMsgMaker.java new file mode 100644 index 000000000..dfc773559 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpSubscribeMsgMaker.java @@ -0,0 +1,72 @@ +package com.fangxuele.tool.push.logic.msgmaker; + +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgMpSubscribe; +import com.fangxuele.tool.push.util.TemplateUtil; +import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage; +import org.apache.velocity.VelocityContext; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *
+ * 公众号订阅通知加工器
+ * 
+ * + * @author Zhou Bo + * @since 2021/3/23. + */ +public class WxMpSubscribeMsgMaker extends BaseMsgMaker implements IMsgMaker { + + private String templateId; + + private String templateUrl; + + private String miniAppId; + + private String miniAppPagePath; + + private List templateDataList; + + public WxMpSubscribeMsgMaker(TMsg tMsg) { + TMsgMpSubscribe tMsgMpSubscribe = JSON.parseObject(tMsg.getContent(), TMsgMpSubscribe.class); + this.templateId = tMsgMpSubscribe.getTemplateId(); + this.templateUrl = tMsgMpSubscribe.getUrl(); + this.miniAppId = tMsgMpSubscribe.getMaAppid(); + this.miniAppPagePath = tMsgMpSubscribe.getMaPagePath(); + this.templateDataList = tMsgMpSubscribe.getTemplateDataList(); + } + + /** + * 组织订阅通知-公众号 + * + * @param msgData 消息数据 + * @return WxMpSubscribeMessage + */ + @Override + public WxMpSubscribeMessage makeMsg(String[] msgData) { + // 拼模板 + WxMpSubscribeMessage wxMessageTemplate = new WxMpSubscribeMessage(); + wxMessageTemplate.setTemplateId(templateId); + + VelocityContext velocityContext = getVelocityContext(msgData); + String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext); + wxMessageTemplate.setPage(templateUrlEvaluated); + String miniAppPagePathEvaluated = TemplateUtil.evaluate(miniAppPagePath, velocityContext); + WxMpSubscribeMessage.MiniProgram miniProgram = new WxMpSubscribeMessage.MiniProgram(miniAppId, miniAppPagePathEvaluated, false); + wxMessageTemplate.setMiniProgram(miniProgram); + + Map dataMap = new HashMap<>(10); + for (TemplateData templateData : templateDataList) { + dataMap.put(templateData.getName(), TemplateUtil.evaluate(templateData.getValue(), velocityContext)); + } + + wxMessageTemplate.setDataMap(dataMap); + + return wxMessageTemplate; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpTemplateMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpTemplateMsgMaker.java index d60037896..797595a4e 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpTemplateMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpTemplateMsgMaker.java @@ -1,14 +1,14 @@ package com.fangxuele.tool.push.logic.msgmaker; +import com.alibaba.fastjson.JSON; import com.fangxuele.tool.push.bean.TemplateData; -import com.fangxuele.tool.push.ui.form.msg.MpTemplateMsgForm; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgMpTemplate; import com.fangxuele.tool.push.util.TemplateUtil; import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; -import org.apache.commons.compress.utils.Lists; import org.apache.velocity.VelocityContext; -import javax.swing.table.DefaultTableModel; import java.util.List; /** @@ -21,45 +21,23 @@ */ public class WxMpTemplateMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String templateId; + private String templateId; - private static String templateUrl; + private String templateUrl; - private static String miniAppId; + private String miniAppId; - private static String miniAppPagePath; + private String miniAppPagePath; - public static List templateDataList; - - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - templateId = MpTemplateMsgForm.getInstance().getMsgTemplateIdTextField().getText().trim(); - templateUrl = MpTemplateMsgForm.getInstance().getMsgTemplateUrlTextField().getText().trim(); - miniAppId = MpTemplateMsgForm.getInstance().getMsgTemplateMiniAppidTextField().getText().trim(); - miniAppPagePath = MpTemplateMsgForm.getInstance().getMsgTemplateMiniPagePathTextField().getText().trim(); - - if (MpTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { - MpTemplateMsgForm.initTemplateDataTable(); - } - - DefaultTableModel tableModel = (DefaultTableModel) MpTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel(); - int rowCount = tableModel.getRowCount(); - TemplateData templateData; - templateDataList = Lists.newArrayList(); - for (int i = 0; i < rowCount; i++) { - String name = ((String) tableModel.getValueAt(i, 0)).trim(); - String value = ((String) tableModel.getValueAt(i, 1)).trim(); - String color = ((String) tableModel.getValueAt(i, 2)).trim(); - templateData = new TemplateData(); - templateData.setName(name); - templateData.setValue(value); - templateData.setColor(color); - templateDataList.add(templateData); - } + private List templateDataList; + public WxMpTemplateMsgMaker(TMsg tMsg) { + TMsgMpTemplate tMsgWxMpTemplate = JSON.parseObject(tMsg.getContent(), TMsgMpTemplate.class); + this.templateId = tMsgWxMpTemplate.getTemplateId(); + this.templateUrl = tMsgWxMpTemplate.getUrl(); + this.miniAppId = tMsgWxMpTemplate.getMaAppid(); + this.miniAppPagePath = tMsgWxMpTemplate.getMaPagePath(); + this.templateDataList = tMsgWxMpTemplate.getTemplateDataList(); } /** diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/YunPianMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/YunPianMsgMaker.java index b0eb45e2c..d120c4eae 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/YunPianMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/YunPianMsgMaker.java @@ -1,6 +1,8 @@ package com.fangxuele.tool.push.logic.msgmaker; -import com.fangxuele.tool.push.ui.form.msg.YunpianMsgForm; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgSms; import com.fangxuele.tool.push.util.TemplateUtil; import com.yunpian.sdk.YunpianClient; import org.apache.velocity.VelocityContext; @@ -18,14 +20,11 @@ */ public class YunPianMsgMaker extends BaseMsgMaker implements IMsgMaker { - public static String msgYunpianMsgContent; + private String msgYunpianMsgContent; - /** - * 准备(界面字段等) - */ - @Override - public void prepare() { - msgYunpianMsgContent = YunpianMsgForm.getInstance().getMsgYunpianMsgContentTextField().getText(); + public YunPianMsgMaker(TMsg tMsg) { + TMsgSms tMsgSms = JSON.parseObject(tMsg.getContent(), TMsgSms.class); + this.msgYunpianMsgContent = tMsgSms.getContent(); } /** diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/AliYunMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/AliYunMsgSender.java index a9f911038..f278cba22 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/AliYunMsgSender.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/AliYunMsgSender.java @@ -1,5 +1,6 @@ package com.fangxuele.tool.push.logic.msgsender; +import com.alibaba.fastjson.JSON; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; @@ -7,11 +8,19 @@ import com.aliyuncs.http.HttpClientConfig; import com.aliyuncs.profile.DefaultProfile; import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.PushControl; +import com.fangxuele.tool.push.bean.account.AliYunAccountConfig; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.logic.msgmaker.AliyunMsgMaker; +import com.fangxuele.tool.push.util.MybatisUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; +import java.util.HashMap; +import java.util.Map; + /** *
  * 阿里云模板短信发送器
@@ -25,13 +34,26 @@ public class AliYunMsgSender implements IMsgSender {
     /**
      * 阿里云短信client
      */
-    public volatile static IAcsClient iAcsClient;
+    private IAcsClient iAcsClient;
 
     private AliyunMsgMaker aliyunMsgMaker;
 
-    public AliYunMsgSender() {
-        aliyunMsgMaker = new AliyunMsgMaker();
-        iAcsClient = getAliyunIAcsClient();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private static Map acsClientMap = new HashMap<>();
+
+    public AliYunMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        aliyunMsgMaker = new AliyunMsgMaker(tMsg);
+        iAcsClient = getAliyunIAcsClient(tMsg.getAccountId());
+        this.dryRun = dryRun;
+    }
+
+    public static void removeAccount(Integer accountId) {
+        acsClientMap.remove(accountId);
     }
 
     @Override
@@ -42,7 +64,7 @@ public SendResult send(String[] msgData) {
             //初始化acsClient,暂不支持region化
             SendSmsRequest sendSmsRequest = aliyunMsgMaker.makeMsg(msgData);
             sendSmsRequest.setPhoneNumbers(msgData[0]);
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -68,32 +90,33 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    /**
-     * 获取阿里云短信发送客户端
-     *
-     * @return IAcsClient
-     */
-    private static IAcsClient getAliyunIAcsClient() {
-        if (iAcsClient == null) {
-            synchronized (AliYunMsgSender.class) {
-                if (iAcsClient == null) {
-                    String aliyunAccessKeyId = App.config.getAliyunAccessKeyId();
-                    String aliyunAccessKeySecret = App.config.getAliyunAccessKeySecret();
-
-                    // 创建DefaultAcsClient实例并初始化
-                    DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", aliyunAccessKeyId, aliyunAccessKeySecret);
-
-                    // 多个SDK client共享一个连接池,此处设置该连接池的参数,
-                    // 比如每个host的最大连接数,超时时间等
-                    HttpClientConfig clientConfig = HttpClientConfig.getDefault();
-                    clientConfig.setMaxRequestsPerHost(App.config.getMaxThreadPool());
-                    clientConfig.setConnectionTimeoutMillis(10000L);
-
-                    profile.setHttpClientConfig(clientConfig);
-                    iAcsClient = new DefaultAcsClient(profile);
-                }
-            }
+    private IAcsClient getAliyunIAcsClient(Integer accountId) {
+        if (acsClientMap.containsKey(accountId)) {
+            return acsClientMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            AliYunAccountConfig aliYunAccountConfig = JSON.parseObject(accountConfig, AliYunAccountConfig.class);
+
+            String aliyunAccessKeyId = aliYunAccountConfig.getAccessKeyId();
+            String aliyunAccessKeySecret = aliYunAccountConfig.getAccessKeySecret();
+
+            // 创建DefaultAcsClient实例并初始化
+            DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", aliyunAccessKeyId, aliyunAccessKeySecret);
+
+            // 多个SDK client共享一个连接池,此处设置该连接池的参数,
+            // 比如每个host的最大连接数,超时时间等
+            HttpClientConfig clientConfig = HttpClientConfig.getDefault();
+            clientConfig.setMaxRequestsPerHost(App.config.getMaxThreads());
+            clientConfig.setConnectionTimeoutMillis(10000L);
+
+            profile.setHttpClientConfig(clientConfig);
+            IAcsClient iAcsClient = new DefaultAcsClient(profile);
+
+            acsClientMap.put(accountId, iAcsClient);
+
+            return iAcsClient;
         }
-        return iAcsClient;
+
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/BdYunMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/BdYunMsgSender.java
index 47177b95b..0928ab5d2 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/BdYunMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/BdYunMsgSender.java
@@ -1,16 +1,22 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
+import com.alibaba.fastjson.JSON;
 import com.baidubce.auth.DefaultBceCredentials;
 import com.baidubce.services.sms.SmsClient;
 import com.baidubce.services.sms.SmsClientConfiguration;
 import com.baidubce.services.sms.model.SendMessageV2Request;
 import com.baidubce.services.sms.model.SendMessageV2Response;
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.fangxuele.tool.push.bean.account.BdYunAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.BdYunMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -27,29 +33,48 @@ public class BdYunMsgSender implements IMsgSender {
     /**
      * 百度云短信SmsClient
      */
-    public volatile static SmsClient smsClient;
+    private SmsClient smsClient;
 
     private BdYunMsgMaker bdYunMsgMaker;
 
-    public BdYunMsgSender() {
-        bdYunMsgMaker = new BdYunMsgMaker();
-        smsClient = getBdYunSmsClient();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private static Map smsClientMap = new HashMap<>();
+
+    private BdYunAccountConfig bdYunAccountConfig;
+
+    public BdYunMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        bdYunMsgMaker = new BdYunMsgMaker(tMsg);
+        smsClient = getBdYunSmsClient(tMsg.getAccountId());
+        this.dryRun = dryRun;
+
+        TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId());
+        String accountConfig = tAccount.getAccountConfig();
+        bdYunAccountConfig = JSON.parseObject(accountConfig, BdYunAccountConfig.class);
+    }
+
+    public static void removeAccount(Integer accountId) {
+        smsClientMap.remove(accountId);
     }
 
     @Override
     public SendResult send(String[] msgData) {
         SendResult sendResult = new SendResult();
         try {
-            String templateCode = BdYunMsgMaker.templateId;
+            String templateCode = bdYunMsgMaker.getTemplateId();
             Map params = bdYunMsgMaker.makeMsg(msgData);
             String phoneNumber = msgData[0];
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
                 // 定义请求参数
                 // 发送使用签名的调用ID
-                String invokeId = App.config.getBdInvokeId();
+                String invokeId = bdYunAccountConfig.getBdInvokeId();
 
                 //实例化请求对象
                 SendMessageV2Request request = new SendMessageV2Request();
@@ -82,32 +107,31 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    /**
-     * 获取百度云短信发送客户端
-     *
-     * @return SmsClient
-     */
-    private static SmsClient getBdYunSmsClient() {
-        if (smsClient == null) {
-            synchronized (BdYunMsgSender.class) {
-                if (smsClient == null) {
-                    // SMS服务域名,可根据环境选择具体域名
-                    String endPoint = App.config.getBdEndPoint();
-                    // 发送账号安全认证的Access Key ID
-                    String accessKeyId = App.config.getBdAccessKeyId();
-                    // 发送账号安全认证的Secret Access Key
-                    String secretAccessKy = App.config.getBdSecretAccessKey();
-
-                    // ak、sk等config
-                    SmsClientConfiguration config = new SmsClientConfiguration();
-                    config.setCredentials(new DefaultBceCredentials(accessKeyId, secretAccessKy));
-                    config.setEndpoint(endPoint);
-
-                    // 实例化发送客户端
-                    smsClient = new SmsClient(config);
-                }
-            }
+    private SmsClient getBdYunSmsClient(Integer accountId) {
+        if (smsClientMap.containsKey(accountId)) {
+            return smsClientMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            BdYunAccountConfig bdYunAccountConfig = JSON.parseObject(accountConfig, BdYunAccountConfig.class);
+
+            // SMS服务域名,可根据环境选择具体域名
+            String endPoint = bdYunAccountConfig.getBdEndPoint();
+            // 发送账号安全认证的Access Key ID
+            String accessKeyId = bdYunAccountConfig.getBdAccessKeyId();
+            // 发送账号安全认证的Secret Access Key
+            String secretAccessKy = bdYunAccountConfig.getBdSecretAccessKey();
+
+            // ak、sk等config
+            SmsClientConfiguration config = new SmsClientConfiguration();
+            config.setCredentials(new DefaultBceCredentials(accessKeyId, secretAccessKy));
+            config.setEndpoint(endPoint);
+
+            // 实例化发送客户端
+            SmsClient smsClient = new SmsClient(config);
+
+            smsClientMap.put(accountId, smsClient);
+            return smsClient;
         }
-        return smsClient;
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/DingMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/DingMsgSender.java
index a89f28fbd..a393d48ab 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/DingMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/DingMsgSender.java
@@ -2,6 +2,7 @@
 
 import cn.hutool.cache.CacheUtil;
 import cn.hutool.cache.impl.TimedCache;
+import com.alibaba.fastjson.JSON;
 import com.dingtalk.api.DefaultDingTalkClient;
 import com.dingtalk.api.DingTalkClient;
 import com.dingtalk.api.request.OapiGettokenRequest;
@@ -10,12 +11,14 @@
 import com.dingtalk.api.response.OapiGettokenResponse;
 import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
 import com.dingtalk.api.response.OapiRobotSendResponse;
-import com.fangxuele.tool.push.bean.DingMsg;
-import com.fangxuele.tool.push.dao.TDingAppMapper;
-import com.fangxuele.tool.push.domain.TDingApp;
+import com.fangxuele.tool.push.bean.account.DingAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
+import com.fangxuele.tool.push.domain.TMsgDing;
 import com.fangxuele.tool.push.logic.PushControl;
 import com.fangxuele.tool.push.logic.msgmaker.DingMsgMaker;
-import com.fangxuele.tool.push.ui.form.msg.DingMsgForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.taobao.api.ApiException;
 import lombok.extern.slf4j.Slf4j;
@@ -23,7 +26,9 @@
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 
@@ -35,21 +40,44 @@
  */
 @Slf4j
 public class DingMsgSender implements IMsgSender {
-    public volatile static DefaultDingTalkClient defaultDingTalkClient;
-    public volatile static DefaultDingTalkClient robotClient;
-    public static TimedCache accessTokenTimedCache;
+    private DefaultDingTalkClient defaultDingTalkClient;
+    private DefaultDingTalkClient robotClient;
+    private TimedCache accessTokenTimedCache;
     private DingMsgMaker dingMsgMaker;
 
-    private static TDingAppMapper dingAppMapper = MybatisUtil.getSqlSession().getMapper(TDingAppMapper.class);
+    private static Map> timedCacheMap = new HashMap<>();
 
-    public DingMsgSender() {
-        dingMsgMaker = new DingMsgMaker();
-        defaultDingTalkClient = getDefaultDingTalkClient();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private DingAccountConfig dingAccountConfig;
+
+    private TAccount tAccount;
+
+    private TMsgDing tMsgDing;
+
+    public DingMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        dingMsgMaker = new DingMsgMaker(tMsg);
+        accessTokenTimedCache = getAccessTokenTimedCache(tMsg.getAccountId());
+        this.dryRun = dryRun;
+
+        tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId());
+        String accountConfig = tAccount.getAccountConfig();
+        dingAccountConfig = JSON.parseObject(accountConfig, DingAccountConfig.class);
+
+        tMsgDing = JSON.parseObject(tMsg.getContent(), TMsgDing.class);
+    }
+
+    public static void removeAccount(Integer account1Id) {
+        timedCacheMap.remove(account1Id);
     }
 
     @Override
     public SendResult send(String[] msgData) {
-        if ("work".equals(DingMsgMaker.radioType)) {
+        if ("work".equals(tMsgDing.getRadioType())) {
             return sendWorkMsg(msgData);
         } else {
             return sendRobotMsg(msgData);
@@ -64,18 +92,19 @@ public SendResult sendWorkMsg(String[] msgData) {
 
             OapiMessageCorpconversationAsyncsendV2Request request2 = new OapiMessageCorpconversationAsyncsendV2Request();
             request2.setUseridList(userId);
-            request2.setAgentId(Long.valueOf(DingMsgMaker.agentId));
+            request2.setAgentId(Long.valueOf(dingAccountConfig.getAgentId()));
             request2.setToAllUser(false);
 
-            DingMsg dingMsg = dingMsgMaker.makeMsg(msgData);
+            TMsgDing dingMsg = dingMsgMaker.makeMsg(msgData);
             OapiMessageCorpconversationAsyncsendV2Request.Msg msg = getMsg(dingMsg);
             request2.setMsg(msg);
 
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
-                OapiMessageCorpconversationAsyncsendV2Response response2 = defaultDingTalkClient.execute(request2, getAccessTokenTimedCache().get("accessToken"));
+                DefaultDingTalkClient defaultDingTalkClient = getDefaultDingTalkClient();
+                OapiMessageCorpconversationAsyncsendV2Response response2 = defaultDingTalkClient.execute(request2, getAccessTokenTimedCache(tAccount.getId()).get("accessToken"));
                 if (response2.getErrcode() != 0) {
                     sendResult.setSuccess(false);
                     sendResult.setInfo(response2.getErrmsg());
@@ -100,8 +129,8 @@ public SendResult sendRobotMsg(String[] msgData) {
         try {
             DingTalkClient client = getRobotClient();
             OapiRobotSendRequest request2 = new OapiRobotSendRequest();
-            DingMsg dingMsg = dingMsgMaker.makeMsg(msgData);
-            if ("文本消息".equals(DingMsgMaker.msgType)) {
+            TMsgDing dingMsg = dingMsgMaker.makeMsg(msgData);
+            if ("文本消息".equals(tMsgDing.getDingMsgType())) {
                 request2.setMsgtype("text");
                 OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
                 text.setContent(dingMsg.getContent());
@@ -115,31 +144,31 @@ public SendResult sendRobotMsg(String[] msgData) {
                     at.setIsAtAll("true");
                 }
                 request2.setAt(at);
-            } else if ("链接消息".equals(DingMsgMaker.msgType)) {
+            } else if ("链接消息".equals(tMsgDing.getDingMsgType())) {
                 request2.setMsgtype("link");
                 OapiRobotSendRequest.Link link = new OapiRobotSendRequest.Link();
                 link.setMessageUrl(dingMsg.getUrl());
                 link.setPicUrl(dingMsg.getPicUrl());
-                link.setTitle(dingMsg.getTitle());
+                link.setTitle(dingMsg.getMsgTitle());
                 link.setText(dingMsg.getContent());
                 request2.setLink(link);
-            } else if ("markdown消息".equals(DingMsgMaker.msgType)) {
+            } else if ("markdown消息".equals(tMsgDing.getDingMsgType())) {
                 request2.setMsgtype("markdown");
                 OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
-                markdown.setTitle(dingMsg.getTitle());
+                markdown.setTitle(dingMsg.getMsgTitle());
                 markdown.setText(dingMsg.getContent());
                 request2.setMarkdown(markdown);
-            } else if ("卡片消息".equals(DingMsgMaker.msgType)) {
+            } else if ("卡片消息".equals(tMsgDing.getDingMsgType())) {
                 request2.setMsgtype("actionCard");
                 OapiRobotSendRequest.Actioncard actionCard = new OapiRobotSendRequest.Actioncard();
-                actionCard.setTitle(dingMsg.getTitle());
+                actionCard.setTitle(dingMsg.getMsgTitle());
                 actionCard.setText(dingMsg.getContent());
                 actionCard.setSingleTitle(dingMsg.getBtnTxt());
                 actionCard.setSingleURL(dingMsg.getBtnUrl());
                 request2.setActionCard(actionCard);
             }
 
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -162,28 +191,28 @@ public SendResult sendRobotMsg(String[] msgData) {
         return sendResult;
     }
 
-    private OapiMessageCorpconversationAsyncsendV2Request.Msg getMsg(DingMsg dingMsg) {
+    private OapiMessageCorpconversationAsyncsendV2Request.Msg getMsg(TMsgDing dingMsg) {
         OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
-        if ("文本消息".equals(DingMsgMaker.msgType)) {
+        if ("文本消息".equals(tMsgDing.getDingMsgType())) {
             msg.setMsgtype("text");
             msg.setText(new OapiMessageCorpconversationAsyncsendV2Request.Text());
             msg.getText().setContent(dingMsg.getContent());
-        } else if ("链接消息".equals(DingMsgMaker.msgType)) {
+        } else if ("链接消息".equals(tMsgDing.getDingMsgType())) {
             msg.setMsgtype("link");
             msg.setLink(new OapiMessageCorpconversationAsyncsendV2Request.Link());
-            msg.getLink().setTitle(dingMsg.getTitle());
+            msg.getLink().setTitle(dingMsg.getMsgTitle());
             msg.getLink().setText(dingMsg.getContent());
             msg.getLink().setMessageUrl(dingMsg.getUrl());
             msg.getLink().setPicUrl(dingMsg.getPicUrl());
-        } else if ("markdown消息".equals(DingMsgMaker.msgType)) {
+        } else if ("markdown消息".equals(tMsgDing.getDingMsgType())) {
             msg.setMsgtype("markdown");
             msg.setMarkdown(new OapiMessageCorpconversationAsyncsendV2Request.Markdown());
             msg.getMarkdown().setText(dingMsg.getContent());
-            msg.getMarkdown().setTitle(dingMsg.getTitle());
-        } else if ("卡片消息".equals(DingMsgMaker.msgType)) {
+            msg.getMarkdown().setTitle(dingMsg.getMsgTitle());
+        } else if ("卡片消息".equals(tMsgDing.getDingMsgType())) {
             msg.setMsgtype("action_card");
             msg.setActionCard(new OapiMessageCorpconversationAsyncsendV2Request.ActionCard());
-            msg.getActionCard().setTitle(dingMsg.getTitle());
+            msg.getActionCard().setTitle(dingMsg.getMsgTitle());
             msg.getActionCard().setMarkdown(dingMsg.getContent());
             msg.getActionCard().setSingleTitle(dingMsg.getBtnTxt());
             msg.getActionCard().setSingleUrl(dingMsg.getBtnUrl());
@@ -196,7 +225,7 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    public static DefaultDingTalkClient getDefaultDingTalkClient() {
+    public DefaultDingTalkClient getDefaultDingTalkClient() {
         if (defaultDingTalkClient == null) {
             synchronized (PushControl.class) {
                 if (defaultDingTalkClient == null) {
@@ -207,39 +236,42 @@ public static DefaultDingTalkClient getDefaultDingTalkClient() {
         return defaultDingTalkClient;
     }
 
-    public static DefaultDingTalkClient getRobotClient() {
+    public DefaultDingTalkClient getRobotClient() {
         if (robotClient == null) {
             synchronized (PushControl.class) {
                 if (robotClient == null) {
-                    robotClient = new DefaultDingTalkClient(DingMsgMaker.webHook);
+                    robotClient = new DefaultDingTalkClient(tMsgDing.getWebHook());
                 }
             }
         }
         return robotClient;
     }
 
-    public static TimedCache getAccessTokenTimedCache() {
-        if (accessTokenTimedCache == null || StringUtils.isEmpty(accessTokenTimedCache.get("accessToken"))) {
-            synchronized (PushControl.class) {
-                if (accessTokenTimedCache == null || StringUtils.isEmpty(accessTokenTimedCache.get("accessToken"))) {
-                    DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
-                    OapiGettokenRequest request = new OapiGettokenRequest();
-                    String agentId = DingMsgForm.appNameToAgentIdMap.get(DingMsgForm.getInstance().getAppNameComboBox().getSelectedItem());
-                    TDingApp tDingApp = dingAppMapper.selectByAgentId(agentId);
-                    request.setAppkey(tDingApp.getAppKey());
-                    request.setAppsecret(tDingApp.getAppSecret());
-                    request.setHttpMethod("GET");
-                    OapiGettokenResponse response = null;
-                    try {
-                        response = client.execute(request);
-                    } catch (ApiException e) {
-                        e.printStackTrace();
-                    }
-                    accessTokenTimedCache = CacheUtil.newTimedCache((response.getExpiresIn() - 60) * 1000);
-                    accessTokenTimedCache.put("accessToken", response.getAccessToken());
-                }
+    public static TimedCache getAccessTokenTimedCache(Integer accountId) {
+        if (timedCacheMap.containsKey(accountId)) {
+            return timedCacheMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            DingAccountConfig dingAccountConfig = JSON.parseObject(accountConfig, DingAccountConfig.class);
+
+            DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
+            OapiGettokenRequest request = new OapiGettokenRequest();
+            request.setAppkey(dingAccountConfig.getAppKey());
+            request.setAppsecret(dingAccountConfig.getAppSecret());
+            request.setHttpMethod("GET");
+            OapiGettokenResponse response = null;
+            try {
+                response = client.execute(request);
+            } catch (ApiException e) {
+                e.printStackTrace();
             }
+            TimedCache accessTokenTimedCache = CacheUtil.newTimedCache((response.getExpiresIn() - 60) * 1000);
+            accessTokenTimedCache.put("accessToken", response.getAccessToken());
+
+            timedCacheMap.put(accountId, accessTokenTimedCache);
+            return accessTokenTimedCache;
         }
-        return accessTokenTimedCache;
+
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/HttpMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/HttpMsgSender.java
index 256f54c06..6a47a8468 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/HttpMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/HttpMsgSender.java
@@ -6,25 +6,25 @@
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.bean.HttpMsg;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.fangxuele.tool.push.bean.account.HttpAccountConfig;
+import com.fangxuele.tool.push.bean.msg.HttpMsg;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.HttpMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
-import okhttp3.ConnectionPool;
-import okhttp3.FormBody;
-import okhttp3.HttpUrl;
-import okhttp3.MediaType;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import okhttp3.Response;
+import okhttp3.*;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
 import java.net.HttpCookie;
 import java.net.InetSocketAddress;
 import java.net.Proxy;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -42,13 +42,28 @@ public class HttpMsgSender implements IMsgSender {
 
     private HttpMsgMaker httpMsgMaker;
 
-    public volatile static OkHttpClient okHttpClient;
+    private static OkHttpClient okHttpClient;
+    private static Map okHttpClientMap = new HashMap<>();
 
-    public volatile static Proxy proxy;
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
-    public HttpMsgSender() {
-        httpMsgMaker = new HttpMsgMaker();
-        okHttpClient = getOkHttpClient();
+    private Integer dryRun;
+
+    private HttpAccountConfig httpAccountConfig;
+
+    public HttpMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        httpMsgMaker = new HttpMsgMaker(tMsg);
+        okHttpClient = getOkHttpClient(tMsg.getAccountId());
+        TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId());
+        String accountConfig = tAccount.getAccountConfig();
+        httpAccountConfig = JSON.parseObject(accountConfig, HttpAccountConfig.class);
+        this.dryRun = dryRun;
+    }
+
+    public static void removeAccount(Integer tAccount1Id) {
+        okHttpClientMap.remove(tAccount1Id);
     }
 
     @Override
@@ -67,7 +82,7 @@ public HttpSendResult sendUseHutool(String[] msgData) {
         try {
             HttpMsg httpMsg = httpMsgMaker.makeMsg(msgData);
             HttpRequest httpRequest;
-            switch (HttpMsgMaker.method) {
+            switch (httpMsgMaker.getMethod()) {
                 case "GET":
                     httpRequest = HttpRequest.get(httpMsg.getUrl());
                     break;
@@ -107,11 +122,12 @@ public HttpSendResult sendUseHutool(String[] msgData) {
             if (StringUtils.isNotEmpty(httpMsg.getBody())) {
                 httpRequest.body(httpMsg.getBody());
             }
-            if (App.config.isHttpUseProxy()) {
-                httpRequest.setProxy(getProxy());
+            if (httpAccountConfig.isUseProxy()) {
+                Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(httpAccountConfig.getProxyHost(), Integer.parseInt(httpAccountConfig.getProxyPort())));
+                httpRequest.setProxy(proxy);
             }
 
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -167,14 +183,14 @@ public HttpSendResult sendUseOkHttp(String[] msgData) {
             Request.Builder requestBuilder = new Request.Builder();
 
             RequestBody requestBody = RequestBody.create("", MediaType.get("text/plain"));
-            if (!"GET".equals(HttpMsgMaker.method) && httpMsg.getParamMap() != null && !httpMsg.getParamMap().isEmpty()) {
+            if (!"GET".equals(httpMsgMaker.getMethod()) && httpMsg.getParamMap() != null && !httpMsg.getParamMap().isEmpty()) {
                 FormBody.Builder formBodyBuilder = new FormBody.Builder();
                 for (Map.Entry paramEntry : httpMsg.getParamMap().entrySet()) {
                     formBodyBuilder.add(paramEntry.getKey(), (String) paramEntry.getValue());
                 }
                 requestBody = formBodyBuilder.build();
-            } else if (!"GET".equals(HttpMsgMaker.method) && StringUtils.isNotEmpty(httpMsg.getBody())) {
-                String bodyType = HttpMsgMaker.bodyType;
+            } else if (!"GET".equals(httpMsgMaker.getMethod()) && StringUtils.isNotEmpty(httpMsg.getBody())) {
+                String bodyType = httpMsgMaker.getBodyType();
                 MediaType mediaType = MediaType.get(bodyType + "; charset=utf-8");
                 requestBody = RequestBody.create(httpMsg.getBody(), mediaType);
             }
@@ -187,7 +203,7 @@ public HttpSendResult sendUseOkHttp(String[] msgData) {
             if (httpMsg.getCookies() != null && !httpMsg.getCookies().isEmpty()) {
                 requestBuilder.addHeader(Header.COOKIE.toString(), cookieHeader(httpMsg.getCookies()));
             }
-            switch (HttpMsgMaker.method) {
+            switch (httpMsgMaker.getMethod()) {
                 case "GET":
                     HttpUrl.Builder urlBuilder = HttpUrl.parse(httpMsg.getUrl()).newBuilder();
                     if (httpMsg.getParamMap() != null && !httpMsg.getParamMap().isEmpty()) {
@@ -220,7 +236,7 @@ public HttpSendResult sendUseOkHttp(String[] msgData) {
 
             Request request = requestBuilder.build();
 
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -278,28 +294,14 @@ private String cookieHeader(List cookies) {
         return cookieHeader.toString();
     }
 
-    private static Proxy getProxy() {
-        if (proxy == null) {
-            synchronized (HttpMsgSender.class) {
-                if (proxy == null) {
-                    proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(App.config.getHttpProxyHost(), Integer.parseInt(App.config.getHttpProxyPort())));
-                }
-            }
-        }
-        return proxy;
-    }
-
     public static OkHttpClient getOkHttpClient() {
         if (okHttpClient == null) {
             synchronized (HttpMsgSender.class) {
                 if (okHttpClient == null) {
                     OkHttpClient.Builder builder = new OkHttpClient.Builder();
                     builder.connectTimeout(3, TimeUnit.MINUTES);
-                    if (App.config.isHttpUseProxy()) {
-                        builder.proxy(getProxy());
-                    }
 
-                    ConnectionPool pool = new ConnectionPool(App.config.getThreadCount(), 10, TimeUnit.MINUTES);
+                    ConnectionPool pool = new ConnectionPool(App.config.getMaxThreads(), 10, TimeUnit.MINUTES);
                     builder.connectionPool(pool);
                     okHttpClient = builder.build();
                 }
@@ -307,4 +309,28 @@ public static OkHttpClient getOkHttpClient() {
         }
         return okHttpClient;
     }
+
+    private OkHttpClient getOkHttpClient(Integer accountId) {
+        if (okHttpClientMap.containsKey(accountId)) {
+            return okHttpClientMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            HttpAccountConfig httpAccountConfig = JSON.parseObject(accountConfig, HttpAccountConfig.class);
+            OkHttpClient.Builder builder = new OkHttpClient.Builder();
+            builder.connectTimeout(3, TimeUnit.MINUTES);
+            if (httpAccountConfig.isUseProxy()) {
+                Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(httpAccountConfig.getProxyHost(), Integer.parseInt(httpAccountConfig.getProxyPort())));
+                builder.proxy(proxy);
+            }
+
+            ConnectionPool pool = new ConnectionPool(App.config.getMaxThreads(), 10, TimeUnit.MINUTES);
+            builder.connectionPool(pool);
+            OkHttpClient okHttpClient = builder.build();
+
+            okHttpClientMap.put(accountId, okHttpClient);
+            return okHttpClient;
+        }
+
+    }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/HwYunMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/HwYunMsgSender.java
index af3a477e8..1a839785e 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/HwYunMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/HwYunMsgSender.java
@@ -1,9 +1,14 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
 import cn.hutool.json.JSONUtil;
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.account.HwYunAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.HwYunMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Hex;
 import org.apache.commons.codec.digest.DigestUtils;
@@ -25,11 +30,7 @@
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * 
@@ -45,7 +46,7 @@ public class HwYunMsgSender implements IMsgSender {
     /**
      * CloseableHttpClient
      */
-    public volatile static CloseableHttpClient closeableHttpClient;
+    private CloseableHttpClient closeableHttpClient;
 
     /**
      * 无需修改,用于格式化鉴权头域,给"X-WSSE"参数赋值
@@ -58,30 +59,49 @@ public class HwYunMsgSender implements IMsgSender {
 
     private HwYunMsgMaker hwYunMsgMaker;
 
-    public HwYunMsgSender() {
-        hwYunMsgMaker = new HwYunMsgMaker();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private HwYunAccountConfig hwYunAccountConfig;
+
+    public HwYunMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        hwYunMsgMaker = new HwYunMsgMaker(tMsg);
+        this.dryRun = dryRun;
+
+        TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId());
+        String accountConfig = tAccount.getAccountConfig();
+        hwYunAccountConfig = JSON.parseObject(accountConfig, HwYunAccountConfig.class);
+
         closeableHttpClient = getHttpClient();
     }
 
+    public static void removeAccount(Integer account1Id) {
+
+        // do nothing
+    }
+
     @Override
     public SendResult send(String[] msgData) {
         SendResult sendResult = new SendResult();
         try {
             //APP接入地址+接口访问URI
-            String url = App.config.getHwAccessUrl();
+            String url = hwYunAccountConfig.getAccessUrl();
             //APP_Key
-            String appKey = App.config.getHwAppKey();
+            String appKey = hwYunAccountConfig.getAppKey();
             //APP_Secret
-            String appSecret = App.config.getHwAppSecretPassword();
+            String appSecret = hwYunAccountConfig.getAppSecret();
             //国内短信签名通道号或国际/港澳台短信通道号
-            String sender = App.config.getHwSenderCode();
-            String signature = App.config.getHwSignature();
+            String sender = hwYunAccountConfig.getSenderCode();
+            String signature = hwYunAccountConfig.getSignature();
             //模板ID
-            String templateId = HwYunMsgMaker.templateId;
+            String templateId = hwYunMsgMaker.getTemplateId();
             //模板变量
             String templateParas = JSONUtil.toJsonStr(hwYunMsgMaker.makeMsg(msgData));
             String receiver = msgData[0];
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -138,7 +158,7 @@ public SendResult asyncSend(String[] msgData) {
      *
      * @return CloseableHttpClient
      */
-    private static CloseableHttpClient getHttpClient() {
+    private CloseableHttpClient getHttpClient() {
         if (closeableHttpClient == null) {
             synchronized (HwYunMsgSender.class) {
                 if (closeableHttpClient == null) {
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/MailMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/MailMsgSender.java
index 7d646d070..71ff208f6 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/MailMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/MailMsgSender.java
@@ -1,19 +1,27 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.extra.mail.MailAccount;
 import cn.hutool.extra.mail.MailUtil;
+import com.alibaba.fastjson.JSON;
 import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.bean.MailMsg;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.fangxuele.tool.push.bean.account.EmailAccountConfig;
+import com.fangxuele.tool.push.bean.msg.MailMsg;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.MailMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
 import java.io.File;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 
@@ -26,13 +34,29 @@
 @Slf4j
 public class MailMsgSender implements IMsgSender {
 
-    public volatile static MailAccount mailAccount;
-
     private MailMsgMaker mailMsgMaker;
 
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private static Map mailAccountMap = new HashMap<>();
+
+    private MailAccount mailAccount;
+
     public MailMsgSender() {
-        mailMsgMaker = new MailMsgMaker();
-        mailAccount = getMailAccount();
+    }
+
+    public MailMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        mailMsgMaker = new MailMsgMaker(tMsg);
+        mailAccount = getMailAccount(tMsg.getAccountId());
+        this.dryRun = dryRun;
+    }
+
+    public static void removeAccount(Integer account1Id) {
+        mailAccountMap.remove(account1Id);
     }
 
     @Override
@@ -43,7 +67,7 @@ public SendResult send(String[] msgData) {
             MailMsg mailMsg = mailMsgMaker.makeMsg(msgData);
             List tos = Lists.newArrayList();
             tos.add(msgData[0]);
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -52,10 +76,10 @@ public SendResult send(String[] msgData) {
                     ccList = Lists.newArrayList();
                     ccList.add(mailMsg.getMailCc());
                 }
-                if (StringUtils.isEmpty(mailMsg.getMailFiles())) {
+                if (CollectionUtils.isEmpty(mailMsg.getMailFiles())) {
                     MailUtil.send(mailAccount, tos, ccList, null, mailMsg.getMailTitle(), mailMsg.getMailContent(), true);
                 } else {
-                    MailUtil.send(mailAccount, tos, ccList, null, mailMsg.getMailTitle(), mailMsg.getMailContent(), true, FileUtil.file(mailMsg.getMailFiles()));
+                    MailUtil.send(mailAccount, tos, ccList, null, mailMsg.getMailTitle(), mailMsg.getMailContent(), true, mailMsg.getMailFiles().toArray(new File[0]));
                 }
                 sendResult.setSuccess(true);
             }
@@ -73,22 +97,6 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    public SendResult sendTestMail(String tos) {
-        SendResult sendResult = new SendResult();
-
-        try {
-            MailUtil.send(mailAccount, tos, "这是一封来自WePush的测试邮件",
-                    "

恭喜,配置正确,邮件发送成功!

来自WePush,一款专注于批量推送的小而美的工具。

", true); - sendResult.setSuccess(true); - } catch (Exception e) { - sendResult.setSuccess(false); - sendResult.setInfo(e.getMessage()); - log.error(e.toString()); - } - - return sendResult; - } - /** * 发送推送结果 * @@ -99,7 +107,7 @@ public SendResult sendPushResultMail(List tos, String title, String cont SendResult sendResult = new SendResult(); try { - MailUtil.send(mailAccount, tos, title, content, true, files); + MailUtil.send(getMailAccount(), tos, title, content, true, files); sendResult.setSuccess(true); } catch (Exception e) { sendResult.setSuccess(false); @@ -115,7 +123,7 @@ public SendResult sendPushResultMail(List tos, String title, String cont * * @return MailAccount */ - private static MailAccount getMailAccount() { + private MailAccount getMailAccount() { if (mailAccount == null) { synchronized (MailMsgSender.class) { if (mailAccount == null) { @@ -133,10 +141,59 @@ private static MailAccount getMailAccount() { mailAccount.setUser(mailUser); mailAccount.setPass(mailPassword); mailAccount.setSslEnable(App.config.isMailUseSSL()); - mailAccount.setStartttlsEnable(App.config.isMailUseStartTLS()); + mailAccount.setStarttlsEnable(App.config.isMailUseStartTLS()); } } } return mailAccount; } + + private MailAccount getMailAccount(Integer accountId) { + if (mailAccountMap.containsKey(accountId)) { + return mailAccountMap.get(accountId); + } else { + TAccount tAccount = accountMapper.selectByPrimaryKey(accountId); + String accountConfig = tAccount.getAccountConfig(); + EmailAccountConfig emailAccountConfig = JSON.parseObject(accountConfig, EmailAccountConfig.class); + + MailAccount mailAccount = new MailAccount(); + mailAccount.setHost(emailAccountConfig.getMailHost()); + mailAccount.setPort(Integer.valueOf(emailAccountConfig.getMailPort())); + mailAccount.setAuth(true); + mailAccount.setFrom(emailAccountConfig.getMailFrom()); + mailAccount.setUser(emailAccountConfig.getMailUser()); + mailAccount.setPass(emailAccountConfig.getMailPassword()); + mailAccount.setSslEnable(emailAccountConfig.isMailSSL()); + mailAccount.setStarttlsEnable(emailAccountConfig.isMailStartTLS()); + + mailAccountMap.put(accountId, mailAccount); + return mailAccount; + } + } + + public SendResult sendTestMail(EmailAccountConfig emailAccountConfig, String tos) { + SendResult sendResult = new SendResult(); + + try { + MailAccount mailAccount = new MailAccount(); + mailAccount.setHost(emailAccountConfig.getMailHost()); + mailAccount.setPort(Integer.valueOf(emailAccountConfig.getMailPort())); + mailAccount.setAuth(true); + mailAccount.setFrom(emailAccountConfig.getMailFrom()); + mailAccount.setUser(emailAccountConfig.getMailUser()); + mailAccount.setPass(emailAccountConfig.getMailPassword()); + mailAccount.setSslEnable(emailAccountConfig.isMailSSL()); + mailAccount.setStarttlsEnable(emailAccountConfig.isMailStartTLS()); + + MailUtil.send(mailAccount, tos, "这是一封来自WePush的测试邮件", + "

恭喜,配置正确,邮件发送成功!

来自WePush,一款专注于批量推送的小而美的工具。

", true); + sendResult.setSuccess(true); + } catch (Exception e) { + sendResult.setSuccess(false); + sendResult.setInfo(e.getMessage()); + log.error(e.toString()); + } + + return sendResult; + } } diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java index f4a2ebbf2..ac95b7fe1 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java @@ -1,7 +1,9 @@ package com.fangxuele.tool.push.logic.msgsender; -import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.logic.MessageTypeEnum; +import com.fangxuele.tool.push.util.MybatisUtil; /** *
@@ -13,64 +15,65 @@
  */
 public class MsgSenderFactory {
 
-    /**
-     * 根据消息类型获取对应的消息发送器
-     *
-     * @return IMsgSender
-     */
-    public static IMsgSender getMsgSender() {
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    public static IMsgSender getMsgSender(Integer msgId, Integer dryRun) {
         IMsgSender iMsgSender = null;
-        switch (App.config.getMsgType()) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        switch (tMsg.getMsgType()) {
             case MessageTypeEnum.MP_TEMPLATE_CODE:
-                iMsgSender = new WxMpTemplateMsgSender();
-                break;
-            case MessageTypeEnum.MA_TEMPLATE_CODE:
-                iMsgSender = new WxMaTemplateMsgSender();
+                iMsgSender = new WxMpTemplateMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.MA_SUBSCRIBE_CODE:
-                iMsgSender = new WxMaSubscribeMsgSender();
+                iMsgSender = new WxMaSubscribeMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.KEFU_CODE:
-                iMsgSender = new WxKefuMsgSender();
+                iMsgSender = new WxKefuMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.KEFU_PRIORITY_CODE:
-                iMsgSender = new WxKefuPriorMsgSender();
+                iMsgSender = new WxKefuPriorMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE:
-                iMsgSender = new WxUniformMsgSender();
+                iMsgSender = new WxUniformMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.ALI_YUN_CODE:
-                iMsgSender = new AliYunMsgSender();
+                iMsgSender = new AliYunMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.TX_YUN_CODE:
-                iMsgSender = new TxYunMsgSender();
+                iMsgSender = new TxYunMsgSender(msgId, dryRun);
+                break;
+            case MessageTypeEnum.TX_YUN_3_CODE:
+                iMsgSender = new TxYun3MsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.HW_YUN_CODE:
-                iMsgSender = new HwYunMsgSender();
+                iMsgSender = new HwYunMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.YUN_PIAN_CODE:
-                iMsgSender = new YunPianMsgSender();
+                iMsgSender = new YunPianMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.EMAIL_CODE:
-                iMsgSender = new MailMsgSender();
+                iMsgSender = new MailMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.WX_CP_CODE:
-                iMsgSender = new WxCpMsgSender();
+                iMsgSender = new WxCpMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.HTTP_CODE:
-                iMsgSender = new HttpMsgSender();
+                iMsgSender = new HttpMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.DING_CODE:
-                iMsgSender = new DingMsgSender();
+                iMsgSender = new DingMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.BD_YUN_CODE:
-                iMsgSender = new BdYunMsgSender();
+                iMsgSender = new BdYunMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.UP_YUN_CODE:
-                iMsgSender = new UpYunMsgSender();
+                iMsgSender = new UpYunMsgSender(msgId, dryRun);
                 break;
             case MessageTypeEnum.QI_NIU_YUN_CODE:
-                iMsgSender = new QiNiuYunMsgSender();
+                iMsgSender = new QiNiuYunMsgSender(msgId, dryRun);
+                break;
+            case MessageTypeEnum.MP_SUBSCRIBE_CODE:
+                iMsgSender = new WxMpSubscribeMsgSender(msgId, dryRun);
                 break;
             default:
                 break;
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/QiNiuYunMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/QiNiuYunMsgSender.java
index 5da5b0e2b..9428c8ed1 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/QiNiuYunMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/QiNiuYunMsgSender.java
@@ -1,14 +1,20 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.account.QiniuYunAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.QiNiuYunMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import com.qiniu.http.Response;
 import com.qiniu.sms.SmsManager;
 import com.qiniu.util.Auth;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -25,24 +31,37 @@ public class QiNiuYunMsgSender implements IMsgSender {
     /**
      * 七牛云短信smsManager
      */
-    public volatile static SmsManager smsManager;
+    private SmsManager smsManager;
 
     private QiNiuYunMsgMaker qiNiuYunMsgMaker;
 
-    public QiNiuYunMsgSender() {
-        qiNiuYunMsgMaker = new QiNiuYunMsgMaker();
-        smsManager = getSmsManager();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private static Map smsManagerMap = new HashMap<>();
+
+    public QiNiuYunMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        qiNiuYunMsgMaker = new QiNiuYunMsgMaker(tMsg);
+        smsManager = getSmsManager(tMsg.getAccountId());
+        this.dryRun = dryRun;
+    }
+
+    public static void removeAccount(Integer account1Id) {
+        smsManagerMap.remove(account1Id);
     }
 
     @Override
     public SendResult send(String[] msgData) {
         SendResult sendResult = new SendResult();
         try {
-            String templateId = QiNiuYunMsgMaker.templateId;
+            String templateId = qiNiuYunMsgMaker.getTemplateId();
             Map params = qiNiuYunMsgMaker.makeMsg(msgData);
             String telNum = msgData[0];
 
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -69,24 +88,24 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    /**
-     * 获取七牛云短信发送客户端
-     *
-     * @return SmsSingleSender
-     */
-    private static SmsManager getSmsManager() {
-        if (smsManager == null) {
-            synchronized (QiNiuYunMsgSender.class) {
-                if (smsManager == null) {
-                    // 设置需要操作的账号的AK和SK
-                    String qiniuAccessKey = App.config.getQiniuAccessKey();
-                    String qiniuSecretKey = App.config.getQiniuSecretKey();
-                    Auth auth = Auth.create(qiniuAccessKey, qiniuSecretKey);
-
-                    smsManager = new SmsManager(auth);
-                }
-            }
+    private SmsManager getSmsManager(Integer accountId) {
+        if (smsManagerMap.containsKey(accountId)) {
+            return smsManagerMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            QiniuYunAccountConfig qiniuYunAccountConfig = JSON.parseObject(accountConfig, QiniuYunAccountConfig.class);
+
+            // 设置需要操作的账号的AK和SK
+            String qiniuAccessKey = qiniuYunAccountConfig.getAccessKey();
+            String qiniuSecretKey = qiniuYunAccountConfig.getSecretKey();
+            Auth auth = Auth.create(qiniuAccessKey, qiniuSecretKey);
+
+            SmsManager smsManager = new SmsManager(auth);
+
+            smsManagerMap.put(accountId, smsManager);
+            return smsManager;
         }
-        return smsManager;
+
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/TxYun3MsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/TxYun3MsgSender.java
new file mode 100644
index 000000000..4cf9829bf
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/TxYun3MsgSender.java
@@ -0,0 +1,193 @@
+package com.fangxuele.tool.push.logic.msgsender;
+
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.account.TxYun3AccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
+import com.fangxuele.tool.push.logic.msgmaker.TxYun3MsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ * 腾讯云3.0模板短信发送器
+ * 
+ * + * @author RememBerBer + * @since 2023/9/4. + */ +@Slf4j +public class TxYun3MsgSender implements IMsgSender { + /** + * 腾讯云短信sender + */ + private SmsClient smsClient; + + private TxYun3MsgMaker txYun3MsgMaker; + + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + private Integer dryRun; + + private static Map smsClientMap = new HashMap<>(); + + private TxYun3AccountConfig txYun3AccountConfig; + + + public TxYun3MsgSender(Integer msgId, Integer dryRun) { + TMsg tMsg = msgMapper.selectByPrimaryKey(msgId); + txYun3MsgMaker = new TxYun3MsgMaker(tMsg); + smsClient = getTxYunSender(tMsg.getAccountId()); + this.dryRun = dryRun; + + TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId()); + String accountConfig = tAccount.getAccountConfig(); + txYun3AccountConfig = JSON.parseObject(accountConfig, TxYun3AccountConfig.class); + } + + public static void removeAccount(Integer account1Id) { + smsClientMap.remove(account1Id); + } + + @Override + public SendResult send(String[] msgData) { + SendResult sendResult = new SendResult(); + try { + String templateId = txYun3MsgMaker.getTemplateId(); + String smsSign = txYun3AccountConfig.getSign(); + String[] params = txYun3MsgMaker.makeMsg(msgData); + String telNum = msgData[0]; + if (dryRun == 1) { + sendResult.setSuccess(true); + return sendResult; + } else { + SendSmsRequest req = new SendSmsRequest(); + + /* 填充请求参数,这里request对象的成员变量即对应接口的入参 + * 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义 + * 基本类型的设置: + * 帮助链接: + * 短信控制台: https://console.cloud.tencent.com/smsv2 + * 腾讯云短信小助手: https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81 */ + + /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */ + // 应用 ID 可前往 [短信控制台](https://console.cloud.tencent.com/smsv2/app-manage) 查看 + String sdkAppId = txYun3AccountConfig.getSdkAppId(); + req.setSmsSdkAppId(sdkAppId); + + /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名 */ + // 签名信息可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-sign) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-sign) 的签名管理查看 + req.setSignName(smsSign); + + /* 模板 ID: 必须填写已审核通过的模板 ID */ + // 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看 + req.setTemplateId(templateId); + + /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */ + String[] templateParamSet = params; + req.setTemplateParamSet(templateParamSet); + + /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号] + * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号 */ + String[] phoneNumberSet = {telNum}; + req.setPhoneNumberSet(phoneNumberSet); + + /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */ +// String sessionContext = ""; +// req.setSessionContext(sessionContext); + + /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */ +// String extendCode = ""; +// req.setExtendCode(extendCode); + + /* 国内短信无需填写该项;国际/港澳台短信已申请独立 SenderId 需要填写该字段,默认使用公共 SenderId,无需填写该字段。注:月度使用量达到指定量级可申请独立 SenderId 使用,详情请联系 [腾讯云短信小助手](https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81)。*/ +// String senderid = ""; +// req.setSenderId(senderid); + + /* 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的 + * 返回的 res 是一个 SendSmsResponse 类的实例,与请求对象对应 */ + SendSmsResponse res = smsClient.SendSms(req); + + if (res.getSendStatusSet()[0].getCode().equals("Ok")) { + sendResult.setSuccess(true); + } else { + sendResult.setSuccess(false); + sendResult.setInfo(JSONUtil.toJsonStr(res)); + } + } + } catch (Exception e) { + sendResult.setSuccess(false); + sendResult.setInfo(e.getMessage()); + log.error(ExceptionUtils.getStackTrace(e)); + } + + return sendResult; + } + + @Override + public SendResult asyncSend(String[] msgData) { + return null; + } + + public SmsClient getTxYunSender(Integer accountId) { + if (smsClientMap.containsKey(accountId)) { + return smsClientMap.get(accountId); + } else { + TAccount tAccount = accountMapper.selectByPrimaryKey(accountId); + String accountConfig = tAccount.getAccountConfig(); + TxYun3AccountConfig txYun3AccountConfig = JSON.parseObject(accountConfig, TxYun3AccountConfig.class); + + /* 必要步骤: + * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。 + * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。 + * 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人, + * 以免泄露密钥对危及你的财产安全。 + * SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi */ + Credential cred = new Credential(txYun3AccountConfig.getSecretId(), txYun3AccountConfig.getSecretKey()); + + + // 实例化一个http选项,可选,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + // 设置代理(无需要直接忽略) + // httpProfile.setProxyHost("真实代理ip"); + // httpProfile.setProxyPort(真实代理端口); + /* SDK默认使用POST方法。 + * 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求 */ + httpProfile.setReqMethod("POST"); + /* SDK有默认的超时时间,非必要请不要进行调整 + * 如有需要请在代码中查阅以获取最新的默认值 */ +// httpProfile.setConnTimeout(60); + /* 指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com ,也支持指定地域域名访问,例如广州地域的域名为 sms.ap-guangzhou.tencentcloudapi.com */ + httpProfile.setEndpoint(txYun3AccountConfig.getEndPoint()); + + + /* 非必要步骤: + * 实例化一个客户端配置对象,可以指定超时时间等配置 */ + ClientProfile clientProfile = new ClientProfile(); + /* SDK默认用TC3-HMAC-SHA256进行签名 + * 非必要请不要修改这个字段 */ +// clientProfile.setSignMethod("HmacSHA256"); + clientProfile.setHttpProfile(httpProfile); + /* 实例化要请求产品(以sms为例)的client对象 + * 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 */ + SmsClient client = new SmsClient(cred, txYun3AccountConfig.getRegion()); + + smsClientMap.put(accountId, client); + return client; + } + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/TxYunMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/TxYunMsgSender.java index 112e856ab..1dfb7b782 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/TxYunMsgSender.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/TxYunMsgSender.java @@ -1,13 +1,21 @@ package com.fangxuele.tool.push.logic.msgsender; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.PushControl; +import com.alibaba.fastjson.JSON; +import com.fangxuele.tool.push.bean.account.TxYunAccountConfig; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.logic.msgmaker.TxYunMsgMaker; +import com.fangxuele.tool.push.util.MybatisUtil; import com.github.qcloudsms.SmsSingleSender; import com.github.qcloudsms.SmsSingleSenderResult; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; +import java.util.HashMap; +import java.util.Map; + /** *
  * 腾讯云模板短信发送器
@@ -21,24 +29,44 @@ public class TxYunMsgSender implements IMsgSender {
     /**
      * 腾讯云短信sender
      */
-    public volatile static SmsSingleSender smsSingleSender;
+    private SmsSingleSender smsSingleSender;
 
     private TxYunMsgMaker txYunMsgMaker;
 
-    public TxYunMsgSender() {
-        txYunMsgMaker = new TxYunMsgMaker();
-        smsSingleSender = getTxYunSender();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private static Map smsSingleSenderMap = new HashMap<>();
+
+    private TxYunAccountConfig txYunAccountConfig;
+
+
+    public TxYunMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        txYunMsgMaker = new TxYunMsgMaker(tMsg);
+        smsSingleSender = getTxYunSender(tMsg.getAccountId());
+        this.dryRun = dryRun;
+
+        TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId());
+        String accountConfig = tAccount.getAccountConfig();
+        txYunAccountConfig = JSON.parseObject(accountConfig, TxYunAccountConfig.class);
+    }
+
+    public static void removeAccount(Integer account1Id) {
+        smsSingleSenderMap.remove(account1Id);
     }
 
     @Override
     public SendResult send(String[] msgData) {
         SendResult sendResult = new SendResult();
         try {
-            int templateId = TxYunMsgMaker.templateId;
-            String smsSign = App.config.getTxyunSign();
+            int templateId = txYunMsgMaker.getTemplateId();
+            String smsSign = txYunAccountConfig.getSign();
             String[] params = txYunMsgMaker.makeMsg(msgData);
             String telNum = msgData[0];
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -66,22 +94,21 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    /**
-     * 获取腾讯云短信发送客户端
-     *
-     * @return SmsSingleSender
-     */
-    private static SmsSingleSender getTxYunSender() {
-        if (smsSingleSender == null) {
-            synchronized (TxYunMsgSender.class) {
-                if (smsSingleSender == null) {
-                    String txyunAppId = App.config.getTxyunAppId();
-                    String txyunAppKey = App.config.getTxyunAppKey();
-
-                    smsSingleSender = new SmsSingleSender(Integer.parseInt(txyunAppId), txyunAppKey);
-                }
-            }
+    public SmsSingleSender getTxYunSender(Integer accountId) {
+        if (smsSingleSenderMap.containsKey(accountId)) {
+            return smsSingleSenderMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            TxYunAccountConfig txYunAccountConfig = JSON.parseObject(accountConfig, TxYunAccountConfig.class);
+
+            String txyunAppId = txYunAccountConfig.getAppId();
+            String txyunAppKey = txYunAccountConfig.getAppKey();
+
+            SmsSingleSender smsSingleSender = new SmsSingleSender(Integer.parseInt(txyunAppId), txyunAppKey);
+
+            smsSingleSenderMap.put(accountId, smsSingleSender);
+            return smsSingleSender;
         }
-        return smsSingleSender;
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/UpYunMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/UpYunMsgSender.java
index e13f96a4e..502098513 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/UpYunMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/UpYunMsgSender.java
@@ -1,8 +1,13 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.account.YunPianAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.UpYunMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
 import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -20,22 +25,39 @@ public class UpYunMsgSender implements IMsgSender {
     /**
      * 又拍云短信sender
      */
-    public volatile static OkHttpClient okHttpClint;
+    private OkHttpClient okHttpClint;
 
     private UpYunMsgMaker upYunMsgMaker;
 
     private static final String URL = "https://sms-api.upyun.com/api/messages";
 
-    public UpYunMsgSender() {
-        upYunMsgMaker = new UpYunMsgMaker();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private YunPianAccountConfig yunPianAccountConfig;
+
+    public UpYunMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        upYunMsgMaker = new UpYunMsgMaker(tMsg);
         okHttpClint = HttpMsgSender.getOkHttpClient();
+        this.dryRun = dryRun;
+
+        TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId());
+        String accountConfig = tAccount.getAccountConfig();
+        yunPianAccountConfig = JSON.parseObject(accountConfig, YunPianAccountConfig.class);
+    }
+
+    public static void removeAccount(Integer account1Id) {
+        // do nothing
     }
 
     @Override
     public SendResult send(String[] msgData) {
         SendResult sendResult = new SendResult();
         try {
-            String templateId = UpYunMsgMaker.templateId;
+            String templateId = upYunMsgMaker.getTemplateId();
             String[] params = upYunMsgMaker.makeMsg(msgData);
             String telNum = msgData[0];
 
@@ -46,9 +68,9 @@ public SendResult send(String[] msgData) {
             formBodyBuilder.add("vars", String.join("|", params));
             RequestBody requestBody = formBodyBuilder.build();
             requestBuilder.url(URL).post(requestBody);
-            requestBuilder.addHeader("Authorization", App.config.getUpAuthorizationToken());
+            requestBuilder.addHeader("Authorization", yunPianAccountConfig.getApiKey());
             Request request = requestBuilder.build();
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxCpMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxCpMsgSender.java
index ad2793118..36e914386 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxCpMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxCpMsgSender.java
@@ -1,23 +1,26 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
+import com.alibaba.fastjson.JSON;
 import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.dao.TWxCpAppMapper;
-import com.fangxuele.tool.push.domain.TWxCpApp;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.fangxuele.tool.push.bean.account.WxCpAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.WxCpMsgMaker;
-import com.fangxuele.tool.push.ui.form.msg.WxCpMsgForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
 import me.chanjar.weixin.cp.api.WxCpService;
 import me.chanjar.weixin.cp.api.impl.WxCpServiceApacheHttpClientImpl;
-import me.chanjar.weixin.cp.bean.WxCpMessage;
-import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
+import me.chanjar.weixin.cp.bean.message.WxCpMessage;
+import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
 import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 
@@ -29,15 +32,25 @@
  */
 @Slf4j
 public class WxCpMsgSender implements IMsgSender {
-    public volatile static WxCpDefaultConfigImpl wxCpConfigStorage;
-    public volatile static WxCpService wxCpService;
-    private WxCpMsgMaker wxCpMsgMaker;
+    private WxCpService wxCpService;
+    private final WxCpMsgMaker wxCpMsgMaker;
 
-    private static TWxCpAppMapper wxCpAppMapper = MybatisUtil.getSqlSession().getMapper(TWxCpAppMapper.class);
+    private static Map wxCpServiceMap = new HashMap<>();
 
-    public WxCpMsgSender() {
-        wxCpMsgMaker = new WxCpMsgMaker();
-        wxCpService = getWxCpService();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    public WxCpMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        wxCpMsgMaker = new WxCpMsgMaker(tMsg);
+        wxCpService = getWxCpService(tMsg.getAccountId());
+        this.dryRun = dryRun;
+    }
+
+    public static void removeAccount(Integer account1Id) {
+        wxCpServiceMap.remove(account1Id);
     }
 
     @Override
@@ -48,11 +61,11 @@ public SendResult send(String[] msgData) {
             String openId = msgData[0];
             WxCpMessage wxCpMessage = wxCpMsgMaker.makeMsg(msgData);
             wxCpMessage.setToUser(openId);
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
-                WxCpMessageSendResult wxCpMessageSendResult = wxCpService.messageSend(wxCpMessage);
+                WxCpMessageSendResult wxCpMessageSendResult = wxCpService.getMessageService().send(wxCpMessage);
                 if (wxCpMessageSendResult.getErrCode() != 0 || StringUtils.isNoneEmpty(wxCpMessageSendResult.getInvalidUser())) {
                     sendResult.setSuccess(false);
                     sendResult.setInfo(wxCpMessageSendResult.toString());
@@ -76,69 +89,48 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    /**
-     * 微信企业号配置
-     *
-     * @return WxCpConfigStorage
-     */
-    private static WxCpDefaultConfigImpl wxCpConfigStorage() {
-        WxCpDefaultConfigImpl configStorage = new WxCpDefaultConfigImpl();
-        configStorage.setCorpId(App.config.getWxCpCorpId());
-        String agentId = WxCpMsgForm.appNameToAgentIdMap.get(WxCpMsgForm.getInstance().getAppNameComboBox().getSelectedItem());
-        configStorage.setAgentId(Integer.valueOf(agentId));
-
-        List wxCpAppList = wxCpAppMapper.selectByAgentId(agentId);
-        if (wxCpAppList.size() > 0) {
-            configStorage.setCorpSecret(wxCpAppList.get(0).getSecret());
-        }
-        if (App.config.isMpUseProxy()) {
-            configStorage.setHttpProxyHost(App.config.getMpProxyHost());
-            configStorage.setHttpProxyPort(Integer.parseInt(App.config.getMpProxyPort()));
-            configStorage.setHttpProxyUsername(App.config.getMpProxyUserName());
-            configStorage.setHttpProxyPassword(App.config.getMpProxyPassword());
-        }
-        DefaultApacheHttpClientBuilder clientBuilder = DefaultApacheHttpClientBuilder.get();
-        //从连接池获取链接的超时时间(单位ms)
-        clientBuilder.setConnectionRequestTimeout(10000);
-        //建立链接的超时时间(单位ms)
-        clientBuilder.setConnectionTimeout(5000);
-        //连接池socket超时时间(单位ms)
-        clientBuilder.setSoTimeout(5000);
-        //空闲链接的超时时间(单位ms)
-        clientBuilder.setIdleConnTimeout(60000);
-        //空闲链接的检测周期(单位ms)
-        clientBuilder.setCheckWaitTime(60000);
-        //每路最大连接数
-        clientBuilder.setMaxConnPerHost(App.config.getMaxThreadPool() * 2);
-        //连接池最大连接数
-        clientBuilder.setMaxTotalConn(App.config.getMaxThreadPool() * 2);
-        //HttpClient请求时使用的User Agent
+    public static WxCpService getWxCpService(Integer accountId) {
+        if (wxCpServiceMap.containsKey(accountId)) {
+            return wxCpServiceMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            WxCpAccountConfig wxCpAccountConfig = JSON.parseObject(accountConfig, WxCpAccountConfig.class);
+
+            WxCpDefaultConfigImpl configStorage = new WxCpDefaultConfigImpl();
+            configStorage.setCorpId(wxCpAccountConfig.getCorpId());
+            String agentId = wxCpAccountConfig.getAgentId();
+            configStorage.setAgentId(Integer.valueOf(agentId));
+            configStorage.setCorpSecret(wxCpAccountConfig.getSecret());
+            DefaultApacheHttpClientBuilder clientBuilder = DefaultApacheHttpClientBuilder.get();
+            //从连接池获取链接的超时时间(单位ms)
+            clientBuilder.setConnectionRequestTimeout(10000);
+            //建立链接的超时时间(单位ms)
+            clientBuilder.setConnectionTimeout(5000);
+            //连接池socket超时时间(单位ms)
+            clientBuilder.setSoTimeout(5000);
+            //空闲链接的超时时间(单位ms)
+            clientBuilder.setIdleConnTimeout(60000);
+            //空闲链接的检测周期(单位ms)
+            clientBuilder.setCheckWaitTime(60000);
+            //每路最大连接数
+            clientBuilder.setMaxConnPerHost(App.config.getMaxThreads());
+            //连接池最大连接数
+            clientBuilder.setMaxTotalConn(App.config.getMaxThreads());
+            //HttpClient请求时使用的User Agent
 //        clientBuilder.setUserAgent(..)
-        configStorage.setApacheHttpClientBuilder(clientBuilder);
-        return configStorage;
-    }
+            configStorage.setApacheHttpClientBuilder(clientBuilder);
 
-    /**
-     * 获取微信企业号工具服务
-     *
-     * @return WxCpService
-     */
-    public static WxCpService getWxCpService() {
-        if (wxCpConfigStorage == null) {
-            synchronized (WxCpMsgSender.class) {
-                if (wxCpConfigStorage == null) {
-                    wxCpConfigStorage = wxCpConfigStorage();
-                }
-            }
-        }
-        if (wxCpService == null && wxCpConfigStorage != null) {
-            synchronized (PushControl.class) {
-                if (wxCpService == null && wxCpConfigStorage != null) {
-                    wxCpService = new WxCpServiceApacheHttpClientImpl();
-                    wxCpService.setWxCpConfigStorage(wxCpConfigStorage);
-                }
+            if (wxCpAccountConfig.getPrivateDep()) {
+                configStorage.setBaseApiUrl(wxCpAccountConfig.getBaseApiUrl());
             }
+
+            WxCpService wxCpService = new WxCpServiceApacheHttpClientImpl();
+            wxCpService.setWxCpConfigStorage(configStorage);
+
+            wxCpServiceMap.put(accountId, wxCpService);
+            return wxCpService;
         }
-        return wxCpService;
+
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuMsgSender.java
index e4819501a..53f406a09 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuMsgSender.java
@@ -1,7 +1,9 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
-import com.fangxuele.tool.push.logic.PushControl;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.WxKefuMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.mp.api.WxMpService;
 import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
@@ -18,11 +20,17 @@
 @Slf4j
 public class WxKefuMsgSender implements IMsgSender {
     private WxKefuMsgMaker wxKefuMsgMaker;
-    public volatile static WxMpService wxMpService;
+    private WxMpService wxMpService;
 
-    public WxKefuMsgSender() {
-        wxKefuMsgMaker = new WxKefuMsgMaker();
-        wxMpService = WxMpTemplateMsgSender.getWxMpService();
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    public WxKefuMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        wxKefuMsgMaker = new WxKefuMsgMaker(tMsg);
+        wxMpService = WxMpTemplateMsgSender.getWxMpService(tMsg.getAccountId());
+        this.dryRun = dryRun;
     }
 
     @Override
@@ -33,7 +41,7 @@ public SendResult send(String[] msgData) {
             String openId = msgData[0];
             WxMpKefuMessage wxMpKefuMessage = wxKefuMsgMaker.makeMsg(msgData);
             wxMpKefuMessage.setToUser(openId);
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuPriorMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuPriorMsgSender.java
index 0f2c3a6c6..c0b43a1e8 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuPriorMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxKefuPriorMsgSender.java
@@ -13,9 +13,9 @@ public class WxKefuPriorMsgSender implements IMsgSender {
     private WxMpTemplateMsgSender wxMpTemplateMsgSender;
     private WxKefuMsgSender wxKefuMsgSender;
 
-    public WxKefuPriorMsgSender() {
-        wxMpTemplateMsgSender = new WxMpTemplateMsgSender();
-        wxKefuMsgSender = new WxKefuMsgSender();
+    public WxKefuPriorMsgSender(Integer msgId, Integer dryRun) {
+        wxMpTemplateMsgSender = new WxMpTemplateMsgSender(msgId, dryRun);
+        wxKefuMsgSender = new WxKefuMsgSender(msgId, dryRun);
     }
 
     @Override
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMaSubscribeMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMaSubscribeMsgSender.java
index 685857f6c..4897f0f53 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMaSubscribeMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMaSubscribeMsgSender.java
@@ -1,12 +1,25 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
 import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
-import com.fangxuele.tool.push.logic.PushControl;
+import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.App;
+import com.fangxuele.tool.push.bean.account.WxMaAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.WxMaSubscribeMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 
  * 微信小程序订阅消息发送器
@@ -17,13 +30,27 @@
  */
 @Slf4j
 public class WxMaSubscribeMsgSender implements IMsgSender {
-    public volatile static WxMaService wxMaService;
+
+    private WxMaService wxMaService;
 
     private WxMaSubscribeMsgMaker wxMaSubscribeMsgMaker;
 
-    public WxMaSubscribeMsgSender() {
-        wxMaSubscribeMsgMaker = new WxMaSubscribeMsgMaker();
-        wxMaService = WxMaTemplateMsgSender.getWxMaService();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private static Map wxMaServiceMap = new HashMap<>();
+
+    public WxMaSubscribeMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        wxMaSubscribeMsgMaker = new WxMaSubscribeMsgMaker(tMsg);
+        wxMaService = getWxMaService(tMsg.getAccountId());
+        this.dryRun = dryRun;
+    }
+
+    public static void removeAccount(Integer accountId) {
+        wxMaServiceMap.remove(accountId);
     }
 
     @Override
@@ -34,7 +61,7 @@ public SendResult send(String[] msgData) {
             String openId = msgData[0];
             WxMaSubscribeMessage wxMaSubscribeMessage = wxMaSubscribeMsgMaker.makeMsg(msgData);
             wxMaSubscribeMessage.setToUser(openId);
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -55,4 +82,51 @@ public SendResult send(String[] msgData) {
     public SendResult asyncSend(String[] msgData) {
         return null;
     }
+
+    public static WxMaService getWxMaService(Integer accountId) {
+        if (wxMaServiceMap.containsKey(accountId)) {
+            return wxMaServiceMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            WxMaAccountConfig wxMaAccountConfig = JSON.parseObject(accountConfig, WxMaAccountConfig.class);
+
+            WxMaDefaultConfigImpl configStorage = new WxMaDefaultConfigImpl();
+            configStorage.setAppid(wxMaAccountConfig.getAppId());
+            configStorage.setSecret(wxMaAccountConfig.getAppSecret());
+            configStorage.setToken(wxMaAccountConfig.getToken());
+            configStorage.setAesKey(wxMaAccountConfig.getAesKey());
+            configStorage.setMsgDataFormat("JSON");
+            if (wxMaAccountConfig.isMaUseProxy()) {
+                configStorage.setHttpProxyHost(wxMaAccountConfig.getMaProxyHost());
+                configStorage.setHttpProxyPort(Integer.parseInt(wxMaAccountConfig.getMaProxyPort()));
+                configStorage.setHttpProxyUsername(wxMaAccountConfig.getMaProxyUserName());
+                configStorage.setHttpProxyPassword(wxMaAccountConfig.getMaProxyPassword());
+            }
+            DefaultApacheHttpClientBuilder clientBuilder = DefaultApacheHttpClientBuilder.get();
+            //从连接池获取链接的超时时间(单位ms)
+            clientBuilder.setConnectionRequestTimeout(10000);
+            //建立链接的超时时间(单位ms)
+            clientBuilder.setConnectionTimeout(5000);
+            //连接池socket超时时间(单位ms)
+            clientBuilder.setSoTimeout(5000);
+            //空闲链接的超时时间(单位ms)
+            clientBuilder.setIdleConnTimeout(60000);
+            //空闲链接的检测周期(单位ms)
+            clientBuilder.setCheckWaitTime(60000);
+            //每路最大连接数
+            clientBuilder.setMaxConnPerHost(App.config.getMaxThreads());
+            //连接池最大连接数
+            clientBuilder.setMaxTotalConn(App.config.getMaxThreads());
+            //HttpClient请求时使用的User Agent
+//        clientBuilder.setUserAgent(..)
+            configStorage.setApacheHttpClientBuilder(clientBuilder);
+
+            WxMaService wxMaService = new WxMaServiceImpl();
+            wxMaService.setWxMaConfig(configStorage);
+
+            wxMaServiceMap.put(accountId, wxMaService);
+            return wxMaService;
+        }
+    }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMaTemplateMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMaTemplateMsgSender.java
deleted file mode 100644
index 6e337f981..000000000
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMaTemplateMsgSender.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package com.fangxuele.tool.push.logic.msgsender;
-
-import cn.binarywang.wx.miniapp.api.WxMaService;
-import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
-import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
-import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
-import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.logic.PushControl;
-import com.fangxuele.tool.push.logic.msgmaker.WxMaTemplateMsgMaker;
-import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-
-/**
- * 
- * 微信小程序模板消息发送器
- * 
- * - * @author RememBerBer - * @since 2019/6/15. - */ -@Slf4j -public class WxMaTemplateMsgSender implements IMsgSender { - public volatile static WxMaService wxMaService; - - public volatile static WxMaDefaultConfigImpl wxMaConfigStorage; - - private WxMaTemplateMsgMaker wxMaTemplateMsgMaker; - - public WxMaTemplateMsgSender() { - wxMaTemplateMsgMaker = new WxMaTemplateMsgMaker(); - wxMaService = getWxMaService(); - } - - @Override - public SendResult send(String[] msgData) { - SendResult sendResult = new SendResult(); - - try { - String openId = msgData[0]; - WxMaSubscribeMessage wxMaSubscribeMessage = new WxMaSubscribeMessage(); - wxMaSubscribeMessage.setToUser(openId); - wxMaSubscribeMessage.setTemplateId(msgData[1]); - if (PushControl.dryRun) { - sendResult.setSuccess(true); - return sendResult; - } else { - wxMaService.getMsgService().sendSubscribeMsg(wxMaSubscribeMessage); - } - } catch (Exception e) { - sendResult.setSuccess(false); - sendResult.setInfo(e.getMessage()); - log.error(ExceptionUtils.getStackTrace(e)); - return sendResult; - } - - sendResult.setSuccess(true); - return sendResult; - } - - @Override - public SendResult asyncSend(String[] msgData) { - return null; - } - - /** - * 微信小程序配置 - * - * @return WxMaInMemoryConfig - */ - private static WxMaDefaultConfigImpl wxMaConfigStorage() { - WxMaDefaultConfigImpl configStorage = new WxMaDefaultConfigImpl(); - configStorage.setAppid(App.config.getMiniAppAppId()); - configStorage.setSecret(App.config.getMiniAppAppSecret()); - configStorage.setToken(App.config.getMiniAppToken()); - configStorage.setAesKey(App.config.getMiniAppAesKey()); - configStorage.setMsgDataFormat("JSON"); - if (App.config.isMaUseProxy()) { - configStorage.setHttpProxyHost(App.config.getMaProxyHost()); - configStorage.setHttpProxyPort(Integer.parseInt(App.config.getMaProxyPort())); - configStorage.setHttpProxyUsername(App.config.getMaProxyUserName()); - configStorage.setHttpProxyPassword(App.config.getMaProxyPassword()); - } - DefaultApacheHttpClientBuilder clientBuilder = DefaultApacheHttpClientBuilder.get(); - //从连接池获取链接的超时时间(单位ms) - clientBuilder.setConnectionRequestTimeout(10000); - //建立链接的超时时间(单位ms) - clientBuilder.setConnectionTimeout(5000); - //连接池socket超时时间(单位ms) - clientBuilder.setSoTimeout(5000); - //空闲链接的超时时间(单位ms) - clientBuilder.setIdleConnTimeout(60000); - //空闲链接的检测周期(单位ms) - clientBuilder.setCheckWaitTime(60000); - //每路最大连接数 - clientBuilder.setMaxConnPerHost(App.config.getMaxThreadPool() * 2); - //连接池最大连接数 - clientBuilder.setMaxTotalConn(App.config.getMaxThreadPool() * 2); - //HttpClient请求时使用的User Agent -// clientBuilder.setUserAgent(..) - configStorage.setApacheHttpClientBuilder(clientBuilder); - return configStorage; - } - - /** - * 获取微信小程序工具服务 - * - * @return WxMaService - */ - static WxMaService getWxMaService() { - if (wxMaService == null) { - synchronized (WxMaTemplateMsgSender.class) { - if (wxMaService == null) { - wxMaService = new WxMaServiceImpl(); - } - } - } - if (wxMaConfigStorage == null) { - synchronized (WxMaTemplateMsgSender.class) { - if (wxMaConfigStorage == null) { - wxMaConfigStorage = wxMaConfigStorage(); - if (wxMaConfigStorage != null) { - wxMaService.setWxMaConfig(wxMaConfigStorage); - } - } - } - } - return wxMaService; - } -} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpSubscribeMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpSubscribeMsgSender.java new file mode 100644 index 000000000..b9b00dcd4 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpSubscribeMsgSender.java @@ -0,0 +1,65 @@ +package com.fangxuele.tool.push.logic.msgsender; + +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.logic.msgmaker.WxMpSubscribeMsgMaker; +import com.fangxuele.tool.push.util.MybatisUtil; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage; +import org.apache.commons.lang3.exception.ExceptionUtils; + +/** + *
+ * 微信公众号订阅通知发送器
+ * 
+ * + * @author RememBerBer + * @since 2021/3/23. + */ +@Slf4j +public class WxMpSubscribeMsgSender implements IMsgSender { + private WxMpService wxMpService; + private WxMpSubscribeMsgMaker wxMpSubscribeMsgMaker; + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + private Integer dryRun; + + public WxMpSubscribeMsgSender(Integer msgId, Integer dryRun) { + TMsg tMsg = msgMapper.selectByPrimaryKey(msgId); + wxMpSubscribeMsgMaker = new WxMpSubscribeMsgMaker(tMsg); + wxMpService = WxMpTemplateMsgSender.getWxMpService(tMsg.getAccountId()); + this.dryRun = dryRun; + } + + @Override + public SendResult send(String[] msgData) { + SendResult sendResult = new SendResult(); + + try { + String openId = msgData[0]; + WxMpSubscribeMessage wxMessageTemplate = wxMpSubscribeMsgMaker.makeMsg(msgData); + wxMessageTemplate.setToUser(openId); + if (dryRun == 1) { + sendResult.setSuccess(true); + return sendResult; + } else { + wxMpService.getSubscribeMsgService().send(wxMessageTemplate); + } + } catch (Exception e) { + sendResult.setSuccess(false); + sendResult.setInfo(e.getMessage()); + log.error(ExceptionUtils.getStackTrace(e)); + return sendResult; + } + + sendResult.setSuccess(true); + return sendResult; + } + + @Override + public SendResult asyncSend(String[] msgData) { + return null; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpTemplateMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpTemplateMsgSender.java index 625b65302..18add8517 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpTemplateMsgSender.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpTemplateMsgSender.java @@ -1,38 +1,24 @@ package com.fangxuele.tool.push.logic.msgsender; -import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.BoostPushRunThread; -import com.fangxuele.tool.push.logic.PushControl; -import com.fangxuele.tool.push.logic.PushData; +import com.fangxuele.tool.push.bean.account.WxMpAccountConfig; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.logic.msgmaker.WxMpTemplateMsgMaker; -import com.fangxuele.tool.push.ui.form.BoostForm; -import com.fangxuele.tool.push.util.ConsoleUtil; +import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.WeWxMpServiceImpl; import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.apache.http.Consts; -import org.apache.http.HttpHost; -import org.apache.http.HttpResponse; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.concurrent.FutureCallback; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; -import org.apache.http.impl.nio.client.HttpAsyncClients; -import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager; -import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor; -import org.apache.http.impl.nio.reactor.IOReactorConfig; -import org.apache.http.nio.reactor.ConnectingIOReactor; -import org.apache.http.nio.reactor.IOReactorException; -import org.apache.http.util.EntityUtils; -import java.util.concurrent.Future; +import java.util.HashMap; +import java.util.Map; /** *
@@ -44,14 +30,21 @@
  */
 @Slf4j
 public class WxMpTemplateMsgSender implements IMsgSender {
-    public volatile static WxMpDefaultConfigImpl wxMpConfigStorage;
-    public volatile static WxMpService wxMpService;
-    public volatile static CloseableHttpAsyncClient closeableHttpAsyncClient;
+    private WxMpService wxMpService;
     private WxMpTemplateMsgMaker wxMpTemplateMsgMaker;
 
-    public WxMpTemplateMsgSender() {
-        wxMpTemplateMsgMaker = new WxMpTemplateMsgMaker();
-        wxMpService = getWxMpService();
+    private static Map wxMpServiceMap = new HashMap<>();
+
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    public WxMpTemplateMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        wxMpTemplateMsgMaker = new WxMpTemplateMsgMaker(tMsg);
+        wxMpService = getWxMpService(tMsg.getAccountId());
+        this.dryRun = dryRun;
     }
 
     @Override
@@ -62,7 +55,8 @@ public SendResult send(String[] msgData) {
             String openId = msgData[0];
             WxMpTemplateMessage wxMessageTemplate = wxMpTemplateMsgMaker.makeMsg(msgData);
             wxMessageTemplate.setToUser(openId);
-            if (PushControl.dryRun) {
+
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -81,94 +75,7 @@ public SendResult send(String[] msgData) {
 
     @Override
     public SendResult asyncSend(String[] msgData) {
-        SendResult sendResult = new SendResult();
-        BoostForm boostForm = BoostForm.getInstance();
-
-        try {
-            if (PushControl.dryRun) {
-                // 已成功+1
-                PushData.increaseSuccess();
-                boostForm.getSuccessCountLabel().setText(String.valueOf(PushData.successRecords));
-                // 保存发送成功
-                PushData.sendSuccessList.add(msgData);
-                // 总进度条
-                boostForm.getCompletedProgressBar().setValue(PushData.successRecords.intValue() + PushData.failRecords.intValue());
-                sendResult.setSuccess(true);
-                return sendResult;
-            } else {
-                String openId = msgData[0];
-                WxMpTemplateMessage wxMessageTemplate = wxMpTemplateMsgMaker.makeMsg(msgData);
-                wxMessageTemplate.setToUser(openId);
-
-                String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + wxMpService.getAccessToken();
-                HttpPost httpPost = new HttpPost(url);
-                StringEntity entity = new StringEntity(wxMessageTemplate.toJson(), Consts.UTF_8);
-                httpPost.setEntity(entity);
-                if (wxMpService.getRequestHttp().getRequestHttpProxy() != null) {
-                    RequestConfig config = RequestConfig.custom().setProxy((HttpHost) wxMpService.getRequestHttp().getRequestHttpProxy()).build();
-                    httpPost.setConfig(config);
-                }
-                Future httpResponseFuture = getCloseableHttpAsyncClient().execute(httpPost, new CallBack(msgData));
-                BoostPushRunThread.futureList.add(httpResponseFuture);
-            }
-        } catch (Exception e) {
-            // 总发送失败+1
-            PushData.increaseFail();
-            boostForm.getFailCountLabel().setText(String.valueOf(PushData.failRecords));
-
-            // 保存发送失败
-            PushData.sendFailList.add(msgData);
-
-            // 失败异常信息输出控制台
-            ConsoleUtil.boostConsoleOnly("发送失败:" + e.toString() + ";msgData:" + JSONUtil.toJsonPrettyStr(msgData));
-            // 总进度条
-            boostForm.getCompletedProgressBar().setValue(PushData.successRecords.intValue() + PushData.failRecords.intValue());
-
-            sendResult.setSuccess(false);
-            sendResult.setInfo(e.getMessage());
-            log.error(e.toString());
-            return sendResult;
-        }
-
-        return sendResult;
-    }
-
-    /**
-     * 微信公众号配置
-     *
-     * @return WxMpConfigStorage
-     */
-    private static WxMpDefaultConfigImpl wxMpConfigStorage() {
-        WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
-        configStorage.setAppId(App.config.getWechatAppId());
-        configStorage.setSecret(App.config.getWechatAppSecret());
-        configStorage.setToken(App.config.getWechatToken());
-        configStorage.setAesKey(App.config.getWechatAesKey());
-        if (App.config.isMpUseProxy()) {
-            configStorage.setHttpProxyHost(App.config.getMpProxyHost());
-            configStorage.setHttpProxyPort(Integer.parseInt(App.config.getMpProxyPort()));
-            configStorage.setHttpProxyUsername(App.config.getMpProxyUserName());
-            configStorage.setHttpProxyPassword(App.config.getMpProxyPassword());
-        }
-        DefaultApacheHttpClientBuilder clientBuilder = DefaultApacheHttpClientBuilder.get();
-        //从连接池获取链接的超时时间(单位ms)
-        clientBuilder.setConnectionRequestTimeout(10000);
-        //建立链接的超时时间(单位ms)
-        clientBuilder.setConnectionTimeout(5000);
-        //连接池socket超时时间(单位ms)
-        clientBuilder.setSoTimeout(5000);
-        //空闲链接的超时时间(单位ms)
-        clientBuilder.setIdleConnTimeout(60000);
-        //空闲链接的检测周期(单位ms)
-        clientBuilder.setCheckWaitTime(60000);
-        //每路最大连接数
-        clientBuilder.setMaxConnPerHost(App.config.getMaxThreadPool() * 2);
-        //连接池最大连接数
-        clientBuilder.setMaxTotalConn(App.config.getMaxThreadPool() * 2);
-        //HttpClient请求时使用的User Agent
-//        clientBuilder.setUserAgent(..)
-        configStorage.setApacheHttpClientBuilder(clientBuilder);
-        return configStorage;
+        return null;
     }
 
     /**
@@ -177,135 +84,56 @@ private static WxMpDefaultConfigImpl wxMpConfigStorage() {
      * @return WxMpService
      */
     public static WxMpService getWxMpService() {
-        if (wxMpConfigStorage == null) {
-            synchronized (WxMpTemplateMsgSender.class) {
-                if (wxMpConfigStorage == null) {
-                    wxMpConfigStorage = wxMpConfigStorage();
-                }
-            }
-        }
-        if (wxMpService == null && wxMpConfigStorage != null) {
-            synchronized (WxMpTemplateMsgSender.class) {
-                if (wxMpService == null && wxMpConfigStorage != null) {
-                    wxMpService = new WeWxMpServiceImpl();
-                    wxMpService.setWxMpConfigStorage(wxMpConfigStorage);
-                }
-            }
-        }
-        return wxMpService;
+        return null;
     }
 
-    public static CloseableHttpAsyncClient getCloseableHttpAsyncClient() throws IOReactorException {
-        if (closeableHttpAsyncClient == null) {
-            synchronized (WxMpTemplateMsgSender.class) {
-                if (closeableHttpAsyncClient == null) {
-                    RequestConfig requestConfig = RequestConfig.custom()
-                            .setConnectTimeout(-1)
-                            .setSocketTimeout(-1)
-                            .setConnectionRequestTimeout(-1)
-                            .build();
-
-                    //配置io线程
-                    IOReactorConfig ioReactorConfig = IOReactorConfig.custom().
-                            setIoThreadCount(Runtime.getRuntime().availableProcessors())
-                            .setSoKeepAlive(true).setConnectTimeout(-1).setSoTimeout(-1)
-                            .build();
-                    //设置连接池大小
-                    ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(ioReactorConfig);
-                    PoolingNHttpClientConnectionManager connManager = new PoolingNHttpClientConnectionManager(ioReactor);
-                    //最大连接数
-                    connManager.setMaxTotal(5000);
-                    //per route最大连接数
-                    connManager.setDefaultMaxPerRoute(5000);
-
-                    closeableHttpAsyncClient = HttpAsyncClients.custom().
-                            setConnectionManager(connManager)
-                            .setDefaultRequestConfig(requestConfig)
-                            .build();
-
-                    closeableHttpAsyncClient.start();
-                }
-            }
-        }
-        return closeableHttpAsyncClient;
-    }
-
-    static class CallBack implements FutureCallback {
-
-        String[] msgData;
-
-        CallBack(String[] msgData) {
-            this.msgData = msgData;
-        }
-
-        @Override
-        public void completed(HttpResponse httpResponse) {
-            BoostForm boostForm = BoostForm.getInstance();
-
-            try {
-                String response = EntityUtils.toString(httpResponse.getEntity(), Consts.UTF_8);
-                if (response.isEmpty()) {
-                    // 总发送失败+1
-                    PushData.increaseFail();
-                    boostForm.getFailCountLabel().setText(String.valueOf(PushData.failRecords));
-
-                    // 保存发送失败
-                    PushData.sendFailList.add(msgData);
-
-                    // 失败异常信息输出控制台
-                    ConsoleUtil.boostConsoleOnly("发送失败:" + WxError.builder().errorCode(9999).errorMsg("无响应内容").build() + ";msgData:" + JSONUtil.toJsonPrettyStr(msgData));
-                    // 总进度条
-                    boostForm.getCompletedProgressBar().setValue(PushData.successRecords.intValue() + PushData.failRecords.intValue());
-                } else {
-                    WxError error = WxError.fromJson(response);
-                    if (error.getErrorCode() != 0) {
-                        // 总发送失败+1
-                        PushData.increaseFail();
-                        boostForm.getFailCountLabel().setText(String.valueOf(PushData.failRecords));
-
-                        // 保存发送失败
-                        PushData.sendFailList.add(msgData);
-
-                        // 失败异常信息输出控制台
-                        ConsoleUtil.boostConsoleOnly("发送失败:" + error + ";msgData:" + JSONUtil.toJsonPrettyStr(msgData));
-                        // 总进度条
-                        boostForm.getCompletedProgressBar().setValue(PushData.successRecords.intValue() + PushData.failRecords.intValue());
-                    } else {
-                        // 已成功+1
-                        PushData.increaseSuccess();
-                        boostForm.getSuccessCountLabel().setText(String.valueOf(PushData.successRecords));
-
-                        // 保存发送成功
-                        PushData.sendSuccessList.add(msgData);
-                        // 总进度条
-                        boostForm.getCompletedProgressBar().setValue(PushData.successRecords.intValue() + PushData.failRecords.intValue());
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
+    public static WxMpService getWxMpService(Integer accountId) {
+        if (wxMpServiceMap.containsKey(accountId)) {
+            return wxMpServiceMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            WxMpAccountConfig wxMpAccountConfig = JSON.parseObject(accountConfig, WxMpAccountConfig.class);
+
+            WxMpDefaultConfigImpl wxMpConfigStorage = new WxMpDefaultConfigImpl();
+            wxMpConfigStorage.setAppId(wxMpAccountConfig.getAppId());
+            wxMpConfigStorage.setSecret(wxMpAccountConfig.getAppSecret());
+            wxMpConfigStorage.setToken(wxMpAccountConfig.getToken());
+            wxMpConfigStorage.setAesKey(wxMpAccountConfig.getAesKey());
+            if (wxMpAccountConfig.isMpUseProxy()) {
+                wxMpConfigStorage.setHttpProxyHost(wxMpAccountConfig.getMpProxyHost());
+                wxMpConfigStorage.setHttpProxyPort(Integer.parseInt(wxMpAccountConfig.getMpProxyPort()));
+                wxMpConfigStorage.setHttpProxyUsername(wxMpAccountConfig.getMpProxyUserName());
+                wxMpConfigStorage.setHttpProxyPassword(wxMpAccountConfig.getMpProxyPassword());
             }
+            DefaultApacheHttpClientBuilder clientBuilder = DefaultApacheHttpClientBuilder.get();
+            //从连接池获取链接的超时时间(单位ms)
+            clientBuilder.setConnectionRequestTimeout(10000);
+            //建立链接的超时时间(单位ms)
+            clientBuilder.setConnectionTimeout(5000);
+            //连接池socket超时时间(单位ms)
+            clientBuilder.setSoTimeout(5000);
+            //空闲链接的超时时间(单位ms)
+            clientBuilder.setIdleConnTimeout(60000);
+            //空闲链接的检测周期(单位ms)
+            clientBuilder.setCheckWaitTime(3000);
+            //每路最大连接数
+            clientBuilder.setMaxConnPerHost(App.config.getMaxThreads());
+            //连接池最大连接数
+            clientBuilder.setMaxTotalConn(App.config.getMaxThreads());
+            //HttpClient请求时使用的User Agent
+//        clientBuilder.setUserAgent(..)
+            wxMpConfigStorage.setApacheHttpClientBuilder(clientBuilder);
+            WxMpService wxMpService = new WeWxMpServiceImpl(wxMpAccountConfig);
+            wxMpService.setWxMpConfigStorage(wxMpConfigStorage);
+            wxMpServiceMap.put(accountId, wxMpService);
+            return wxMpService;
         }
 
-        @Override
-        public void failed(Exception e) {
-            BoostForm boostForm = BoostForm.getInstance();
-
-            // 总发送失败+1
-            PushData.increaseFail();
-            boostForm.getFailCountLabel().setText(String.valueOf(PushData.failRecords));
-
-            // 保存发送失败
-            PushData.sendFailList.add(msgData);
-
-            // 失败异常信息输出控制台
-            ConsoleUtil.boostConsoleOnly("发送失败:" + e.toString() + ";msgData:" + JSONUtil.toJsonPrettyStr(msgData));
-            // 总进度条
-            boostForm.getCompletedProgressBar().setValue(PushData.successRecords.intValue() + PushData.failRecords.intValue());
-        }
+    }
 
-        @Override
-        public void cancelled() {
-            PushData.TO_SEND_COUNT.getAndDecrement();
-        }
+    public static void removeAccount(Integer accountId) {
+        wxMpServiceMap.remove(accountId);
     }
+
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java
index c5aeb213f..df6450378 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java
@@ -1,16 +1,26 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
-import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
+import cn.binarywang.wx.miniapp.bean.WxMaTemplateData;
 import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage;
 import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage.MiniProgram;
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.logic.PushControl;
-import com.fangxuele.tool.push.logic.msgmaker.WxMaTemplateMsgMaker;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.account.WxMaAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
+import com.fangxuele.tool.push.logic.msgmaker.WxMaSubscribeMsgMaker;
 import com.fangxuele.tool.push.logic.msgmaker.WxMpTemplateMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
+import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
+import java.util.List;
+
 /**
  * 
  * 微信统一服务消息发送器
@@ -24,11 +34,28 @@ public class WxUniformMsgSender implements IMsgSender {
 
     private WxMpTemplateMsgMaker wxMpTemplateMsgMaker;
 
-    private WxMaTemplateMsgMaker wxMaTemplateMsgMaker;
+    private WxMaSubscribeMsgMaker wxMaSubscribeMsgMaker;
+
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private WxMaService wxMaService;
 
-    public WxUniformMsgSender() {
-        wxMpTemplateMsgMaker = new WxMpTemplateMsgMaker();
-        wxMaTemplateMsgMaker = new WxMaTemplateMsgMaker();
+    private WxMaAccountConfig WxMaAccountConfig;
+
+
+    public WxUniformMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        wxMpTemplateMsgMaker = new WxMpTemplateMsgMaker(tMsg);
+        wxMaSubscribeMsgMaker = new WxMaSubscribeMsgMaker(tMsg);
+        wxMaService = WxMaSubscribeMsgSender.getWxMaService(tMsg.getAccountId());
+        this.dryRun = dryRun;
+
+        TAccount tAccount = accountMapper.selectByPrimaryKey(tMsg.getAccountId());
+        String accountConfig = tAccount.getAccountConfig();
+        WxMaAccountConfig = JSON.parseObject(accountConfig, WxMaAccountConfig.class);
     }
 
     @Override
@@ -37,30 +64,38 @@ public SendResult send(String[] msgData) {
 
         try {
             String openId = msgData[0];
-            WxMaTemplateMessage wxMaTemplateMessage = wxMaTemplateMsgMaker.makeMsg(msgData);
+            WxMaSubscribeMessage wxMaSubscribeMessage = wxMaSubscribeMsgMaker.makeMsg(msgData);
             WxMpTemplateMessage wxMpTemplateMessage = wxMpTemplateMsgMaker.makeMsg(msgData);
 
             WxMaUniformMessage wxMaUniformMessage = new WxMaUniformMessage();
             wxMaUniformMessage.setMpTemplateMsg(true);
             wxMaUniformMessage.setToUser(openId);
-            wxMaUniformMessage.setAppid(App.config.getMiniAppAppId());
+            wxMaUniformMessage.setAppid(WxMaAccountConfig.getAppId());
             wxMaUniformMessage.setTemplateId(wxMpTemplateMessage.getTemplateId());
             wxMaUniformMessage.setUrl(wxMpTemplateMessage.getUrl());
-            wxMaUniformMessage.setPage(wxMaTemplateMessage.getPage());
+            wxMaUniformMessage.setPage(wxMaSubscribeMessage.getPage());
             wxMaUniformMessage.setFormId(msgData[1]);
             MiniProgram miniProgram = new MiniProgram();
-            miniProgram.setAppid(App.config.getMiniAppAppId());
-            miniProgram.setPagePath(wxMaTemplateMessage.getPage());
+            miniProgram.setAppid(WxMaAccountConfig.getAppId());
+            miniProgram.setPagePath(wxMaSubscribeMessage.getPage());
 
             wxMaUniformMessage.setMiniProgram(miniProgram);
-            wxMaUniformMessage.setData(wxMaTemplateMessage.getData());
-            wxMaUniformMessage.setEmphasisKeyword(wxMaTemplateMessage.getEmphasisKeyword());
+            List wxMaTemplateDataList = Lists.newArrayList();
+            List data = wxMaSubscribeMessage.getData();
+            WxMaTemplateData wxMaTemplateData;
+            for (WxMaSubscribeMessage.MsgData datum : data) {
+                wxMaTemplateData = new WxMaTemplateData();
+                wxMaTemplateData.setName(datum.getName());
+                wxMaTemplateData.setValue(datum.getValue());
+                wxMaTemplateDataList.add(wxMaTemplateData);
+            }
+            wxMaUniformMessage.setData(wxMaTemplateDataList);
 
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
-                WxMaTemplateMsgSender.getWxMaService().getMsgService().sendUniformMsg(wxMaUniformMessage);
+                wxMaService.getMsgService().sendUniformMsg(wxMaUniformMessage);
             }
         } catch (Exception e) {
             sendResult.setSuccess(false);
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/YunPianMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/YunPianMsgSender.java
index f6040bb05..3a27a861f 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/YunPianMsgSender.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/YunPianMsgSender.java
@@ -1,14 +1,20 @@
 package com.fangxuele.tool.push.logic.msgsender;
 
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.logic.PushControl;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.account.YunPianAccountConfig;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.logic.msgmaker.YunPianMsgMaker;
+import com.fangxuele.tool.push.util.MybatisUtil;
 import com.yunpian.sdk.YunpianClient;
 import com.yunpian.sdk.model.Result;
 import com.yunpian.sdk.model.SmsSingleSend;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -24,15 +30,30 @@ public class YunPianMsgSender implements IMsgSender {
     /**
      * 云片网短信client
      */
-    public volatile static YunpianClient yunpianClient;
+    private YunpianClient yunpianClient;
 
     private YunPianMsgMaker yunPianMsgMaker;
 
-    public YunPianMsgSender() {
-        yunPianMsgMaker = new YunPianMsgMaker();
-        yunpianClient = getYunpianClient();
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    private Integer dryRun;
+
+    private static Map yunpianClientMap = new HashMap<>();
+
+
+    public YunPianMsgSender(Integer msgId, Integer dryRun) {
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        yunPianMsgMaker = new YunPianMsgMaker(tMsg);
+        yunpianClient = getYunpianClient(tMsg.getAccountId());
+        this.dryRun = dryRun;
     }
 
+    public static void removeAccount(Integer account1Id) {
+        yunpianClientMap.remove(account1Id);
+    }
+
+
     @Override
     public SendResult send(String[] msgData) {
         SendResult sendResult = new SendResult();
@@ -41,7 +62,7 @@ public SendResult send(String[] msgData) {
             Map params = yunPianMsgMaker.makeMsg(msgData);
             String telNum = msgData[0];
             params.put(YunpianClient.MOBILE, telNum);
-            if (PushControl.dryRun) {
+            if (dryRun == 1) {
                 sendResult.setSuccess(true);
                 return sendResult;
             } else {
@@ -67,21 +88,21 @@ public SendResult asyncSend(String[] msgData) {
         return null;
     }
 
-    /**
-     * 获取云片网短信发送客户端
-     *
-     * @return YunpianClient
-     */
-    private static YunpianClient getYunpianClient() {
-        if (yunpianClient == null) {
-            synchronized (YunPianMsgSender.class) {
-                if (yunpianClient == null) {
-                    String yunpianApiKey = App.config.getYunpianApiKey();
+    private YunpianClient getYunpianClient(Integer accountId) {
+        if (yunpianClientMap.containsKey(accountId)) {
+            return yunpianClientMap.get(accountId);
+        } else {
+            TAccount tAccount = accountMapper.selectByPrimaryKey(accountId);
+            String accountConfig = tAccount.getAccountConfig();
+            YunPianAccountConfig yunPianAccountConfig = JSON.parseObject(accountConfig, YunPianAccountConfig.class);
 
-                    yunpianClient = new YunpianClient(yunpianApiKey).init();
-                }
-            }
+            String yunpianApiKey = yunPianAccountConfig.getApiKey();
+
+            YunpianClient yunpianClient = new YunpianClient(yunpianApiKey).init();
+
+            yunpianClientMap.put(accountId, yunpianClient);
+            return yunpianClient;
         }
-        return yunpianClient;
+
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgthread/BaseMsgThread.java b/src/main/java/com/fangxuele/tool/push/logic/msgthread/BaseMsgThread.java
index 94f114063..e3814145e 100644
--- a/src/main/java/com/fangxuele/tool/push/logic/msgthread/BaseMsgThread.java
+++ b/src/main/java/com/fangxuele/tool/push/logic/msgthread/BaseMsgThread.java
@@ -2,11 +2,9 @@
 
 import cn.hutool.log.Log;
 import cn.hutool.log.LogFactory;
-import com.fangxuele.tool.push.logic.PushData;
-import com.fangxuele.tool.push.ui.form.PushForm;
+import com.fangxuele.tool.push.logic.TaskRunThread;
 import com.fangxuele.tool.push.util.ConsoleUtil;
 
-import javax.swing.*;
 import java.util.List;
 
 /**
@@ -17,7 +15,7 @@
  * @author RememBerBer
  * @since 2017/3/29.
  */
-public class BaseMsgThread extends Thread {
+public class BaseMsgThread implements Runnable {
 
     public static final Log logger = LogFactory.get();
 
@@ -36,37 +34,14 @@ public class BaseMsgThread extends Thread {
      */
     public List list;
 
-    /**
-     * 当前线程成功数
-     */
-    public final ThreadLocal successCountLocal = ThreadLocal.withInitial(() -> 0);
-
-    /**
-     * 当前线程失败数
-     */
-    public final ThreadLocal failCountLocal = ThreadLocal.withInitial(() -> 0);
-
-    /**
-     * 线程列表table
-     */
-    public final ThreadLocal pushTableLocal = new ThreadLocal<>();
-
-    /**
-     * 当前线程所在的线程列表行
-     */
-    public int tableRow;
+    protected TaskRunThread taskRunThread;
 
     public static int msgType;
 
-    /**
-     * 构造函数
-     *
-     * @param start 起始页
-     * @param end   截止页
-     */
-    public BaseMsgThread(int start, int end) {
-        this.startIndex = start;
-        this.endIndex = end;
+    public BaseMsgThread(int startIndex, int endIndex, TaskRunThread taskRunThread) {
+        this.startIndex = startIndex;
+        this.endIndex = endIndex;
+        this.taskRunThread = taskRunThread;
     }
 
     @Override
@@ -78,34 +53,17 @@ public void run() {
      * 初始化当前线程
      */
     public void initCurrentThread() {
-        ConsoleUtil.consoleWithLog("线程" + this.getName() + "负责处理第:" + startIndex + "-" + endIndex + "条数据");
-
-        list = PushData.toSendList.subList(startIndex, endIndex);
-
-        // 初始化线程列表行
-        pushTableLocal.set(PushForm.getInstance().getPushThreadTable());
-        successCountLocal.set(0);
-        failCountLocal.set(0);
-        pushTableLocal.get().setValueAt(successCountLocal.get(), tableRow, 2);
-        pushTableLocal.get().setValueAt(failCountLocal.get(), tableRow, 3);
-        pushTableLocal.get().setValueAt(list.size(), tableRow, 4);
-        pushTableLocal.get().setValueAt(0, tableRow, 5);
+        ConsoleUtil.pushLog(taskRunThread.getLogWriter(), "线程" + Thread.currentThread().getName() + "负责处理第:" + startIndex + "-" + endIndex + "条数据");
+
+        list = taskRunThread.getToSendList().subList(startIndex, endIndex);
+
     }
 
     /**
      * 当前线程结束
      */
     public void currentThreadFinish() {
-        ConsoleUtil.consoleWithLog(this.getName() + "已处理完第" + startIndex + "-" + endIndex + "条的数据");
-
-        PushData.increaseStoppedThread();
-    }
-
-    public int getTableRow() {
-        return tableRow;
+        ConsoleUtil.pushLog(taskRunThread.getLogWriter(), Thread.currentThread().getName() + "已处理完第" + startIndex + "-" + endIndex + "条的数据");
     }
 
-    public void setTableRow(int tableRow) {
-        this.tableRow = tableRow;
-    }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgAsyncSendThread.java b/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgAsyncSendThread.java
deleted file mode 100644
index 38d10dc70..000000000
--- a/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgAsyncSendThread.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.fangxuele.tool.push.logic.msgthread;
-
-import com.fangxuele.tool.push.logic.PushData;
-import com.fangxuele.tool.push.logic.msgsender.IMsgSender;
-import com.fangxuele.tool.push.ui.form.BoostForm;
-
-/**
- * 
- * 消息异步发送服务线程
- * 
- * - * @author RememBerBer - * @since 2019/7/7. - */ -public class MsgAsyncSendThread extends Thread { - - private IMsgSender iMsgSender; - - public MsgAsyncSendThread(IMsgSender msgSender) { - this.iMsgSender = msgSender; - } - - @Override - public void run() { - - for (int i = 0; i < PushData.toSendList.size(); i++) { - if (!PushData.running) { - PushData.TO_SEND_COUNT.set(i); - return; - } - // 本条消息所需的数据 - String[] msgData = PushData.toSendList.get(i); - iMsgSender.asyncSend(msgData); - // 已处理+1 - PushData.increaseProcessed(); - BoostForm.getInstance().getProcessedCountLabel().setText(String.valueOf(PushData.processedRecords)); - - // 总进度条 - BoostForm.getInstance().getProcessedProgressBar().setValue(PushData.processedRecords.intValue()); - } - - } -} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgInfinitySendThread.java b/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgInfinitySendThread.java new file mode 100644 index 000000000..b4f169983 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgInfinitySendThread.java @@ -0,0 +1,64 @@ +package com.fangxuele.tool.push.logic.msgthread; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.logic.InfinityTaskRunThread; +import com.fangxuele.tool.push.logic.msgsender.IMsgSender; +import com.fangxuele.tool.push.logic.msgsender.SendResult; +import com.fangxuele.tool.push.util.ConsoleUtil; +import org.apache.commons.lang3.exception.ExceptionUtils; + +/** + *
+ * 消息异步发送服务线程
+ * 
+ * + * @author RememBerBer + * @since 2019/7/7. + */ +public class MsgInfinitySendThread extends Thread { + + private IMsgSender iMsgSender; + + private InfinityTaskRunThread infinityTaskRunThread; + + public MsgInfinitySendThread(IMsgSender msgSender, InfinityTaskRunThread infinityTaskRunThread) { + this.iMsgSender = msgSender; + infinityTaskRunThread.activeThreadConcurrentLinkedQueue.offer(this.getName()); + infinityTaskRunThread.threadStatusMap.put(this.getName(), true); + this.iMsgSender = msgSender; + this.infinityTaskRunThread = infinityTaskRunThread; + } + + @Override + public void run() { + + while (infinityTaskRunThread.running && infinityTaskRunThread.threadStatusMap.get(this.getName()) && !infinityTaskRunThread.toSendConcurrentLinkedQueue.isEmpty()) { + String[] msgData = infinityTaskRunThread.toSendConcurrentLinkedQueue.poll(); + if (msgData == null) { + continue; + } + try { + SendResult sendResult = iMsgSender.send(msgData); + if (sendResult.isSuccess()) { + infinityTaskRunThread.increaseSuccess(); + // 保存发送成功 + infinityTaskRunThread.sendSuccessList.add(msgData); + } else { + infinityTaskRunThread.increaseFail(); + // 保存发送失败 + infinityTaskRunThread.sendFailList.add(msgData); + ConsoleUtil.pushLog(infinityTaskRunThread.getLogWriter(), "发送失败:" + sendResult.getInfo() + ";msgData:" + JSONUtil.toJsonPrettyStr(msgData)); + } + } catch (Exception e) { + infinityTaskRunThread.increaseFail(); + ConsoleUtil.pushLog(infinityTaskRunThread.getLogWriter(), "发送异常:" + ExceptionUtils.getStackTrace(e)); + // 保存发送失败 + infinityTaskRunThread.sendFailList.add(msgData); + } + // 已处理+1 + infinityTaskRunThread.increaseProcessed(); + } + infinityTaskRunThread.activeThreadConcurrentLinkedQueue.remove(this.getName()); + infinityTaskRunThread.threadStatusMap.put(this.getName(), false); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgSendThread.java b/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgSendThread.java index 624fa9ebf..fe3657774 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgSendThread.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgthread/MsgSendThread.java @@ -1,12 +1,11 @@ package com.fangxuele.tool.push.logic.msgthread; import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.domain.TTask; import com.fangxuele.tool.push.logic.MessageTypeEnum; -import com.fangxuele.tool.push.logic.PushControl; -import com.fangxuele.tool.push.logic.PushData; +import com.fangxuele.tool.push.logic.TaskRunThread; import com.fangxuele.tool.push.logic.msgsender.IMsgSender; import com.fangxuele.tool.push.logic.msgsender.SendResult; -import com.fangxuele.tool.push.ui.form.PushForm; import com.fangxuele.tool.push.util.ConsoleUtil; import org.apache.commons.lang3.exception.ExceptionUtils; import org.bouncycastle.util.Arrays; @@ -23,15 +22,9 @@ public class MsgSendThread extends BaseMsgThread { private IMsgSender iMsgSender; - /** - * 构造函数 - * - * @param startIndex 起始页 - * @param endIndex 截止页 - */ - public MsgSendThread(int startIndex, int endIndex, IMsgSender iMsgSender) { - super(startIndex, endIndex); - this.iMsgSender = iMsgSender; + public MsgSendThread(int startIndex, int endIndex, IMsgSender msgSender, TaskRunThread taskRunThread) { + super(startIndex, endIndex, taskRunThread); + this.iMsgSender = msgSender; } @Override @@ -39,55 +32,47 @@ public void run() { try { // 初始化当前线程 initCurrentThread(); + TTask tTask = taskRunThread.getTTask(); + + // 间隔推送 + boolean isIntervalPush = tTask.getIntervalPush() != null && tTask.getIntervalPush() == 1 && tTask.getIntervalTime() != null; for (int i = 0; i < list.size(); i++) { - if (!PushData.running) { + if (!taskRunThread.running) { // 停止 - PushData.increaseStoppedThread(); return; } + // 间隔推送 + if (isIntervalPush) { + Thread.sleep(tTask.getIntervalTime() * 1000); + } + // 本条消息所需的数据 String[] msgData = list.get(i); SendResult sendResult = iMsgSender.send(msgData); - if (msgType == MessageTypeEnum.HTTP_CODE && PushControl.saveResponseBody) { + if (tTask.getMsgType() == MessageTypeEnum.HTTP_CODE && tTask.getSaveResult() == 1) { String body = sendResult.getInfo() == null ? "" : sendResult.getInfo(); msgData = Arrays.append(msgData, body); } if (sendResult.isSuccess()) { // 总发送成功+1 - PushData.increaseSuccess(); - PushForm.getInstance().getPushSuccessCount().setText(String.valueOf(PushData.successRecords)); - - // 当前线程发送成功+1 - successCountLocal.set(successCountLocal.get() + 1); - pushTableLocal.get().setValueAt(successCountLocal.get(), tableRow, 2); + taskRunThread.increaseSuccess(); // 保存发送成功 - PushData.sendSuccessList.add(msgData); + taskRunThread.sendSuccessList.add(msgData); } else { // 总发送失败+1 - PushData.increaseFail(); - PushForm.getInstance().getPushFailCount().setText(String.valueOf(PushData.failRecords)); + taskRunThread.increaseFail(); // 保存发送失败 - PushData.sendFailList.add(msgData); + taskRunThread.sendFailList.add(msgData); // 失败异常信息输出控制台 - ConsoleUtil.consoleOnly("发送失败:" + sendResult.getInfo() + ";msgData:" + JSONUtil.toJsonPrettyStr(msgData)); - - // 当前线程发送失败+1 - failCountLocal.set(failCountLocal.get() + 1); - pushTableLocal.get().setValueAt(failCountLocal.get(), tableRow, 3); + ConsoleUtil.pushLog(taskRunThread.getLogWriter(), "发送失败:" + sendResult.getInfo() + ";msgData:" + JSONUtil.toJsonPrettyStr(msgData)); } - - // 当前线程进度条 - pushTableLocal.get().setValueAt((int) ((double) (i + 1) / list.size() * 100), tableRow, 5); - - // 总进度条 - PushForm.getInstance().getPushTotalProgressBar().setValue(PushData.successRecords.intValue() + PushData.failRecords.intValue()); } // 当前线程结束 @@ -95,11 +80,9 @@ public void run() { } catch (Exception e) { logger.error(ExceptionUtils.getStackTrace(e)); } finally { - successCountLocal.remove(); - failCountLocal.remove(); - pushTableLocal.remove(); + // 线程结束,处理完毕的线程数+1 + taskRunThread.finishedThreadCount.incrementAndGet(); } - } } diff --git a/src/main/java/com/fangxuele/tool/push/ui/Init.java b/src/main/java/com/fangxuele/tool/push/ui/Init.java index df0d6b7b2..cdd904c3b 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/Init.java +++ b/src/main/java/com/fangxuele/tool/push/ui/Init.java @@ -5,26 +5,18 @@ import cn.hutool.log.LogFactory; import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.ui.dialog.FontSizeAdjustDialog; -import com.fangxuele.tool.push.ui.form.AboutForm; -import com.fangxuele.tool.push.ui.form.BoostForm; -import com.fangxuele.tool.push.ui.form.HelpForm; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.MemberForm; -import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.MessageManageForm; -import com.fangxuele.tool.push.ui.form.MessageTypeForm; -import com.fangxuele.tool.push.ui.form.PushForm; -import com.fangxuele.tool.push.ui.form.PushHisForm; -import com.fangxuele.tool.push.ui.form.ScheduleForm; -import com.fangxuele.tool.push.ui.form.SettingForm; -import com.fangxuele.tool.push.ui.form.UserCaseForm; -import com.fangxuele.tool.push.ui.listener.AboutListener; +import com.fangxuele.tool.push.ui.form.*; import com.fangxuele.tool.push.util.SystemUtil; import com.fangxuele.tool.push.util.UIUtil; import com.fangxuele.tool.push.util.UpgradeUtil; +import com.formdev.flatlaf.*; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.formdev.flatlaf.intellijthemes.*; +import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubDarkIJTheme; +import com.formdev.flatlaf.themes.FlatMacDarkLaf; +import com.formdev.flatlaf.themes.FlatMacLightLaf; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper; import javax.swing.*; import javax.swing.plaf.FontUIResource; @@ -32,6 +24,8 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Enumeration; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; /** *
@@ -48,7 +42,7 @@ public class Init {
     /**
      * 字号初始化KEY
      */
-    private static final String FONT_SIZE_INIT_PROP = "fontSizeInit";
+    public static final String FONT_SIZE_INIT_PROP = "fontSizeInit";
 
     /**
      * 设置全局字体
@@ -64,11 +58,12 @@ public static void initGlobalFont() {
 
             // Mac等高分辨率屏幕字号初始化
             if (SystemUtil.isMacOs()) {
-                fontSize = 15;
+                fontSize = 13;
             } else {
-                fontSize = (int) (UIUtil.getScreenScale() * fontSize);
+                fontSize = 12;
             }
             App.config.setFontSize(fontSize);
+            App.config.save();
         }
 
         Font font = new Font(App.config.getFont(), Font.PLAIN, App.config.getFontSize());
@@ -87,63 +82,124 @@ public static void initGlobalFont() {
      * 其他初始化
      */
     public static void initOthers() {
-        // 设置版本
-        AboutForm.getInstance().getVersionLabel().setText(UiConsts.APP_VERSION);
+
     }
 
     /**
      * 初始化look and feel
      */
     public static void initTheme() {
-
         try {
             switch (App.config.getTheme()) {
-                case "BeautyEye":
-                    BeautyEyeLNFHelper.launchBeautyEyeLNF();
-                    UIManager.put("RootPane.setupButtonVisible", false);
-                    break;
                 case "系统默认":
                     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                     break;
-                case "weblaf":
-                case "Darcula(推荐)":
+                case "Flat Light":
+                    setAccentColor();
+                    FlatLightLaf.setup();
+                    break;
+                case "Flat IntelliJ":
+                    setAccentColor();
+                    FlatIntelliJLaf.setup();
+                    break;
+                case "Flat Dark":
+                    setAccentColor();
+                    FlatDarkLaf.setup();
+                    break;
+                case "Dark purple":
+                    FlatDarkPurpleIJTheme.setup();
+                    break;
+                case "IntelliJ Cyan":
+                    FlatCyanLightIJTheme.setup();
+                    break;
+                case "IntelliJ Light":
+                    FlatLightFlatIJTheme.setup();
+                    break;
+                case "Monocai":
+                    FlatMonocaiIJTheme.setup();
+                    break;
+                case "Monokai Pro":
+                    FlatMonokaiProIJTheme.setup();
+                    UIManager.put("Button.arc", 5);
+                    break;
+                case "One Dark":
+                    FlatOneDarkIJTheme.setup();
+                    break;
+                case "Gray":
+                    FlatGrayIJTheme.setup();
+                    break;
+                case "High contrast":
+                    FlatHighContrastIJTheme.setup();
+                    break;
+                case "GitHub Dark":
+                    FlatGitHubDarkIJTheme.setup();
+                    break;
+                case "Xcode-Dark":
+                    FlatXcodeDarkIJTheme.setup();
+                    break;
+                case "Vuesion":
+                    FlatVuesionIJTheme.setup();
+                    break;
+                case "Flat macOS Light":
+                    FlatMacLightLaf.setup();
+                    break;
+                case "Flat macOS Dark":
+                    FlatMacDarkLaf.setup();
+                    break;
                 default:
-                    UIManager.setLookAndFeel("com.bulenkov.darcula.DarculaLaf");
+                    setAccentColor();
+                    FlatDarculaLaf.setup();
+            }
+
+            if (FlatLaf.isLafDark()) {
+//                FlatSVGIcon.ColorFilter.getInstance().setMapper(color -> color.brighter().brighter());
+            } else {
+                FlatSVGIcon.ColorFilter.getInstance().setMapper(color -> color.darker().darker());
+//                SwingUtilities.windowForComponent(App.mainFrame).repaint();
             }
+
+            if (App.config.isUnifiedBackground()) {
+                UIManager.put("TitlePane.unifiedBackground", true);
+            }
+
         } catch (Exception e) {
             logger.error(e);
         }
     }
 
+    private static void setAccentColor() {
+//        String accentColor = App.config.getAccentColor();
+//        FlatLaf.setGlobalExtraDefaults((!accentColor.equals(SettingDialog.accentColorKeys[0]))
+//                ? Collections.singletonMap("@accentColor", "$" + accentColor)
+//                : null);
+    }
+
     /**
      * 初始化所有tab
      */
     public static void initAllTab() {
-        ThreadUtil.execute(AboutForm::init);
         MessageTypeForm.init();
+        ThreadUtil.execute(AboutForm::init);
         ThreadUtil.execute(HelpForm::init);
-        ThreadUtil.execute(UserCaseForm::init);
-        ThreadUtil.execute(() -> MessageEditForm.init(null));
+//        ThreadUtil.execute(UserCaseForm::init);
+        ThreadUtil.execute(AccountManageForm::init);
+        ThreadUtil.execute(() -> AccountEditForm.init(null));
         ThreadUtil.execute(MessageManageForm::init);
-        ThreadUtil.execute(MemberForm::init);
-        ThreadUtil.execute(PushForm::init);
-        ThreadUtil.execute(BoostForm::init);
-        ThreadUtil.execute(ScheduleForm::init);
-        ThreadUtil.execute(SettingForm::init);
-        ThreadUtil.execute(PushHisForm::init);
+        ThreadUtil.execute(PeopleManageForm::init);
+        ThreadUtil.execute(() -> PeopleEditForm.init(null));
+        ThreadUtil.execute(TaskForm::init);
 
         // 检查新版版
         if (App.config.isAutoCheckUpdate()) {
-            ThreadUtil.execute(() -> UpgradeUtil.checkUpdate(true));
+            ScheduledThreadPoolExecutor threadPoolExecutor = new ScheduledThreadPoolExecutor(1);
+            threadPoolExecutor.scheduleAtFixedRate(() -> UpgradeUtil.checkUpdate(true), 0, 24, TimeUnit.HOURS);
         }
-        // 更新二维码
-        ThreadUtil.execute(AboutListener::initQrCode);
     }
 
     /**
      * 引导用户调整字号
      */
-    public static void initFontSize() {
+    public static void fontSizeGuide() {
         if (StringUtils.isEmpty(App.config.getProps(FONT_SIZE_INIT_PROP))) {
             FontSizeAdjustDialog fontSizeAdjustDialog = new FontSizeAdjustDialog();
             fontSizeAdjustDialog.pack();
@@ -167,7 +223,7 @@ public static void initTray() {
                 popupMenu.setFont(App.mainFrame.getContentPane().getFont());
 
                 MenuItem openItem = new MenuItem("WePush");
-                MenuItem exitItem = new MenuItem("退出");
+                MenuItem exitItem = new MenuItem("Exit");
 
                 openItem.addActionListener(e -> {
                     App.mainFrame.setExtendedState(JFrame.NORMAL);
@@ -175,22 +231,17 @@ public static void initTray() {
                     App.mainFrame.requestFocus();
                 });
                 exitItem.addActionListener(e -> {
-                    if (!PushForm.getInstance().getPushStartButton().isEnabled()) {
-                        JOptionPane.showMessageDialog(MainWindow.getInstance().getPushPanel(),
-                                "有推送任务正在进行!\n\n为避免数据丢失,请先停止!\n\n", "Sorry~",
-                                JOptionPane.WARNING_MESSAGE);
-                    } else {
-                        App.config.save();
-                        App.sqlSession.close();
-                        App.mainFrame.dispose();
-                        System.exit(0);
-                    }
+                    shutdown();
                 });
 
                 popupMenu.add(openItem);
                 popupMenu.add(exitItem);
 
-                App.trayIcon = new TrayIcon(UiConsts.IMAGE_LOGO_64, "WePush", popupMenu);
+                if (SystemUtil.isWindowsOs()) {
+                    App.trayIcon = new TrayIcon(UiConsts.IMAGE_LOGO_64, "WePush", popupMenu);
+                } else {
+                    App.trayIcon = new TrayIcon(new FlatSVGIcon("icon/icon_push.svg").getImage(), "WePush", popupMenu);
+                }
                 App.trayIcon.setImageAutoSize(true);
 
                 App.trayIcon.addActionListener(e -> {
@@ -236,4 +287,11 @@ public void mouseClicked(MouseEvent e) {
             logger.error(ExceptionUtils.getStackTrace(e));
         }
     }
+
+    public static void shutdown() {
+        App.config.save();
+        App.sqlSession.close();
+        App.mainFrame.dispose();
+        System.exit(0);
+    }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java b/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java
index eb5bd4740..5564dff27 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java
@@ -1,5 +1,8 @@
 package com.fangxuele.tool.push.ui;
 
+import com.formdev.flatlaf.extras.FlatSVGIcon;
+
+import javax.swing.*;
 import java.awt.*;
 
 /**
@@ -16,7 +19,9 @@ public class UiConsts {
      * 软件名称,版本
      */
     public final static String APP_NAME = "WePush";
-    public final static String APP_VERSION = "v_4.2.1_200308";
+    public final static String APP_VERSION = "v_5.0.5";
+
+    public static final int TABLE_ROW_HEIGHT = 30;
 
     /**
      * Logo-1024*1024
@@ -75,33 +80,32 @@ public class UiConsts {
     /**
      * 帮助图标
      */
-    public final static Image HELP_ICON = Toolkit.getDefaultToolkit()
-            .getImage(UiConsts.class.getResource("/icon/helpButton.png"));
+    public final static Icon HELP_ICON = new FlatSVGIcon("icon/help.svg");
 
     /**
      * 帮助图标-focused
      */
-    public final static Image HELP_FOCUSED_ICON = Toolkit.getDefaultToolkit()
-            .getImage(UiConsts.class.getResource("/icon/helpButtonFocused.png"));
+    public final static Icon HELP_FOCUSED_ICON = new FlatSVGIcon("icon/help-filling.svg");
 
     /**
      * 软件版本检查url
      */
-    public final static String CHECK_VERSION_URL = "https://gitee.com/zhoubochina/WePush/raw/master/src/main/resources/version_summary.json";
+    public final static String CHECK_VERSION_URL = "https://gitee.com/zhoubochina/WePush/raw/5.x/src/main/resources/version_summary.json";
 
     /**
      * 用户案例url
      */
-    public final static String USER_CASE_URL = "http://download.zhoubochina.com/file/user_case.json";
+    public final static String USER_CASE_URL = "https://gitee.com/zhoubochina/WePush/raw/5.x/assets/files/user_case.json";
 
     /**
      * 二维码url
      */
-    public final static String QR_CODE_URL = "http://download.zhoubochina.com/file/wepush_qrcode.json";
+    public final static String QR_CODE_URL = "https://gitee.com/zhoubochina/WePush/raw/5.x/assets/files/wx-zanshang.jpg";
 
     /**
      * 介绍二维码URL
      */
-    public final static String INTRODUCE_QRCODE_URL = "http://download.zhoubochina.com/qrcode/introduce-wepush-qrcode.png";
+    public final static String INTRODUCE_QRCODE_URL = "https://gitee.com/zhoubochina/WePush/raw/5.x/assets/files/introduce-wepush-qrcode.png";
 
+    public static final String DOWNLOAD_LINK_INFO_URL = "https://gitee.com/zhoubochina/WePush/raw/5.x/assets/files/download_links.json";
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellButtonColumn.java b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellButtonColumn.java
index 6c7e8318a..7fade8af8 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellButtonColumn.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellButtonColumn.java
@@ -1,6 +1,7 @@
 package com.fangxuele.tool.push.ui.component;
 
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 
 import javax.swing.*;
 import javax.swing.table.DefaultTableModel;
@@ -53,7 +54,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
         }
 
         renderButton.setText("");
-        renderButton.setIcon(new ImageIcon(getClass().getResource("/icon/remove.png")));
+        renderButton.setIcon(new FlatSVGIcon("icon/remove.svg"));
         return renderButton;
     }
 
@@ -61,7 +62,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
     public Component getTableCellEditorComponent(JTable table, Object value,
                                                  boolean isSelected, int row, int column) {
         editButton.setText("");
-        editButton.setIcon(new ImageIcon(getClass().getResource("/icon/remove.png")));
+        editButton.setIcon(new FlatSVGIcon("icon/remove.svg"));
         return editButton;
     }
 
diff --git a/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskDetailButtonColumn.java b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskDetailButtonColumn.java
new file mode 100644
index 000000000..acf77ca6b
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskDetailButtonColumn.java
@@ -0,0 +1,81 @@
+package com.fangxuele.tool.push.ui.component;
+
+import com.fangxuele.tool.push.ui.form.MainWindow;
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumnModel;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * 
+ * 自定义单元格按钮渲染器-任务详情
+ * 
+ * + * @author Zhou Bo + * @since 2021/5/25. + */ +public class TableInCellTaskDetailButtonColumn extends AbstractCellEditor implements + TableCellRenderer, TableCellEditor, ActionListener { + JTable table; + JButton renderButton; + JButton editButton; + + public TableInCellTaskDetailButtonColumn(JTable table, int column) { + super(); + this.table = table; + renderButton = new JButton(); + editButton = new JButton(); + editButton.setFocusPainted(false); + editButton.addActionListener(this); + + TableColumnModel columnModel = table.getColumnModel(); + columnModel.getColumn(column).setCellRenderer(this); + columnModel.getColumn(column).setCellEditor(this); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + if (hasFocus) { + renderButton.setForeground(table.getForeground()); + renderButton.setBackground(UIManager.getColor("Button.background")); + } else if (isSelected) { + renderButton.setForeground(table.getSelectionForeground()); + renderButton.setBackground(table.getSelectionBackground()); + } else { + renderButton.setForeground(table.getForeground()); + renderButton.setBackground(UIManager.getColor("Button.background")); + } + + renderButton.setText("详情"); + return renderButton; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + editButton.setText("详情"); + return editButton; + } + + @Override + public Object getCellEditorValue() { + return "remove"; + } + + @Override + public void actionPerformed(ActionEvent e) { + int isDelete = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "确定移除?", "请确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + fireEditingStopped(); + DefaultTableModel model = (DefaultTableModel) table.getModel(); + model.removeRow(table.getSelectedRow()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskExecuteButtonColumn.java b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskExecuteButtonColumn.java new file mode 100644 index 000000000..a722c8347 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskExecuteButtonColumn.java @@ -0,0 +1,81 @@ +package com.fangxuele.tool.push.ui.component; + +import com.fangxuele.tool.push.ui.form.MainWindow; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + *
+ * 自定义单元格按钮渲染器-执行任务
+ * 
+ * + * @author Zhou Bo + * @since 2021/5/25. + */ +public class TableInCellTaskExecuteButtonColumn extends AbstractCellEditor implements + TableCellRenderer, TableCellEditor, ActionListener { + JTable table; + JButton renderButton; + JButton editButton; + + public TableInCellTaskExecuteButtonColumn(JTable table, int column) { + super(); + this.table = table; + renderButton = new JButton(); + editButton = new JButton(); + editButton.setFocusPainted(false); + editButton.addActionListener(this); + + TableColumnModel columnModel = table.getColumnModel(); + columnModel.getColumn(column).setCellRenderer(this); + columnModel.getColumn(column).setCellEditor(this); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + if (hasFocus) { + renderButton.setForeground(table.getForeground()); + renderButton.setBackground(UIManager.getColor("Button.background")); + } else if (isSelected) { + renderButton.setForeground(table.getSelectionForeground()); + renderButton.setBackground(table.getSelectionBackground()); + } else { + renderButton.setForeground(table.getForeground()); + renderButton.setBackground(UIManager.getColor("Button.background")); + } + + renderButton.setText("开始"); + return renderButton; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + editButton.setText("开始"); + return editButton; + } + + @Override + public Object getCellEditorValue() { + return "remove"; + } + + @Override + public void actionPerformed(ActionEvent e) { + int isDelete = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "确定移除?", "请确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + fireEditingStopped(); + DefaultTableModel model = (DefaultTableModel) table.getModel(); + model.removeRow(table.getSelectedRow()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskModifyButtonColumn.java b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskModifyButtonColumn.java new file mode 100644 index 000000000..f94b5b186 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/component/TableInCellTaskModifyButtonColumn.java @@ -0,0 +1,81 @@ +package com.fangxuele.tool.push.ui.component; + +import com.fangxuele.tool.push.ui.form.MainWindow; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + *
+ * 自定义单元格按钮渲染器-任务修改
+ * 
+ * + * @author Zhou Bo + * @since 2021/5/25. + */ +public class TableInCellTaskModifyButtonColumn extends AbstractCellEditor implements + TableCellRenderer, TableCellEditor, ActionListener { + JTable table; + JButton renderButton; + JButton editButton; + + public TableInCellTaskModifyButtonColumn(JTable table, int column) { + super(); + this.table = table; + renderButton = new JButton(); + editButton = new JButton(); + editButton.setFocusPainted(false); + editButton.addActionListener(this); + + TableColumnModel columnModel = table.getColumnModel(); + columnModel.getColumn(column).setCellRenderer(this); + columnModel.getColumn(column).setCellEditor(this); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + if (hasFocus) { + renderButton.setForeground(table.getForeground()); + renderButton.setBackground(UIManager.getColor("Button.background")); + } else if (isSelected) { + renderButton.setForeground(table.getSelectionForeground()); + renderButton.setBackground(table.getSelectionBackground()); + } else { + renderButton.setForeground(table.getForeground()); + renderButton.setBackground(UIManager.getColor("Button.background")); + } + + renderButton.setText("修改"); + return renderButton; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + editButton.setText("修改"); + return editButton; + } + + @Override + public Object getCellEditorValue() { + return "remove"; + } + + @Override + public void actionPerformed(ActionEvent e) { + int isDelete = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "确定移除?", "请确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + fireEditingStopped(); + DefaultTableModel model = (DefaultTableModel) table.getModel(); + model.removeRow(table.getSelectedRow()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/component/TopMenuBar.java b/src/main/java/com/fangxuele/tool/push/ui/component/TopMenuBar.java new file mode 100644 index 000000000..923ead947 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/component/TopMenuBar.java @@ -0,0 +1,458 @@ +package com.fangxuele.tool.push.ui.component; + +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.ui.Init; +import com.fangxuele.tool.push.ui.dialog.AboutDialog; +import com.fangxuele.tool.push.ui.dialog.AppreciateDialog; +import com.fangxuele.tool.push.ui.dialog.SettingDialog; +import com.fangxuele.tool.push.ui.dialog.SystemEnvResultDialog; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.FlatLaf; +import com.formdev.flatlaf.extras.FlatAnimatedLafChange; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; +import java.util.Properties; + +/** + * 顶部菜单栏 + */ +public class TopMenuBar extends JMenuBar { + private static final Log logger = LogFactory.get(); + + private static TopMenuBar menuBar; + + private static JMenu themeMenu; + + private static JMenu fontFamilyMenu; + + private static JMenu fontSizeMenu; + + private static int initialThemeItemCount = -1; + + private static int initialFontFamilyItemCount = -1; + + private static int initialFontSizeItemCount = -1; + + private static String[] themeNames = { + "系统默认", + "Flat Light", + "Flat Dark", + "Flat IntelliJ", + "Flat Darcula(推荐)", + "Flat macOS Light", + "Flat macOS Dark", + "Dark purple", + "IntelliJ Cyan", + "IntelliJ Light", + "Monocai", + "Monokai Pro", + "One Dark", + "Gray", + "High contrast", + "GitHub Dark", + "Xcode-Dark", + "Vuesion"}; + + private static String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); + + private static String[] fontSizes = { + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "20", + "21", + "22", + "23", + "24", + "25", + "26"}; + + private TopMenuBar() { + } + + public static TopMenuBar getInstance() { + if (menuBar == null) { + menuBar = new TopMenuBar(); + } + return menuBar; + } + + public void init() { + TopMenuBar topMenuBar = getInstance(); + // ---------应用 + JMenu appMenu = new JMenu(); + appMenu.setText("应用"); + // 设置 + JMenuItem settingMenuItem = new JMenuItem(); + settingMenuItem.setText("设置"); + settingMenuItem.addActionListener(e -> settingActionPerformed()); + appMenu.add(settingMenuItem); + // 退出 + JMenuItem exitMenuItem = new JMenuItem(); + exitMenuItem.setText("退出"); + exitMenuItem.addActionListener(e -> exitActionPerformed()); + appMenu.add(exitMenuItem); + topMenuBar.add(appMenu); + + // ---------外观 + JMenu appearanceMenu = new JMenu(); + appearanceMenu.setText("外观"); + + JCheckBoxMenuItem defaultMaxWindowitem = new JCheckBoxMenuItem("默认最大化窗口"); + defaultMaxWindowitem.setSelected(App.config.isDefaultMaxWindow()); + defaultMaxWindowitem.addActionListener(e -> { + boolean selected = defaultMaxWindowitem.isSelected(); + if (selected) { + App.mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); + } else { + App.mainFrame.setExtendedState(JFrame.NORMAL); + } + App.config.setDefaultMaxWindow(selected); + App.config.save(); + }); + appearanceMenu.add(defaultMaxWindowitem); + + JCheckBoxMenuItem unifiedBackgrounditem = new JCheckBoxMenuItem("窗口颜色沉浸式"); + unifiedBackgrounditem.setSelected(App.config.isUnifiedBackground()); + unifiedBackgrounditem.addActionListener(e -> { + boolean selected = unifiedBackgrounditem.isSelected(); + App.config.setUnifiedBackground(selected); + App.config.save(); + UIManager.put("TitlePane.unifiedBackground", selected); + FlatLaf.updateUI(); + }); + appearanceMenu.add(unifiedBackgrounditem); + + themeMenu = new JMenu(); + themeMenu.setText("主题风格"); + + initThemesMenu(); + + appearanceMenu.add(themeMenu); + + fontFamilyMenu = new JMenu(); + fontFamilyMenu.setText("字体"); + initFontFamilyMenu(); + + appearanceMenu.add(fontFamilyMenu); + + fontSizeMenu = new JMenu(); + fontSizeMenu.setText("字号"); + initFontSizeMenu(); + + appearanceMenu.add(fontSizeMenu); + + topMenuBar.add(appearanceMenu); + // ---------调试 + JMenu debugMenu = new JMenu(); + debugMenu.setText("调试"); + // 查看日志 + JMenuItem logMenuItem = new JMenuItem(); + logMenuItem.setText("查看日志"); + logMenuItem.addActionListener(e -> logActionPerformed()); + + debugMenu.add(logMenuItem); + // 系统环境变量 + JMenuItem sysEnvMenuItem = new JMenuItem(); + sysEnvMenuItem.setText("系统环境变量"); + sysEnvMenuItem.addActionListener(e -> sysEnvActionPerformed()); + + debugMenu.add(sysEnvMenuItem); + topMenuBar.add(debugMenu); + + // ---------帮助 + JMenu helpMenu = new JMenu(); + helpMenu.setText("帮助"); + // 帮助 + JMenuItem helpMenuItem = new JMenuItem(); + helpMenuItem.setText("帮助"); + helpMenuItem.addActionListener(e -> helpActionPerformed()); + + helpMenu.add(helpMenuItem); + // 关于 + JMenuItem aboutMenuItem = new JMenuItem(); + aboutMenuItem.setText("关于"); + aboutMenuItem.addActionListener(e -> aboutActionPerformed()); + + helpMenu.add(aboutMenuItem); + topMenuBar.add(helpMenu); + + // ---------鼓励一下 + JMenu appreciateMenu = new JMenu(); + appreciateMenu.setText("❤ 鼓励一下"); + // 鼓励一下 + JMenuItem appreciateMenuItem = new JMenuItem(); + appreciateMenuItem.setText("❤ 鼓励一下"); + appreciateMenuItem.addActionListener(e -> appreciateActionPerformed()); + + appreciateMenu.add(appreciateMenuItem); + // 其他作品 + JMenuItem otherWorksMenuItem = new JMenuItem(); + otherWorksMenuItem.setText("其他作品"); + otherWorksMenuItem.addActionListener(e -> otherWorksActionPerformed()); + + appreciateMenu.add(otherWorksMenuItem); + topMenuBar.add(appreciateMenu); + } + + /** + * 其他作品 + */ + private void otherWorksActionPerformed() { + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI("http://www.luoboduner.com/post/works/")); + } catch (IOException | URISyntaxException e1) { + logger.error(e1); + } + } + + /** + * 鼓励一下 + */ + private void appreciateActionPerformed() { + try { + AppreciateDialog dialog = new AppreciateDialog(); + + dialog.pack(); + dialog.setVisible(true); + } catch (Exception e2) { + logger.error(e2); + } + } + + /** + * 关于 + */ + private void aboutActionPerformed() { + try { + AboutDialog dialog = new AboutDialog(); + + dialog.pack(); + dialog.setVisible(true); + } catch (Exception e2) { + logger.error(e2); + } + } + + /** + * 帮助 + */ + private void helpActionPerformed() { + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI("https://gitee.com/zhoubochina/WePush/wikis")); + } catch (IOException | URISyntaxException e1) { + logger.error(e1); + } + } + + private void initFontSizeMenu() { + + if (initialFontSizeItemCount < 0) + initialFontSizeItemCount = fontSizeMenu.getItemCount(); + else { + // remove old items + for (int i = fontSizeMenu.getItemCount() - 1; i >= initialFontSizeItemCount; i--) + fontSizeMenu.remove(i); + } + for (String fontSize : fontSizes) { + JCheckBoxMenuItem item = new JCheckBoxMenuItem(fontSize); + item.setSelected(fontSize.equals(String.valueOf(App.config.getFontSize()))); + item.addActionListener(this::fontSizeChanged); + fontSizeMenu.add(item); + } + } + + + private void initFontFamilyMenu() { + + if (initialFontFamilyItemCount < 0) + initialFontFamilyItemCount = fontFamilyMenu.getItemCount(); + else { + // remove old items + for (int i = fontFamilyMenu.getItemCount() - 1; i >= initialFontFamilyItemCount; i--) + fontFamilyMenu.remove(i); + } + for (String font : fontNames) { + JCheckBoxMenuItem item = new JCheckBoxMenuItem(font); + item.setSelected(font.equals(App.config.getFont())); + item.addActionListener(this::fontFamilyChanged); + fontFamilyMenu.add(item); + } + } + + private void initThemesMenu() { + + if (initialThemeItemCount < 0) + initialThemeItemCount = themeMenu.getItemCount(); + else { + // remove old items + for (int i = themeMenu.getItemCount() - 1; i >= initialThemeItemCount; i--) + themeMenu.remove(i); + } + for (String themeName : themeNames) { + JCheckBoxMenuItem item = new JCheckBoxMenuItem(themeName); + item.setSelected(themeName.equals(App.config.getTheme())); + item.addActionListener(this::themeChanged); + themeMenu.add(item); + } + } + + private void fontSizeChanged(ActionEvent actionEvent) { + try { + String selectedFontSize = actionEvent.getActionCommand(); + + FlatAnimatedLafChange.showSnapshot(); + + App.config.setFontSize(Integer.parseInt(selectedFontSize)); + App.config.save(); + + Init.initGlobalFont(); + SwingUtilities.updateComponentTreeUI(App.mainFrame); + SwingUtilities.updateComponentTreeUI(MainWindow.getInstance().getTabbedPane()); + +// FlatLaf.updateUI(); + + FlatAnimatedLafChange.hideSnapshotWithAnimation(); + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功", + JOptionPane.INFORMATION_MESSAGE); + + initFontSizeMenu(); + + } catch (Exception e1) { + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + } + + + private void fontFamilyChanged(ActionEvent actionEvent) { + try { + String selectedFamily = actionEvent.getActionCommand(); + + FlatAnimatedLafChange.showSnapshot(); + + App.config.setFont(selectedFamily); + App.config.save(); + + Init.initGlobalFont(); + SwingUtilities.updateComponentTreeUI(App.mainFrame); + SwingUtilities.updateComponentTreeUI(MainWindow.getInstance().getTabbedPane()); + +// FlatLaf.updateUI(); + + FlatAnimatedLafChange.hideSnapshotWithAnimation(); + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功", + JOptionPane.INFORMATION_MESSAGE); + + initFontFamilyMenu(); + + } catch (Exception e1) { + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + } + + private void themeChanged(ActionEvent actionEvent) { + try { + String selectedThemeName = actionEvent.getActionCommand(); + + FlatAnimatedLafChange.showSnapshot(); + + App.config.setTheme(selectedThemeName); + App.config.save(); + + Init.initTheme(); + SwingUtilities.updateComponentTreeUI(App.mainFrame); + SwingUtilities.updateComponentTreeUI(MainWindow.getInstance().getTabbedPane()); + +// FlatLaf.updateUI(); + + FlatAnimatedLafChange.hideSnapshotWithAnimation(); + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功", + JOptionPane.INFORMATION_MESSAGE); + + initThemesMenu(); + + } catch (Exception e1) { + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + } + + private void sysEnvActionPerformed() { + try { + SystemEnvResultDialog dialog = new SystemEnvResultDialog(); + + dialog.appendTextArea("------------System.getenv---------------"); + Map map = System.getenv(); + for (Map.Entry envEntry : map.entrySet()) { + dialog.appendTextArea(envEntry.getKey() + "=" + envEntry.getValue()); + } + + dialog.appendTextArea("------------System.getProperties---------------"); + Properties properties = System.getProperties(); + for (Map.Entry objectObjectEntry : properties.entrySet()) { + dialog.appendTextArea(objectObjectEntry.getKey() + "=" + objectObjectEntry.getValue()); + } + + dialog.pack(); + dialog.setVisible(true); + } catch (Exception e2) { + logger.error("查看系统环境变量失败", e2); + } + } + + private void logActionPerformed() { + try { + Desktop desktop = Desktop.getDesktop(); + desktop.open(new File(SystemUtil.LOG_DIR)); + } catch (Exception e2) { + logger.error("查看日志打开失败", e2); + } + } + + private void exitActionPerformed() { + Init.shutdown(); + } + + private void settingActionPerformed() { + try { + SettingDialog dialog = new SettingDialog(); + + dialog.pack(); + dialog.setVisible(true); + } catch (Exception e2) { + logger.error(e2); + } + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/AboutDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/AboutDialog.form new file mode 100644 index 000000000..9594ba6f8 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/AboutDialog.form @@ -0,0 +1,120 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/AboutDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/AboutDialog.java new file mode 100644 index 000000000..fab2e14a2 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/AboutDialog.java @@ -0,0 +1,262 @@ +package com.fangxuele.tool.push.ui.dialog; + +import cn.hutool.core.thread.ThreadUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.fangxuele.tool.push.util.UpgradeUtil; +import com.formdev.flatlaf.util.SystemInfo; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.exception.ExceptionUtils; + +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Locale; + +@Slf4j +public class AboutDialog extends JDialog { + private JPanel contentPane; + private JPanel aboutPanel; + private JLabel sloganLabel; + private JLabel qrCodeLabel; + private JLabel versionLabel; + private JLabel checkUpdateLabel; + private JLabel companyLabel; + private JLabel helpDocLabel; + private JLabel pushTotalLabel; + + public AboutDialog() { + super(App.mainFrame, "关于"); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.64); + setContentPane(contentPane); + setModal(true); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + + addListeners(); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + pushTotalLabel.setText("已累计为您推送 " + App.config.getPushTotal() + " 条消息"); + // 设置版本 + versionLabel.setText(UiConsts.APP_VERSION); + + ThreadUtil.execute(this::initQrCode); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(new ActionListener() { + public void actionPerformed(ActionEvent e) { + onCancel(); + } + }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED); + } + + private void onOK() { + // add your code here + dispose(); + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + public void addListeners() { + companyLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI("https://gitee.com/zhoubochina/WePush")); + } catch (IOException | URISyntaxException e1) { + e1.printStackTrace(); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + super.mouseEntered(e); + e.getComponent().setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + }); + + // 检查更新 + checkUpdateLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + ThreadUtil.execute(() -> UpgradeUtil.checkUpdate(false)); + } + + @Override + public void mouseEntered(MouseEvent e) { + super.mouseEntered(e); + e.getComponent().setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + }); + + // 帮助文档 + helpDocLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI("https://github.com/rememberber/WePush/wiki")); + } catch (IOException | URISyntaxException e1) { + e1.printStackTrace(); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + super.mouseEntered(e); + e.getComponent().setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + }); + } + + /** + * 初始化二维码 + */ + public void initQrCode() { + try { + URL url = new URL(UiConsts.QR_CODE_URL); + BufferedImage image = ImageIO.read(url); + qrCodeLabel.setIcon(new ImageIcon(image)); + } catch (IOException e) { + e.printStackTrace(); + log.error(ExceptionUtils.getStackTrace(e)); + } + + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JScrollPane scrollPane1 = new JScrollPane(); + contentPane.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + aboutPanel = new JPanel(); + aboutPanel.setLayout(new GridLayoutManager(9, 2, new Insets(0, 0, 10, 0), -1, -1)); + scrollPane1.setViewportView(aboutPanel); + sloganLabel = new JLabel(); + sloganLabel.setIcon(new ImageIcon(getClass().getResource("/icon/logo-128.png"))); + sloganLabel.setText(""); + aboutPanel.add(sloganLabel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setEnabled(true); + Font label1Font = this.$$$getFont$$$(null, -1, 36, label1.getFont()); + if (label1Font != null) label1.setFont(label1Font); + label1.setText("WePush"); + aboutPanel.add(label1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + qrCodeLabel = new JLabel(); + qrCodeLabel.setIcon(new ImageIcon(getClass().getResource("/icon/wx-zanshang.jpg"))); + qrCodeLabel.setText(""); + qrCodeLabel.setToolTipText("感谢您的鼓励和支持!"); + aboutPanel.add(qrCodeLabel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + versionLabel = new JLabel(); + Font versionLabelFont = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, versionLabel.getFont()); + if (versionLabelFont != null) versionLabel.setFont(versionLabelFont); + versionLabel.setText("v_0.0.0"); + aboutPanel.add(versionLabel, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + checkUpdateLabel = new JLabel(); + Font checkUpdateLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, checkUpdateLabel.getFont()); + if (checkUpdateLabelFont != null) checkUpdateLabel.setFont(checkUpdateLabelFont); + checkUpdateLabel.setText("检查更新"); + aboutPanel.add(checkUpdateLabel, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + companyLabel = new JLabel(); + Font companyLabelFont = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, companyLabel.getFont()); + if (companyLabelFont != null) companyLabel.setFont(companyLabelFont); + companyLabel.setText("Fork me on Gitee: https://gitee.com/zhoubochina/WePush"); + aboutPanel.add(companyLabel, new GridConstraints(8, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + helpDocLabel = new JLabel(); + Font helpDocLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, helpDocLabel.getFont()); + if (helpDocLabelFont != null) helpDocLabel.setFont(helpDocLabelFont); + helpDocLabel.setText("| 帮助文档"); + aboutPanel.add(helpDocLabel, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushTotalLabel = new JLabel(); + pushTotalLabel.setText("已累计为您推送 0 条消息"); + pushTotalLabel.setToolTipText(" 自3.4.0版本开始算起"); + aboutPanel.add(pushTotalLabel, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("专注批量推送的小而美的工具"); + aboutPanel.add(label2, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("Proudly by RememBerBer 周波"); + aboutPanel.add(label3, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/AppreciateDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/AppreciateDialog.form new file mode 100644 index 000000000..963a84d83 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/AppreciateDialog.form @@ -0,0 +1,33 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/AppreciateDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/AppreciateDialog.java new file mode 100644 index 000000000..1eff6ee3e --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/AppreciateDialog.java @@ -0,0 +1,113 @@ +package com.fangxuele.tool.push.ui.dialog; + +import cn.hutool.core.thread.ThreadUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.exception.ExceptionUtils; + +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URL; + +@Slf4j +public class AppreciateDialog extends JDialog { + private JPanel contentPane; + private JLabel qrCodeLabel; + + public AppreciateDialog() { + super(App.mainFrame, "鼓励一下"); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 400, 400); + setContentPane(contentPane); + setModal(true); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + + ThreadUtil.execute(this::initQrCode); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(new ActionListener() { + public void actionPerformed(ActionEvent e) { + onCancel(); + } + }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED); + } + + /** + * 初始化二维码 + */ + public void initQrCode() { + try { + URL url = new URL(UiConsts.QR_CODE_URL); + BufferedImage image = ImageIO.read(url); + qrCodeLabel.setIcon(new ImageIcon(image)); + } catch (IOException e) { + e.printStackTrace(); + log.error(ExceptionUtils.getStackTrace(e)); + } + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + qrCodeLabel = new JLabel(); + qrCodeLabel.setIcon(new ImageIcon(getClass().getResource("/icon/wx-zanshang.jpg"))); + qrCodeLabel.setText(""); + qrCodeLabel.setToolTipText("感谢您的鼓励和支持!"); + panel1.add(qrCodeLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.form index 5a1dac1b6..890eeee37 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.form +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.form @@ -9,7 +9,7 @@ - + @@ -59,13 +59,14 @@ - + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.java index 6a6bb7876..9492c8be8 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.java +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/CommonTipsDialog.java @@ -2,12 +2,15 @@ import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; import lombok.Getter; import javax.swing.*; +import javax.swing.border.TitledBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; @@ -38,6 +41,15 @@ public CommonTipsDialog() { setModal(true); getRootPane().setDefaultButton(buttonOK); + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.64); textPane1.addHyperlinkListener(e -> { @@ -118,7 +130,7 @@ public void setHtmlText(String htmlText) { contentPane = new JPanel(); contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 10, 0), -1, -1)); final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 10, 0), -1, -1)); contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); @@ -135,9 +147,11 @@ public void setHtmlText(String htmlText) { contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JScrollPane scrollPane1 = new JScrollPane(); panel3.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); textPane1 = new JTextPane(); textPane1.setEditable(false); textPane1.setMargin(new Insets(80, 28, 3, 28)); + textPane1.setRequestFocusEnabled(false); scrollPane1.setViewportView(textPane1); } diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/DingAppDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/DingAppDialog.form deleted file mode 100644 index 56186a889..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/DingAppDialog.form +++ /dev/null @@ -1,156 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/DingAppDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/DingAppDialog.java deleted file mode 100644 index d2f6fcc21..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/DingAppDialog.java +++ /dev/null @@ -1,277 +0,0 @@ -package com.fangxuele.tool.push.ui.dialog; - -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TDingAppMapper; -import com.fangxuele.tool.push.domain.TDingApp; -import com.fangxuele.tool.push.ui.form.SettingForm; -import com.fangxuele.tool.push.util.ComponentUtil; -import com.fangxuele.tool.push.util.JTableUtil; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.fangxuele.tool.push.util.SqliteUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.List; - -/** - *
- * DingAppDialog
- * 
- * - * @author Zhou Bo - * @since 2019/9/5. - */ -public class DingAppDialog extends JDialog { - private JPanel contentPane; - private JButton buttonDelete; - private JButton buttonCancel; - private JTable appsTable; - private JTextField appNameTextField; - private JTextField agentIdTextField; - private JTextField appKeyTextField; - private JTextField appSecretTextField; - private JButton saveButton; - - private Log logger = LogFactory.get(); - private static TDingAppMapper dingAppMapper = MybatisUtil.getSqlSession().getMapper(TDingAppMapper.class); - - public DingAppDialog() { - super(App.mainFrame, "钉钉-应用管理"); - setContentPane(contentPane); - setModal(true); - - ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.5, 0.5); - - // 保存按钮事件 - saveButton.addActionListener(e -> { - String appName = appNameTextField.getText(); - if (StringUtils.isBlank(appName)) { - JOptionPane.showMessageDialog(this, "请填写账号名称!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - String agentId = agentIdTextField.getText(); - if (StringUtils.isBlank(agentId)) { - JOptionPane.showMessageDialog(this, "请填写AgentId!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - boolean update = false; - List tDingAppList = dingAppMapper.selectByAppName(appName); - if (tDingAppList.size() > 0) { - update = true; - } - - TDingApp tDingApp = new TDingApp(); - String now = SqliteUtil.nowDateForSqlite(); - tDingApp.setAppName(appName); - tDingApp.setAgentId(agentIdTextField.getText()); - tDingApp.setAppKey(appKeyTextField.getText()); - tDingApp.setAppSecret(appSecretTextField.getText()); - tDingApp.setModifiedTime(now); - - if (update) { - tDingApp.setId(tDingAppList.get(0).getId()); - dingAppMapper.updateByPrimaryKeySelective(tDingApp); - } else { - tDingApp.setCreateTime(now); - dingAppMapper.insert(tDingApp); - } - renderTable(); - JOptionPane.showMessageDialog(this, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - }); - - // 删除按钮事件 - buttonDelete.addActionListener(e -> ThreadUtil.execute(() -> { - try { - int[] selectedRows = appsTable.getSelectedRows(); - if (selectedRows.length == 0) { - JOptionPane.showMessageDialog(this, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } else { - int isDelete = JOptionPane.showConfirmDialog(this, "确认删除?", "确认", - JOptionPane.YES_NO_OPTION); - if (isDelete == JOptionPane.YES_OPTION) { - DefaultTableModel tableModel = (DefaultTableModel) appsTable.getModel(); - for (int i = selectedRows.length; i > 0; i--) { - int selectedRow = appsTable.getSelectedRow(); - Integer selectedId = (Integer) tableModel.getValueAt(selectedRow, 0); - dingAppMapper.deleteByPrimaryKey(selectedId); - tableModel.removeRow(selectedRow); - } - SettingForm.initSwitchMultiAccount(); - } - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(this, "删除失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - })); - - appsTable.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - clearFields(); - - int selectedRow = appsTable.getSelectedRow(); - String selectedId = appsTable.getValueAt(selectedRow, 0).toString(); - TDingApp tDingApp = dingAppMapper.selectByPrimaryKey(Integer.valueOf(selectedId)); - appNameTextField.setText(tDingApp.getAppName()); - agentIdTextField.setText(tDingApp.getAgentId()); - appKeyTextField.setText(tDingApp.getAppKey()); - appSecretTextField.setText(tDingApp.getAppSecret()); - super.mousePressed(e); - } - }); - - buttonCancel.addActionListener(e -> onCancel()); - - // call onCancel() when cross is clicked - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - onCancel(); - } - }); - - // call onCancel() on ESCAPE - contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - } - - private void onCancel() { - // add your code here if necessary - dispose(); - } - - /** - * 应用列表表格 - */ - public void renderTable() { - String[] headerNames = {"id", "应用名称", "AgentId", "AppKey", "AppSecret"}; - DefaultTableModel model = new DefaultTableModel(null, headerNames); - appsTable.setModel(model); - - DefaultTableCellRenderer hr = (DefaultTableCellRenderer) appsTable.getTableHeader().getDefaultRenderer(); - // 表头列名居左 - hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); - - List dingAppList = dingAppMapper.selectAll(); - Object[] data; - for (TDingApp tDingApp : dingAppList) { - data = new Object[5]; - data[0] = tDingApp.getId(); - data[1] = tDingApp.getAppName(); - data[2] = tDingApp.getAgentId(); - data[3] = tDingApp.getAppKey(); - data[4] = tDingApp.getAppSecret(); - model.addRow(data); - } - - // 隐藏id列 - JTableUtil.hideColumn(appsTable, 0); - } - - /** - * 清空表单 - */ - public void clearFields() { - appNameTextField.setText(""); - agentIdTextField.setText(""); - appKeyTextField.setText(""); - appSecretTextField.setText(""); - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - contentPane.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false)); - panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - buttonDelete = new JButton(); - buttonDelete.setText("删除"); - panel2.add(buttonDelete, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - buttonCancel = new JButton(); - buttonCancel.setText("好了"); - panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(5, 3, new Insets(5, 5, 0, 5), -1, -1)); - contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "添加应用", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); - final JLabel label1 = new JLabel(); - label1.setText("应用名称"); - panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("AgentId"); - panel3.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("Appkey"); - panel3.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("AppSecret"); - panel3.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - appNameTextField = new JTextField(); - panel3.add(appNameTextField, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - agentIdTextField = new JTextField(); - panel3.add(agentIdTextField, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - appKeyTextField = new JTextField(); - panel3.add(appKeyTextField, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - appSecretTextField = new JTextField(); - panel3.add(appSecretTextField, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - saveButton = new JButton(); - saveButton.setText("保存"); - panel3.add(saveButton, new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer2 = new Spacer(); - panel3.add(spacer2, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JScrollPane scrollPane1 = new JScrollPane(); - contentPane.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - appsTable = new JTable(); - appsTable.setRowHeight(36); - scrollPane1.setViewportView(appsTable); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return contentPane; - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.form index 85f2896da..58d2e7a93 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.form +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.form @@ -9,7 +9,7 @@ - + @@ -50,7 +50,7 @@
- + @@ -93,14 +93,24 @@ - + + - + - - - - + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.java index 2dd2010b0..4aa5cfe39 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.java +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/ExportDialog.java @@ -2,6 +2,8 @@ import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; @@ -46,6 +48,15 @@ public ExportDialog() { setModal(true); getRootPane().setDefaultButton(buttonOK); + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + ComponentUtil.setPreferSizeAndLocateToCenter(this, 420, 300); buttonOK.addActionListener(e -> onOK()); @@ -130,7 +141,7 @@ private void unSelectAll() { contentPane = new JPanel(); contentPane.setLayout(new GridLayoutManager(5, 1, new Insets(10, 10, 10, 10), -1, -1)); final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 10, 10), -1, -1)); contentPane.add(panel1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); @@ -144,7 +155,7 @@ private void unSelectAll() { buttonCancel.setText("取消"); panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.setLayout(new GridLayoutManager(3, 1, new Insets(0, 10, 0, 10), -1, -1)); contentPane.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); excelRadioButton = new JRadioButton(); excelRadioButton.setText("Excel"); @@ -159,9 +170,12 @@ private void unSelectAll() { contentPane.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final Spacer spacer3 = new Spacer(); contentPane.add(spacer3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 10), -1, -1)); + contentPane.add(panel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("导出文件类型:"); - contentPane.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel4.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); } /** diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.form index cff04ad28..bfa127f9b 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.form +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.form @@ -9,7 +9,7 @@ - + @@ -21,7 +21,7 @@ - + @@ -29,17 +29,9 @@ - - - - - - - - - + @@ -76,7 +68,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.java index 2628a9f68..1a1e44a11 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.java +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/FontSizeAdjustDialog.java @@ -1,19 +1,21 @@ package com.fangxuele.tool.push.ui.dialog; -import cn.hutool.core.thread.ThreadUtil; import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.SettingForm; import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.util.Locale; /** *
@@ -26,19 +28,25 @@
 public class FontSizeAdjustDialog extends JDialog {
     private static final long serialVersionUID = -5644281737118296595L;
     private JPanel contentPane;
-    private JButton buttonOK;
     private JButton buttonCancel;
 
     public FontSizeAdjustDialog() {
         super(App.mainFrame, "字号初始化设置");
         setContentPane(contentPane);
         setModal(true);
-        getRootPane().setDefaultButton(buttonOK);
+        getRootPane().setDefaultButton(buttonCancel);
+
+        if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) {
+            this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true);
+            this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true);
+            this.getRootPane().putClientProperty("apple.awt.fullscreenable", true);
+            this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false);
+            GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout();
+            gridLayoutManager.setMargin(new Insets(28, 0, 0, 0));
+        }
 
         ComponentUtil.setPreferSizeAndLocateToCenter(this, 420, 200);
 
-        buttonOK.addActionListener(e -> onOK());
-
         buttonCancel.addActionListener(e -> onCancel());
 
         // call onCancel() when cross is clicked
@@ -55,13 +63,6 @@ public void windowClosing(WindowEvent e) {
     }
 
     private void onOK() {
-        MainWindow.getInstance().getTabbedPane().setSelectedIndex(7);
-        Point p = new Point(0, Integer.MAX_VALUE);
-        SettingForm.getInstance().getSettingScrollPane().getViewport().setViewPosition(p);
-        ThreadUtil.execute(() -> {
-            ThreadUtil.safeSleep(3000);
-            SettingForm.getInstance().getSettingFontSizeComboBox().grabFocus();
-        });
         dispose();
     }
 
@@ -88,19 +89,16 @@ private void onCancel() {
         contentPane = new JPanel();
         contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
         final JPanel panel1 = new JPanel();
-        panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
+        panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 10, 0), -1, -1));
         contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
         final Spacer spacer1 = new Spacer();
         panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
         final JPanel panel2 = new JPanel();
-        panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
+        panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
-        buttonOK = new JButton();
-        buttonOK.setText("这就去设置");
-        panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         buttonCancel = new JButton();
         buttonCancel.setText("知道了");
-        panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel2.add(buttonCancel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final Spacer spacer2 = new Spacer();
         panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
         final JPanel panel3 = new JPanel();
@@ -112,7 +110,7 @@ private void onCancel() {
         label1.setText("字体太大或太小?");
         panel3.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final JLabel label2 = new JLabel();
-        label2.setText("可以在\"设置\"->\"外观\"中设置字体大小");
+        label2.setText("可以在\"外观\"菜单中设置字体大小");
         panel3.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final Spacer spacer3 = new Spacer();
         panel3.add(spacer3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
@@ -136,7 +134,10 @@ private void onCancel() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
     /**
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/InfinityTaskHisDetailDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/InfinityTaskHisDetailDialog.form
new file mode 100644
index 000000000..db977ed48
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/InfinityTaskHisDetailDialog.form
@@ -0,0 +1,410 @@
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/InfinityTaskHisDetailDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/InfinityTaskHisDetailDialog.java new file mode 100644 index 000000000..621bba890 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/InfinityTaskHisDetailDialog.java @@ -0,0 +1,750 @@ +package com.fangxuele.tool.push.ui.dialog; + +import cn.hutool.core.date.BetweenFormater; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.domain.*; +import com.fangxuele.tool.push.logic.InfinityTaskRunThread; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.ui.form.PeopleManageForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.formdev.flatlaf.util.SystemInfo; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.opencsv.CSVReader; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.Locale; + +public class InfinityTaskHisDetailDialog extends JDialog { + private JPanel contentPane; + private JTextArea consoleTextArea; + private JPanel pushUpPanel; + private JLabel pushSuccessCount; + private JLabel pushFailCount; + private JLabel pushLastTimeLabel; + private JLabel pushLeftTimeLabel; + private JLabel tpsLabel; + private JLabel pushTotalProgressLabel; + private JProgressBar pushTotalProgressBar; + private JLabel pushTotalCountLabel; + private JLabel pushMsgName; + private JLabel scheduleDetailLabel; + private JLabel activeThreadCountLabel; + private JLabel corePoolSizeLabel; + private JLabel maxPoolSizeLabel; + private JPanel pushControlPanel; + private JTextField sliderValueTextField; + private JButton pushStopButton; + private JLabel threadTipsLabel; + private JSlider threadCountSlider; + private JTextField successFileTextField; + private JTextField failFileTextField; + private JTextField noSendFileTextField; + private JButton openSuccessButton; + private JButton openFailButton; + private JButton openNoSendButton; + private JButton successToPeopleButton; + private JButton failToPeopleButton; + private JButton noSendToPeopleButton; + + private static TTaskHisMapper taskHisMapper = MybatisUtil.getSqlSession().getMapper(TTaskHisMapper.class); + private static TTaskMapper taskMapper = MybatisUtil.getSqlSession().getMapper(TTaskMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + private static final Log logger = LogFactory.get(); + + private Boolean dialogClosed = false; + + public InfinityTaskHisDetailDialog() { + super(App.mainFrame, "执行详情"); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.68, 0.64); + setContentPane(contentPane); + setModal(true); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + + successToPeopleButton.setIcon(new FlatSVGIcon("icon/people.svg")); + failToPeopleButton.setIcon(new FlatSVGIcon("icon/people.svg")); + noSendToPeopleButton.setIcon(new FlatSVGIcon("icon/people.svg")); + openSuccessButton.setIcon(new FlatSVGIcon("icon/file-open.svg")); + openFailButton.setIcon(new FlatSVGIcon("icon/file-open.svg")); + openNoSendButton.setIcon(new FlatSVGIcon("icon/file-open.svg")); + pushStopButton.setIcon(new FlatSVGIcon("icon/stop.svg")); + + threadTipsLabel.setIcon(new FlatSVGIcon("icon/help.svg")); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onClose(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onClose(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + + } + + private void onClose() { + dialogClosed = true; + dispose(); + } + + public InfinityTaskHisDetailDialog(InfinityTaskRunThread infinityTaskRunThread, Integer taskHisId) { + this(); + + TTaskHis tTaskHis = taskHisMapper.selectByPrimaryKey(taskHisId); + TTask tTask = taskMapper.selectByPrimaryKey(tTaskHis.getTaskId()); + TMsg tmsg = msgMapper.selectByPrimaryKey(tTask.getMessageId()); + + threadCountSlider.setMaximum(tTask.getMaxThreadCnt()); + threadCountSlider.setValue(tTask.getThreadCnt()); + sliderValueTextField.setText(String.valueOf(tTask.getThreadCnt())); + + ThreadUtil.execute(() -> threadCountSlider.addChangeListener(e -> { + JSlider slider = (JSlider) e.getSource(); + int value = slider.getValue(); + int finalValue = value; + sliderValueTextField.setText(String.valueOf(finalValue)); + if (infinityTaskRunThread != null && infinityTaskRunThread.getThreadPoolExecutor() != null && infinityTaskRunThread.isRunning()) { + infinityTaskRunThread.adjustThreadCount(infinityTaskRunThread.getThreadPoolExecutor(), finalValue); + } + })); + + successToPeopleButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar memberTabImportProgressBar = peopleEditForm.getMemberTabImportProgressBar(); + CSVReader reader = null; + try { + MainWindow.getInstance().getTabbedPane().setSelectedIndex(3); + + TPeople tPeopleToSave = new TPeople(); + tPeopleToSave.setMsgType(tTask.getMsgType()); + tPeopleToSave.setAccountId(tTask.getAccountId()); + tPeopleToSave.setPeopleName(FileUtil.getName(tTaskHis.getSuccessFilePath()).replace(".csv", "")); + tPeopleToSave.setAppVersion(UiConsts.APP_VERSION); + String now = SqliteUtil.nowDateForSqlite(); + tPeopleToSave.setCreateTime(now); + tPeopleToSave.setModifiedTime(now); + + peopleMapper.insert(tPeopleToSave); + + memberTabImportProgressBar.setVisible(true); + memberTabImportProgressBar.setIndeterminate(true); + File msgTemplateDataFile = new File(tTaskHis.getSuccessFilePath()); + if (msgTemplateDataFile.exists()) { + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(msgTemplateDataFile)); + reader = new CSVReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + String[] nextLine; + TPeopleData tPeopleData; + while ((nextLine = reader.readNext()) != null) { + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(tPeopleToSave.getId()); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } + PeopleManageForm.initPeopleList(); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + memberTabImportProgressBar.setMaximum(100); + memberTabImportProgressBar.setValue(100); + memberTabImportProgressBar.setIndeterminate(false); + memberTabImportProgressBar.setVisible(false); + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + logger.error(e1); + e1.printStackTrace(); + } + } + } + + }); + + dispose(); + }); + + failToPeopleButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar memberTabImportProgressBar = peopleEditForm.getMemberTabImportProgressBar(); + CSVReader reader = null; + try { + MainWindow.getInstance().getTabbedPane().setSelectedIndex(3); + + TPeople tPeopleToSave = new TPeople(); + tPeopleToSave.setMsgType(tTask.getMsgType()); + tPeopleToSave.setAccountId(tTask.getAccountId()); + tPeopleToSave.setPeopleName(FileUtil.getName(tTaskHis.getFailFilePath()).replace(".csv", "")); + tPeopleToSave.setAppVersion(UiConsts.APP_VERSION); + String now = SqliteUtil.nowDateForSqlite(); + tPeopleToSave.setCreateTime(now); + tPeopleToSave.setModifiedTime(now); + + peopleMapper.insert(tPeopleToSave); + + memberTabImportProgressBar.setVisible(true); + memberTabImportProgressBar.setIndeterminate(true); + File msgTemplateDataFile = new File(tTaskHis.getFailFilePath()); + if (msgTemplateDataFile.exists()) { + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(msgTemplateDataFile)); + reader = new CSVReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + String[] nextLine; + TPeopleData tPeopleData; + while ((nextLine = reader.readNext()) != null) { + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(tPeopleToSave.getId()); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } + PeopleManageForm.initPeopleList(); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + memberTabImportProgressBar.setMaximum(100); + memberTabImportProgressBar.setValue(100); + memberTabImportProgressBar.setIndeterminate(false); + memberTabImportProgressBar.setVisible(false); + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + logger.error(e1); + e1.printStackTrace(); + } + } + } + + }); + + dispose(); + }); + + noSendToPeopleButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar memberTabImportProgressBar = peopleEditForm.getMemberTabImportProgressBar(); + CSVReader reader = null; + try { + MainWindow.getInstance().getTabbedPane().setSelectedIndex(3); + + TPeople tPeopleToSave = new TPeople(); + tPeopleToSave.setMsgType(tTask.getMsgType()); + tPeopleToSave.setAccountId(tTask.getAccountId()); + tPeopleToSave.setPeopleName(FileUtil.getName(tTaskHis.getNoSendFilePath()).replace(".csv", "")); + tPeopleToSave.setAppVersion(UiConsts.APP_VERSION); + String now = SqliteUtil.nowDateForSqlite(); + tPeopleToSave.setCreateTime(now); + tPeopleToSave.setModifiedTime(now); + + peopleMapper.insert(tPeopleToSave); + + memberTabImportProgressBar.setVisible(true); + memberTabImportProgressBar.setIndeterminate(true); + File msgTemplateDataFile = new File(tTaskHis.getNoSendFilePath()); + if (msgTemplateDataFile.exists()) { + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(msgTemplateDataFile)); + reader = new CSVReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + String[] nextLine; + TPeopleData tPeopleData; + while ((nextLine = reader.readNext()) != null) { + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(tPeopleToSave.getId()); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } + PeopleManageForm.initPeopleList(); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + memberTabImportProgressBar.setMaximum(100); + memberTabImportProgressBar.setValue(100); + memberTabImportProgressBar.setIndeterminate(false); + memberTabImportProgressBar.setVisible(false); + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + logger.error(e1); + e1.printStackTrace(); + } + } + } + + }); + + dispose(); + }); + + openSuccessButton.addActionListener(e -> { + try { + if (StringUtils.isEmpty(tTaskHis.getSuccessFilePath())) { + return; + } + Desktop.getDesktop().open(new File(tTaskHis.getSuccessFilePath())); + } catch (IOException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "打开文件失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + openFailButton.addActionListener(e -> { + try { + if (StringUtils.isEmpty(tTaskHis.getFailFilePath())) { + return; + } + Desktop.getDesktop().open(new File(tTaskHis.getFailFilePath())); + } catch (IOException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "打开文件失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + openNoSendButton.addActionListener(e -> { + try { + if (StringUtils.isEmpty(tTaskHis.getNoSendFilePath())) { + return; + } + Desktop.getDesktop().open(new File(tTaskHis.getNoSendFilePath())); + } catch (IOException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "打开文件失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + pushStopButton.addActionListener(e -> { + int isStop = JOptionPane.showConfirmDialog(App.mainFrame, + "确定停止当前的推送吗?", "确认停止?", + JOptionPane.YES_NO_OPTION); + if (isStop == JOptionPane.YES_OPTION) { + infinityTaskRunThread.running = false; + pushStopButton.setEnabled(false); + } + }); + + BufferedReader logReader = null; + + pushMsgName.setText(tmsg.getMsgName()); + pushTotalCountLabel.setText("总量:" + tTaskHis.getTotalCnt()); + pushTotalProgressBar.setMaximum(tTaskHis.getTotalCnt()); + + if (infinityTaskRunThread != null && infinityTaskRunThread.isRunning()) { + try { + logReader = new BufferedReader(new FileReader(infinityTaskRunThread.getLogFilePath())); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + BufferedReader finalLogReader = logReader; + + ThreadUtil.execAsync(() -> { + int totalSentCountBefore = 0; + + while (true) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + String line = finalLogReader.readLine(); + if (line != null) { + consoleTextArea.append(line + "\n"); + consoleTextArea.setCaretPosition(consoleTextArea.getText().length()); + } + } catch (IOException e) { + e.printStackTrace(); + } + if (!infinityTaskRunThread.running || dialogClosed) { + try { + pushStopButton.setEnabled(false); + + finalLogReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + TTaskHis taskHis = taskHisMapper.selectByPrimaryKey(taskHisId); + successFileTextField.setText(taskHis.getSuccessFilePath()); + failFileTextField.setText(taskHis.getFailFilePath()); + noSendFileTextField.setText(taskHis.getNoSendFilePath()); + + break; + } + pushSuccessCount.setText(String.valueOf(infinityTaskRunThread.getSuccessRecords())); + pushFailCount.setText(String.valueOf(infinityTaskRunThread.getFailRecords())); + + pushStopButton.setEnabled(true); + + pushSuccessCount.setText(String.valueOf(infinityTaskRunThread.getSuccessRecords())); + pushFailCount.setText(String.valueOf(infinityTaskRunThread.getFailRecords())); + + int totalSentCount = infinityTaskRunThread.getSuccessRecords().intValue() + infinityTaskRunThread.getFailRecords().intValue(); + pushTotalProgressBar.setValue(totalSentCount); + long currentTimeMillis = System.currentTimeMillis(); + long lastTimeMillis = currentTimeMillis - infinityTaskRunThread.getStartTime(); + // 耗时 + String formatBetweenLast = DateUtil.formatBetween(lastTimeMillis, BetweenFormater.Level.SECOND); + pushLastTimeLabel.setText("".equals(formatBetweenLast) ? "0s" : formatBetweenLast); + + // 预计剩余 + + long leftTimeMillis = (long) ((double) lastTimeMillis / (totalSentCount) * (tTaskHis.getTotalCnt() - totalSentCount)); + String formatBetweenLeft = DateUtil.formatBetween(leftTimeMillis, BetweenFormater.Level.SECOND); + pushLeftTimeLabel.setText("".equals(formatBetweenLeft) ? "0s" : formatBetweenLeft); + + int tps = (totalSentCount - totalSentCountBefore) * 2; + totalSentCountBefore = totalSentCount; + tpsLabel.setText(tps + ""); + + activeThreadCountLabel.setText("活跃线程数:" + infinityTaskRunThread.getThreadPoolExecutor().getActiveCount()); + corePoolSizeLabel.setText("核心线程数:" + infinityTaskRunThread.getThreadPoolExecutor().getCorePoolSize()); + maxPoolSizeLabel.setText("最大线程数:" + infinityTaskRunThread.getThreadPoolExecutor().getMaximumPoolSize()); + } + }); + } else { + pushStopButton.setEnabled(false); + + pushSuccessCount.setText(String.valueOf(tTaskHis.getSuccessCnt())); + pushFailCount.setText(String.valueOf(tTaskHis.getFailCnt())); + pushTotalProgressBar.setValue(tTaskHis.getSuccessCnt() + tTaskHis.getFailCnt()); + + long lastTimeMillis = DateUtil.parseDateTime(tTaskHis.getEndTime()).getTime() - DateUtil.parseDateTime(tTaskHis.getStartTime()).getTime(); + + // 耗时 + String formatBetweenLast = DateUtil.formatBetween(lastTimeMillis, BetweenFormater.Level.SECOND); + pushLastTimeLabel.setText("".equals(formatBetweenLast) ? "0s" : formatBetweenLast); + + int tps; + if (lastTimeMillis == 0) { + tps = 0; + } else { + tps = (int) ((tTaskHis.getSuccessCnt() + tTaskHis.getFailCnt()) / (lastTimeMillis / 1000)); + } + tpsLabel.setText(tps + ""); + + successFileTextField.setText(tTaskHis.getSuccessFilePath()); + failFileTextField.setText(tTaskHis.getFailFilePath()); + noSendFileTextField.setText(tTaskHis.getNoSendFilePath()); + + if (!StringUtils.isEmpty(tTaskHis.getLogFilePath())) { + try { + logReader = new BufferedReader(new FileReader(tTaskHis.getLogFilePath())); + + String line; + while ((line = logReader.readLine()) != null) { + consoleTextArea.append(line + "\n"); + consoleTextArea.setCaretPosition(consoleTextArea.getText().length()); + if (dialogClosed) { + logReader.close(); + break; + } + } + if (logReader != null) { + logReader.close(); + } + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 10), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, true)); + final JScrollPane scrollPane1 = new JScrollPane(); + panel1.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + consoleTextArea = new JTextArea(); + scrollPane1.setViewportView(consoleTextArea); + pushUpPanel = new JPanel(); + pushUpPanel.setLayout(new GridLayoutManager(4, 9, new Insets(10, 10, 0, 10), -1, -1)); + contentPane.add(pushUpPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, true)); + pushSuccessCount = new JLabel(); + Font pushSuccessCountFont = this.$$$getFont$$$(null, -1, 72, pushSuccessCount.getFont()); + if (pushSuccessCountFont != null) pushSuccessCount.setFont(pushSuccessCountFont); + pushSuccessCount.setForeground(new Color(-13587376)); + pushSuccessCount.setText("0"); + pushUpPanel.add(pushSuccessCount, new GridConstraints(0, 0, 4, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushFailCount = new JLabel(); + Font pushFailCountFont = this.$$$getFont$$$(null, -1, 72, pushFailCount.getFont()); + if (pushFailCountFont != null) pushFailCount.setFont(pushFailCountFont); + pushFailCount.setForeground(new Color(-2200483)); + pushFailCount.setText("0"); + pushUpPanel.add(pushFailCount, new GridConstraints(0, 2, 4, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("成功"); + pushUpPanel.add(label1, new GridConstraints(1, 1, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("失败"); + pushUpPanel.add(label2, new GridConstraints(1, 3, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JSeparator separator1 = new JSeparator(); + separator1.setOrientation(1); + pushUpPanel.add(separator1, new GridConstraints(0, 4, 4, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + pushLastTimeLabel = new JLabel(); + pushLastTimeLabel.setEnabled(true); + Font pushLastTimeLabelFont = this.$$$getFont$$$("Microsoft YaHei UI Light", -1, 36, pushLastTimeLabel.getFont()); + if (pushLastTimeLabelFont != null) pushLastTimeLabel.setFont(pushLastTimeLabelFont); + pushLastTimeLabel.setForeground(new Color(-6710887)); + pushLastTimeLabel.setText("0s"); + pushUpPanel.add(pushLastTimeLabel, new GridConstraints(0, 6, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setHorizontalAlignment(0); + label3.setHorizontalTextPosition(0); + label3.setText("耗时"); + pushUpPanel.add(label3, new GridConstraints(0, 5, 2, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JSeparator separator2 = new JSeparator(); + separator2.setOrientation(1); + pushUpPanel.add(separator2, new GridConstraints(0, 7, 4, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("预计剩余"); + pushUpPanel.add(label4, new GridConstraints(2, 5, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushLeftTimeLabel = new JLabel(); + Font pushLeftTimeLabelFont = this.$$$getFont$$$("Microsoft YaHei UI Light", -1, 36, pushLeftTimeLabel.getFont()); + if (pushLeftTimeLabelFont != null) pushLeftTimeLabel.setFont(pushLeftTimeLabelFont); + pushLeftTimeLabel.setForeground(new Color(-6710887)); + pushLeftTimeLabel.setText("0s"); + pushUpPanel.add(pushLeftTimeLabel, new GridConstraints(2, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("TPS"); + pushUpPanel.add(label5, new GridConstraints(3, 5, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + tpsLabel = new JLabel(); + tpsLabel.setText("0"); + pushUpPanel.add(tpsLabel, new GridConstraints(3, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + pushUpPanel.add(panel2, new GridConstraints(0, 8, 4, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + pushTotalProgressLabel = new JLabel(); + pushTotalProgressLabel.setText("总进度"); + panel2.add(pushTotalProgressLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushTotalProgressBar = new JProgressBar(); + pushTotalProgressBar.setStringPainted(true); + panel2.add(pushTotalProgressBar, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushTotalCountLabel = new JLabel(); + pushTotalCountLabel.setText("消息总数:-"); + panel2.add(pushTotalCountLabel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushMsgName = new JLabel(); + Font pushMsgNameFont = this.$$$getFont$$$(null, -1, 24, pushMsgName.getFont()); + if (pushMsgNameFont != null) pushMsgName.setFont(pushMsgNameFont); + pushMsgName.setForeground(new Color(-276358)); + pushMsgName.setText("消息标题"); + panel2.add(pushMsgName, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + scheduleDetailLabel = new JLabel(); + scheduleDetailLabel.setForeground(new Color(-276358)); + scheduleDetailLabel.setText(""); + panel2.add(scheduleDetailLabel, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + activeThreadCountLabel = new JLabel(); + Font activeThreadCountLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, activeThreadCountLabel.getFont()); + if (activeThreadCountLabelFont != null) activeThreadCountLabel.setFont(activeThreadCountLabelFont); + activeThreadCountLabel.setText("活跃线程数:-"); + panel2.add(activeThreadCountLabel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + corePoolSizeLabel = new JLabel(); + corePoolSizeLabel.setText("核心线程数:-"); + panel2.add(corePoolSizeLabel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + maxPoolSizeLabel = new JLabel(); + maxPoolSizeLabel.setText("最大线程数:-"); + panel2.add(maxPoolSizeLabel, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushControlPanel = new JPanel(); + pushControlPanel.setLayout(new GridLayoutManager(1, 4, new Insets(0, 10, 10, 10), -1, -1)); + contentPane.add(pushControlPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, true)); + sliderValueTextField = new JTextField(); + sliderValueTextField.setEditable(false); + sliderValueTextField.setHorizontalAlignment(10); + sliderValueTextField.setMargin(new Insets(2, 6, 2, 6)); + sliderValueTextField.setRequestFocusEnabled(true); + sliderValueTextField.setToolTipText("输入结束后请按回车键确认"); + pushControlPanel.add(sliderValueTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(60, -1), null, 0, false)); + pushStopButton = new JButton(); + pushStopButton.setEnabled(false); + pushStopButton.setText("停止"); + pushControlPanel.add(pushStopButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + threadTipsLabel = new JLabel(); + threadTipsLabel.setText(""); + pushControlPanel.add(threadTipsLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + threadCountSlider = new JSlider(); + threadCountSlider.setDoubleBuffered(true); + threadCountSlider.setExtent(0); + threadCountSlider.setFocusCycleRoot(false); + threadCountSlider.setFocusTraversalPolicyProvider(false); + threadCountSlider.setFocusable(false); + threadCountSlider.setInverted(false); + threadCountSlider.setMajorTickSpacing(10); + threadCountSlider.setMinimum(0); + threadCountSlider.setMinorTickSpacing(5); + threadCountSlider.setOpaque(false); + threadCountSlider.setOrientation(0); + threadCountSlider.setPaintLabels(true); + threadCountSlider.setPaintTicks(true); + threadCountSlider.setPaintTrack(true); + threadCountSlider.setRequestFocusEnabled(false); + threadCountSlider.setSnapToTicks(false); + threadCountSlider.setToolTipText("线程数"); + threadCountSlider.setValue(0); + threadCountSlider.setValueIsAdjusting(false); + pushControlPanel.add(threadCountSlider, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(3, 4, new Insets(0, 10, 0, 10), -1, -1)); + contentPane.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("成功"); + panel3.add(label6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setText("失败"); + panel3.add(label7, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setText("未发送"); + panel3.add(label8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + successFileTextField = new JTextField(); + successFileTextField.setEditable(false); + panel3.add(successFileTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + failFileTextField = new JTextField(); + failFileTextField.setEditable(false); + panel3.add(failFileTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + noSendFileTextField = new JTextField(); + noSendFileTextField.setEditable(false); + panel3.add(noSendFileTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + openSuccessButton = new JButton(); + openSuccessButton.setText("打开"); + panel3.add(openSuccessButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + openFailButton = new JButton(); + openFailButton.setText("打开"); + panel3.add(openFailButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + openNoSendButton = new JButton(); + openNoSendButton.setText("打开"); + panel3.add(openNoSendButton, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + successToPeopleButton = new JButton(); + successToPeopleButton.setText("创建为人群"); + panel3.add(successToPeopleButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + failToPeopleButton = new JButton(); + failToPeopleButton.setText("创建为人群"); + panel3.add(failToPeopleButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + noSendToPeopleButton = new JButton(); + noSendToPeopleButton.setText("创建为人群"); + panel3.add(noSendToPeopleButton, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.form index d8338e1eb..e1f6766f6 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.form +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.form @@ -22,7 +22,7 @@ - + @@ -50,7 +50,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.java index 0d89f6d3a..8a2969aa3 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.java +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/MailTestDialog.java @@ -1,10 +1,12 @@ package com.fangxuele.tool.push.ui.dialog; import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.EmailAccountConfig; import com.fangxuele.tool.push.logic.msgsender.MailMsgSender; import com.fangxuele.tool.push.logic.msgsender.SendResult; -import com.fangxuele.tool.push.ui.form.SettingForm; import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; @@ -31,12 +33,23 @@ public class MailTestDialog extends JDialog { private JButton buttonCancel; private JTextField mailToTextField; - public MailTestDialog() { + private EmailAccountConfig emailAccountConfig; + + private MailTestDialog() { super(App.mainFrame, "测试E-Mail服务器设置"); setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + ComponentUtil.setPreferSizeAndLocateToCenter(this, 420, 200); buttonOK.addActionListener(e -> onOK()); @@ -56,18 +69,23 @@ public void windowClosing(WindowEvent e) { contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } + public MailTestDialog(EmailAccountConfig emailAccountConfig) { + this(); + this.emailAccountConfig = emailAccountConfig; + } + private void onOK() { if (StringUtils.isBlank(mailToTextField.getText())) { mailToTextField.grabFocus(); } else { MailMsgSender mailMsgSender = new MailMsgSender(); - SendResult sendResult = mailMsgSender.sendTestMail(mailToTextField.getText()); + SendResult sendResult = mailMsgSender.sendTestMail(emailAccountConfig, mailToTextField.getText()); dispose(); if (sendResult.isSuccess()) { - JOptionPane.showMessageDialog(SettingForm.getInstance().getSettingPanel(), "发送成功!", "成功", + JOptionPane.showMessageDialog(App.mainFrame, "发送成功!", "成功", JOptionPane.INFORMATION_MESSAGE); } else { - JOptionPane.showMessageDialog(SettingForm.getInstance().getSettingPanel(), "发送失败!\n\n" + sendResult.getInfo(), "失败", + JOptionPane.showMessageDialog(App.mainFrame, "发送失败!\n\n" + sendResult.getInfo(), "失败", JOptionPane.ERROR_MESSAGE); } } @@ -101,7 +119,7 @@ private void onCancel() { final Spacer spacer1 = new Spacer(); panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false)); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 10, 10), -1, -1, true, false)); panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); buttonOK = new JButton(); buttonOK.setText("发送"); @@ -110,7 +128,7 @@ private void onCancel() { buttonCancel.setText("取消"); panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.setLayout(new GridLayoutManager(4, 1, new Insets(0, 10, 0, 10), -1, -1)); contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("请输入接收测试邮件的邮箱地址:"); diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/NewPeopleDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewPeopleDialog.form new file mode 100644 index 000000000..91929d033 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewPeopleDialog.form @@ -0,0 +1,91 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/NewPeopleDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewPeopleDialog.java new file mode 100644 index 000000000..73493335d --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewPeopleDialog.java @@ -0,0 +1,208 @@ +package com.fangxuele.tool.push.ui.dialog; + +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.form.PeopleManageForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; +import com.google.common.collect.Maps; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; +import java.util.Map; + +/** + *
+ * DingAppDialog
+ * 
+ * + * @author Zhou Bo + * @since 2019/9/5. + */ +public class NewPeopleDialog extends JDialog { + private JPanel contentPane; + private JTextField peopleNameTextField; + private JButton saveButton; + private JComboBox accountComboBox; + private static Map accountMap; + + private Log logger = LogFactory.get(); + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + + public NewPeopleDialog() { + super(App.mainFrame, "新建人群"); + setContentPane(contentPane); + setModal(true); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + + int msgType = App.config.getMsgType(); + + initAccountComboBox(msgType); + + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.5, 0.5); + + // 保存按钮事件 + saveButton.addActionListener(e -> { + try { + String peopleName = peopleNameTextField.getText(); + if (StringUtils.isBlank(peopleName)) { + JOptionPane.showMessageDialog(this, "请填写人群名称!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + String selectedAccountName = (String) accountComboBox.getSelectedItem(); + if (StringUtils.isBlank(selectedAccountName)) { + JOptionPane.showMessageDialog(this, "请创建并选择账号!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + Integer selectedAccountId = accountMap.get(selectedAccountName); + if (selectedAccountId == null) { + logger.error("创建人群失败:selectedAccountId为空"); + return; + } + + // 校验是否有同名人群 + TPeople tPeople = peopleMapper.selectByMsgTypeAndAccountIdAndName(String.valueOf(msgType), selectedAccountId, peopleName); + if (tPeople != null) { + JOptionPane.showMessageDialog(this, "该人群名称已存在!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + TPeople tPeopleToSave = new TPeople(); + tPeopleToSave.setMsgType(msgType); + tPeopleToSave.setAccountId(selectedAccountId); + tPeopleToSave.setPeopleName(peopleName); + tPeopleToSave.setAppVersion(UiConsts.APP_VERSION); + String now = SqliteUtil.nowDateForSqlite(); + tPeopleToSave.setCreateTime(now); + tPeopleToSave.setModifiedTime(now); + + peopleMapper.insert(tPeopleToSave); + + PeopleManageForm.initPeopleList(); + + dispose(); + } catch (Exception e1) { + JOptionPane.showMessageDialog(this, "保存失败!\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + } + + }); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void initAccountComboBox(int msgType) { + accountMap = Maps.newHashMap(); + List tAccountList = accountMapper.selectByMsgType(msgType); + for (TAccount tAccount : tAccountList) { + String accountName = tAccount.getAccountName(); + Integer accountId = tAccount.getId(); + accountComboBox.addItem(accountName); + accountMap.put(accountName, accountId); + } + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + /** + * 清空表单 + */ + public void clearFields() { + peopleNameTextField.setText(""); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 10, 10), -1, -1)); + contentPane.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + saveButton = new JButton(); + saveButton.setText("保存"); + panel2.add(saveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 2, new Insets(10, 10, 0, 10), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("人群名称"); + panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + peopleNameTextField = new JTextField(); + panel3.add(peopleNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("账号"); + panel3.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + accountComboBox = new JComboBox(); + panel3.add(accountComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + contentPane.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/NewTaskDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewTaskDialog.form new file mode 100644 index 000000000..134e8866e --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewTaskDialog.form @@ -0,0 +1,548 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/NewTaskDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewTaskDialog.java new file mode 100644 index 000000000..459180feb --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/NewTaskDialog.java @@ -0,0 +1,1093 @@ +package com.fangxuele.tool.push.ui.dialog; + +import cn.hutool.cron.Scheduler; +import cn.hutool.cron.pattern.CronPattern; +import cn.hutool.cron.pattern.CronPatternUtil; +import cn.hutool.cron.task.Task; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.domain.TTask; +import com.fangxuele.tool.push.logic.*; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.form.TaskForm; +import com.fangxuele.tool.push.ui.listener.TaskListener; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.formdev.flatlaf.util.SystemInfo; +import com.google.common.collect.Maps; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.lang3.time.DateUtils; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +@Slf4j +public class NewTaskDialog extends JDialog { + private JPanel contentPane; + private JButton buttonOK; + private JButton buttonCancel; + private JTextField titleTextField; + private JComboBox msgTypeComboBox; + private JComboBox accountComboBox; + private JComboBox msgComboBox; + private JComboBox peopleComboBox; + private JRadioButton manualTaskRadioButton; + private JRadioButton scheduleTaskRadioButton; + private JRadioButton triggerTaskRadioButton; + private JPanel schedulePanel; + private JRadioButton runAtThisTimeRadioButton; + private JTextField startAtThisTimeTextField; + private JRadioButton runPerDayRadioButton; + private JTextField startPerDayTextField; + private JRadioButton runPerWeekRadioButton; + private JComboBox schedulePerWeekComboBox; + private JTextField startPerWeekTextField; + private JCheckBox reimportCheckBox; + private JCheckBox sendPushResultCheckBox; + private JTextField mailResultToTextField; + private JRadioButton cronRadioButton; + private JTextField cronTextField; + private JLabel cronOnlineLabel; + private JLabel cronHelpLabel; + private JScrollPane scrollPane; + private JRadioButton fixThreadModeRadioButton; + private JRadioButton infinityModeRadioButton; + private JTextField threadCntTextField; + private JCheckBox saveResponseBodyCheckBox; + private JPanel otherPanel; + private JTextField maxThreadCntTextField; + private JCheckBox intervalPushCheckBox; + private JTextField intervalTextField; + + private static TTaskMapper taskMapper = MybatisUtil.getSqlSession().getMapper(TTaskMapper.class); + private static TTaskExtMapper taskExtMapper = MybatisUtil.getSqlSession().getMapper(TTaskExtMapper.class); + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + private Map msgTypeMap = Maps.newHashMap(); + private Map msgTypeMapReverse = Maps.newHashMap(); + private Map accountMap = Maps.newHashMap(); + private Map accountMapReverse = Maps.newHashMap(); + private Map messageMap = Maps.newHashMap(); + private Map messageMapReverse = Maps.newHashMap(); + private Map peopleMap = Maps.newHashMap(); + private Map peopleMapReverse = Maps.newHashMap(); + + private static final String CRON_DATE_FORMAT = "ss mm HH dd MM ? yyyy"; + + private TTask beforeTTask; + + public NewTaskDialog() { + + super(App.mainFrame, "新建任务"); + setContentPane(contentPane); + setModal(true); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.6, 0.8); + + getRootPane().setDefaultButton(buttonOK); + + init(); + + cronHelpLabel.setIcon(new FlatSVGIcon("icon/help.svg")); + + buttonOK.addActionListener(e -> onOK()); + + buttonCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + onCancel(); + } + }); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(new ActionListener() { + public void actionPerformed(ActionEvent e) { + onCancel(); + } + }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + + cronHelpLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + CommonTipsDialog dialog = new CommonTipsDialog(); + + StringBuilder tipsBuilder = new StringBuilder(); + tipsBuilder.append("

什么是Cron表达式?

"); + tipsBuilder.append("百度百科"); + tipsBuilder.append("

举几个例子:

\n"); + tipsBuilder.append("

\"0 0 2 1 * ? *\" 表示在每月的1日的凌晨2点调度任务

\n"); + tipsBuilder.append("

\"0 15 10 ? * MON-FRI\" 表示周一到周五每天上午10:15执行作业

\n"); + tipsBuilder.append("

\"0 15 10 ? * 6L 2002-2006\" 表示2002-2006年的每个月的最后一个星期五上午10:15执行作

\n"); + tipsBuilder.append("

\"0 0 10,14,16 * * ?\" 每天上午10点,下午2点,4点

\n"); + tipsBuilder.append("

\"0 0/30 9-17 * * ?\" 朝九晚五工作时间内每半小时

\n"); + tipsBuilder.append("

\"0 0 12 ? * WED\" 表示每个星期三中午12点

\n"); + tipsBuilder.append("

\"0 0 12 * * ?\" 每天中午12点触发

\n"); + tipsBuilder.append("

\"0 15 10 ? * *\" 每天上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 * * ?\" 每天上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 * * ? *\" 每天上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 * * ? 2005\" 2005年的每天上午10:15触发

\n"); + tipsBuilder.append("

\"0 * 14 * * ?\" 在每天下午2点到下午2:59期间的每1分钟触发

\n"); + tipsBuilder.append("

\"0 0/5 14 * * ?\" 在每天下午2点到下午2:55期间的每5分钟触发

\n"); + tipsBuilder.append("

\"0 0/5 14,18 * * ?\" 在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发

\n"); + tipsBuilder.append("

\"0 0-5 14 * * ?\" 在每天下午2点到下午2:05期间的每1分钟触发

\n"); + tipsBuilder.append("

\"0 10,44 14 ? 3 WED\" 每年三月的星期三的下午2:10和2:44触发

\n"); + tipsBuilder.append("

\"0 15 10 ? * MON-FRI\" 周一至周五的上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 15 * ?\" 每月15日上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 L * ?\" 每月最后一日的上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 ? * 6L\" 每月的最后一个星期五上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 ? * 6L 2002-2005\" 2002年至2005年的每月的最后一个星期五上午10:15触发

\n"); + tipsBuilder.append("

\"0 15 10 ? * 6#3\" 每月的第三个星期五上午10:15触发"); + + dialog.setHtmlText(tipsBuilder.toString()); + dialog.getTextPane1().setCaretPosition(0); + dialog.pack(); + dialog.setVisible(true); + + super.mousePressed(e); + } + + @Override + public void mouseEntered(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setCursor(new Cursor(Cursor.HAND_CURSOR)); + label.setIcon(UiConsts.HELP_FOCUSED_ICON); + super.mouseEntered(e); + } + + @Override + public void mouseExited(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setIcon(UiConsts.HELP_ICON); + super.mouseExited(e); + } + }); + + cronOnlineLabel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI("http://cron.qqe2.com/")); + } catch (IOException | URISyntaxException e1) { + e1.printStackTrace(); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + super.mouseEntered(e); + e.getComponent().setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + }); + msgTypeComboBox.addItemListener(e -> { + if (e.getStateChange() == ItemEvent.SELECTED) { + initAccountComboBoxData(); + initMessageComboBoxData(); + initPeopleComboBoxData(); + } + }); + accountComboBox.addItemListener(e -> { + if (e.getStateChange() == ItemEvent.SELECTED) { + initMessageComboBoxData(); + initPeopleComboBoxData(); + } + }); + manualTaskRadioButton.addActionListener(e -> { + resetTaskType(); + manualTaskRadioButton.setSelected(true); + schedulePanel.setVisible(false); + }); + scheduleTaskRadioButton.addActionListener(e -> { + resetTaskType(); + scheduleTaskRadioButton.setSelected(true); + schedulePanel.setVisible(true); + }); + runAtThisTimeRadioButton.addActionListener(e -> { + resetScheduleRadio(); + runAtThisTimeRadioButton.setSelected(true); + }); + runPerDayRadioButton.addActionListener(e -> { + resetScheduleRadio(); + runPerDayRadioButton.setSelected(true); + }); + runPerWeekRadioButton.addActionListener(e -> { + resetScheduleRadio(); + runPerWeekRadioButton.setSelected(true); + }); + cronRadioButton.addActionListener(e -> { + resetScheduleRadio(); + cronRadioButton.setSelected(true); + }); + fixThreadModeRadioButton.addActionListener(e -> { + resetTaskMode(); + fixThreadModeRadioButton.setSelected(true); + }); + infinityModeRadioButton.addActionListener(e -> { + resetTaskMode(); + infinityModeRadioButton.setSelected(true); + }); + } + + public NewTaskDialog(TTask tTask) { + this(); + beforeTTask = tTask; + fillForm(beforeTTask); + } + + /** + * 填充表单 + * + * @param beforeTTask + */ + private void fillForm(TTask beforeTTask) { + resetTaskType(); + resetTaskMode(); + resetScheduleRadio(); + // 任务名称 + titleTextField.setText(beforeTTask.getTitle()); + // 消息类型 + msgTypeComboBox.setSelectedItem(msgTypeMapReverse.get(beforeTTask.getMsgType())); + // 账号 + accountComboBox.setSelectedItem(accountMapReverse.get(beforeTTask.getAccountId())); + // 消息 + msgComboBox.setSelectedItem(messageMapReverse.get(beforeTTask.getMessageId())); + // 人群 + peopleComboBox.setSelectedItem(peopleMapReverse.get(beforeTTask.getPeopleId())); + // 任务模式 + if (beforeTTask.getTaskMode() == TaskModeEnum.FIX_THREAD_TASK_CODE) { + fixThreadModeRadioButton.setSelected(true); + } else if (beforeTTask.getTaskMode() == TaskModeEnum.INFINITY_TASK_CODE) { + infinityModeRadioButton.setSelected(true); + } + // 线程数 + threadCntTextField.setText(String.valueOf(beforeTTask.getThreadCnt())); + // 最大线程数 + maxThreadCntTextField.setText(String.valueOf(beforeTTask.getMaxThreadCnt())); + // 任务周期 + if (beforeTTask.getTaskPeriod() == TaskTypeEnum.MANUAL_TASK_CODE) { + manualTaskRadioButton.setSelected(true); + schedulePanel.setVisible(false); + } else { + scheduleTaskRadioButton.setSelected(true); + schedulePanel.setVisible(true); + } + // 任务时间 + if (beforeTTask.getPeriodType() != null) { + if (beforeTTask.getPeriodType() == PeriodTypeEnum.RUN_AT_THIS_TIME_TASK_CODE) { + runAtThisTimeRadioButton.setSelected(true); + startAtThisTimeTextField.setText(beforeTTask.getPeriodTime()); + } else if (beforeTTask.getPeriodType() == PeriodTypeEnum.RUN_PER_DAY_TASK_CODE) { + runPerDayRadioButton.setSelected(true); + startPerDayTextField.setText(beforeTTask.getPeriodTime()); + } else if (beforeTTask.getPeriodType() == PeriodTypeEnum.RUN_PER_WEEK_TASK_CODE) { + runPerWeekRadioButton.setSelected(true); + startPerWeekTextField.setText(beforeTTask.getPeriodTime().split(",")[1]); + } else if (beforeTTask.getPeriodType() == PeriodTypeEnum.CRON_TASK_CODE) { + cronRadioButton.setSelected(true); + cronTextField.setText(beforeTTask.getPeriodTime()); + } + } + intervalPushCheckBox.setSelected(beforeTTask.getIntervalPush() != null && beforeTTask.getIntervalPush() == 1); + if (beforeTTask.getIntervalTime() != null) { + intervalTextField.setText(String.valueOf(beforeTTask.getIntervalTime())); + } + reimportCheckBox.setSelected(beforeTTask.getReimportPeople() != null && beforeTTask.getReimportPeople() == 1); + sendPushResultCheckBox.setSelected(beforeTTask.getResultAlert() != null && beforeTTask.getResultAlert() == 1); + mailResultToTextField.setText(beforeTTask.getAlertEmails()); + } + + private void init() { + initUI(); + initData(); + } + + private void initUI() { + scrollPane.getVerticalScrollBar().setUnitIncrement(15); + scrollPane.getVerticalScrollBar().setDoubleBuffered(true); + schedulePanel.setVisible(false); + threadCntTextField.setText("8"); + maxThreadCntTextField.setText("100"); + } + + private void initData() { + // 消息类型 + initMsgTypeComboBoxData(); + // 账号 + initAccountComboBoxData(); + // 消息 + initMessageComboBoxData(); + // 人群 + initPeopleComboBoxData(); + } + + /** + * 初始化消息类型下拉框数据 + */ + private void initMsgTypeComboBoxData() { + msgTypeMap.clear(); + msgTypeMapReverse.clear(); + this.msgTypeComboBox.removeAllItems(); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.HTTP), MessageTypeEnum.HTTP_CODE); + msgTypeMapReverse.put(MessageTypeEnum.HTTP_CODE, MessageTypeEnum.getName(MessageTypeEnum.HTTP)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.HTTP)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.MP_TEMPLATE), MessageTypeEnum.MP_TEMPLATE_CODE); + msgTypeMapReverse.put(MessageTypeEnum.MP_TEMPLATE_CODE, MessageTypeEnum.getName(MessageTypeEnum.MP_TEMPLATE)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.MP_TEMPLATE)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.MP_SUBSCRIBE), MessageTypeEnum.MP_SUBSCRIBE_CODE); + msgTypeMapReverse.put(MessageTypeEnum.MP_SUBSCRIBE_CODE, MessageTypeEnum.getName(MessageTypeEnum.MP_SUBSCRIBE)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.MP_SUBSCRIBE)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.MA_SUBSCRIBE), MessageTypeEnum.MA_SUBSCRIBE_CODE); + msgTypeMapReverse.put(MessageTypeEnum.MA_SUBSCRIBE_CODE, MessageTypeEnum.getName(MessageTypeEnum.MA_SUBSCRIBE)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.MA_SUBSCRIBE)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.KEFU), MessageTypeEnum.KEFU_CODE); + msgTypeMapReverse.put(MessageTypeEnum.KEFU_CODE, MessageTypeEnum.getName(MessageTypeEnum.KEFU)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.KEFU)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.KEFU_PRIORITY), MessageTypeEnum.KEFU_PRIORITY_CODE); + msgTypeMapReverse.put(MessageTypeEnum.KEFU_PRIORITY_CODE, MessageTypeEnum.getName(MessageTypeEnum.KEFU_PRIORITY)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.KEFU_PRIORITY)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.WX_UNIFORM_MESSAGE), MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE); + msgTypeMapReverse.put(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE, MessageTypeEnum.getName(MessageTypeEnum.WX_UNIFORM_MESSAGE)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.WX_UNIFORM_MESSAGE)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.WX_CP), MessageTypeEnum.WX_CP_CODE); + msgTypeMapReverse.put(MessageTypeEnum.WX_CP_CODE, MessageTypeEnum.getName(MessageTypeEnum.WX_CP)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.WX_CP)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.DING), MessageTypeEnum.DING_CODE); + msgTypeMapReverse.put(MessageTypeEnum.DING_CODE, MessageTypeEnum.getName(MessageTypeEnum.DING)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.DING)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.ALI_YUN), MessageTypeEnum.ALI_YUN_CODE); + msgTypeMapReverse.put(MessageTypeEnum.ALI_YUN_CODE, MessageTypeEnum.getName(MessageTypeEnum.ALI_YUN)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.ALI_YUN)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.TX_YUN), MessageTypeEnum.TX_YUN_CODE); + msgTypeMapReverse.put(MessageTypeEnum.TX_YUN_CODE, MessageTypeEnum.getName(MessageTypeEnum.TX_YUN)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.TX_YUN)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.TX_YUN_3), MessageTypeEnum.TX_YUN_3_CODE); + msgTypeMapReverse.put(MessageTypeEnum.TX_YUN_3_CODE, MessageTypeEnum.getName(MessageTypeEnum.TX_YUN_3)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.TX_YUN_3)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.HW_YUN), MessageTypeEnum.HW_YUN_CODE); + msgTypeMapReverse.put(MessageTypeEnum.HW_YUN_CODE, MessageTypeEnum.getName(MessageTypeEnum.HW_YUN)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.HW_YUN)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.BD_YUN), MessageTypeEnum.BD_YUN_CODE); + msgTypeMapReverse.put(MessageTypeEnum.BD_YUN_CODE, MessageTypeEnum.getName(MessageTypeEnum.BD_YUN)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.BD_YUN)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.YUN_PIAN), MessageTypeEnum.YUN_PIAN_CODE); + msgTypeMapReverse.put(MessageTypeEnum.YUN_PIAN_CODE, MessageTypeEnum.getName(MessageTypeEnum.YUN_PIAN)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.YUN_PIAN)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.UP_YUN), MessageTypeEnum.UP_YUN_CODE); + msgTypeMapReverse.put(MessageTypeEnum.UP_YUN_CODE, MessageTypeEnum.getName(MessageTypeEnum.UP_YUN)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.UP_YUN)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.QI_NIU_YUN), MessageTypeEnum.QI_NIU_YUN_CODE); + msgTypeMapReverse.put(MessageTypeEnum.QI_NIU_YUN_CODE, MessageTypeEnum.getName(MessageTypeEnum.QI_NIU_YUN)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.QI_NIU_YUN)); + + msgTypeMap.put(MessageTypeEnum.getName(MessageTypeEnum.EMAIL), MessageTypeEnum.EMAIL_CODE); + msgTypeMapReverse.put(MessageTypeEnum.EMAIL_CODE, MessageTypeEnum.getName(MessageTypeEnum.EMAIL)); + this.msgTypeComboBox.addItem(MessageTypeEnum.getName(MessageTypeEnum.EMAIL)); + } + + /** + * 初始化账号下拉框数据 + */ + private void initAccountComboBoxData() { + String selectedMsgTypeStr = (String) msgTypeComboBox.getSelectedItem(); + Integer selectedMsgType = msgTypeMap.get(selectedMsgTypeStr); + List tAccounts = accountMapper.selectByMsgType(selectedMsgType); + + accountMap.clear(); + accountMapReverse.clear(); + accountComboBox.removeAllItems(); + for (TAccount tAccount : tAccounts) { + accountMap.put(tAccount.getAccountName(), tAccount.getId()); + accountMapReverse.put(tAccount.getId(), tAccount.getAccountName()); + accountComboBox.addItem(tAccount.getAccountName()); + } + } + + /** + * 初始化消息下拉框数据 + */ + private void initMessageComboBoxData() { + String selectedMsgTypeStr = (String) msgTypeComboBox.getSelectedItem(); + Integer msgType = msgTypeMap.get(selectedMsgTypeStr); + + String selectedAccountStr = (String) accountComboBox.getSelectedItem(); + Integer selectedAccount = accountMap.get(selectedAccountStr); + + messageMap.clear(); + messageMapReverse.clear(); + msgComboBox.removeAllItems(); + List tMsgList = msgMapper.selectByMsgTypeAndAccountId(msgType, selectedAccount); + for (TMsg tMsg : tMsgList) { + messageMap.put(tMsg.getMsgName(), tMsg.getId()); + messageMapReverse.put(tMsg.getId(), tMsg.getMsgName()); + msgComboBox.addItem(tMsg.getMsgName()); + } + saveResponseBodyCheckBox.setSelected(false); + otherPanel.setVisible(false); + } + + /** + * 初始化人群下拉框数据 + */ + private void initPeopleComboBoxData() { + String selectedMsgTypeStr = (String) msgTypeComboBox.getSelectedItem(); + Integer msgType = msgTypeMap.get(selectedMsgTypeStr); + + String selectedAccountStr = (String) accountComboBox.getSelectedItem(); + Integer selectedAccount = accountMap.get(selectedAccountStr); + + peopleMap.clear(); + peopleMapReverse.clear(); + peopleComboBox.removeAllItems(); + + List tPeopleList = peopleMapper.selectByMsgTypeAndAccountId(String.valueOf(msgType), selectedAccount); + for (TPeople tPeople : tPeopleList) { + peopleMap.put(tPeople.getPeopleName(), tPeople.getId()); + peopleMapReverse.put(tPeople.getId(), tPeople.getPeopleName()); + peopleComboBox.addItem(tPeople.getPeopleName()); + } + } + + private void resetTaskType() { + manualTaskRadioButton.setSelected(false); + scheduleTaskRadioButton.setSelected(false); + triggerTaskRadioButton.setSelected(false); + } + + private void resetTaskMode() { + fixThreadModeRadioButton.setSelected(false); + infinityModeRadioButton.setSelected(false); + } + + private Integer getTaskPeriod() { + if (manualTaskRadioButton.isSelected()) { + return TaskTypeEnum.MANUAL_TASK_CODE; + } else if (scheduleTaskRadioButton.isSelected()) { + return TaskTypeEnum.SCHEDULE_TASK_CODE; + } else if (triggerTaskRadioButton.isSelected()) { + return TaskTypeEnum.TRIGGER_TASK_CODE; + } else { + return null; + } + } + + private void resetScheduleRadio() { + runAtThisTimeRadioButton.setSelected(false); + runPerDayRadioButton.setSelected(false); + runPerWeekRadioButton.setSelected(false); + cronRadioButton.setSelected(false); + } + + private String getCron() throws ParseException { + String cron = null; + if (runAtThisTimeRadioButton.isSelected()) { + String startAtThisTime = startAtThisTimeTextField.getText().trim(); + Date date = DateUtils.parseDate(startAtThisTime, "yyyy-MM-dd HH:mm:ss"); + cron = DateFormatUtils.format(date, CRON_DATE_FORMAT); + } else if (runPerDayRadioButton.isSelected()) { + String startPerDay = startPerDayTextField.getText().replace(";", ";"); + String[] split = startPerDay.split(":"); + cron = split[2] + " " + split[1] + " " + split[0] + " * * ?"; + } else if (runPerWeekRadioButton.isSelected()) { + String startPerWeek = startPerWeekTextField.getText().replace(";", ";"); + String[] split = startPerWeek.split(":"); + + String selectedWeek = (String) schedulePerWeekComboBox.getSelectedItem(); + + cron = split[2] + " " + split[1] + " " + split[0] + " ? * " + getWeekEn(selectedWeek); + } else if (cronRadioButton.isSelected()) { + cron = cronTextField.getText().trim(); + } + return cron; + } + + private String getWeekEn(String week) { + String weekEn; + // MON TUE WED THU FRI SAT SUN + switch (week) { + case "一": + weekEn = "MON"; + break; + case "二": + weekEn = "TUE"; + break; + case "三": + weekEn = "WED"; + break; + case "四": + weekEn = "THU"; + break; + case "五": + weekEn = "FRI"; + break; + case "六": + weekEn = "SAT"; + break; + case "日": + weekEn = "SUN"; + break; + default: + weekEn = null; + } + return weekEn; + } + + private void onOK() { + String title = this.titleTextField.getText().trim(); + TTask tTask = taskExtMapper.selectByTitle(title); + if (tTask != null && beforeTTask == null) { + JOptionPane.showMessageDialog(this, "存在同名任务!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } else { + try { + // 非空校验 + if (nullCheck()) return; + + String nowDateForSqlite = SqliteUtil.nowDateForSqlite(); + TTask task = new TTask(); + task.setTitle(title); + task.setMsgType(msgTypeMap.get((String) msgTypeComboBox.getSelectedItem())); + task.setAccountId(accountMap.get((String) accountComboBox.getSelectedItem())); + task.setMessageId(messageMap.get((String) msgComboBox.getSelectedItem())); + task.setPeopleId(peopleMap.get((String) peopleComboBox.getSelectedItem())); + task.setTaskMode(getTaskMode()); + task.setThreadCnt(Integer.parseInt(threadCntTextField.getText().trim())); + task.setMaxThreadCnt(Integer.parseInt(maxThreadCntTextField.getText().trim())); + task.setTaskPeriod(getTaskPeriod()); + task.setPeriodType(getPeriodType()); + task.setPeriodTime(getPeriodTime()); + task.setCron(getCron()); + task.setReimportPeople(reimportCheckBox.isSelected() ? 1 : 0); + task.setResultAlert(sendPushResultCheckBox.isSelected() ? 1 : 0); + task.setAlertEmails(mailResultToTextField.getText().trim()); + task.setSaveResult(saveResponseBodyCheckBox.isSelected() ? 1 : 0); + task.setIntervalPush(intervalPushCheckBox.isSelected() ? 1 : 0); + if (StringUtils.isNotBlank(intervalTextField.getText())) { + task.setIntervalTime(Integer.parseInt(intervalTextField.getText().trim())); + } + task.setModifiedTime(nowDateForSqlite); + + // 如果是定时任务 + if (task.getTaskPeriod() == TaskTypeEnum.SCHEDULE_TASK_CODE) { + { + List latest5RunTimeList = Lists.newArrayList(); + Date now = new Date(); + for (int i = 0; i < 5; i++) { + if (PeriodTypeEnum.RUN_AT_THIS_TIME_TASK_CODE == task.getPeriodType()) { + latest5RunTimeList.add(tTask.getPeriodTime()); + break; + } + if (PeriodTypeEnum.RUN_PER_DAY_TASK_CODE == task.getPeriodType()) { + Date date = CronPatternUtil.nextDateAfter(new CronPattern(task.getCron()), DateUtils.addDays(now, i), true); + latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); + continue; + } + if (PeriodTypeEnum.RUN_PER_WEEK_TASK_CODE == task.getPeriodType()) { + Date date = CronPatternUtil.nextDateAfter(new CronPattern(task.getCron()), DateUtils.addDays(now, i * 7), true); + latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); + continue; + } + if (PeriodTypeEnum.CRON_TASK_CODE == task.getPeriodType()) { + Date date = CronPatternUtil.nextDateAfter(new CronPattern(task.getCron()), DateUtils.addDays(now, i), true); + latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); + continue; + } + } + + int isSchedulePush = JOptionPane.showConfirmDialog(App.mainFrame, + "将按" + + task.getCron() + + "表达式触发推送\n\n" + + "最近5次运行时间:\n" + + String.join("\n", latest5RunTimeList), "确认定时推送?", + JOptionPane.YES_NO_OPTION); + if (isSchedulePush == JOptionPane.YES_OPTION && StringUtils.isNotEmpty(task.getCron())) { + if (beforeTTask != null) { + Scheduler scheduler = TaskListener.scheduledTaskMap.get(beforeTTask.getId()); + if (scheduler != null) { + if (scheduler.isStarted()) { + scheduler.stop(); + } + } + } + + // 支持秒级别定时任务 + Scheduler scheduler = new Scheduler(); + scheduler.setMatchSecond(true); + String schedulerId = scheduler.schedule(task.getCron(), (Task) () -> { + if (task.getTaskMode() == TaskModeEnum.FIX_THREAD_TASK_CODE) { + TaskRunThread taskRunThread = new TaskRunThread(task.getId(), 0); + taskRunThread.setFixRateScheduling(true); + taskRunThread.start(); + } else if (task.getTaskMode() == TaskModeEnum.INFINITY_TASK_CODE) { + InfinityTaskRunThread infinityTaskRunThread = new InfinityTaskRunThread(task.getId(), 0); + infinityTaskRunThread.setFixRateScheduling(true); + infinityTaskRunThread.start(); + } + }); + scheduler.start(); + TaskListener.scheduledTaskMap.put(task.getId(), scheduler); + } else { + return; + } + } + } else { + if (beforeTTask != null) { + Scheduler scheduler = TaskListener.scheduledTaskMap.get(beforeTTask.getId()); + if (scheduler != null) { + scheduler.stop(); + TaskListener.scheduledTaskMap.remove(beforeTTask.getId()); + } + } + + } + + if (beforeTTask == null) { + task.setCreateTime(nowDateForSqlite); + taskMapper.insert(task); + } else { + task.setCreateTime(beforeTTask.getCreateTime()); + task.setId(beforeTTask.getId()); + taskMapper.updateByPrimaryKey(task); + } + + TaskForm.initTaskListTable(); + + dispose(); + } catch (Exception e) { + log.error("保存任务异常:{}", ExceptionUtils.getStackTrace(e)); + JOptionPane.showMessageDialog(this, "保存失败!\n" + e.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + } + } + + } + + private boolean nullCheck() { + if (StringUtils.isBlank(titleTextField.getText())) { + JOptionPane.showMessageDialog(this, "任务名称不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + if (StringUtils.isBlank((String) msgTypeComboBox.getSelectedItem())) { + JOptionPane.showMessageDialog(this, "消息类型不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + if (StringUtils.isBlank((String) accountComboBox.getSelectedItem())) { + JOptionPane.showMessageDialog(this, "账号不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + if (StringUtils.isBlank((String) msgComboBox.getSelectedItem())) { + JOptionPane.showMessageDialog(this, "消息不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + if (StringUtils.isBlank((String) peopleComboBox.getSelectedItem())) { + JOptionPane.showMessageDialog(this, "人群不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + if (StringUtils.isBlank(threadCntTextField.getText())) { + JOptionPane.showMessageDialog(this, "线程数不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + // 如果是变速模式,最大线程数不能为空 + if (infinityModeRadioButton.isSelected()) { + if (StringUtils.isBlank(maxThreadCntTextField.getText())) { + JOptionPane.showMessageDialog(this, "最大线程数不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + } + if (scheduleTaskRadioButton.isSelected()) { + if (runAtThisTimeRadioButton.isSelected()) { + if (StringUtils.isBlank(startAtThisTimeTextField.getText())) { + JOptionPane.showMessageDialog(this, "定时时间不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + } else if (runPerDayRadioButton.isSelected()) { + if (StringUtils.isBlank(startPerDayTextField.getText())) { + JOptionPane.showMessageDialog(this, "定时时间不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + } else if (runPerWeekRadioButton.isSelected()) { + if (StringUtils.isBlank(startPerWeekTextField.getText())) { + JOptionPane.showMessageDialog(this, "定时时间不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + } else if (cronRadioButton.isSelected()) { + if (StringUtils.isBlank(cronTextField.getText())) { + JOptionPane.showMessageDialog(this, "定时时间不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + } else { + JOptionPane.showMessageDialog(this, "定时时间不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + } + if (sendPushResultCheckBox.isSelected()) { + if (StringUtils.isBlank(mailResultToTextField.getText())) { + JOptionPane.showMessageDialog(this, "推送结果邮箱不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return true; + } + } + return false; + } + + private String getPeriodTime() { + if (runAtThisTimeRadioButton.isSelected()) { + return startAtThisTimeTextField.getText().trim(); + } else if (runPerDayRadioButton.isSelected()) { + return startPerDayTextField.getText().trim(); + } else if (runPerWeekRadioButton.isSelected()) { + return schedulePerWeekComboBox.getSelectedItem() + "," + startPerWeekTextField.getText().trim(); + } else if (cronRadioButton.isSelected()) { + return cronTextField.getText().trim(); + } else { + return null; + } + } + + private Integer getTaskMode() { + if (fixThreadModeRadioButton.isSelected()) { + return TaskModeEnum.FIX_THREAD_TASK_CODE; + } else if (infinityModeRadioButton.isSelected()) { + return TaskModeEnum.INFINITY_TASK_CODE; + } else { + return null; + } + } + + private Integer getPeriodType() { + if (runAtThisTimeRadioButton.isSelected()) { + return PeriodTypeEnum.RUN_AT_THIS_TIME_TASK_CODE; + } else if (runPerDayRadioButton.isSelected()) { + return PeriodTypeEnum.RUN_PER_DAY_TASK_CODE; + } else if (runPerWeekRadioButton.isSelected()) { + return PeriodTypeEnum.RUN_PER_WEEK_TASK_CODE; + } else if (cronRadioButton.isSelected()) { + return PeriodTypeEnum.CRON_TASK_CODE; + } else { + return null; + } + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 10, 10), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + buttonOK = new JButton(); + buttonOK.setText("确定"); + panel2.add(buttonOK, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + buttonCancel = new JButton(); + buttonCancel.setText("取消"); + panel2.add(buttonCancel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + scrollPane = new JScrollPane(); + contentPane.add(scrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(5, 1, new Insets(10, 10, 10, 10), -1, -1)); + scrollPane.setViewportView(panel3); + panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final Spacer spacer2 = new Spacer(); + panel3.add(spacer2, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(5, 2, new Insets(10, 10, 10, 10), -1, -1)); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel4.setBorder(BorderFactory.createTitledBorder(null, "基本信息", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel4.getFont()), null)); + final JLabel label1 = new JLabel(); + label1.setText("任务名称"); + panel4.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + titleTextField = new JTextField(); + panel4.add(titleTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("消息类型"); + panel4.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("账号"); + panel4.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("消息"); + panel4.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("人群"); + panel4.add(label5, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeComboBox = new JComboBox(); + panel4.add(msgTypeComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + accountComboBox = new JComboBox(); + panel4.add(accountComboBox, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgComboBox = new JComboBox(); + panel4.add(msgComboBox, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + peopleComboBox = new JComboBox(); + panel4.add(peopleComboBox, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1)); + panel3.add(panel5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel5.setBorder(BorderFactory.createTitledBorder(null, "运行规则", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel5.getFont()), null)); + schedulePanel = new JPanel(); + schedulePanel.setLayout(new GridLayoutManager(5, 7, new Insets(5, 5, 0, 0), -1, -1)); + panel5.add(schedulePanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + runAtThisTimeRadioButton = new JRadioButton(); + runAtThisTimeRadioButton.setText("在此时间开始推送:"); + schedulePanel.add(runAtThisTimeRadioButton, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + startAtThisTimeTextField = new JTextField(); + startAtThisTimeTextField.setText(""); + schedulePanel.add(startAtThisTimeTextField, new GridConstraints(0, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + runPerDayRadioButton = new JRadioButton(); + runPerDayRadioButton.setText("每天固定时间开始推送:"); + schedulePanel.add(runPerDayRadioButton, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + startPerDayTextField = new JTextField(); + schedulePanel.add(startPerDayTextField, new GridConstraints(1, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + runPerWeekRadioButton = new JRadioButton(); + runPerWeekRadioButton.setText("每周固定时间开始推送:"); + schedulePanel.add(runPerWeekRadioButton, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("yyyy-MM-dd HH:mm:ss"); + schedulePanel.add(label6, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setText("HH:mm:ss"); + schedulePanel.add(label7, new GridConstraints(1, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setText("HH:mm:ss"); + schedulePanel.add(label8, new GridConstraints(2, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label9 = new JLabel(); + label9.setText("每周"); + schedulePanel.add(label9, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label10 = new JLabel(); + label10.setText("的"); + schedulePanel.add(label10, new GridConstraints(2, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + schedulePerWeekComboBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("一"); + defaultComboBoxModel1.addElement("二"); + defaultComboBoxModel1.addElement("三"); + defaultComboBoxModel1.addElement("四"); + defaultComboBoxModel1.addElement("五"); + defaultComboBoxModel1.addElement("六"); + defaultComboBoxModel1.addElement("日"); + schedulePerWeekComboBox.setModel(defaultComboBoxModel1); + schedulePanel.add(schedulePerWeekComboBox, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + startPerWeekTextField = new JTextField(); + schedulePanel.add(startPerWeekTextField, new GridConstraints(2, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + reimportCheckBox = new JCheckBox(); + reimportCheckBox.setText("开始执行时更新人群"); + schedulePanel.add(reimportCheckBox, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cronRadioButton = new JRadioButton(); + cronRadioButton.setText("按Cron表达式触发推送:"); + schedulePanel.add(cronRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cronTextField = new JTextField(); + schedulePanel.add(cronTextField, new GridConstraints(3, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + cronOnlineLabel = new JLabel(); + cronOnlineLabel.setText("在线Cron表达式生成器"); + schedulePanel.add(cronOnlineLabel, new GridConstraints(3, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cronHelpLabel = new JLabel(); + cronHelpLabel.setText(""); + schedulePanel.add(cronHelpLabel, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1)); + panel5.add(panel6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label11 = new JLabel(); + label11.setText("周期"); + panel6.add(label11, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel6.add(spacer3, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + manualTaskRadioButton = new JRadioButton(); + manualTaskRadioButton.setSelected(true); + manualTaskRadioButton.setText("手动任务"); + panel6.add(manualTaskRadioButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + scheduleTaskRadioButton = new JRadioButton(); + scheduleTaskRadioButton.setText("定时任务"); + panel6.add(scheduleTaskRadioButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + triggerTaskRadioButton = new JRadioButton(); + triggerTaskRadioButton.setEnabled(false); + triggerTaskRadioButton.setText("触发任务"); + panel6.add(triggerTaskRadioButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new GridLayoutManager(1, 8, new Insets(0, 0, 0, 0), -1, -1)); + panel5.add(panel7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label12 = new JLabel(); + label12.setText("模式"); + panel7.add(label12, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + fixThreadModeRadioButton = new JRadioButton(); + fixThreadModeRadioButton.setSelected(true); + fixThreadModeRadioButton.setText("固定线程"); + panel7.add(fixThreadModeRadioButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + infinityModeRadioButton = new JRadioButton(); + infinityModeRadioButton.setText("变速模式"); + panel7.add(infinityModeRadioButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + threadCntTextField = new JTextField(); + threadCntTextField.setHorizontalAlignment(2); + panel7.add(threadCntTextField, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(60, -1), null, 0, false)); + final JLabel label13 = new JLabel(); + label13.setText("线程数"); + panel7.add(label13, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel7.add(spacer4, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label14 = new JLabel(); + label14.setText("最大线程数"); + panel7.add(label14, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + maxThreadCntTextField = new JTextField(); + panel7.add(maxThreadCntTextField, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(60, -1), null, 0, false)); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel5.add(panel8, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + intervalPushCheckBox = new JCheckBox(); + intervalPushCheckBox.setText("间隔发送"); + panel8.add(intervalPushCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + panel8.add(spacer5, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + intervalTextField = new JTextField(); + panel8.add(intervalTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(60, -1), null, 0, false)); + final JLabel label15 = new JLabel(); + label15.setText("秒"); + panel8.add(label15, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel9 = new JPanel(); + panel9.setLayout(new GridLayoutManager(2, 2, new Insets(10, 10, 10, 10), -1, -1)); + panel3.add(panel9, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel9.setBorder(BorderFactory.createTitledBorder(null, "告警和通知", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel9.getFont()), null)); + sendPushResultCheckBox = new JCheckBox(); + sendPushResultCheckBox.setText("将推送结果发送邮件给(多个以分号分隔):"); + panel9.add(sendPushResultCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer6 = new Spacer(); + panel9.add(spacer6, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + mailResultToTextField = new JTextField(); + panel9.add(mailResultToTextField, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + otherPanel = new JPanel(); + otherPanel.setLayout(new GridLayoutManager(1, 2, new Insets(10, 10, 10, 10), -1, -1)); + panel3.add(otherPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + otherPanel.setBorder(BorderFactory.createTitledBorder(null, "其他", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, otherPanel.getFont()), null)); + saveResponseBodyCheckBox = new JCheckBox(); + saveResponseBodyCheckBox.setText("保存请求返回的Body"); + otherPanel.add(saveResponseBodyCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer7 = new Spacer(); + otherPanel.add(spacer7, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/SettingDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/SettingDialog.form new file mode 100644 index 000000000..3e9ba24dd --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/SettingDialog.form @@ -0,0 +1,375 @@ + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/SettingDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/SettingDialog.java new file mode 100644 index 000000000..f484e45c9 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/SettingDialog.java @@ -0,0 +1,440 @@ +package com.fangxuele.tool.push.ui.dialog; + +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.EmailAccountConfig; +import com.fangxuele.tool.push.ui.Init; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.HikariUtil; +import com.fangxuele.tool.push.util.ScrollUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.formdev.flatlaf.util.SystemInfo; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import com.zaxxer.hikari.HikariDataSource; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.Locale; + +public class SettingDialog extends JDialog { + private JPanel contentPane; + private JScrollPane settingScrollPane; + private JCheckBox autoCheckUpdateCheckBox; + private JCheckBox useTrayCheckBox; + private JCheckBox closeToTrayCheckBox; + private JCheckBox defaultMaxWindowCheckBox; + private JTextField maxThreadsTextField; + private JButton maxThreadsSaveButton; + private JButton saveMailButton; + private JButton testMailButton; + private JCheckBox mailStartTLSCheckBox; + private JCheckBox mailSSLCheckBox; + private JTextField mailHostTextField; + private JTextField mailPortTextField; + private JTextField mailFromTextField; + private JTextField mailUserTextField; + private JPasswordField mailPasswordField; + private JTextField mysqlUrlTextField; + private JTextField mysqlUserTextField; + private JPasswordField mysqlPasswordField; + private JButton settingTestDbLinkButton; + private JButton settingDbInfoSaveButton; + + private static final Log logger = LogFactory.get(); + + public SettingDialog() { + super(App.mainFrame, "设置"); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.5, 0.64); + setContentPane(contentPane); + setModal(true); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> dispose(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + + // 设置滚动条速度 + ScrollUtil.smoothPane(settingScrollPane); + + // 常规 + autoCheckUpdateCheckBox.setSelected(App.config.isAutoCheckUpdate()); + useTrayCheckBox.setSelected(App.config.isUseTray()); + closeToTrayCheckBox.setSelected(App.config.isCloseToTray()); + defaultMaxWindowCheckBox.setSelected(App.config.isDefaultMaxWindow()); + maxThreadsTextField.setText(String.valueOf(App.config.getMaxThreads())); + + // E-Mail + mailHostTextField.setText(App.config.getMailHost()); + mailPortTextField.setText(App.config.getMailPort()); + mailFromTextField.setText(App.config.getMailFrom()); + mailUserTextField.setText(App.config.getMailUser()); + mailPasswordField.setText(App.config.getMailPassword()); + mailStartTLSCheckBox.setSelected(App.config.isMailUseStartTLS()); + mailSSLCheckBox.setSelected(App.config.isMailUseSSL()); + + // MySQL + mysqlUrlTextField.setText(App.config.getMysqlUrl()); + mysqlUserTextField.setText(App.config.getMysqlUser()); + mysqlPasswordField.setText(App.config.getMysqlPassword()); + + saveMailButton.setIcon(new FlatSVGIcon("icon/save.svg")); + settingDbInfoSaveButton.setIcon(new FlatSVGIcon("icon/save.svg")); + maxThreadsSaveButton.setIcon(new FlatSVGIcon("icon/save.svg")); + testMailButton.setIcon(new FlatSVGIcon("icon/test.svg")); + settingTestDbLinkButton.setIcon(new FlatSVGIcon("icon/test.svg")); + + // 监听事件 + // 设置-常规-启动时自动检查更新 + autoCheckUpdateCheckBox.addActionListener(e -> { + App.config.setAutoCheckUpdate(autoCheckUpdateCheckBox.isSelected()); + App.config.save(); + }); + // 设置-常规-显示系统托盘图标 + useTrayCheckBox.addActionListener(e -> { + App.config.setUseTray(useTrayCheckBox.isSelected()); + App.config.save(); + if (App.tray == null && App.config.isUseTray()) { + Init.initTray(); + } else if (App.tray != null && !App.config.isUseTray()) { + App.tray.remove(App.trayIcon); + App.trayIcon = null; + App.tray = null; + } + }); + // 设置-常规-关闭窗口时最小化到系统托盘 + closeToTrayCheckBox.addActionListener(e -> { + App.config.setCloseToTray(closeToTrayCheckBox.isSelected()); + App.config.save(); + }); + // 设置-常规-默认最大化窗口 + defaultMaxWindowCheckBox.addActionListener(e -> { + App.config.setDefaultMaxWindow(defaultMaxWindowCheckBox.isSelected()); + App.config.save(); + }); + + // 设置-常规-最大线程数 + maxThreadsSaveButton.addActionListener(e -> { + try { + App.config.setMaxThreads(Integer.valueOf(maxThreadsTextField.getText())); + App.config.save(); +// PushListener.refreshPushInfo(); + + JOptionPane.showMessageDialog(this, "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(this, "保存失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + // E-Mail测试 + testMailButton.addActionListener(e -> { + App.config.setMailHost(mailHostTextField.getText()); + App.config.setMailPort(mailPortTextField.getText()); + App.config.setMailFrom(mailFromTextField.getText()); + App.config.setMailUser(mailUserTextField.getText()); + App.config.setMailPassword(new String(mailPasswordField.getPassword())); + App.config.setMailUseStartTLS(mailStartTLSCheckBox.isSelected()); + App.config.setMailUseSSL(mailSSLCheckBox.isSelected()); + + EmailAccountConfig emailAccountConfig = new EmailAccountConfig(); + emailAccountConfig.setMailHost(mailHostTextField.getText()); + emailAccountConfig.setMailPort(mailPortTextField.getText()); + emailAccountConfig.setMailFrom(mailFromTextField.getText()); + emailAccountConfig.setMailUser(mailUserTextField.getText()); + emailAccountConfig.setMailPassword(new String(mailPasswordField.getPassword())); + emailAccountConfig.setMailStartTLS(mailStartTLSCheckBox.isSelected()); + emailAccountConfig.setMailSSL(mailSSLCheckBox.isSelected()); + + MailTestDialog mailTestDialog = new MailTestDialog(emailAccountConfig); + mailTestDialog.pack(); + mailTestDialog.setVisible(true); + }); + + // E-Mail保存 + saveMailButton.addActionListener(e -> { + try { + App.config.setMailHost(mailHostTextField.getText()); + App.config.setMailPort(mailPortTextField.getText()); + App.config.setMailFrom(mailFromTextField.getText()); + App.config.setMailUser(mailUserTextField.getText()); + App.config.setMailPassword(new String(mailPasswordField.getPassword())); + App.config.setMailUseStartTLS(mailStartTLSCheckBox.isSelected()); + App.config.setMailUseSSL(mailSSLCheckBox.isSelected()); + App.config.save(); + + JOptionPane.showMessageDialog(this, "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(this, "保存失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + // mysql数据库-测试链接 + settingTestDbLinkButton.addActionListener(e -> { + HikariDataSource hikariDataSource = null; + try { + String dbUrl = mysqlUrlTextField.getText(); + String dbUser = mysqlUserTextField.getText(); + String dbPassword = new String(mysqlPasswordField.getPassword()); + if (StringUtils.isBlank(dbUrl)) { + mysqlUrlTextField.grabFocus(); + return; + } + if (StringUtils.isBlank(dbUser)) { + mysqlUserTextField.grabFocus(); + return; + } + if (StringUtils.isBlank(dbPassword)) { + mysqlPasswordField.grabFocus(); + return; + } + hikariDataSource = new HikariDataSource(); + hikariDataSource.setJdbcUrl("jdbc:mysql://" + dbUrl); + hikariDataSource.setUsername(dbUser); + hikariDataSource.setPassword(dbPassword); + if (hikariDataSource.getConnection() == null) { + JOptionPane.showMessageDialog(this, "连接失败", "失败", + JOptionPane.ERROR_MESSAGE); + } else { + JOptionPane.showMessageDialog(this, "连接成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(this, "连接失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + if (hikariDataSource != null) { + try { + hikariDataSource.close(); + } catch (Exception e2) { + logger.error(e2); + } + } + } + }); + + // mysql数据库-保存 + settingDbInfoSaveButton.addActionListener(e -> { + try { + App.config.setMysqlUrl(mysqlUrlTextField.getText()); + App.config.setMysqlUser(mysqlUserTextField.getText()); + App.config.setMysqlPassword(new String(mysqlPasswordField.getPassword())); + App.config.save(); + + if (HikariUtil.getHikariDataSource() != null) { + HikariUtil.getHikariDataSource().close(); + } + + JOptionPane.showMessageDialog(this, "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(this, "保存失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + settingScrollPane = new JScrollPane(); + panel1.add(settingScrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + settingScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + panel2.setMaximumSize(new Dimension(-1, -1)); + panel2.setMinimumSize(new Dimension(-1, -1)); + settingScrollPane.setViewportView(panel2); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(3, 1, new Insets(20, 20, 0, 20), -1, -1)); + panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(600, -1), null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(5, 1, new Insets(15, 15, 10, 0), -1, -1)); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "常规", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel4.getFont()), null)); + autoCheckUpdateCheckBox = new JCheckBox(); + autoCheckUpdateCheckBox.setText("自动检查更新"); + panel4.add(autoCheckUpdateCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + useTrayCheckBox = new JCheckBox(); + useTrayCheckBox.setText("显示系统托盘图标"); + panel4.add(useTrayCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + closeToTrayCheckBox = new JCheckBox(); + closeToTrayCheckBox.setText("关闭窗口时最小化到系统托盘"); + panel4.add(closeToTrayCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + defaultMaxWindowCheckBox = new JCheckBox(); + defaultMaxWindowCheckBox.setText("默认最大化窗口"); + panel4.add(defaultMaxWindowCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel4.add(panel5, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("最大线程数"); + panel5.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + maxThreadsTextField = new JTextField(); + panel5.add(maxThreadsTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(80, -1), null, 0, false)); + maxThreadsSaveButton = new JButton(); + maxThreadsSaveButton.setText("保存"); + panel5.add(maxThreadsSaveButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel5.add(spacer2, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(8, 2, new Insets(15, 15, 10, 0), -1, -1)); + panel3.add(panel6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel6.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "E-Mail", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel6.getFont()), null)); + final JLabel label2 = new JLabel(); + label2.setText("邮件服务器的SMTP地址"); + panel6.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("邮件服务器的SMTP端口"); + panel6.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("发件人(邮箱地址)"); + panel6.add(label4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("用户名"); + label5.setToolTipText("如果使用foxmail邮箱,此处为qq号"); + panel6.add(label5, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("密码"); + panel6.add(label6, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel6.add(panel7, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + saveMailButton = new JButton(); + saveMailButton.setText("保存"); + panel7.add(saveMailButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel7.add(spacer3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + testMailButton = new JButton(); + testMailButton.setText("测试"); + panel7.add(testMailButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mailStartTLSCheckBox = new JCheckBox(); + mailStartTLSCheckBox.setText("使用STARTTLS安全连接"); + panel6.add(mailStartTLSCheckBox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mailSSLCheckBox = new JCheckBox(); + mailSSLCheckBox.setText("使用SSL安全连接"); + panel6.add(mailSSLCheckBox, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mailHostTextField = new JTextField(); + panel6.add(mailHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailPortTextField = new JTextField(); + panel6.add(mailPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailFromTextField = new JTextField(); + panel6.add(mailFromTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailUserTextField = new JTextField(); + panel6.add(mailUserTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailPasswordField = new JPasswordField(); + panel6.add(mailPasswordField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new GridLayoutManager(4, 2, new Insets(15, 15, 10, 0), -1, -1)); + panel3.add(panel8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel8.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "MySQL数据库", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel8.getFont()), null)); + final JLabel label7 = new JLabel(); + label7.setText("数据库地址"); + panel8.add(label7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mysqlUrlTextField = new JTextField(); + panel8.add(mysqlUrlTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setText("用户名"); + panel8.add(label8, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mysqlUserTextField = new JTextField(); + panel8.add(mysqlUserTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label9 = new JLabel(); + label9.setText("密码"); + panel8.add(label9, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mysqlPasswordField = new JPasswordField(); + panel8.add(mysqlPasswordField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel9 = new JPanel(); + panel9.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel8.add(panel9, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + settingTestDbLinkButton = new JButton(); + settingTestDbLinkButton.setText("测试连接"); + panel9.add(settingTestDbLinkButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel9.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + settingDbInfoSaveButton = new JButton(); + settingDbInfoSaveButton.setText("保存"); + panel9.add(settingDbInfoSaveButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/SwitchWxAccountDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/SwitchWxAccountDialog.java deleted file mode 100644 index b3d313c3b..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/SwitchWxAccountDialog.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.fangxuele.tool.push.ui.dialog; - -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TWxAccountMapper; -import com.fangxuele.tool.push.domain.TWxAccount; -import com.fangxuele.tool.push.ui.form.SettingForm; -import com.fangxuele.tool.push.ui.listener.SettingListener; -import com.fangxuele.tool.push.util.ComponentUtil; -import com.fangxuele.tool.push.util.JTableUtil; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.fangxuele.tool.push.util.SqliteUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.List; - -/** - *
- * 多账号管理dialog
- * 
- * - * @author RememBerBer - * @since 2019/5/23. - */ -public class SwitchWxAccountDialog extends JDialog { - private static final long serialVersionUID = -356412591638869973L; - private JPanel contentPane; - private JButton buttonOk; - private JTable accountsTable; - private JTextField nameTextField; - private JTextField appIdTextField; - private JTextField appSecretTextField; - private JTextField tokenTextField; - private JTextField aesKeyTextField; - private JButton addButton; - private JButton deleteButton; - - private Log logger = LogFactory.get(); - private static TWxAccountMapper wxAccountMapper = MybatisUtil.getSqlSession().getMapper(TWxAccountMapper.class); - - public SwitchWxAccountDialog() { - super(App.mainFrame, "多账号管理"); - String title = "多账号管理"; - if (SettingForm.WX_ACCOUNT_TYPE_MP.equals(SettingListener.wxAccountType)) { - title = "多账号管理-公众号"; - } else if (SettingForm.WX_ACCOUNT_TYPE_MA.equals(SettingListener.wxAccountType)) { - title = "多账号管理-小程序"; - } - setTitle(title); - setContentPane(contentPane); - setModal(true); - - ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.6, 0.63); - - buttonOk.addActionListener(e -> onCancel()); - - // call onCancel() when cross is clicked - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - onCancel(); - } - }); - // call onCancel() on ESCAPE - contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - - // 保存按钮事件 - addButton.addActionListener(e -> { - String accountName = nameTextField.getText(); - if (StringUtils.isBlank(accountName)) { - JOptionPane.showMessageDialog(this, "请填写账号名称!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - boolean update = false; - List tWxAccountList = wxAccountMapper.selectByAccountTypeAndAccountName(SettingListener.wxAccountType, accountName); - if (tWxAccountList.size() > 0) { - update = true; - } - - TWxAccount tWxAccount = new TWxAccount(); - String now = SqliteUtil.nowDateForSqlite(); - tWxAccount.setAccountType(SettingListener.wxAccountType); - tWxAccount.setAccountName(accountName); - tWxAccount.setAppId(appIdTextField.getText()); - tWxAccount.setAppSecret(appSecretTextField.getText()); - tWxAccount.setToken(tokenTextField.getText()); - tWxAccount.setAesKey(aesKeyTextField.getText()); - tWxAccount.setModifiedTime(now); - - if (update) { - tWxAccount.setId(tWxAccountList.get(0).getId()); - wxAccountMapper.updateByPrimaryKeySelective(tWxAccount); - } else { - tWxAccount.setCreateTime(now); - wxAccountMapper.insert(tWxAccount); - } - renderTable(); - SettingForm.initSwitchMultiAccount(); - JOptionPane.showMessageDialog(this, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - }); - - // 删除按钮事件 - deleteButton.addActionListener(e -> ThreadUtil.execute(() -> { - try { - int[] selectedRows = accountsTable.getSelectedRows(); - if (selectedRows.length == 0) { - JOptionPane.showMessageDialog(this, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } else { - int isDelete = JOptionPane.showConfirmDialog(this, "确认删除?", "确认", - JOptionPane.YES_NO_OPTION); - if (isDelete == JOptionPane.YES_OPTION) { - DefaultTableModel tableModel = (DefaultTableModel) accountsTable.getModel(); - for (int i = selectedRows.length; i > 0; i--) { - int selectedRow = accountsTable.getSelectedRow(); - Integer selectedId = (Integer) tableModel.getValueAt(selectedRow, 0); - wxAccountMapper.deleteByPrimaryKey(selectedId); - tableModel.removeRow(selectedRow); - } - SettingForm.initSwitchMultiAccount(); - } - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(this, "删除失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - })); - - accountsTable.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - clearFields(); - - int selectedRow = accountsTable.getSelectedRow(); - String selectedId = accountsTable.getValueAt(selectedRow, 0).toString(); - TWxAccount tWxAccount = wxAccountMapper.selectByPrimaryKey(Integer.valueOf(selectedId)); - nameTextField.setText(tWxAccount.getAccountName()); - appIdTextField.setText(tWxAccount.getAppId()); - appSecretTextField.setText(tWxAccount.getAppSecret()); - tokenTextField.setText(tWxAccount.getToken()); - aesKeyTextField.setText(tWxAccount.getAesKey()); - super.mousePressed(e); - } - }); - } - - private void onCancel() { - // add your code here if necessary - dispose(); - } - - /** - * 多账号表格 - */ - public void renderTable() { - String[] headerNames = {"id", "账号名称", "AppId", "AppSecret", "Token", "AesKey"}; - DefaultTableModel model = new DefaultTableModel(null, headerNames); - accountsTable.setModel(model); - - DefaultTableCellRenderer hr = (DefaultTableCellRenderer) accountsTable.getTableHeader() - .getDefaultRenderer(); - // 表头列名居左 - hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); - - List wxAccountList = wxAccountMapper.selectByAccountType(SettingListener.wxAccountType); - Object[] data; - for (TWxAccount tWxAccount : wxAccountList) { - data = new Object[6]; - data[0] = tWxAccount.getId(); - data[1] = tWxAccount.getAccountName(); - data[2] = tWxAccount.getAppId(); - data[3] = tWxAccount.getAppSecret(); - data[4] = tWxAccount.getToken(); - data[5] = tWxAccount.getAesKey(); - model.addRow(data); - } - - // 隐藏id列 - JTableUtil.hideColumn(accountsTable, 0); - } - - /** - * 清空表单 - */ - public void clearFields() { - nameTextField.setText(""); - appIdTextField.setText(""); - appSecretTextField.setText(""); - tokenTextField.setText(""); - aesKeyTextField.setText(""); - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - contentPane.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - buttonOk = new JButton(); - buttonOk.setText("好了"); - panel2.add(buttonOk, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - deleteButton = new JButton(); - deleteButton.setText("删除"); - panel2.add(deleteButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(4, 5, new Insets(5, 5, 0, 5), -1, -1)); - contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "添加新账号", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); - final JLabel label1 = new JLabel(); - label1.setText("名称"); - panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - nameTextField = new JTextField(); - panel3.add(nameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("AppId"); - panel3.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - appIdTextField = new JTextField(); - panel3.add(appIdTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("AppSecret"); - panel3.add(label3, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - appSecretTextField = new JTextField(); - panel3.add(appSecretTextField, new GridConstraints(1, 3, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("Token"); - panel3.add(label4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - tokenTextField = new JTextField(); - panel3.add(tokenTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label5 = new JLabel(); - label5.setText("AES Key"); - panel3.add(label5, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - aesKeyTextField = new JTextField(); - panel3.add(aesKeyTextField, new GridConstraints(2, 3, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final Spacer spacer2 = new Spacer(); - panel3.add(spacer2, new GridConstraints(3, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - addButton = new JButton(); - addButton.setText("保存"); - panel3.add(addButton, new GridConstraints(3, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JScrollPane scrollPane1 = new JScrollPane(); - contentPane.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - accountsTable = new JTable(); - accountsTable.setRowHeight(36); - scrollPane1.setViewportView(accountsTable); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return contentPane; - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/SystemEnvResultDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/SystemEnvResultDialog.form new file mode 100644 index 000000000..6bd79de3b --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/SystemEnvResultDialog.form @@ -0,0 +1,69 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/SystemEnvResultDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/SystemEnvResultDialog.java new file mode 100644 index 000000000..2d6692014 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/SystemEnvResultDialog.java @@ -0,0 +1,114 @@ +package com.fangxuele.tool.push.ui.dialog; + +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class SystemEnvResultDialog extends JDialog { + private JPanel contentPane; + private JButton buttonOK; + private JTextArea textArea1; + + public SystemEnvResultDialog() { + + super(App.mainFrame, "系统环境变量"); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.64); + setContentPane(contentPane); + setModal(true); + getRootPane().setDefaultButton(buttonOK); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + + buttonOK.addActionListener(e -> onOK()); + + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + onOK(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onOK(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + + } + + private void onOK() { + // add your code here + dispose(); + } + + public void setTextArea(String str) { + textArea1.setText(str); + } + + public void appendTextArea(String str) { + textArea1.append(str); + textArea1.append("\n"); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 10, 10), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + buttonOK = new JButton(); + buttonOK.setText("OK"); + panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JScrollPane scrollPane1 = new JScrollPane(); + panel3.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + textArea1 = new JTextArea(); + scrollPane1.setViewportView(textArea1); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/TaskHisDetailDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/TaskHisDetailDialog.form new file mode 100644 index 000000000..00142bba8 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/TaskHisDetailDialog.form @@ -0,0 +1,337 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/TaskHisDetailDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/TaskHisDetailDialog.java new file mode 100644 index 000000000..e3094d8a6 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/TaskHisDetailDialog.java @@ -0,0 +1,678 @@ +package com.fangxuele.tool.push.ui.dialog; + +import cn.hutool.core.date.BetweenFormater; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.domain.*; +import com.fangxuele.tool.push.logic.TaskRunThread; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.ui.form.PeopleManageForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.formdev.flatlaf.util.StringUtils; +import com.formdev.flatlaf.util.SystemInfo; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.opencsv.CSVReader; + +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.Locale; + +public class TaskHisDetailDialog extends JDialog { + private JPanel contentPane; + private JTextArea textArea1; + private JPanel pushUpPanel; + private JLabel pushSuccessCount; + private JLabel pushFailCount; + private JLabel pushTotalProgressLabel; + private JProgressBar pushTotalProgressBar; + private JLabel pushLastTimeLabel; + private JLabel pushTotalCountLabel; + private JLabel pushMsgName; + private JLabel scheduleDetailLabel; + private JLabel pushLeftTimeLabel; + private JLabel tpsLabel; + private JButton pushStopButton; + private JTextField successFileTextField; + private JButton openSuccessButton; + private JButton successToPeopleButton; + private JTextField failFileTextField; + private JButton failToPeopleButton; + private JButton openFailButton; + private JTextField noSendFileTextField; + private JButton openNoSendButton; + private JButton noSendToPeopleButton; + + private static TTaskHisMapper taskHisMapper = MybatisUtil.getSqlSession().getMapper(TTaskHisMapper.class); + private static TTaskMapper taskMapper = MybatisUtil.getSqlSession().getMapper(TTaskMapper.class); + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + + private static final Log logger = LogFactory.get(); + + private Boolean dialogClosed = false; + + public TaskHisDetailDialog() { + super(App.mainFrame, "执行详情"); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.68, 0.64); + setContentPane(contentPane); + setModal(true); + + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + + successToPeopleButton.setIcon(new FlatSVGIcon("icon/people.svg")); + failToPeopleButton.setIcon(new FlatSVGIcon("icon/people.svg")); + noSendToPeopleButton.setIcon(new FlatSVGIcon("icon/people.svg")); + openSuccessButton.setIcon(new FlatSVGIcon("icon/file-open.svg")); + openFailButton.setIcon(new FlatSVGIcon("icon/file-open.svg")); + openNoSendButton.setIcon(new FlatSVGIcon("icon/file-open.svg")); + pushStopButton.setIcon(new FlatSVGIcon("icon/stop.svg")); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onClose(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onClose(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + + } + + private void onClose() { + dialogClosed = true; + dispose(); + } + + public TaskHisDetailDialog(TaskRunThread taskRunThread, Integer taskHisId) { + this(); + + TTaskHis tTaskHis = taskHisMapper.selectByPrimaryKey(taskHisId); + TTask tTask = taskMapper.selectByPrimaryKey(tTaskHis.getTaskId()); + TMsg tMsg = msgMapper.selectByPrimaryKey(tTask.getMessageId()); + + successToPeopleButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar memberTabImportProgressBar = peopleEditForm.getMemberTabImportProgressBar(); + CSVReader reader = null; + try { + MainWindow.getInstance().getTabbedPane().setSelectedIndex(3); + + TPeople tPeopleToSave = new TPeople(); + tPeopleToSave.setMsgType(tTask.getMsgType()); + tPeopleToSave.setAccountId(tTask.getAccountId()); + tPeopleToSave.setPeopleName(FileUtil.getName(tTaskHis.getSuccessFilePath()).replace(".csv", "")); + tPeopleToSave.setAppVersion(UiConsts.APP_VERSION); + String now = SqliteUtil.nowDateForSqlite(); + tPeopleToSave.setCreateTime(now); + tPeopleToSave.setModifiedTime(now); + + peopleMapper.insert(tPeopleToSave); + + memberTabImportProgressBar.setVisible(true); + memberTabImportProgressBar.setIndeterminate(true); + File msgTemplateDataFile = new File(tTaskHis.getSuccessFilePath()); + if (msgTemplateDataFile.exists()) { + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(msgTemplateDataFile)); + reader = new CSVReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + String[] nextLine; + TPeopleData tPeopleData; + while ((nextLine = reader.readNext()) != null) { + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(tPeopleToSave.getId()); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } + PeopleManageForm.initPeopleList(); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + memberTabImportProgressBar.setMaximum(100); + memberTabImportProgressBar.setValue(100); + memberTabImportProgressBar.setIndeterminate(false); + memberTabImportProgressBar.setVisible(false); + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + logger.error(e1); + e1.printStackTrace(); + } + } + } + + }); + + dispose(); + }); + + failToPeopleButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar memberTabImportProgressBar = peopleEditForm.getMemberTabImportProgressBar(); + CSVReader reader = null; + try { + MainWindow.getInstance().getTabbedPane().setSelectedIndex(3); + + TPeople tPeopleToSave = new TPeople(); + tPeopleToSave.setMsgType(tTask.getMsgType()); + tPeopleToSave.setAccountId(tTask.getAccountId()); + tPeopleToSave.setPeopleName(FileUtil.getName(tTaskHis.getFailFilePath()).replace(".csv", "")); + tPeopleToSave.setAppVersion(UiConsts.APP_VERSION); + String now = SqliteUtil.nowDateForSqlite(); + tPeopleToSave.setCreateTime(now); + tPeopleToSave.setModifiedTime(now); + + peopleMapper.insert(tPeopleToSave); + + memberTabImportProgressBar.setVisible(true); + memberTabImportProgressBar.setIndeterminate(true); + File msgTemplateDataFile = new File(tTaskHis.getFailFilePath()); + if (msgTemplateDataFile.exists()) { + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(msgTemplateDataFile)); + reader = new CSVReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + String[] nextLine; + TPeopleData tPeopleData; + while ((nextLine = reader.readNext()) != null) { + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(tPeopleToSave.getId()); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } + PeopleManageForm.initPeopleList(); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + memberTabImportProgressBar.setMaximum(100); + memberTabImportProgressBar.setValue(100); + memberTabImportProgressBar.setIndeterminate(false); + memberTabImportProgressBar.setVisible(false); + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + logger.error(e1); + e1.printStackTrace(); + } + } + } + + }); + + dispose(); + }); + + noSendToPeopleButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar memberTabImportProgressBar = peopleEditForm.getMemberTabImportProgressBar(); + CSVReader reader = null; + try { + MainWindow.getInstance().getTabbedPane().setSelectedIndex(3); + + TPeople tPeopleToSave = new TPeople(); + tPeopleToSave.setMsgType(tTask.getMsgType()); + tPeopleToSave.setAccountId(tTask.getAccountId()); + tPeopleToSave.setPeopleName(FileUtil.getName(tTaskHis.getNoSendFilePath()).replace(".csv", "")); + tPeopleToSave.setAppVersion(UiConsts.APP_VERSION); + String now = SqliteUtil.nowDateForSqlite(); + tPeopleToSave.setCreateTime(now); + tPeopleToSave.setModifiedTime(now); + + peopleMapper.insert(tPeopleToSave); + + memberTabImportProgressBar.setVisible(true); + memberTabImportProgressBar.setIndeterminate(true); + File msgTemplateDataFile = new File(tTaskHis.getNoSendFilePath()); + if (msgTemplateDataFile.exists()) { + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(msgTemplateDataFile)); + reader = new CSVReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + String[] nextLine; + TPeopleData tPeopleData; + while ((nextLine = reader.readNext()) != null) { + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(tPeopleToSave.getId()); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } + PeopleManageForm.initPeopleList(); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + memberTabImportProgressBar.setMaximum(100); + memberTabImportProgressBar.setValue(100); + memberTabImportProgressBar.setIndeterminate(false); + memberTabImportProgressBar.setVisible(false); + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + logger.error(e1); + e1.printStackTrace(); + } + } + } + + }); + + dispose(); + }); + + openSuccessButton.addActionListener(e -> { + try { + if (StringUtils.isEmpty(tTaskHis.getSuccessFilePath())) { + return; + } + Desktop.getDesktop().open(new File(tTaskHis.getSuccessFilePath())); + } catch (IOException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "打开文件失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + openFailButton.addActionListener(e -> { + try { + if (StringUtils.isEmpty(tTaskHis.getFailFilePath())) { + return; + } + Desktop.getDesktop().open(new File(tTaskHis.getFailFilePath())); + } catch (IOException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "打开文件失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + openNoSendButton.addActionListener(e -> { + try { + if (StringUtils.isEmpty(tTaskHis.getNoSendFilePath())) { + return; + } + Desktop.getDesktop().open(new File(tTaskHis.getNoSendFilePath())); + } catch (IOException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "打开文件失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + pushStopButton.addActionListener(e -> { + int isStop = JOptionPane.showConfirmDialog(App.mainFrame, + "确定停止当前的推送吗?", "确认停止?", + JOptionPane.YES_NO_OPTION); + if (isStop == JOptionPane.YES_OPTION) { + taskRunThread.running = false; + pushStopButton.setEnabled(false); + } + }); + + BufferedReader logReader = null; + + pushMsgName.setText(tMsg.getMsgName()); + pushTotalCountLabel.setText("总量:" + tTaskHis.getTotalCnt()); + pushTotalProgressBar.setMaximum(tTaskHis.getTotalCnt()); + + if (taskRunThread != null && taskRunThread.running) { + try { + logReader = new BufferedReader(new FileReader(taskRunThread.getLogFilePath())); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + BufferedReader finalLogReader = logReader; + + ThreadUtil.execAsync(() -> { + int totalSentCountBefore = 0; + + while (true) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + String line = finalLogReader.readLine(); + if (line != null) { + textArea1.append(line + "\n"); + textArea1.setCaretPosition(textArea1.getText().length()); + } + } catch (IOException e) { + e.printStackTrace(); + } + if (!taskRunThread.running || dialogClosed) { + pushStopButton.setEnabled(false); + try { + finalLogReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + TTaskHis taskHis = taskHisMapper.selectByPrimaryKey(taskHisId); + successFileTextField.setText(taskHis.getSuccessFilePath()); + failFileTextField.setText(taskHis.getFailFilePath()); + noSendFileTextField.setText(taskHis.getNoSendFilePath()); + + break; + } + pushStopButton.setEnabled(true); + + pushSuccessCount.setText(String.valueOf(taskRunThread.getSuccessRecords())); + pushFailCount.setText(String.valueOf(taskRunThread.getFailRecords())); + + int totalSentCount = taskRunThread.getSuccessRecords().intValue() + taskRunThread.getFailRecords().intValue(); + pushTotalProgressBar.setValue(totalSentCount); + long currentTimeMillis = System.currentTimeMillis(); + long lastTimeMillis = currentTimeMillis - taskRunThread.getStartTime(); + // 耗时 + String formatBetweenLast = DateUtil.formatBetween(lastTimeMillis, BetweenFormater.Level.SECOND); + pushLastTimeLabel.setText("".equals(formatBetweenLast) ? "0s" : formatBetweenLast); + + // 预计剩余 + + long leftTimeMillis = (long) ((double) lastTimeMillis / (totalSentCount) * (tTaskHis.getTotalCnt() - totalSentCount)); + String formatBetweenLeft = DateUtil.formatBetween(leftTimeMillis, BetweenFormater.Level.SECOND); + pushLeftTimeLabel.setText("".equals(formatBetweenLeft) ? "0s" : formatBetweenLeft); + + int tps = (totalSentCount - totalSentCountBefore) * 2; + totalSentCountBefore = totalSentCount; + tpsLabel.setText(tps + ""); + } + }); + } else { + + pushStopButton.setEnabled(false); + + pushSuccessCount.setText(String.valueOf(tTaskHis.getSuccessCnt())); + pushFailCount.setText(String.valueOf(tTaskHis.getFailCnt())); + pushTotalProgressBar.setValue(tTaskHis.getSuccessCnt() + tTaskHis.getFailCnt()); + + long lastTimeMillis = DateUtil.parseDateTime(tTaskHis.getEndTime()).getTime() - DateUtil.parseDateTime(tTaskHis.getStartTime()).getTime(); + + // 耗时 + String formatBetweenLast = DateUtil.formatBetween(lastTimeMillis, BetweenFormater.Level.SECOND); + pushLastTimeLabel.setText("".equals(formatBetweenLast) ? "0s" : formatBetweenLast); + + int tps; + if (lastTimeMillis == 0) { + tps = 0; + } else { + tps = (int) ((tTaskHis.getSuccessCnt() + tTaskHis.getFailCnt()) / (lastTimeMillis / 1000)); + } + tpsLabel.setText(tps + ""); + + successFileTextField.setText(tTaskHis.getSuccessFilePath()); + failFileTextField.setText(tTaskHis.getFailFilePath()); + noSendFileTextField.setText(tTaskHis.getNoSendFilePath()); + + if (!StringUtils.isEmpty(tTaskHis.getLogFilePath())) { + try { + logReader = new BufferedReader(new FileReader(tTaskHis.getLogFilePath())); + + String line; + while ((line = logReader.readLine()) != null) { + textArea1.append(line + "\n"); + textArea1.setCaretPosition(textArea1.getText().length()); + if (dialogClosed) { + logReader.close(); + break; + } + } + if (logReader != null) { + logReader.close(); + } + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 10), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + pushUpPanel = new JPanel(); + pushUpPanel.setLayout(new GridLayoutManager(6, 10, new Insets(0, 0, 0, 0), -1, -1)); + panel2.add(pushUpPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + pushSuccessCount = new JLabel(); + Font pushSuccessCountFont = this.$$$getFont$$$(null, -1, 72, pushSuccessCount.getFont()); + if (pushSuccessCountFont != null) pushSuccessCount.setFont(pushSuccessCountFont); + pushSuccessCount.setForeground(new Color(-13587376)); + pushSuccessCount.setText("0"); + pushUpPanel.add(pushSuccessCount, new GridConstraints(0, 0, 6, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushFailCount = new JLabel(); + Font pushFailCountFont = this.$$$getFont$$$(null, -1, 72, pushFailCount.getFont()); + if (pushFailCountFont != null) pushFailCount.setFont(pushFailCountFont); + pushFailCount.setForeground(new Color(-2200483)); + pushFailCount.setText("0"); + pushUpPanel.add(pushFailCount, new GridConstraints(0, 2, 6, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushTotalProgressLabel = new JLabel(); + pushTotalProgressLabel.setText("总进度"); + pushUpPanel.add(pushTotalProgressLabel, new GridConstraints(5, 8, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushTotalProgressBar = new JProgressBar(); + pushTotalProgressBar.setStringPainted(true); + pushUpPanel.add(pushTotalProgressBar, new GridConstraints(5, 9, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("成功"); + pushUpPanel.add(label1, new GridConstraints(2, 1, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("失败"); + pushUpPanel.add(label2, new GridConstraints(2, 3, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JSeparator separator1 = new JSeparator(); + separator1.setOrientation(1); + pushUpPanel.add(separator1, new GridConstraints(0, 4, 6, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + pushLastTimeLabel = new JLabel(); + pushLastTimeLabel.setEnabled(true); + Font pushLastTimeLabelFont = this.$$$getFont$$$("Microsoft YaHei UI Light", -1, 36, pushLastTimeLabel.getFont()); + if (pushLastTimeLabelFont != null) pushLastTimeLabel.setFont(pushLastTimeLabelFont); + pushLastTimeLabel.setForeground(new Color(-6710887)); + pushLastTimeLabel.setText("0s"); + pushUpPanel.add(pushLastTimeLabel, new GridConstraints(0, 6, 3, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setHorizontalAlignment(0); + label3.setHorizontalTextPosition(0); + label3.setText("耗时"); + pushUpPanel.add(label3, new GridConstraints(0, 5, 3, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JSeparator separator2 = new JSeparator(); + separator2.setOrientation(1); + pushUpPanel.add(separator2, new GridConstraints(0, 7, 6, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + pushTotalCountLabel = new JLabel(); + pushTotalCountLabel.setText("消息总数:--"); + pushUpPanel.add(pushTotalCountLabel, new GridConstraints(1, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushMsgName = new JLabel(); + Font pushMsgNameFont = this.$$$getFont$$$(null, -1, 24, pushMsgName.getFont()); + if (pushMsgNameFont != null) pushMsgName.setFont(pushMsgNameFont); + pushMsgName.setForeground(new Color(-276358)); + pushMsgName.setText("消息标题"); + pushUpPanel.add(pushMsgName, new GridConstraints(0, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + scheduleDetailLabel = new JLabel(); + scheduleDetailLabel.setForeground(new Color(-276358)); + scheduleDetailLabel.setText(""); + pushUpPanel.add(scheduleDetailLabel, new GridConstraints(4, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("预计剩余"); + pushUpPanel.add(label4, new GridConstraints(3, 5, 2, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushLeftTimeLabel = new JLabel(); + Font pushLeftTimeLabelFont = this.$$$getFont$$$("Microsoft YaHei UI Light", -1, 36, pushLeftTimeLabel.getFont()); + if (pushLeftTimeLabelFont != null) pushLeftTimeLabel.setFont(pushLeftTimeLabelFont); + pushLeftTimeLabel.setForeground(new Color(-6710887)); + pushLeftTimeLabel.setText("0s"); + pushUpPanel.add(pushLeftTimeLabel, new GridConstraints(3, 6, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("TPS"); + pushUpPanel.add(label5, new GridConstraints(5, 5, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + tpsLabel = new JLabel(); + tpsLabel.setText("0"); + pushUpPanel.add(tpsLabel, new GridConstraints(5, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 10), -1, -1)); + panel1.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JScrollPane scrollPane1 = new JScrollPane(); + panel3.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + textArea1 = new JTextArea(); + scrollPane1.setViewportView(textArea1); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(4, 4, new Insets(10, 10, 10, 10), -1, -1)); + panel1.add(panel4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("成功"); + panel4.add(label6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setText("失败"); + panel4.add(label7, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setText("未发送"); + panel4.add(label8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + successFileTextField = new JTextField(); + successFileTextField.setEditable(false); + panel4.add(successFileTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + failFileTextField = new JTextField(); + failFileTextField.setEditable(false); + panel4.add(failFileTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + noSendFileTextField = new JTextField(); + noSendFileTextField.setEditable(false); + panel4.add(noSendFileTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + openSuccessButton = new JButton(); + openSuccessButton.setText("打开"); + panel4.add(openSuccessButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + openFailButton = new JButton(); + openFailButton.setText("打开"); + panel4.add(openFailButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + openNoSendButton = new JButton(); + openNoSendButton.setText("打开"); + panel4.add(openNoSendButton, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + successToPeopleButton = new JButton(); + successToPeopleButton.setText("创建为人群"); + panel4.add(successToPeopleButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + failToPeopleButton = new JButton(); + failToPeopleButton.setText("创建为人群"); + panel4.add(failToPeopleButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + noSendToPeopleButton = new JButton(); + noSendToPeopleButton.setText("创建为人群"); + panel4.add(noSendToPeopleButton, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + pushStopButton = new JButton(); + pushStopButton.setEnabled(false); + pushStopButton.setText("停止"); + panel4.add(pushStopButton, new GridConstraints(3, 2, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.form index fd05d719c..dbc144d1e 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.form +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.form @@ -1,7 +1,7 @@
- + @@ -9,7 +9,7 @@ - + @@ -58,7 +58,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.java index ef44dea7b..976179625 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.java +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateDialog.java @@ -5,10 +5,16 @@ import cn.hutool.core.thread.ThreadUtil; import cn.hutool.http.HttpUtil; import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.ui.UiConsts; import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; +import org.apache.commons.lang3.StringUtils; import javax.swing.*; import java.awt.*; @@ -46,6 +52,15 @@ public UpdateDialog() { setModal(true); getRootPane().setDefaultButton(buttonOK); + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + ComponentUtil.setPreferSizeAndLocateToCenter(this, 600, 200); buttonOK.addActionListener(e -> onOK()); @@ -66,7 +81,7 @@ public void windowClosing(WindowEvent e) { buttonDownloadFromWeb.addActionListener(e -> { Desktop desktop = Desktop.getDesktop(); try { - desktop.browse(new URI("https://github.com/rememberber/WePush/releases")); + desktop.browse(new URI("https://gitee.com/zhoubochina/WePush/releases")); } catch (IOException | URISyntaxException ex) { ex.printStackTrace(); } @@ -77,7 +92,25 @@ public void downLoad(String newVersion) { buttonOK.setEnabled(false); ThreadUtil.execute( () -> { - String fileUrl = "http://download.zhoubochina.com/exe/WePush-" + newVersion.replace("v_", "v") + "-x64-Setup.exe"; + String fileUrl = ""; + // 从github获取最新版本相关信息 + String downloadLinkInfo = HttpUtil.get(UiConsts.DOWNLOAD_LINK_INFO_URL); + if (StringUtils.isEmpty(downloadLinkInfo) || downloadLinkInfo.contains("404: Not Found")) { + JOptionPane.showMessageDialog(App.mainFrame, + "获取下载链接失败,请关注Gitee Release!", "网络错误", + JOptionPane.INFORMATION_MESSAGE); + return; + } else { + DocumentContext parse = JsonPath.parse(downloadLinkInfo); + if (SystemUtil.isWindowsOs()) { + fileUrl = parse.read("$.windows"); + } else if (SystemUtil.isMacOs()) { + fileUrl = parse.read("$.mac"); + } else if (SystemUtil.isLinuxOs()) { + fileUrl = parse.read("$.linux"); + } + } + String fileName = FileUtil.getName(fileUrl); URL url; try { @@ -150,9 +183,9 @@ private void onCancel() { */ private void $$$setupUI$$$() { contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(10, 10, 10, 10), -1, -1)); contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); @@ -169,7 +202,7 @@ private void onCancel() { buttonDownloadFromWeb.setText("打开下载页面"); panel2.add(buttonDownloadFromWeb, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1)); contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); progressBarDownload = new JProgressBar(); panel3.add(progressBarDownload, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.form index 2970b09ac..276b94af1 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.form +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.form @@ -1,7 +1,7 @@ - + @@ -9,7 +9,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.java index 92ac7cd4a..908b3c262 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.java +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/UpdateInfoDialog.java @@ -3,12 +3,14 @@ import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.util.ComponentUtil; import com.fangxuele.tool.push.util.SystemUtil; +import com.formdev.flatlaf.util.SystemInfo; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; import lombok.Getter; import javax.swing.*; +import javax.swing.border.TitledBorder; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; import java.awt.*; @@ -47,6 +49,15 @@ public UpdateInfoDialog() { setModal(true); getRootPane().setDefaultButton(buttonOK); + if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) { + this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true); + this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true); + this.getRootPane().putClientProperty("apple.awt.fullscreenable", true); + this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false); + GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout(); + gridLayoutManager.setMargin(new Insets(28, 0, 0, 0)); + } + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.64); buttonOK.addActionListener(e -> onOK()); @@ -70,7 +81,7 @@ private void onOK() { if (SystemUtil.isMacOs()) { Desktop desktop = Desktop.getDesktop(); try { - desktop.browse(new URI("https://github.com/rememberber/WePush/releases")); + desktop.browse(new URI("https://gitee.com/zhoubochina/WePush/releases")); } catch (IOException | URISyntaxException ex) { ex.printStackTrace(); } @@ -122,9 +133,9 @@ public void setHtmlText(String htmlText) { */ private void $$$setupUI$$$() { contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 10, 0), -1, -1)); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 10, 10), -1, -1)); contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); @@ -140,10 +151,11 @@ public void setHtmlText(String htmlText) { final Spacer spacer2 = new Spacer(); panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(20, 10, 10, 10), -1, -1)); contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JScrollPane scrollPane1 = new JScrollPane(); panel3.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); textPane1 = new JTextPane(); textPane1.setEditable(false); textPane1.setMargin(new Insets(80, 28, 3, 28)); diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/WxCpAppDialog.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/WxCpAppDialog.form deleted file mode 100644 index 09293d483..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/WxCpAppDialog.form +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/WxCpAppDialog.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/WxCpAppDialog.java deleted file mode 100644 index 9e8248e52..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/WxCpAppDialog.java +++ /dev/null @@ -1,270 +0,0 @@ -package com.fangxuele.tool.push.ui.dialog; - -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TWxCpAppMapper; -import com.fangxuele.tool.push.domain.TWxCpApp; -import com.fangxuele.tool.push.ui.form.SettingForm; -import com.fangxuele.tool.push.util.ComponentUtil; -import com.fangxuele.tool.push.util.JTableUtil; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.fangxuele.tool.push.util.SqliteUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.List; - -/** - *
- * WxCpAppDialog
- * 
- * - * @author Zhou Bo - * @since 2019/6/7. - */ -public class WxCpAppDialog extends JDialog { - private static final long serialVersionUID = -1508175617622474963L; - private JPanel contentPane; - private JButton buttonDelete; - private JButton buttonCancel; - private JTable appsTable; - private JTextField appNameTextField; - private JTextField agentIdTextField; - private JTextField secretTextField; - private JButton saveButton; - - private Log logger = LogFactory.get(); - private static TWxCpAppMapper wxCpAppMapper = MybatisUtil.getSqlSession().getMapper(TWxCpAppMapper.class); - - public WxCpAppDialog() { - super(App.mainFrame, "企业号/企业微信 应用管理"); - setContentPane(contentPane); - setModal(true); - - ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.5, 0.5); - - // 保存按钮事件 - saveButton.addActionListener(e -> { - String appName = appNameTextField.getText(); - if (StringUtils.isBlank(appName)) { - JOptionPane.showMessageDialog(this, "请填写账号名称!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - String agentId = agentIdTextField.getText(); - if (StringUtils.isBlank(agentId)) { - JOptionPane.showMessageDialog(this, "请填写AgentId!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - boolean update = false; - List tWxCpAppList = wxCpAppMapper.selectByAppName(appName); - if (tWxCpAppList.size() > 0) { - update = true; - } - - TWxCpApp tWxCpApp = new TWxCpApp(); - String now = SqliteUtil.nowDateForSqlite(); - tWxCpApp.setAppName(appName); - tWxCpApp.setCorpid(SettingForm.getInstance().getWxCpCorpIdTextField().getText()); - tWxCpApp.setAgentId(agentIdTextField.getText()); - tWxCpApp.setSecret(secretTextField.getText()); - tWxCpApp.setModifiedTime(now); - - if (update) { - tWxCpApp.setId(tWxCpAppList.get(0).getId()); - wxCpAppMapper.updateByPrimaryKeySelective(tWxCpApp); - } else { - tWxCpApp.setCreateTime(now); - wxCpAppMapper.insert(tWxCpApp); - } - renderTable(); - JOptionPane.showMessageDialog(this, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - }); - - // 删除按钮事件 - buttonDelete.addActionListener(e -> ThreadUtil.execute(() -> { - try { - int[] selectedRows = appsTable.getSelectedRows(); - if (selectedRows.length == 0) { - JOptionPane.showMessageDialog(this, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } else { - int isDelete = JOptionPane.showConfirmDialog(this, "确认删除?", "确认", - JOptionPane.YES_NO_OPTION); - if (isDelete == JOptionPane.YES_OPTION) { - DefaultTableModel tableModel = (DefaultTableModel) appsTable.getModel(); - for (int i = selectedRows.length; i > 0; i--) { - int selectedRow = appsTable.getSelectedRow(); - Integer selectedId = (Integer) tableModel.getValueAt(selectedRow, 0); - wxCpAppMapper.deleteByPrimaryKey(selectedId); - tableModel.removeRow(selectedRow); - } - SettingForm.initSwitchMultiAccount(); - } - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(this, "删除失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - })); - - appsTable.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - clearFields(); - - int selectedRow = appsTable.getSelectedRow(); - String selectedId = appsTable.getValueAt(selectedRow, 0).toString(); - TWxCpApp tWxCpApp = wxCpAppMapper.selectByPrimaryKey(Integer.valueOf(selectedId)); - appNameTextField.setText(tWxCpApp.getAppName()); - agentIdTextField.setText(tWxCpApp.getAgentId()); - secretTextField.setText(tWxCpApp.getSecret()); - super.mousePressed(e); - } - }); - - buttonCancel.addActionListener(e -> onCancel()); - - // call onCancel() when cross is clicked - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - onCancel(); - } - }); - - // call onCancel() on ESCAPE - contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - } - - private void onCancel() { - // add your code here if necessary - dispose(); - } - - /** - * 应用列表表格 - */ - public void renderTable() { - String[] headerNames = {"id", "应用名称", "AgentId", "Secret"}; - DefaultTableModel model = new DefaultTableModel(null, headerNames); - appsTable.setModel(model); - - DefaultTableCellRenderer hr = (DefaultTableCellRenderer) appsTable.getTableHeader() - .getDefaultRenderer(); - // 表头列名居左 - hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); - - List wxCpAppList = wxCpAppMapper.selectAll(); - Object[] data; - for (TWxCpApp tWxCpApp : wxCpAppList) { - data = new Object[4]; - data[0] = tWxCpApp.getId(); - data[1] = tWxCpApp.getAppName(); - data[2] = tWxCpApp.getAgentId(); - data[3] = tWxCpApp.getSecret(); - model.addRow(data); - } - - // 隐藏id列 - JTableUtil.hideColumn(appsTable, 0); - } - - /** - * 清空表单 - */ - public void clearFields() { - appNameTextField.setText(""); - agentIdTextField.setText(""); - secretTextField.setText(""); - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - contentPane.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false)); - panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - buttonDelete = new JButton(); - buttonDelete.setText("删除"); - panel2.add(buttonDelete, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - buttonCancel = new JButton(); - buttonCancel.setText("好了"); - panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(4, 3, new Insets(5, 5, 0, 5), -1, -1)); - contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "添加应用", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); - final JLabel label1 = new JLabel(); - label1.setText("应用名称"); - panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - appNameTextField = new JTextField(); - panel3.add(appNameTextField, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("AgentId"); - panel3.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - agentIdTextField = new JTextField(); - panel3.add(agentIdTextField, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("Secret"); - panel3.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - secretTextField = new JTextField(); - panel3.add(secretTextField, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - saveButton = new JButton(); - saveButton.setText("保存"); - panel3.add(saveButton, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer2 = new Spacer(); - panel3.add(spacer2, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JScrollPane scrollPane1 = new JScrollPane(); - contentPane.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - appsTable = new JTable(); - appsTable.setRowHeight(36); - scrollPane1.setViewportView(appsTable); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return contentPane; - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByDing.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByDing.form new file mode 100644 index 000000000..17cf2afc5 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByDing.form @@ -0,0 +1,85 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByDing.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByDing.java new file mode 100644 index 000000000..e5620b053 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByDing.java @@ -0,0 +1,590 @@ +package com.fangxuele.tool.push.ui.dialog.importway; + +import cn.hutool.core.lang.UUID; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.dingtalk.api.DefaultDingTalkClient; +import com.dingtalk.api.DingTalkClient; +import com.dingtalk.api.request.OapiDepartmentListRequest; +import com.dingtalk.api.request.OapiUserSimplelistRequest; +import com.dingtalk.api.response.OapiDepartmentListResponse; +import com.dingtalk.api.response.OapiUserSimplelistResponse; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleImportConfigMapper; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.logic.msgsender.DingMsgSender; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.dialog.importway.config.DingImportConfig; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.google.common.collect.Maps; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import org.apache.commons.lang3.exception.ExceptionUtils; + +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +public class ImportByDing extends JDialog { + private JPanel contentPane; + private JComboBox dingDeptsComboBox; + private JButton dingImportAllButton; + private JButton dingDeptsRefreshButton; + private JButton dingDeptsImportButton; + + private static final Log logger = LogFactory.get(); + + private Integer peopleId; + + private TPeople tPeople; + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + /** + * 企业号部门名称->部门ID + */ + private static Map wxCpDeptNameToIdMap = Maps.newHashMap(); + + /** + * 企业号部门ID>部门名称 + */ + private static Map wxCpIdToDeptNameMap = Maps.newHashMap(); + + public ImportByDing(Integer peopleId) { + super(App.mainFrame, "通过钉钉通讯录导入"); + setContentPane(contentPane); + setModal(true); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.3, 0.2); + getRootPane().setDefaultButton(dingImportAllButton); + + this.peopleId = peopleId; + tPeople = peopleMapper.selectByPrimaryKey(peopleId); + + dingDeptsImportButton.setIcon(new FlatSVGIcon("icon/import.svg")); + dingImportAllButton.setIcon(new FlatSVGIcon("icon/import.svg")); + dingDeptsRefreshButton.setIcon(new FlatSVGIcon("icon/refresh.svg")); + + // 钉钉-按部门导入-刷新 + dingDeptsRefreshButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + dingDeptsComboBox.removeAllItems(); + + try { + // 获取部门列表 + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/list"); + OapiDepartmentListRequest request = new OapiDepartmentListRequest(); + request.setHttpMethod("GET"); + OapiDepartmentListResponse response = client.execute(request, DingMsgSender.getAccessTokenTimedCache(tPeople.getAccountId()).get("accessToken")); + if (response.getErrcode() != 0) { + JOptionPane.showMessageDialog(App.mainFrame, "刷新失败!\n\n" + response.getErrmsg(), "失败", + JOptionPane.ERROR_MESSAGE); + return; + } + List departmentList = response.getDepartment(); + for (OapiDepartmentListResponse.Department department : departmentList) { + dingDeptsComboBox.addItem(department.getName()); + wxCpDeptNameToIdMap.put(department.getName(), department.getId()); + wxCpIdToDeptNameMap.put(department.getId(), department.getName()); + } + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "刷新失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ExceptionUtils.getStackTrace(ex)); + } + }); + }); + + // 钉钉-按部门导入-导入 + dingDeptsImportButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + JLabel memberCountLabel = peopleEditForm.getMemberTabCountLabel(); + + if (dingDeptsComboBox.getSelectedItem() == null) { + return; + } + try { + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + + String dataVersion = UUID.fastUUID().toString(true); + + // 获取部门id + Long deptId = wxCpDeptNameToIdMap.get(dingDeptsComboBox.getSelectedItem()); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_DING_CODE)); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setModifiedTime(now); + + DingImportConfig dingImportConfig = new DingImportConfig(); + dingImportConfig.setUserType(2); + dingImportConfig.setDeptId(deptId); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(dingImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 获取用户 + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/simplelist"); + OapiUserSimplelistRequest request = new OapiUserSimplelistRequest(); + request.setDepartmentId(deptId); + request.setOffset(0L); + request.setSize(100L); + request.setHttpMethod("GET"); + + long offset = 0; + OapiUserSimplelistResponse response = new OapiUserSimplelistResponse(); + while (response.getErrcode() == null || response.getUserlist().size() > 0) { + response = client.execute(request, DingMsgSender.getAccessTokenTimedCache(tPeople.getAccountId()).get("accessToken")); + if (response.getErrcode() != 0) { + if (response.getErrcode() == 60011) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg() + "\n\n进入开发者后台,在小程序或者微应用详情的「接口权限」模块,点击申请对应的通讯录接口读写权限", "失败", + JOptionPane.ERROR_MESSAGE); + } else { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg(), "失败", JOptionPane.ERROR_MESSAGE); + } + + logger.error(response.getErrmsg()); + return; + } + List userlist = response.getUserlist(); + for (OapiUserSimplelistResponse.Userlist dingUser : userlist) { + String[] dataArray = new String[]{dingUser.getUserid(), dingUser.getName()}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + memberCountLabel.setText(String.valueOf(importedCount)); + } + offset += 100; + request.setOffset(offset); + } + + PeopleEditForm.initDataTable(peopleId); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ex.toString()); + } finally { + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + } + + }); + }); + + // 钉钉-导入全部 + dingImportAllButton.addActionListener(e -> onOK()); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void onOK() { + ThreadUtil.execute(() -> { + importDingAll(); + }); + dispose(); + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + + /** + * 导入钉钉通讯录全员 + */ + public void importDingAll() { + PeopleEditForm instance = PeopleEditForm.getInstance(); + JProgressBar progressBar = instance.getMemberTabImportProgressBar(); + JLabel memberCountLabel = instance.getMemberTabCountLabel(); + + try { + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + int importedCount = 0; + + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_DING_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + DingImportConfig dingImportConfig = new DingImportConfig(); + dingImportConfig.setUserType(1); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(dingImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 最小部门id为1 + // 获取用户 + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/simplelist"); + OapiUserSimplelistRequest request = new OapiUserSimplelistRequest(); + request.setDepartmentId(1L); + request.setOffset(0L); + request.setSize(100L); + request.setHttpMethod("GET"); + + long offset = 0; + OapiUserSimplelistResponse response = new OapiUserSimplelistResponse(); + while (response.getErrcode() == null || response.getUserlist().size() > 0) { + response = client.execute(request, DingMsgSender.getAccessTokenTimedCache(tPeople.getAccountId()).get("accessToken")); + if (response.getErrcode() != 0) { + if (response.getErrcode() == 60011) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg() + "\n\n进入开发者后台,在小程序或者微应用详情的「接口权限」模块,点击申请对应的通讯录接口读写权限", "失败", + JOptionPane.ERROR_MESSAGE); + } else { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg(), "失败", JOptionPane.ERROR_MESSAGE); + } + + logger.error(response.getErrmsg()); + return; + } + List userlist = response.getUserlist(); + for (OapiUserSimplelistResponse.Userlist dingUser : userlist) { + String[] dataArray = new String[]{dingUser.getUserid(), dingUser.getName()}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + memberCountLabel.setText(String.valueOf(importedCount)); + } + offset += 100; + request.setOffset(offset); + } + + PeopleEditForm.initDataTable(peopleId); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ExceptionUtils.getStackTrace(ex)); + } finally { + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + dingImportAllButton = new JButton(); + Font dingImportAllButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, dingImportAllButton.getFont()); + if (dingImportAllButtonFont != null) dingImportAllButton.setFont(dingImportAllButtonFont); + dingImportAllButton.setText("导入通讯录中所有用户"); + panel2.add(dingImportAllButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + dingDeptsComboBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + dingDeptsComboBox.setModel(defaultComboBoxModel1); + panel3.add(dingDeptsComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + dingDeptsRefreshButton = new JButton(); + Font dingDeptsRefreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, dingDeptsRefreshButton.getFont()); + if (dingDeptsRefreshButtonFont != null) dingDeptsRefreshButton.setFont(dingDeptsRefreshButtonFont); + dingDeptsRefreshButton.setText("刷新"); + panel3.add(dingDeptsRefreshButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("按部门导入"); + panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + dingDeptsImportButton = new JButton(); + dingDeptsImportButton.setText("导入"); + panel3.add(dingDeptsImportButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + + public void reImport() { + TPeopleImportConfig peopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + String lastWayConfig = peopleImportConfig.getLastWayConfig(); + DingImportConfig dingImportConfigBefore = JSONUtil.toBean(lastWayConfig, DingImportConfig.class); + if (dingImportConfigBefore == null) { + return; + } + + try { + if (dingImportConfigBefore.getUserType() == 1) { + int importedCount = 0; + + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_DING_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + DingImportConfig dingImportConfig = new DingImportConfig(); + dingImportConfig.setUserType(1); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(dingImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 最小部门id为1 + // 获取用户 + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/simplelist"); + OapiUserSimplelistRequest request = new OapiUserSimplelistRequest(); + request.setDepartmentId(1L); + request.setOffset(0L); + request.setSize(100L); + request.setHttpMethod("GET"); + + long offset = 0; + OapiUserSimplelistResponse response = new OapiUserSimplelistResponse(); + + peopleDataMapper.deleteByPeopleId(peopleId); + + while (response.getErrcode() == null || response.getUserlist().size() > 0) { + response = client.execute(request, DingMsgSender.getAccessTokenTimedCache(tPeople.getAccountId()).get("accessToken")); + if (response.getErrcode() != 0) { + if (response.getErrcode() == 60011) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg() + "\n\n进入开发者后台,在小程序或者微应用详情的「接口权限」模块,点击申请对应的通讯录接口读写权限", "失败", + JOptionPane.ERROR_MESSAGE); + } else { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg(), "失败", JOptionPane.ERROR_MESSAGE); + } + + logger.error(response.getErrmsg()); + return; + } + List userlist = response.getUserlist(); + for (OapiUserSimplelistResponse.Userlist dingUser : userlist) { + String[] dataArray = new String[]{dingUser.getUserid(), dingUser.getName()}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + } + offset += 100; + request.setOffset(offset); + } + } else if (dingImportConfigBefore.getUserType() == 2) { + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + + String dataVersion = UUID.fastUUID().toString(true); + + // 获取部门id + Long deptId = dingImportConfigBefore.getDeptId(); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_DING_CODE)); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setModifiedTime(now); + + DingImportConfig dingImportConfig = new DingImportConfig(); + dingImportConfig.setUserType(2); + dingImportConfig.setDeptId(deptId); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(dingImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 获取用户 + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/simplelist"); + OapiUserSimplelistRequest request = new OapiUserSimplelistRequest(); + request.setDepartmentId(deptId); + request.setOffset(0L); + request.setSize(100L); + request.setHttpMethod("GET"); + + long offset = 0; + OapiUserSimplelistResponse response = new OapiUserSimplelistResponse(); + + peopleDataMapper.deleteByPeopleId(peopleId); + + while (response.getErrcode() == null || response.getUserlist().size() > 0) { + response = client.execute(request, DingMsgSender.getAccessTokenTimedCache(tPeople.getAccountId()).get("accessToken")); + if (response.getErrcode() != 0) { + if (response.getErrcode() == 60011) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg() + "\n\n进入开发者后台,在小程序或者微应用详情的「接口权限」模块,点击申请对应的通讯录接口读写权限", "失败", + JOptionPane.ERROR_MESSAGE); + } else { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + response.getErrmsg(), "失败", JOptionPane.ERROR_MESSAGE); + } + + logger.error(response.getErrmsg()); + return; + } + List userlist = response.getUserlist(); + for (OapiUserSimplelistResponse.Userlist dingUser : userlist) { + String[] dataArray = new String[]{dingUser.getUserid(), dingUser.getName()}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + } + offset += 100; + request.setOffset(offset); + } + } + } catch (Exception e) { + logger.error(ExceptionUtils.getStackTrace(e)); + } + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByFile.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByFile.form new file mode 100644 index 000000000..0501483fd --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByFile.form @@ -0,0 +1,88 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByFile.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByFile.java new file mode 100644 index 000000000..bd067d246 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByFile.java @@ -0,0 +1,371 @@ +package com.fangxuele.tool.push.ui.dialog.importway; + +import cn.hutool.core.io.file.FileReader; +import cn.hutool.core.lang.UUID; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import cn.hutool.poi.excel.ExcelReader; +import cn.hutool.poi.excel.ExcelUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleImportConfigMapper; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.FileCharSetUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import com.opencsv.CSVReader; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.util.List; + +public class ImportByFile extends JDialog { + private JPanel contentPane; + private JButton buttonCancel; + private JLabel importFromFileLabel; + private JTextField memberFilePathField; + private JButton memberImportExploreButton; + private JButton importFromFileButton; + + private static final Log logger = LogFactory.get(); + + public static final String TXT_FILE_DATA_SEPERATOR_REGEX = "\\|"; + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + private Integer peopleId; + + public ImportByFile(Integer peopleId) { + super(App.mainFrame, "通过文件导入人群"); + setContentPane(contentPane); + setModal(true); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.2); + getRootPane().setDefaultButton(importFromFileButton); + + this.peopleId = peopleId; + + importFromFileButton.setIcon(new FlatSVGIcon("icon/import.svg")); + + // 获取上一次导入的配置 + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + if (tPeopleImportConfig != null) { + memberFilePathField.setText(tPeopleImportConfig.getLastFilePath()); + } + + // 文件浏览按钮 + memberImportExploreButton.addActionListener(e -> { + File beforeFile = new File(memberFilePathField.getText()); + JFileChooser fileChooser; + + if (beforeFile.exists()) { + fileChooser = new JFileChooser(beforeFile); + } else { + fileChooser = new JFileChooser(); + } + + FileFilter filter = new FileNameExtensionFilter("*.txt,*.csv,*.xlsx,*.xls", "txt", "csv", "TXT", "CSV", "xlsx", "xls"); + fileChooser.setFileFilter(filter); + + int approve = fileChooser.showOpenDialog(App.mainFrame); + if (approve == JFileChooser.APPROVE_OPTION) { + memberFilePathField.setText(fileChooser.getSelectedFile().getAbsolutePath()); + } + + }); + + importFromFileButton.addActionListener(e -> onOK()); + + buttonCancel.addActionListener(e -> onCancel()); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void onOK() { + String filePath = memberFilePathField.getText(); + if (StringUtils.isBlank(filePath)) { + JOptionPane.showMessageDialog(PeopleEditForm.getInstance().getMainPanel(), "请填写或点击浏览按钮选择要导入的文件的路径!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + ThreadUtil.execute(() -> importFromFile(filePath, false, false)); + dispose(); + } + + private void onCancel() { + dispose(); + } + + /** + * 通过文件导入 + */ + public void importFromFile(String filePath, Boolean clear, Boolean silence) { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + if (!silence) { + peopleEditForm.getImportButton().setEnabled(false); + } + JPanel memberPanel = peopleEditForm.getMainPanel(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + JLabel memberCountLabel = peopleEditForm.getMemberTabCountLabel(); + + File file = new File(filePath); + if (!file.exists()) { + if (!silence) { + JOptionPane.showMessageDialog(memberPanel, filePath + "\n该文件不存在!", "文件不存在", + JOptionPane.ERROR_MESSAGE); + peopleEditForm.getImportButton().setEnabled(true); + } else { + logger.warn("该文件不存在"); + } + return; + } + CSVReader reader = null; + FileReader fileReader; + + int currentImported = 0; + Long totalCount = peopleDataMapper.countByPeopleId(peopleId); + if (totalCount != null) { + currentImported = Math.toIntExact(totalCount); + } + + try { + if (!silence) { + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + } + String fileNameLowerCase = file.getName().toLowerCase(); + TPeopleData tPeopleData; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_FILE_CODE)); + tPeopleImportConfig.setLastFilePath(filePath); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + if (fileNameLowerCase.endsWith(".csv")) { + // 可以解决中文乱码问题 + DataInputStream in = new DataInputStream(new FileInputStream(file)); + reader = new CSVReader(new InputStreamReader(in, FileCharSetUtil.getCharSet(file))); + + if (clear) { + peopleDataMapper.deleteByPeopleId(peopleId); + } + + String[] nextLine; + while (peopleId != null && (nextLine = reader.readNext()) != null) { + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + currentImported++; + if (!silence) { + memberCountLabel.setText(String.valueOf(currentImported)); + } + } + } else if (fileNameLowerCase.endsWith(".xlsx") || fileNameLowerCase.endsWith(".xls")) { + ExcelReader excelReader = ExcelUtil.getReader(file); + List> readAll = excelReader.read(1, Integer.MAX_VALUE); + + if (clear) { + peopleDataMapper.deleteByPeopleId(peopleId); + } + + for (List objects : readAll) { + if (objects != null && objects.size() > 0) { + String[] nextLine = new String[objects.size()]; + for (int i = 0; i < objects.size(); i++) { + nextLine[i] = objects.get(i).toString(); + } + + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + currentImported++; + if (!silence) { + memberCountLabel.setText(String.valueOf(currentImported)); + } + } + } + } else if (fileNameLowerCase.endsWith(".txt")) { + fileReader = new FileReader(file, FileCharSetUtil.getCharSetName(file)); + BufferedReader br = fileReader.getReader(); + + if (clear) { + peopleDataMapper.deleteByPeopleId(peopleId); + } + + String line; + while (peopleId != null && (line = br.readLine()) != null) { + String[] nextLine = line.split(TXT_FILE_DATA_SEPERATOR_REGEX); + + tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(nextLine[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(nextLine)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + currentImported++; + if (!silence) { + memberCountLabel.setText(String.valueOf(currentImported)); + } + } + } else { + if (!silence) { + JOptionPane.showMessageDialog(memberPanel, "不支持该格式的文件!", "文件格式不支持", + JOptionPane.ERROR_MESSAGE); + peopleEditForm.getImportButton().setEnabled(true); + } else { + logger.warn("不支持该格式的文件"); + } + return; + } + + if (!silence) { + PeopleEditForm.initDataTable(peopleId); + + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + } + } catch (Exception e1) { + if (!silence) { + JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + } + logger.error(e1); + e1.printStackTrace(); + } finally { + if (!silence) { + progressBar.setMaximum(100); + progressBar.setValue(100); + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + peopleEditForm.getImportButton().setEnabled(true); + } + if (reader != null) { + try { + reader.close(); + } catch (IOException e1) { + logger.error(e1); + e1.printStackTrace(); + } + } + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + buttonCancel = new JButton(); + buttonCancel.setText("取消"); + panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + importFromFileButton = new JButton(); + importFromFileButton.setText("导入"); + panel2.add(importFromFileButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + importFromFileLabel = new JLabel(); + importFromFileLabel.setHorizontalAlignment(11); + importFromFileLabel.setHorizontalTextPosition(4); + importFromFileLabel.setText("文件路径(*.txt,*.csv,*.xlsx)"); + panel3.add(importFromFileLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberFilePathField = new JTextField(); + panel3.add(memberFilePathField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberImportExploreButton = new JButton(); + memberImportExploreButton.setText("..."); + panel3.add(memberImportExploreButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + + public void reImport() { + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + importFromFile(tPeopleImportConfig.getLastFilePath(), true, true); + dispose(); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByNum.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByNum.form new file mode 100644 index 000000000..d6f09bc46 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByNum.form @@ -0,0 +1,72 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByNum.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByNum.java new file mode 100644 index 000000000..e4f4070d7 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByNum.java @@ -0,0 +1,223 @@ +package com.fangxuele.tool.push.ui.dialog.importway; + +import cn.hutool.core.lang.UUID; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleImportConfigMapper; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.ui.listener.PeopleManageListener; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class ImportByNum extends JDialog { + private JPanel contentPane; + private JLabel 数量Label; + private JTextField importNumTextField; + private JButton importFromNumButton; + + private static final Log logger = LogFactory.get(); + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + private Integer peopleId; + + public ImportByNum(Integer peopleId) { + super(App.mainFrame, "没有变量,直接按数量发送"); + setContentPane(contentPane); + setModal(true); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.2, 0.2); + getRootPane().setDefaultButton(importFromNumButton); + + this.peopleId = peopleId; + + importFromNumButton.addActionListener(e -> onOK()); + + importFromNumButton.setIcon(new FlatSVGIcon("icon/import.svg")); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void onOK() { + if (StringUtils.isBlank(importNumTextField.getText())) { + JOptionPane.showMessageDialog(App.mainFrame, "请填写数量!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer num = Integer.valueOf(importNumTextField.getText()); + + if (num <= 0) { + JOptionPane.showMessageDialog(App.mainFrame, "数量必须大于0!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + importFromNum(num, false, false); + } + + private void importFromNum(Integer num, Boolean clear, Boolean silence) { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + JLabel memberCountLabel = peopleEditForm.getMemberTabCountLabel(); + + int currentImported = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(PeopleManageListener.selectedPeopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(PeopleManageListener.selectedPeopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_NUM_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + try { + int importNum = num; + if (!silence) { + progressBar.setVisible(true); + progressBar.setMaximum(importNum); + } + + + for (int i = 0; i < importNum; i++) { + String[] array = new String[1]; + array[0] = String.valueOf(i); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(PeopleManageListener.selectedPeopleId); + tPeopleData.setPin(array[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(array)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + currentImported++; + if (!silence) { + memberCountLabel.setText(String.valueOf(currentImported)); + } + } + if (!silence) { + PeopleEditForm.initDataTable(PeopleManageListener.selectedPeopleId); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + dispose(); + } + } catch (Exception e1) { + if (!silence) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + } + logger.error(e1); + e1.printStackTrace(); + } finally { + if (!silence) { + progressBar.setMaximum(100); + progressBar.setValue(100); + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + } + } + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + importFromNumButton = new JButton(); + importFromNumButton.setText("导入"); + panel2.add(importFromNumButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + 数量Label = new JLabel(); + 数量Label.setHorizontalAlignment(11); + 数量Label.setHorizontalTextPosition(4); + 数量Label.setText("数量"); + panel3.add(数量Label, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + importNumTextField = new JTextField(); + panel3.add(importNumTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + + public void reImport() { + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + importFromNum(0, true, true); + dispose(); + + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportBySQL.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportBySQL.form new file mode 100644 index 000000000..095d8d8a2 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportBySQL.form @@ -0,0 +1,72 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportBySQL.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportBySQL.java new file mode 100644 index 000000000..30bd97718 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportBySQL.java @@ -0,0 +1,272 @@ +package com.fangxuele.tool.push.ui.dialog.importway; + +import cn.hutool.core.lang.UUID; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.db.DbUtil; +import cn.hutool.db.Entity; +import cn.hutool.db.handler.EntityListHandler; +import cn.hutool.db.sql.SqlExecutor; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleImportConfigMapper; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.HikariUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.sql.Connection; +import java.util.List; +import java.util.Set; + +public class ImportBySQL extends JDialog { + private JPanel contentPane; + private JButton buttonCancel; + private JButton importFromSqlButton; + private JTextArea importFromSqlTextArea; + + private static final Log logger = LogFactory.get(); + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + private Integer peopleId; + + public ImportBySQL(Integer peopleId) { + super(App.mainFrame, "通过SQL导入人群"); + setContentPane(contentPane); + setModal(true); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.4); + getRootPane().setDefaultButton(importFromSqlButton); + + this.peopleId = peopleId; + + importFromSqlButton.setIcon(new FlatSVGIcon("icon/import.svg")); + + // 获取上一次导入的配置 + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + if (tPeopleImportConfig != null) { + importFromSqlTextArea.setText(tPeopleImportConfig.getLastSql()); + } + + importFromSqlButton.addActionListener(e -> onOK()); + + buttonCancel.addActionListener(e -> onCancel()); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void onOK() { + // add your code here + String sql = importFromSqlTextArea.getText(); + + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + + if (StringUtils.isBlank(App.config.getMysqlUrl()) || StringUtils.isBlank(App.config.getMysqlUser())) { + JOptionPane.showMessageDialog(App.mainFrame, "请先在设置中填写并保存MySQL的配置信息!", "提示", + JOptionPane.INFORMATION_MESSAGE); + peopleEditForm.getImportButton().setEnabled(true); + return; + } + if (StringUtils.isBlank(sql)) { + JOptionPane.showMessageDialog(App.mainFrame, "请先填写要执行导入的SQL!", "提示", + JOptionPane.INFORMATION_MESSAGE); + peopleEditForm.getImportButton().setEnabled(true); + return; + } + + ThreadUtil.execute(() -> importFromSql(sql, false, false)); + + dispose(); + } + + private void onCancel() { + dispose(); + } + + /** + * 通过SQL导入 + */ + public void importFromSql(String querySql, Boolean clear, Boolean silence) { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + if (!silence) { + peopleEditForm.getImportButton().setEnabled(false); + } + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + JLabel memberCountLabel = peopleEditForm.getMemberTabCountLabel(); + + if (StringUtils.isNotEmpty(querySql)) { + Connection conn = null; + try { + if (!silence) { + peopleEditForm.getImportButton().setEnabled(false); + peopleEditForm.getImportButton().updateUI(); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + } + + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_SQL_CODE)); + tPeopleImportConfig.setLastSql(querySql); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 表查询 + int currentImported = 0; + + conn = HikariUtil.getConnection(); + List entityList = SqlExecutor.query(conn, querySql, new EntityListHandler()); + + if (clear) { + peopleDataMapper.deleteByPeopleId(peopleId); + } + + for (Entity entity : entityList) { + Set fieldNames = entity.getFieldNames(); + String[] msgData = new String[fieldNames.size()]; + int i = 0; + for (String fieldName : fieldNames) { + msgData[i] = entity.getStr(fieldName); + i++; + } + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(msgData[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(msgData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + currentImported++; + if (!silence) { + memberCountLabel.setText(String.valueOf(currentImported)); + } + } + + if (!silence) { + PeopleEditForm.initDataTable(peopleId); + + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + + App.config.setMemberSql(querySql); + App.config.save(); + } + } catch (Exception e1) { + if (!silence) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + } + logger.error(e1); + } finally { + DbUtil.close(conn); + if (!silence) { + peopleEditForm.getImportButton().setEnabled(true); + peopleEditForm.getImportButton().updateUI(); + progressBar.setMaximum(100); + progressBar.setValue(100); + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + peopleEditForm.getImportButton().setEnabled(true); + } + } + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + buttonCancel = new JButton(); + buttonCancel.setText("取消"); + panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + importFromSqlButton = new JButton(); + importFromSqlButton.setText("导入"); + panel2.add(importFromSqlButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + importFromSqlTextArea = new JTextArea(); + panel3.add(importFromSqlTextArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(40, 50), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + + public void reImport() { + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + importFromSql(tPeopleImportConfig.getLastSql(), true, true); + dispose(); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxCp.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxCp.form new file mode 100644 index 000000000..c30aaa0be --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxCp.form @@ -0,0 +1,118 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxCp.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxCp.java new file mode 100644 index 000000000..8e01eb376 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxCp.java @@ -0,0 +1,767 @@ +package com.fangxuele.tool.push.ui.dialog.importway; + +import cn.hutool.core.lang.UUID; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleImportConfigMapper; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.logic.msgsender.WxCpMsgSender; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.dialog.importway.config.WxCpImportConfig; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.google.common.collect.Maps; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.cp.bean.WxCpDepart; +import me.chanjar.weixin.cp.bean.WxCpTag; +import me.chanjar.weixin.cp.bean.WxCpUser; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.exception.ExceptionUtils; + +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +@Slf4j +public class ImportByWxCp extends JDialog { + private JPanel contentPane; + private JComboBox wxCpTagsComboBox; + private JComboBox wxCpDeptsComboBox; + private JButton wxCpImportAllButton; + private JButton wxCpTagsRefreshButton; + private JButton wxCpDeptsRefreshButton; + private JButton wxCpTagsImportButton; + private JButton wxCpDeptsImportButton; + + private static final Log logger = LogFactory.get(); + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + private Integer peopleId; + + private TPeople tPeople; + + /** + * 企业号标签名称->标签ID + */ + private static Map wxCpTagNameToIdMap = Maps.newHashMap(); + + /** + * 企业号标签ID>标签名称 + */ + private static Map wxCpIdToTagNameMap = Maps.newHashMap(); + + /** + * 企业号部门名称->部门ID + */ + private static Map wxCpDeptNameToIdMap = Maps.newHashMap(); + + /** + * 企业号部门ID>部门名称 + */ + private static Map wxCpIdToDeptNameMap = Maps.newHashMap(); + + public ImportByWxCp(Integer peopleId) { + super(App.mainFrame, "通过微信企业通讯录导入"); + setContentPane(contentPane); + setModal(true); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.3, 0.2); + getRootPane().setDefaultButton(wxCpImportAllButton); + + this.peopleId = peopleId; + tPeople = peopleMapper.selectByPrimaryKey(peopleId); + + wxCpDeptsImportButton.setIcon(new FlatSVGIcon("icon/import.svg")); + wxCpImportAllButton.setIcon(new FlatSVGIcon("icon/import.svg")); + wxCpTagsImportButton.setIcon(new FlatSVGIcon("icon/import.svg")); + wxCpDeptsRefreshButton.setIcon(new FlatSVGIcon("icon/refresh.svg")); + wxCpTagsRefreshButton.setIcon(new FlatSVGIcon("icon/refresh.svg")); + + // 企业号-按标签导入-刷新 + wxCpTagsRefreshButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + wxCpTagsComboBox.removeAllItems(); + + try { + // 获取标签列表 + List wxCpTagList = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getTagService().listAll(); + for (WxCpTag wxCpTag : wxCpTagList) { + wxCpTagsComboBox.addItem(wxCpTag.getName()); + wxCpTagNameToIdMap.put(wxCpTag.getName(), wxCpTag.getId()); + wxCpIdToTagNameMap.put(wxCpTag.getId(), wxCpTag.getName()); + } + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "刷新失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ex.toString()); + } + }); + }); + + // 企业号-按标签导入-导入 + wxCpTagsImportButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + JLabel memberCountLabel = peopleEditForm.getMemberTabCountLabel(); + + if (wxCpTagsComboBox.getSelectedItem() == null) { + return; + } + try { + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 获取标签id + String tagId = wxCpTagNameToIdMap.get(wxCpTagsComboBox.getSelectedItem()); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_CP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxCpImportConfig wxCpImportConfig = new WxCpImportConfig(); + wxCpImportConfig.setUserType(2); + wxCpImportConfig.setTagId(tagId); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxCpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 获取用户 + List wxCpUsers = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getTagService().listUsersByTagId(tagId); + for (WxCpUser wxCpUser : wxCpUsers) { + Long[] depIds = wxCpUser.getDepartIds(); + List deptNameList = Lists.newArrayList(); + if (depIds != null) { + for (Long depId : depIds) { + deptNameList.add(wxCpIdToDeptNameMap.get(depId)); + } + } + String[] dataArray = new String[]{wxCpUser.getUserId(), wxCpUser.getName(), String.join("/", deptNameList)}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + memberCountLabel.setText(String.valueOf(importedCount)); + } + PeopleEditForm.initDataTable(peopleId); + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ex.toString()); + } finally { + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + } + + }); + }); + + // 企业号-按部门导入-刷新 + wxCpDeptsRefreshButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + wxCpDeptsComboBox.removeAllItems(); + + try { + // 获取部门列表 + List wxCpDepartList = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getDepartmentService().list(null); + for (WxCpDepart wxCpDepart : wxCpDepartList) { + wxCpDeptsComboBox.addItem(wxCpDepart.getName()); + wxCpDeptNameToIdMap.put(wxCpDepart.getName(), wxCpDepart.getId()); + wxCpIdToDeptNameMap.put(wxCpDepart.getId(), wxCpDepart.getName()); + } + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "刷新失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ex.toString()); + } + }); + }); + + // 企业号-按部门导入-导入 + wxCpDeptsImportButton.addActionListener(e -> { + ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + JLabel memberCountLabel = peopleEditForm.getMemberTabCountLabel(); + + if (wxCpDeptsComboBox.getSelectedItem() == null) { + return; + } + try { + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 获取部门id + Long deptId = wxCpDeptNameToIdMap.get(wxCpDeptsComboBox.getSelectedItem()); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_CP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxCpImportConfig wxCpImportConfig = new WxCpImportConfig(); + wxCpImportConfig.setUserType(3); + wxCpImportConfig.setDepId(deptId); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxCpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + + // 获取用户 + List wxCpUsers = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getUserService().listByDepartment(deptId, true, 0); + for (WxCpUser wxCpUser : wxCpUsers) { + String statusStr = ""; + if (wxCpUser.getStatus() == 1) { + statusStr = "已关注"; + } else if (wxCpUser.getStatus() == 2) { + statusStr = "已冻结"; + } else if (wxCpUser.getStatus() == 4) { + statusStr = "未关注"; + } + Long[] depIds = wxCpUser.getDepartIds(); + List deptNameList = Lists.newArrayList(); + if (depIds != null) { + for (Long depId : depIds) { + deptNameList.add(wxCpIdToDeptNameMap.get(depId)); + } + } + String[] dataArray = new String[]{wxCpUser.getUserId(), + wxCpUser.getName(), + wxCpUser.getGender() == null ? "" : wxCpUser.getGender().getGenderName(), + wxCpUser.getEmail(), + String.join("/", deptNameList), wxCpUser.getPosition(), statusStr}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + memberCountLabel.setText(String.valueOf(importedCount)); + } + PeopleEditForm.initDataTable(peopleId); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ex.toString()); + } finally { + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + } + + }); + }); + + // 企业号-导入全部 + wxCpImportAllButton.addActionListener(e -> onOK()); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void onOK() { + ThreadUtil.execute(() -> { + importWxCpAll(); + }); + + dispose(); + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + /** + * 导入企业通讯录全员 + */ + public void importWxCpAll() { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + JLabel memberCountLabel = peopleEditForm.getMemberTabCountLabel(); + + try { + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_CP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxCpImportConfig wxCpImportConfig = new WxCpImportConfig(); + wxCpImportConfig.setUserType(1); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxCpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 获取最小部门id + List wxCpDepartList = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getDepartmentService().list(null); + long minDeptId = Long.MAX_VALUE; + for (WxCpDepart wxCpDepart : wxCpDepartList) { + if (wxCpDepart.getId() < minDeptId) { + minDeptId = wxCpDepart.getId(); + } + } + // 获取用户 + List wxCpUsers = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getUserService().listByDepartment(minDeptId, true, 0); + for (WxCpUser wxCpUser : wxCpUsers) { + String statusStr = ""; + if (wxCpUser.getStatus() == 1) { + statusStr = "已关注"; + } else if (wxCpUser.getStatus() == 2) { + statusStr = "已冻结"; + } else if (wxCpUser.getStatus() == 4) { + statusStr = "未关注"; + } + Long[] depIds = wxCpUser.getDepartIds(); + List deptNameList = Lists.newArrayList(); + if (depIds != null) { + for (Long depId : depIds) { + deptNameList.add(wxCpIdToDeptNameMap.get(depId)); + } + } + String[] dataArray = new String[]{wxCpUser.getUserId(), + wxCpUser.getName(), + wxCpUser.getGender() == null ? "" : wxCpUser.getGender().getGenderName(), + wxCpUser.getEmail(), + String.join("/", deptNameList), + wxCpUser.getPosition(), + statusStr}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + memberCountLabel.setText(String.valueOf(importedCount)); + } + + PeopleEditForm.initDataTable(peopleId); + + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + } catch (Exception ex) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + ex, "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(ExceptionUtils.getStackTrace(ex)); + } finally { + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + wxCpImportAllButton = new JButton(); + Font wxCpImportAllButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, wxCpImportAllButton.getFont()); + if (wxCpImportAllButtonFont != null) wxCpImportAllButton.setFont(wxCpImportAllButtonFont); + wxCpImportAllButton.setText("导入通讯录中所有用户"); + panel2.add(wxCpImportAllButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 4, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + wxCpTagsComboBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + wxCpTagsComboBox.setModel(defaultComboBoxModel1); + panel3.add(wxCpTagsComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + wxCpDeptsComboBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); + wxCpDeptsComboBox.setModel(defaultComboBoxModel2); + panel3.add(wxCpDeptsComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + wxCpTagsRefreshButton = new JButton(); + Font wxCpTagsRefreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, wxCpTagsRefreshButton.getFont()); + if (wxCpTagsRefreshButtonFont != null) wxCpTagsRefreshButton.setFont(wxCpTagsRefreshButtonFont); + wxCpTagsRefreshButton.setText("刷新"); + panel3.add(wxCpTagsRefreshButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + wxCpDeptsRefreshButton = new JButton(); + Font wxCpDeptsRefreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, wxCpDeptsRefreshButton.getFont()); + if (wxCpDeptsRefreshButtonFont != null) wxCpDeptsRefreshButton.setFont(wxCpDeptsRefreshButtonFont); + wxCpDeptsRefreshButton.setText("刷新"); + panel3.add(wxCpDeptsRefreshButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("按标签导入"); + panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("按部门导入"); + panel3.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + wxCpTagsImportButton = new JButton(); + wxCpTagsImportButton.setText("导入"); + panel3.add(wxCpTagsImportButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + wxCpDeptsImportButton = new JButton(); + wxCpDeptsImportButton.setText("导入"); + panel3.add(wxCpDeptsImportButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + + public void reImport() { + TPeopleImportConfig peopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + String lastWayConfig = peopleImportConfig.getLastWayConfig(); + WxCpImportConfig wxCpImportConfigBefore = JSONUtil.toBean(lastWayConfig, WxCpImportConfig.class); + if (wxCpImportConfigBefore == null) { + return; + } + + try { + if (wxCpImportConfigBefore.getUserType() == 1) { + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_CP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxCpImportConfig wxCpImportConfig = new WxCpImportConfig(); + wxCpImportConfig.setUserType(1); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxCpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 获取最小部门id + List wxCpDepartList = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getDepartmentService().list(null); + long minDeptId = Long.MAX_VALUE; + for (WxCpDepart wxCpDepart : wxCpDepartList) { + if (wxCpDepart.getId() < minDeptId) { + minDeptId = wxCpDepart.getId(); + } + } + // 获取用户 + List wxCpUsers = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getUserService().listByDepartment(minDeptId, true, 0); + + peopleDataMapper.deleteByPeopleId(peopleId); + + for (WxCpUser wxCpUser : wxCpUsers) { + String statusStr = ""; + if (wxCpUser.getStatus() == 1) { + statusStr = "已关注"; + } else if (wxCpUser.getStatus() == 2) { + statusStr = "已冻结"; + } else if (wxCpUser.getStatus() == 4) { + statusStr = "未关注"; + } + Long[] depIds = wxCpUser.getDepartIds(); + List deptNameList = Lists.newArrayList(); + if (depIds != null) { + for (Long depId : depIds) { + deptNameList.add(wxCpIdToDeptNameMap.get(depId)); + } + } + String[] dataArray = new String[]{wxCpUser.getUserId(), + wxCpUser.getName(), + wxCpUser.getGender() == null ? "" : wxCpUser.getGender().getGenderName(), + wxCpUser.getEmail(), + String.join("/", deptNameList), + wxCpUser.getPosition(), + statusStr}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + } + } else if (wxCpImportConfigBefore.getUserType() == 2) { + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 获取标签id + String tagId = wxCpImportConfigBefore.getTagId(); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_CP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxCpImportConfig wxCpImportConfig = new WxCpImportConfig(); + wxCpImportConfig.setUserType(2); + wxCpImportConfig.setTagId(tagId); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxCpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + // 获取用户 + List wxCpUsers = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getTagService().listUsersByTagId(tagId); + + peopleDataMapper.deleteByPeopleId(peopleId); + + for (WxCpUser wxCpUser : wxCpUsers) { + Long[] depIds = wxCpUser.getDepartIds(); + List deptNameList = Lists.newArrayList(); + if (depIds != null) { + for (Long depId : depIds) { + deptNameList.add(wxCpIdToDeptNameMap.get(depId)); + } + } + String[] dataArray = new String[]{wxCpUser.getUserId(), wxCpUser.getName(), String.join("/", deptNameList)}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + } + } else if (wxCpImportConfigBefore.getUserType() == 3) { + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 获取部门id + Long deptId = wxCpImportConfigBefore.getDepId(); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_CP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxCpImportConfig wxCpImportConfig = new WxCpImportConfig(); + wxCpImportConfig.setUserType(3); + wxCpImportConfig.setDepId(deptId); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxCpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + + // 获取用户 + List wxCpUsers = WxCpMsgSender.getWxCpService(tPeople.getAccountId()).getUserService().listByDepartment(deptId, true, 0); + + peopleDataMapper.deleteByPeopleId(peopleId); + + for (WxCpUser wxCpUser : wxCpUsers) { + String statusStr = ""; + if (wxCpUser.getStatus() == 1) { + statusStr = "已关注"; + } else if (wxCpUser.getStatus() == 2) { + statusStr = "已冻结"; + } else if (wxCpUser.getStatus() == 4) { + statusStr = "未关注"; + } + Long[] depIds = wxCpUser.getDepartIds(); + List deptNameList = Lists.newArrayList(); + if (depIds != null) { + for (Long depId : depIds) { + deptNameList.add(wxCpIdToDeptNameMap.get(depId)); + } + } + String[] dataArray = new String[]{wxCpUser.getUserId(), + wxCpUser.getName(), + wxCpUser.getGender() == null ? "" : wxCpUser.getGender().getGenderName(), + wxCpUser.getEmail(), + String.join("/", deptNameList), + wxCpUser.getPosition(), + statusStr}; + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(dataArray[0]); + tPeopleData.setVarData(JSONUtil.toJsonStr(dataArray)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + } + } + } catch (Exception e) { + logger.error(ExceptionUtils.getStackTrace(e)); + } + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxMp.form b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxMp.form new file mode 100644 index 000000000..494fccedc --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxMp.form @@ -0,0 +1,150 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxMp.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxMp.java new file mode 100644 index 000000000..cb5a8f81f --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/ImportByWxMp.java @@ -0,0 +1,888 @@ +package com.fangxuele.tool.push.ui.dialog.importway; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.lang.UUID; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleImportConfigMapper; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.dao.TWxMpUserMapper; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import com.fangxuele.tool.push.domain.TWxMpUser; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.dialog.importway.config.WxMpImportConfig; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.util.ComponentUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.result.WxMpUser; +import me.chanjar.weixin.mp.bean.result.WxMpUserList; +import me.chanjar.weixin.mp.bean.tag.WxTagListUser; +import me.chanjar.weixin.mp.bean.tag.WxUserTag; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; +import java.util.*; + +@Getter +public class ImportByWxMp extends JDialog { + private JPanel contentPane; + private JComboBox memberImportTagComboBox; + private JButton memberImportAllButton; + private JButton memberImportTagFreshButton; + private JButton memberImportTagButton; + private JButton memberImportTagRetainButton; + private JPanel importOptionPanel; + private JCheckBox importOptionOpenIdCheckBox; + private JCheckBox importOptionBasicInfoCheckBox; + private JCheckBox importOptionAvatarCheckBox; + private JButton clearDbCacheButton; + + private static final Log logger = LogFactory.get(); + + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + private static TWxMpUserMapper tWxMpUserMapper = MybatisUtil.getSqlSession().getMapper(TWxMpUserMapper.class); + + public static Map userTagMap = new HashMap<>(); + /** + * 用于导入多个标签的用户时去重判断 + */ + private Set tagUserSet; + + private Integer peopleId; + + private TPeople tPeople; + + public ImportByWxMp(Integer peopleId) { + super(App.mainFrame, "通过微信公众平台导入人群"); + setContentPane(contentPane); + setModal(true); + ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.3, 0.3); + getRootPane().setDefaultButton(memberImportAllButton); + + this.peopleId = peopleId; + tPeople = peopleMapper.selectByPrimaryKey(peopleId); + + memberImportAllButton.setIcon(new FlatSVGIcon("icon/import.svg")); + memberImportTagButton.setIcon(new FlatSVGIcon("icon/import.svg")); + memberImportTagRetainButton.setIcon(new FlatSVGIcon("icon/import.svg")); + memberImportTagFreshButton.setIcon(new FlatSVGIcon("icon/refresh.svg")); + + // 公众号-导入全员按钮事件 + memberImportAllButton.addActionListener(e -> { + ThreadUtil.execute(() -> importWxAll(this)); + dispose(); + }); + + // 公众号-刷新可选的标签按钮事件 + memberImportTagFreshButton.addActionListener(e -> { + + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(tPeople.getAccountId()); + if (wxMpService.getWxMpConfigStorage() == null) { + return; + } + + try { + List wxUserTagList = wxMpService.getUserTagService().tagGet(); + + memberImportTagComboBox.removeAllItems(); + userTagMap = new HashMap<>(); + + for (WxUserTag wxUserTag : wxUserTagList) { + String item = wxUserTag.getName() + "/" + wxUserTag.getCount() + "用户"; + memberImportTagComboBox.addItem(item); + userTagMap.put(item, wxUserTag.getId()); + } + + } catch (WxErrorException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "刷新失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + e1.printStackTrace(); + } + }); + + // 公众号-导入选择的标签分组用户按钮事件(取并集) + memberImportTagButton.addActionListener(e -> ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + + try { + if (memberImportTagComboBox.getSelectedItem() != null + && StringUtils.isNotEmpty(memberImportTagComboBox.getSelectedItem().toString())) { + + long selectedTagId = userTagMap.get(memberImportTagComboBox.getSelectedItem()); + getMpUserListByTag(this, selectedTagId, false); + PeopleEditForm.initDataTable(peopleId); + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(App.mainFrame, "请先选择需要导入的标签!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } + } catch (WxErrorException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } finally { + progressBar.setIndeterminate(false); + progressBar.setValue(progressBar.getMaximum()); + progressBar.setVisible(false); + } + })); + + // 公众号-导入选择的标签分组用户按钮事件(取交集) + memberImportTagRetainButton.addActionListener(e -> ThreadUtil.execute(() -> { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + JProgressBar progressBar = peopleEditForm.getMemberTabImportProgressBar(); + + try { + if (memberImportTagComboBox.getSelectedItem() != null + && StringUtils.isNotEmpty(memberImportTagComboBox.getSelectedItem().toString())) { + + long selectedTagId = userTagMap.get(memberImportTagComboBox.getSelectedItem()); + getMpUserListByTag(this, selectedTagId, true); + PeopleEditForm.initDataTable(peopleId); + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(App.mainFrame, "请先选择需要导入的标签!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } + } catch (WxErrorException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + e1.printStackTrace(); + } finally { + progressBar.setIndeterminate(false); + progressBar.setValue(progressBar.getMaximum()); + progressBar.setVisible(false); + } + })); + + // 公众号-清空本地缓存按钮事件 + clearDbCacheButton.addActionListener(e -> { + int count = tWxMpUserMapper.deleteAll(); + JOptionPane.showMessageDialog(App.mainFrame, "清理完毕!\n\n共清理:" + count + "条本地数据", "提示", + JOptionPane.INFORMATION_MESSAGE); + }); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void onCancel() { + // add your code here if necessary + dispose(); + } + + /** + * 导入微信全员 + */ + public void importWxAll(ImportByWxMp dialog) { + PeopleEditForm instance = PeopleEditForm.getInstance(); + JProgressBar progressBar = instance.getMemberTabImportProgressBar(); + instance.getImportButton().setEnabled(false); + + try { + getMpUserList(dialog); + PeopleEditForm.initDataTable(peopleId); + progressBar.setVisible(false); + JOptionPane.showMessageDialog(App.mainFrame, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); + } catch (WxErrorException e1) { + JOptionPane.showMessageDialog(App.mainFrame, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + e1.printStackTrace(); + } finally { + progressBar.setIndeterminate(false); + progressBar.setVisible(false); + instance.getImportButton().setEnabled(true); + } + } + + /** + * 拉取公众平台用户列表 + */ + public void getMpUserList(ImportByWxMp dialog) throws WxErrorException { + PeopleEditForm instance = PeopleEditForm.getInstance(); + JProgressBar progressBar = instance.getMemberTabImportProgressBar(); + JLabel memberCountLabel = instance.getMemberTabCountLabel(); + + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(tPeople.getAccountId()); + if (wxMpService.getWxMpConfigStorage() == null) { + return; + } + + WxMpUserList wxMpUserList = wxMpService.getUserService().userList(null); + + logger.info("关注该公众账号的总用户数:" + wxMpUserList.getTotal()); + logger.info("拉取的OPENID个数:" + wxMpUserList.getCount()); + + progressBar.setIndeterminate(false); + progressBar.setMaximum((int) wxMpUserList.getTotal()); + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_MP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxMpImportConfig wxMpImportConfig = new WxMpImportConfig(); + wxMpImportConfig.setUserType(1); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxMpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + if (wxMpUserList.getCount() == 0) { + memberCountLabel.setText(String.valueOf(importedCount)); + progressBar.setValue(importedCount); + return; + } + + List openIds = wxMpUserList.getOpenids(); + + for (String openId : openIds) { + List varData = getVarDatas(dialog, openId); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(openId); + tPeopleData.setVarData(JSONUtil.toJsonStr(varData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + memberCountLabel.setText(String.valueOf(importedCount)); + progressBar.setValue(importedCount); + } + + while (StringUtils.isNotEmpty(wxMpUserList.getNextOpenid())) { + wxMpUserList = wxMpService.getUserService().userList(wxMpUserList.getNextOpenid()); + + logger.info("拉取的OPENID个数:" + wxMpUserList.getCount()); + + if (wxMpUserList.getCount() == 0) { + break; + } + openIds = wxMpUserList.getOpenids(); + for (String openId : openIds) { + List varData = getVarDatas(dialog, openId); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(openId); + tPeopleData.setVarData(JSONUtil.toJsonStr(varData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + memberCountLabel.setText(String.valueOf(importedCount)); + progressBar.setValue(importedCount); + } + } + + progressBar.setValue((int) wxMpUserList.getTotal()); + } + + @NotNull + private List getVarDatas(ImportByWxMp dialog, String openId) { + boolean needToGetInfoFromWeiXin = false; + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(tPeople.getAccountId()); + + if (dialog.getImportOptionBasicInfoCheckBox().isSelected() || + dialog.getImportOptionAvatarCheckBox().isSelected()) { + needToGetInfoFromWeiXin = true; + } + + List varData = Lists.newArrayList(); + varData.add(openId); + if (needToGetInfoFromWeiXin) { + WxMpUser wxMpUser = null; + TWxMpUser tWxMpUser = tWxMpUserMapper.selectByPrimaryKey(openId); + if (tWxMpUser != null) { + wxMpUser = new WxMpUser(); + BeanUtil.copyProperties(tWxMpUser, wxMpUser); + } else { + if (wxMpService != null) { + try { + wxMpUser = wxMpService.getUserService().userInfo(openId); + if (wxMpUser != null) { + tWxMpUser = new TWxMpUser(); + BeanUtil.copyProperties(wxMpUser, tWxMpUser); + tWxMpUserMapper.insertSelective(tWxMpUser); + } + } catch (Exception e) { + logger.error(e); + } + } + } + + if (wxMpUser != null) { + if (dialog.getImportOptionAvatarCheckBox().isSelected()) { + varData.add(wxMpUser.getHeadImgUrl()); + } + if (dialog.getImportOptionBasicInfoCheckBox().isSelected()) { + varData.add(wxMpUser.getNickname()); + varData.add(""); + varData.add(""); + varData.add(DateFormatUtils.format(wxMpUser.getSubscribeTime() * 1000, "yyyy-MM-dd HH:mm:ss")); + } + } else { + if (dialog.getImportOptionAvatarCheckBox().isSelected()) { + varData.add(""); + } + if (dialog.getImportOptionBasicInfoCheckBox().isSelected()) { + varData.add(""); + varData.add(""); + varData.add(""); + varData.add(""); + } + } + } + return varData; + } + + /** + * 按标签拉取公众平台用户列表 + * + * @param tagId + * @param retain 是否取交集 + * @throws WxErrorException + */ + public void getMpUserListByTag(ImportByWxMp dialog, Long tagId, boolean retain) throws WxErrorException { + PeopleEditForm instance = PeopleEditForm.getInstance(); + JProgressBar progressBar = instance.getMemberTabImportProgressBar(); + + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(tPeople.getAccountId()); + if (wxMpService.getWxMpConfigStorage() == null) { + return; + } + + WxTagListUser wxTagListUser = wxMpService.getUserTagService().tagListUser(tagId, ""); + + logger.info("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + return; + } + + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_MP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxMpImportConfig wxMpImportConfig = new WxMpImportConfig(); + wxMpImportConfig.setTagId(tagId); + wxMpImportConfig.setUserType(retain ? 3 : 2); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxMpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + List openIds = wxTagListUser.getData().getOpenidList(); + + if (tagUserSet == null) { + tagUserSet = Collections.synchronizedSet(new HashSet<>()); + tagUserSet.addAll(openIds); + } + + if (retain) { + // 取交集 + tagUserSet.retainAll(openIds); + } else { + // 无重复并集 + openIds.removeAll(tagUserSet); + tagUserSet.addAll(openIds); + } + + while (StringUtils.isNotEmpty(wxTagListUser.getNextOpenid())) { + wxTagListUser = wxMpService.getUserTagService().tagListUser(tagId, wxTagListUser.getNextOpenid()); + + logger.info("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + break; + } + openIds = wxTagListUser.getData().getOpenidList(); + + if (retain) { + // 取交集 + tagUserSet.retainAll(openIds); + } else { + // 无重复并集 + openIds.removeAll(tagUserSet); + tagUserSet.addAll(openIds); + } + } + + for (String openId : tagUserSet) { + List varData = getVarDatas(dialog, openId); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(openId); + tPeopleData.setVarData(JSONUtil.toJsonStr(varData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + + progressBar.setIndeterminate(false); + progressBar.setValue(progressBar.getMaximum()); + + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + memberImportTagButton = new JButton(); + Font memberImportTagButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagButton.getFont()); + if (memberImportTagButtonFont != null) memberImportTagButton.setFont(memberImportTagButtonFont); + memberImportTagButton.setText("导入选择的标签分组-取并集"); + panel2.add(memberImportTagButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberImportTagRetainButton = new JButton(); + Font memberImportTagRetainButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagRetainButton.getFont()); + if (memberImportTagRetainButtonFont != null) + memberImportTagRetainButton.setFont(memberImportTagRetainButtonFont); + memberImportTagRetainButton.setText("导入选择的标签分组-取交集"); + panel2.add(memberImportTagRetainButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberImportAllButton = new JButton(); + Font memberImportAllButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportAllButton.getFont()); + if (memberImportAllButtonFont != null) memberImportAllButton.setFont(memberImportAllButtonFont); + memberImportAllButton.setText("导入所有关注公众号的用户"); + panel2.add(memberImportAllButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + importOptionPanel = new JPanel(); + importOptionPanel.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(importOptionPanel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + importOptionOpenIdCheckBox = new JCheckBox(); + importOptionOpenIdCheckBox.setEnabled(false); + importOptionOpenIdCheckBox.setSelected(true); + importOptionOpenIdCheckBox.setText("openId"); + importOptionPanel.add(importOptionOpenIdCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + importOptionPanel.add(spacer1, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + importOptionBasicInfoCheckBox = new JCheckBox(); + importOptionBasicInfoCheckBox.setText("昵称、性别等基本信息"); + importOptionBasicInfoCheckBox.setToolTipText("每获取一条信息会花费一次每日接口调用量"); + importOptionPanel.add(importOptionBasicInfoCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + importOptionAvatarCheckBox = new JCheckBox(); + importOptionAvatarCheckBox.setText("头像"); + importOptionAvatarCheckBox.setToolTipText("勾选会导致左侧列表甚至WePush变卡哦"); + importOptionPanel.add(importOptionAvatarCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + clearDbCacheButton = new JButton(); + clearDbCacheButton.setText("清空本地缓存"); + importOptionPanel.add(clearDbCacheButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberImportTagComboBox = new JComboBox(); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + memberImportTagComboBox.setModel(defaultComboBoxModel1); + panel3.add(memberImportTagComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + memberImportTagFreshButton = new JButton(); + Font memberImportTagFreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagFreshButton.getFont()); + if (memberImportTagFreshButtonFont != null) memberImportTagFreshButton.setFont(memberImportTagFreshButtonFont); + memberImportTagFreshButton.setText("刷新"); + panel3.add(memberImportTagFreshButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("标签分组"); + panel3.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + + public void reImport() { + TPeopleImportConfig peopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + String lastWayConfig = peopleImportConfig.getLastWayConfig(); + WxMpImportConfig wxMpImportConfigBefore = JSONUtil.toBean(lastWayConfig, WxMpImportConfig.class); + if (wxMpImportConfigBefore == null) { + return; + } + + try { + // 1:全部,2:标签取并集,3:标签取交集 + if (wxMpImportConfigBefore.getUserType() == 1) { + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(tPeople.getAccountId()); + if (wxMpService.getWxMpConfigStorage() == null) { + return; + } + + WxMpUserList wxMpUserList = wxMpService.getUserService().userList(null); + + logger.info("关注该公众账号的总用户数:" + wxMpUserList.getTotal()); + logger.info("拉取的OPENID个数:" + wxMpUserList.getCount()); + + int importedCount = 0; + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_MP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxMpImportConfig wxMpImportConfig = new WxMpImportConfig(); + wxMpImportConfig.setUserType(1); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxMpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + if (wxMpUserList.getCount() == 0) { + return; + } + + List openIds = wxMpUserList.getOpenids(); + + peopleDataMapper.deleteByPeopleId(peopleId); + + for (String openId : openIds) { + List varData = getVarDatas(this, openId); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(openId); + tPeopleData.setVarData(JSONUtil.toJsonStr(varData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + } + + while (StringUtils.isNotEmpty(wxMpUserList.getNextOpenid())) { + wxMpUserList = wxMpService.getUserService().userList(wxMpUserList.getNextOpenid()); + + logger.info("拉取的OPENID个数:" + wxMpUserList.getCount()); + + if (wxMpUserList.getCount() == 0) { + break; + } + openIds = wxMpUserList.getOpenids(); + for (String openId : openIds) { + List varData = getVarDatas(this, openId); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(openId); + tPeopleData.setVarData(JSONUtil.toJsonStr(varData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + + importedCount++; + } + } + } else if (wxMpImportConfigBefore.getUserType() == 2) { + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(tPeople.getAccountId()); + if (wxMpService.getWxMpConfigStorage() == null) { + return; + } + + WxTagListUser wxTagListUser = wxMpService.getUserTagService().tagListUser(wxMpImportConfigBefore.getTagId(), ""); + + logger.info("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + return; + } + + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_MP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxMpImportConfig wxMpImportConfig = new WxMpImportConfig(); + wxMpImportConfig.setTagId(wxMpImportConfigBefore.getTagId()); + wxMpImportConfig.setUserType(2); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxMpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + List openIds = wxTagListUser.getData().getOpenidList(); + + if (tagUserSet == null) { + tagUserSet = Collections.synchronizedSet(new HashSet<>()); + tagUserSet.addAll(openIds); + } + + // 无重复并集 + openIds.removeAll(tagUserSet); + tagUserSet.addAll(openIds); + + while (StringUtils.isNotEmpty(wxTagListUser.getNextOpenid())) { + wxTagListUser = wxMpService.getUserTagService().tagListUser(wxMpImportConfigBefore.getTagId(), wxTagListUser.getNextOpenid()); + + logger.info("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + break; + } + openIds = wxTagListUser.getData().getOpenidList(); + + // 无重复并集 + openIds.removeAll(tagUserSet); + tagUserSet.addAll(openIds); + } + + peopleDataMapper.deleteByPeopleId(peopleId); + + for (String openId : tagUserSet) { + List varData = getVarDatas(this, openId); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(openId); + tPeopleData.setVarData(JSONUtil.toJsonStr(varData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } else if (wxMpImportConfigBefore.getUserType() == 3) { + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(tPeople.getAccountId()); + if (wxMpService.getWxMpConfigStorage() == null) { + return; + } + + WxTagListUser wxTagListUser = wxMpService.getUserTagService().tagListUser(wxMpImportConfigBefore.getTagId(), ""); + + logger.info("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + return; + } + + String now = SqliteUtil.nowDateForSqlite(); + String dataVersion = UUID.fastUUID().toString(true); + + // 保存导入配置 + TPeopleImportConfig beforePeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + + TPeopleImportConfig tPeopleImportConfig = new TPeopleImportConfig(); + tPeopleImportConfig.setPeopleId(peopleId); + tPeopleImportConfig.setLastWay(String.valueOf(PeopleImportWayEnum.BY_WX_MP_CODE)); + tPeopleImportConfig.setAppVersion(UiConsts.APP_VERSION); + tPeopleImportConfig.setLastDataVersion(dataVersion); + tPeopleImportConfig.setModifiedTime(now); + + WxMpImportConfig wxMpImportConfig = new WxMpImportConfig(); + wxMpImportConfig.setTagId(wxMpImportConfigBefore.getTagId()); + wxMpImportConfig.setUserType(3); + tPeopleImportConfig.setLastWayConfig(JSONUtil.toJsonStr(wxMpImportConfig)); + + if (beforePeopleImportConfig != null) { + tPeopleImportConfig.setId(beforePeopleImportConfig.getId()); + peopleImportConfigMapper.updateByPrimaryKeySelective(tPeopleImportConfig); + } else { + tPeopleImportConfig.setCreateTime(now); + peopleImportConfigMapper.insert(tPeopleImportConfig); + } + + List openIds = wxTagListUser.getData().getOpenidList(); + + if (tagUserSet == null) { + tagUserSet = Collections.synchronizedSet(new HashSet<>()); + tagUserSet.addAll(openIds); + } + + // 取交集 + tagUserSet.retainAll(openIds); + + while (StringUtils.isNotEmpty(wxTagListUser.getNextOpenid())) { + wxTagListUser = wxMpService.getUserTagService().tagListUser(wxMpImportConfigBefore.getTagId(), wxTagListUser.getNextOpenid()); + + logger.info("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + break; + } + openIds = wxTagListUser.getData().getOpenidList(); + + // 取交集 + tagUserSet.retainAll(openIds); + } + + peopleDataMapper.deleteByPeopleId(peopleId); + + for (String openId : tagUserSet) { + List varData = getVarDatas(this, openId); + + TPeopleData tPeopleData = new TPeopleData(); + tPeopleData.setPeopleId(peopleId); + tPeopleData.setPin(openId); + tPeopleData.setVarData(JSONUtil.toJsonStr(varData)); + tPeopleData.setAppVersion(UiConsts.APP_VERSION); + tPeopleData.setDataVersion(dataVersion); + tPeopleData.setCreateTime(now); + tPeopleData.setModifiedTime(now); + + peopleDataMapper.insert(tPeopleData); + } + } + } catch (Exception e) { + logger.error(e); + } + + dispose(); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/DingImportConfig.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/DingImportConfig.java new file mode 100644 index 000000000..a3e96f974 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/DingImportConfig.java @@ -0,0 +1,17 @@ +package com.fangxuele.tool.push.ui.dialog.importway.config; + +import lombok.Data; + +@Data +public class DingImportConfig { + + /** + * 1:全部,2:按部门 + */ + private Integer userType; + + /** + * 部门id + */ + private Long deptId; +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/WxCpImportConfig.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/WxCpImportConfig.java new file mode 100644 index 000000000..b97f639c7 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/WxCpImportConfig.java @@ -0,0 +1,22 @@ +package com.fangxuele.tool.push.ui.dialog.importway.config; + +import lombok.Data; + +@Data +public class WxCpImportConfig { + + /** + * 1:全部,2:按标签,3:按部门 + */ + private Integer userType; + + /** + * 标签id + */ + private String tagId; + + /** + * 部门id + */ + private Long depId; +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/WxMpImportConfig.java b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/WxMpImportConfig.java new file mode 100644 index 000000000..c55c05135 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/dialog/importway/config/WxMpImportConfig.java @@ -0,0 +1,17 @@ +package com.fangxuele.tool.push.ui.dialog.importway.config; + +import lombok.Data; + +@Data +public class WxMpImportConfig { + + /** + * 1:全部,2:标签取并集,3:标签取交集 + */ + private Integer userType; + + /** + * 标签id + */ + private Long tagId; +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.form index ae08a9fdd..487ad2b6f 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.form @@ -32,7 +32,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.java index 7c1bf8094..cc86b5808 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/AboutForm.java @@ -1,12 +1,22 @@ package com.fangxuele.tool.push.ui.form; import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.ui.UiConsts; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.exception.ExceptionUtils; +import javax.imageio.ImageIO; import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URL; +import java.util.Locale; /** *
@@ -17,6 +27,7 @@
  * @since 2019/5/6.
  */
 @Getter
+@Slf4j
 public class AboutForm {
     private JPanel aboutPanel;
     private JLabel sloganLabel;
@@ -42,6 +53,26 @@ public static AboutForm getInstance() {
     public static void init() {
         getInstance().getPushTotalLabel().setText("已累计为您推送 " + App.config.getPushTotal() + " 条消息");
         aboutForm.getAboutPanel().updateUI();
+        // 设置版本
+        aboutForm.getVersionLabel().setText(UiConsts.APP_VERSION);
+
+        // 初始化二维码
+        aboutForm.initQrCode();
+    }
+
+    /**
+     * 初始化二维码
+     */
+    private void initQrCode() {
+        try {
+            URL url = new URL(UiConsts.QR_CODE_URL);
+            BufferedImage image = ImageIO.read(url);
+            qrCodeLabel.setIcon(new ImageIcon(image));
+        } catch (IOException e) {
+            e.printStackTrace();
+            log.error(ExceptionUtils.getStackTrace(e));
+        }
+
     }
 
     {
@@ -72,7 +103,7 @@ public static void init() {
         label1.setText("WePush");
         aboutPanel.add(label1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         qrCodeLabel = new JLabel();
-        qrCodeLabel.setIcon(new ImageIcon(getClass().getResource("/icon/weixin-qrcode.png")));
+        qrCodeLabel.setIcon(new ImageIcon(getClass().getResource("/icon/wx-zanshang.jpg")));
         qrCodeLabel.setText("");
         qrCodeLabel.setToolTipText("感谢您的鼓励和支持!");
         aboutPanel.add(qrCodeLabel, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
@@ -124,7 +155,10 @@ public static void init() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
     /**
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/AccountEditForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/AccountEditForm.form
new file mode 100644
index 000000000..d53f6fcb1
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/AccountEditForm.form
@@ -0,0 +1,97 @@
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/AccountEditForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/AccountEditForm.java new file mode 100644 index 000000000..b0cd3b952 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/AccountEditForm.java @@ -0,0 +1,154 @@ +package com.fangxuele.tool.push.ui.form; + +import com.fangxuele.tool.push.ui.form.account.AccountFormFactory; +import com.fangxuele.tool.push.ui.form.account.IAccountForm; +import com.fangxuele.tool.push.util.UndoUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; + +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.util.Locale; + +/** + *
+ * AccountEditForm
+ * 
+ * + * @author RememBerBer + * @since 2021/3/19. + */ +@Getter +public class AccountEditForm { + private JPanel accountEditPanel; + private JLabel accountNameLabel; + private JTextField accountNameField; + private JButton accountSaveButton; + private JPanel accountEditorPanel; + private JScrollPane accountEditScrollPane; + + private static AccountEditForm accountEditForm; + + private AccountEditForm() { + UndoUtil.register(this); + } + + public static AccountEditForm getInstance() { + if (accountEditForm == null) { + accountEditForm = new AccountEditForm(); + } + return accountEditForm; + } + + /** + * 初始化tab + */ + public static void init(String selectedAccountName) { + accountEditForm = getInstance(); + // 设置滚动条速度 + accountEditForm.getAccountEditScrollPane().getVerticalScrollBar().setUnitIncrement(15); + accountEditForm.getAccountEditScrollPane().getVerticalScrollBar().setDoubleBuffered(true); + + accountEditForm.getAccountNameField().setText(selectedAccountName); + IAccountForm accountForm = AccountFormFactory.getAccountForm(); + accountForm.clear(); + accountForm.init(selectedAccountName); + + accountEditForm.getAccountSaveButton().setIcon(new FlatSVGIcon("icon/save.svg")); + } + + /** + * 清空表单 + */ + public static void clear() { + AccountEditForm.getInstance().getAccountNameField().setText(""); + AccountFormFactory.getAccountForm().clear(); + } + + public static void switchMainPanel() { + accountEditForm = getInstance(); + accountEditForm.getAccountEditorPanel().removeAll(); + GridConstraints gridConstraintsRow0 = new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false); + accountEditForm.getAccountEditorPanel().add(AccountFormFactory.getAccountMainPanelAndInit(null), gridConstraintsRow0); + + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + accountEditPanel = new JPanel(); + accountEditPanel.setLayout(new GridLayoutManager(3, 1, new Insets(10, 0, 10, 10), -1, -1)); + accountEditPanel.setMaximumSize(new Dimension(-1, -1)); + accountEditPanel.setMinimumSize(new Dimension(-1, -1)); + accountEditPanel.setPreferredSize(new Dimension(-1, -1)); + panel1.add(accountEditPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + accountEditPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + accountNameLabel = new JLabel(); + Font accountNameLabelFont = this.$$$getFont$$$(null, Font.BOLD, -1, accountNameLabel.getFont()); + if (accountNameLabelFont != null) accountNameLabel.setFont(accountNameLabelFont); + accountNameLabel.setText("账号名称 *"); + accountNameLabel.setToolTipText(""); + panel2.add(accountNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + accountNameField = new JTextField(); + accountNameField.setToolTipText(""); + panel2.add(accountNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + accountEditPanel.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + accountSaveButton = new JButton(); + accountSaveButton.setText("保存"); + panel3.add(accountSaveButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel3.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + accountEditScrollPane = new JScrollPane(); + accountEditPanel.add(accountEditScrollPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + accountEditorPanel = new JPanel(); + accountEditorPanel.setLayout(new GridLayoutManager(1, 1, new Insets(5, 5, 0, 5), -1, -1, true, false)); + accountEditScrollPane.setViewportView(accountEditorPanel); + accountNameLabel.setLabelFor(accountNameField); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/AccountManageForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/AccountManageForm.form new file mode 100644 index 000000000..747c47b21 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/AccountManageForm.form @@ -0,0 +1,76 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/AccountManageForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/AccountManageForm.java new file mode 100644 index 000000000..aa8493d58 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/AccountManageForm.java @@ -0,0 +1,124 @@ +package com.fangxuele.tool.push.ui.form; + +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.util.JTableUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.*; +import java.util.List; + +/** + *
+ * AccountManageForm
+ * 
+ * + * @author RememBerBer + * @since 2021/3/10. + */ +@Getter +public class AccountManageForm { + + private JPanel accountManagePanel; + private JTable accountListTable; + private JButton accountListTableDeleteButton; + private JButton createAccountButton; + + private static AccountManageForm accountManageForm; + + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + + private AccountManageForm() { + } + + public static AccountManageForm getInstance() { + if (accountManageForm == null) { + accountManageForm = new AccountManageForm(); + } + return accountManageForm; + } + + /** + * 初始化消息列表 + */ + public static void init() { + accountManageForm = getInstance(); + + accountManageForm.getCreateAccountButton().setIcon(new FlatSVGIcon("icon/add.svg")); + accountManageForm.getAccountListTableDeleteButton().setIcon(new FlatSVGIcon("icon/remove.svg")); + + initMessageList(); + } + + public static void initMessageList() { + // 历史消息管理 + String[] headerNames = {"账户名称"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + accountManageForm.getAccountListTable().setModel(model); + // 隐藏表头 + JTableUtil.hideTableHeader(accountManageForm.getAccountListTable()); + + int msgType = App.config.getMsgType(); + + Object[] data; + + List tAccountList = accountMapper.selectByMsgType(msgType); + for (TAccount tAccount : tAccountList) { + data = new Object[1]; + data[0] = tAccount.getAccountName(); + model.addRow(data); + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + accountManagePanel = new JPanel(); + accountManagePanel.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 0), -1, -1)); + accountManagePanel.setMaximumSize(new Dimension(-1, -1)); + accountManagePanel.setMinimumSize(new Dimension(-1, -1)); + accountManagePanel.setPreferredSize(new Dimension(280, -1)); + panel1.add(accountManagePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JScrollPane scrollPane1 = new JScrollPane(); + accountManagePanel.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + accountListTable = new JTable(); + accountListTable.setGridColor(new Color(-12236470)); + accountListTable.setRowHeight(36); + accountListTable.setShowVerticalLines(false); + scrollPane1.setViewportView(accountListTable); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + accountManagePanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + accountListTableDeleteButton = new JButton(); + accountListTableDeleteButton.setText("删除"); + panel2.add(accountListTableDeleteButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + createAccountButton = new JButton(); + createAccountButton.setEnabled(true); + createAccountButton.setText("新建"); + panel2.add(createAccountButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/BoostForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/BoostForm.form deleted file mode 100644 index 495be453f..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/BoostForm.form +++ /dev/null @@ -1,295 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/BoostForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/BoostForm.java deleted file mode 100644 index 99809cd11..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/BoostForm.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.fangxuele.tool.push.ui.form; - -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.util.UndoUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import lombok.Getter; - -import javax.swing.*; -import java.awt.*; - -/** - *
- * 性能模式Form
- * 
- * - * @author RememBerBer - * @since 2019/6/15. - */ -@Getter -public class BoostForm { - private JPanel boostPanel; - private JTextArea consoleTextArea; - private JButton startButton; - private JButton stopButton; - private JButton scheduledRunButton; - private JCheckBox dryRunCheckBox; - private JProgressBar processedProgressBar; - private JProgressBar completedProgressBar; - private JLabel boostModeHelpLabel; - private JLabel processedCountLabel; - private JLabel successCountLabel; - private JLabel failCountLabel; - private JLabel lastTimeLabel; - private JLabel leftTimeLabel; - private JLabel msgNameLabel; - private JLabel memberCountLabel; - private JLabel processorCountLabel; - private JLabel jvmMemoryLabel; - private JLabel scheduledTaskLabel; - - private static BoostForm boostForm; - - private BoostForm() { - UndoUtil.register(this); - } - - public static BoostForm getInstance() { - if (boostForm == null) { - boostForm = new BoostForm(); - } - return boostForm; - } - - public static void init() { - boostForm = getInstance(); - boostForm.getDryRunCheckBox().setSelected(App.config.isDryRun()); - boostForm.getScheduledTaskLabel().setVisible(false); - - if ("Darcula(推荐)".equals(App.config.getTheme())) { - Color bgColor = new Color(43, 43, 43); - boostForm.getConsoleTextArea().setBackground(bgColor); - Color foreColor = new Color(187, 187, 187); - boostForm.getConsoleTextArea().setForeground(foreColor); - } - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - boostPanel = new JPanel(); - boostPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(5, 13, new Insets(0, 8, 0, 10), -1, -1)); - boostPanel.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JSeparator separator1 = new JSeparator(); - separator1.setOrientation(1); - panel1.add(separator1, new GridConstraints(0, 3, 5, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - successCountLabel = new JLabel(); - Font successCountLabelFont = this.$$$getFont$$$(null, -1, 72, successCountLabel.getFont()); - if (successCountLabelFont != null) successCountLabel.setFont(successCountLabelFont); - successCountLabel.setForeground(new Color(-13587376)); - successCountLabel.setText("0"); - panel1.add(successCountLabel, new GridConstraints(0, 5, 2, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label1 = new JLabel(); - label1.setText("成功"); - panel1.add(label1, new GridConstraints(0, 6, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - failCountLabel = new JLabel(); - Font failCountLabelFont = this.$$$getFont$$$(null, -1, 72, failCountLabel.getFont()); - if (failCountLabelFont != null) failCountLabel.setFont(failCountLabelFont); - failCountLabel.setForeground(new Color(-2200483)); - failCountLabel.setText("0"); - panel1.add(failCountLabel, new GridConstraints(2, 5, 2, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("失败"); - panel1.add(label2, new GridConstraints(2, 6, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - completedProgressBar = new JProgressBar(); - panel1.add(completedProgressBar, new GridConstraints(4, 4, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JSeparator separator2 = new JSeparator(); - separator2.setEnabled(true); - separator2.setOrientation(1); - panel1.add(separator2, new GridConstraints(0, 7, 5, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - processedProgressBar = new JProgressBar(); - panel1.add(processedProgressBar, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - processedCountLabel = new JLabel(); - Font processedCountLabelFont = this.$$$getFont$$$(null, -1, 72, processedCountLabel.getFont()); - if (processedCountLabelFont != null) processedCountLabel.setFont(processedCountLabelFont); - processedCountLabel.setText("0"); - panel1.add(processedCountLabel, new GridConstraints(2, 1, 2, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("已处理"); - panel1.add(label3, new GridConstraints(2, 2, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JSeparator separator3 = new JSeparator(); - separator3.setOrientation(1); - panel1.add(separator3, new GridConstraints(0, 11, 5, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - memberCountLabel = new JLabel(); - memberCountLabel.setText("消息总数:0"); - panel1.add(memberCountLabel, new GridConstraints(1, 12, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - processorCountLabel = new JLabel(); - processorCountLabel.setText("可用处理器核心:-"); - panel1.add(processorCountLabel, new GridConstraints(2, 12, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("耗时"); - panel1.add(label4, new GridConstraints(0, 9, 2, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label5 = new JLabel(); - label5.setText("预计剩余"); - panel1.add(label5, new GridConstraints(2, 9, 2, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - lastTimeLabel = new JLabel(); - Font lastTimeLabelFont = this.$$$getFont$$$(null, -1, 36, lastTimeLabel.getFont()); - if (lastTimeLabelFont != null) lastTimeLabel.setFont(lastTimeLabelFont); - lastTimeLabel.setText("0s"); - panel1.add(lastTimeLabel, new GridConstraints(0, 10, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - leftTimeLabel = new JLabel(); - Font leftTimeLabelFont = this.$$$getFont$$$(null, -1, 36, leftTimeLabel.getFont()); - if (leftTimeLabelFont != null) leftTimeLabel.setFont(leftTimeLabelFont); - leftTimeLabel.setText("0s"); - panel1.add(leftTimeLabel, new GridConstraints(2, 10, 2, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - panel1.add(spacer1, new GridConstraints(2, 0, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final Spacer spacer2 = new Spacer(); - panel1.add(spacer2, new GridConstraints(2, 4, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final Spacer spacer3 = new Spacer(); - panel1.add(spacer3, new GridConstraints(2, 8, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - boostModeHelpLabel = new JLabel(); - Font boostModeHelpLabelFont = this.$$$getFont$$$(null, -1, 28, boostModeHelpLabel.getFont()); - if (boostModeHelpLabelFont != null) boostModeHelpLabel.setFont(boostModeHelpLabelFont); - boostModeHelpLabel.setForeground(new Color(-3513110)); - boostModeHelpLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); - boostModeHelpLabel.setText("性能模式"); - panel1.add(boostModeHelpLabel, new GridConstraints(0, 0, 2, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - msgNameLabel = new JLabel(); - Font msgNameLabelFont = this.$$$getFont$$$(null, -1, 24, msgNameLabel.getFont()); - if (msgNameLabelFont != null) msgNameLabel.setFont(msgNameLabelFont); - msgNameLabel.setForeground(new Color(-276358)); - msgNameLabel.setText("消息名称:-"); - panel1.add(msgNameLabel, new GridConstraints(0, 12, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - jvmMemoryLabel = new JLabel(); - jvmMemoryLabel.setText("JVM内存占用:-"); - panel1.add(jvmMemoryLabel, new GridConstraints(3, 12, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - scheduledTaskLabel = new JLabel(); - scheduledTaskLabel.setForeground(new Color(-276358)); - scheduledTaskLabel.setText("计划任务执行中"); - scheduledTaskLabel.setVisible(true); - panel1.add(scheduledTaskLabel, new GridConstraints(4, 12, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - boostPanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - final JScrollPane scrollPane1 = new JScrollPane(); - panel2.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - consoleTextArea = new JTextArea(); - scrollPane1.setViewportView(consoleTextArea); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(1, 5, new Insets(0, 5, 5, 5), -1, -1)); - boostPanel.add(panel3, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - startButton = new JButton(); - startButton.setIcon(new ImageIcon(getClass().getResource("/icon/run@2x.png"))); - startButton.setText("开始"); - panel3.add(startButton, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer4 = new Spacer(); - panel3.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - stopButton = new JButton(); - stopButton.setIcon(new ImageIcon(getClass().getResource("/icon/suspend.png"))); - stopButton.setText("停止"); - panel3.add(stopButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - scheduledRunButton = new JButton(); - scheduledRunButton.setIcon(new ImageIcon(getClass().getResource("/icon/clock.png"))); - scheduledRunButton.setText("按计划执行"); - panel3.add(scheduledRunButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - dryRunCheckBox = new JCheckBox(); - dryRunCheckBox.setText("空跑"); - panel3.add(dryRunCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer5 = new Spacer(); - boostPanel.add(spacer5, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - } - - /** - * @noinspection ALL - */ - private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { - if (currentFont == null) return null; - String resultName; - if (fontName == null) { - resultName = currentFont.getName(); - } else { - Font testFont = new Font(fontName, Font.PLAIN, 10); - if (testFont.canDisplay('a') && testFont.canDisplay('1')) { - resultName = fontName; - } else { - resultName = currentFont.getName(); - } - } - return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return boostPanel; - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.form index f83df9af3..4952b4896 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.form @@ -30,7 +30,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.java index f8414c7b3..b1e7c39bf 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/HttpResultForm.java @@ -1,12 +1,13 @@ package com.fangxuele.tool.push.ui.form; -import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.util.UIUtil; import com.fangxuele.tool.push.util.UndoUtil; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import lombok.Getter; import javax.swing.*; +import javax.swing.border.TitledBorder; import java.awt.*; /** @@ -32,7 +33,7 @@ private HttpResultForm() { this.getHttpResultScrollPane().getVerticalScrollBar().setUnitIncrement(15); this.getHttpResultScrollPane().getVerticalScrollBar().setDoubleBuffered(true); - if ("Darcula(推荐)".equals(App.config.getTheme())) { + if (UIUtil.isDarkLaf()) { Color bgColor = new Color(43, 43, 43); bodyTextArea.setBackground(bgColor); headersTextArea.setBackground(bgColor); @@ -76,6 +77,7 @@ public static HttpResultForm getInstance() { tabbedPane1.addTab("Body", panel1); httpResultScrollPane = new JScrollPane(); panel1.add(httpResultScrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + httpResultScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); bodyTextArea = new JTextArea(); httpResultScrollPane.setViewportView(bodyTextArea); final JPanel panel2 = new JPanel(); @@ -83,6 +85,7 @@ public static HttpResultForm getInstance() { tabbedPane1.addTab("Headers", panel2); final JScrollPane scrollPane1 = new JScrollPane(); panel2.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); headersTextArea = new JTextArea(); scrollPane1.setViewportView(headersTextArea); final JPanel panel3 = new JPanel(); @@ -90,6 +93,7 @@ public static HttpResultForm getInstance() { tabbedPane1.addTab("Cookies", panel3); final JScrollPane scrollPane2 = new JScrollPane(); panel3.add(scrollPane2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPane2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); cookiesTextArea = new JTextArea(); scrollPane2.setViewportView(cookiesTextArea); } diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/LoadingForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/LoadingForm.java index 3b7c1bff9..53de7a4ec 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/LoadingForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/LoadingForm.java @@ -5,7 +5,10 @@ import lombok.Getter; import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.*; +import java.util.Locale; /** *
@@ -61,7 +64,10 @@ public class LoadingForm {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
     /**
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.form b/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.form
index 6e5e4e0df..18c355b4c 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.form
@@ -23,14 +23,12 @@
         
         
         
-          
-            
+          
+            
             
-              
+              
             
-            
-              
-            
+            
             
             
           
@@ -45,16 +43,47 @@
             
             
           
+          
+            
+              
+            
+            
+              
+              
+              
+            
+            
+            
+              
+                
+                
+                  
+                
+                
+                
+                
+              
+              
+                
+                
+                  
+                
+                
+                
+                
+              
+            
+          
           
             
-              
+              
             
             
               
               
-              
+              
               
-              
+              
               
             
             
@@ -87,82 +116,46 @@
               
             
           
-          
-            
+          
             
-              
+              
             
             
-              
-            
-            
-            
-          
-          
-            
-            
-              
-            
-            
-              
+              
+              
+              
             
             
-            
-          
-          
+            
+              
+                
+                
+                  
+                
+                
+                
+                
+              
+              
+                
+                
+                  
+                
+                
+                
+                
+              
+            
+          
+          
             
             
-              
+              
             
             
             
             
           
-          
-            
-            
-              
-            
-            
-              
-            
-            
-            
-          
-          
-            
-            
-              
-            
-            
-              
-            
-            
-            
-          
-          
-            
-            
-              
-            
-            
-              
-              
-            
-            
-            
-          
-          
-            
-            
-              
-            
-            
-              
-            
-            
-            
-          
         
       
     
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.java b/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.java
index c6236195a..68a938463 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/MainWindow.java
@@ -1,12 +1,17 @@
 package com.fangxuele.tool.push.ui.form;
 
 import com.fangxuele.tool.push.App;
+import com.fangxuele.tool.push.util.SystemUtil;
+import com.formdev.flatlaf.util.SystemInfo;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import lombok.Getter;
 
 import javax.swing.*;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.text.StyleContext;
 import java.awt.*;
+import java.util.Locale;
 
 /**
  * 
@@ -20,18 +25,18 @@
 public class MainWindow {
     private JPanel mainPanel;
     private JTabbedPane tabbedPane;
-    private JPanel aboutPanel;
     private JSplitPane messagePanel;
-    private JPanel memberPanel;
-    private JPanel pushPanel;
-    private JPanel settingPanel;
-    private JPanel schedulePanel;
-    private JPanel pushHisPanel;
-    private JPanel userCasePanel;
     private JPanel messageEditPanel;
     private JPanel messageManagePanel;
     private JPanel messageTypePanel;
-    private JPanel boostPanel;
+    private JSplitPane accountPanel;
+    private JPanel accountManagePanel;
+    private JPanel accountEditPanel;
+    private JSplitPane peoplePanel;
+    private JPanel peopleManagePanel;
+    private JPanel peopleEditPanel;
+    private JPanel taskPanel;
+    private JPanel aboutPanel;
 
     private static MainWindow mainWindow;
 
@@ -45,23 +50,29 @@ public static MainWindow getInstance() {
         return mainWindow;
     }
 
-    private static GridConstraints gridConstraints = new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false);
+    private static final GridConstraints GRID_CONSTRAINTS = new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false);
 
     public void init() {
         mainWindow = getInstance();
         mainWindow.getMainPanel().updateUI();
-        mainWindow.getAboutPanel().add(AboutForm.getInstance().getAboutPanel(), gridConstraints);
-        mainWindow.getUserCasePanel().add(UserCaseForm.getInstance().getUserCasePanel(), gridConstraints);
-        mainWindow.getSchedulePanel().add(ScheduleForm.getInstance().getSchedulePanel(), gridConstraints);
-        mainWindow.getPushHisPanel().add(PushHisForm.getInstance().getPushHisPanel(), gridConstraints);
-        mainWindow.getSettingPanel().add(SettingForm.getInstance().getSettingPanel(), gridConstraints);
-        mainWindow.getMessageEditPanel().add(MessageEditForm.getInstance().getMessageEditPanel(), gridConstraints);
-        mainWindow.getMessageManagePanel().add(MessageManageForm.getInstance().getMessageManagePanel(), gridConstraints);
-        mainWindow.getMemberPanel().add(MemberForm.getInstance().getMemberPanel(), gridConstraints);
-        mainWindow.getPushPanel().add(PushForm.getInstance().getPushPanel(), gridConstraints);
-        mainWindow.getMessageTypePanel().add(MessageTypeForm.getInstance().getMessageTypePanel(), gridConstraints);
-        mainWindow.getBoostPanel().add(BoostForm.getInstance().getBoostPanel(), gridConstraints);
-        mainWindow.getMessagePanel().setDividerLocation((int) (App.mainFrame.getWidth() / 5.6));
+
+        if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) {
+            GridLayoutManager gridLayoutManager = (GridLayoutManager) mainPanel.getLayout();
+            gridLayoutManager.setMargin(new Insets(25, 0, 0, 0));
+        }
+
+        mainWindow.getAboutPanel().add(AboutForm.getInstance().getAboutPanel(), GRID_CONSTRAINTS);
+        mainWindow.getAccountPanel().setDividerLocation((int) (App.mainFrame.getWidth() / 5));
+        mainWindow.getMessagePanel().setDividerLocation((int) (App.mainFrame.getWidth() / 5));
+        mainWindow.getPeoplePanel().setDividerLocation((int) (App.mainFrame.getWidth() / 5));
+        mainWindow.getAccountManagePanel().add(AccountManageForm.getInstance().getAccountManagePanel(), GRID_CONSTRAINTS);
+        mainWindow.getAccountEditPanel().add(AccountEditForm.getInstance().getAccountEditPanel(), GRID_CONSTRAINTS);
+        mainWindow.getMessageEditPanel().add(MessageEditForm.getInstance().getMessageEditPanel(), GRID_CONSTRAINTS);
+        mainWindow.getMessageManagePanel().add(MessageManageForm.getInstance().getMessageManagePanel(), GRID_CONSTRAINTS);
+        mainWindow.getPeopleManagePanel().add(PeopleManageForm.getInstance().getPeopleManagePanel(), GRID_CONSTRAINTS);
+        mainWindow.getPeopleEditPanel().add(PeopleEditForm.getInstance().getMainPanel(), GRID_CONSTRAINTS);
+        mainWindow.getTaskPanel().add(TaskForm.getInstance().getMainPanel(), GRID_CONSTRAINTS);
+        mainWindow.getMessageTypePanel().add(MessageTypeForm.getInstance().getMessageTypePanel(), GRID_CONSTRAINTS);
         mainWindow.getMainPanel().updateUI();
     }
 
@@ -90,21 +101,31 @@ public void init() {
         tabbedPane.setTabLayoutPolicy(1);
         mainPanel.add(tabbedPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false));
         aboutPanel = new JPanel();
-        aboutPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
-        aboutPanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("关于", aboutPanel);
+        aboutPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        tabbedPane.addTab("WePush", aboutPanel);
         messageTypePanel = new JPanel();
         messageTypePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         messageTypePanel.setMinimumSize(new Dimension(-1, -1));
         tabbedPane.addTab("①选择消息类型", messageTypePanel);
+        accountPanel = new JSplitPane();
+        accountPanel.setContinuousLayout(true);
+        accountPanel.setDividerLocation(250);
+        accountPanel.setDividerSize(10);
+        tabbedPane.addTab("②设置账号", accountPanel);
+        accountManagePanel = new JPanel();
+        accountManagePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        accountPanel.setLeftComponent(accountManagePanel);
+        accountEditPanel = new JPanel();
+        accountEditPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        accountPanel.setRightComponent(accountEditPanel);
         messagePanel = new JSplitPane();
         messagePanel.setContinuousLayout(true);
         messagePanel.setDividerLocation(250);
-        messagePanel.setDividerSize(4);
+        messagePanel.setDividerSize(10);
         messagePanel.setDoubleBuffered(true);
-        messagePanel.setLastDividerLocation(250);
+        messagePanel.setLastDividerLocation(-1);
         messagePanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("②编辑消息", messagePanel);
+        tabbedPane.addTab("③编辑消息", messagePanel);
         messageEditPanel = new JPanel();
         messageEditPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         messageEditPanel.setMaximumSize(new Dimension(-1, -1));
@@ -117,35 +138,20 @@ public void init() {
         messageManagePanel.setMinimumSize(new Dimension(-1, -1));
         messageManagePanel.setPreferredSize(new Dimension(280, -1));
         messagePanel.setLeftComponent(messageManagePanel);
-        memberPanel = new JPanel();
-        memberPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
-        memberPanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("③准备目标用户", memberPanel);
-        pushPanel = new JPanel();
-        pushPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
-        pushPanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("④开始推送", pushPanel);
-        boostPanel = new JPanel();
-        boostPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
-        tabbedPane.addTab("性能模式", boostPanel);
-        pushHisPanel = new JPanel();
-        pushHisPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
-        pushHisPanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("推送历史", pushHisPanel);
-        schedulePanel = new JPanel();
-        schedulePanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
-        schedulePanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("计划任务", schedulePanel);
-        settingPanel = new JPanel();
-        settingPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
-        Font settingPanelFont = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, settingPanel.getFont());
-        if (settingPanelFont != null) settingPanel.setFont(settingPanelFont);
-        settingPanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("设置", settingPanel);
-        userCasePanel = new JPanel();
-        userCasePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 10, 0), -1, -1));
-        userCasePanel.setMinimumSize(new Dimension(-1, -1));
-        tabbedPane.addTab("他们都在用", userCasePanel);
+        peoplePanel = new JSplitPane();
+        peoplePanel.setContinuousLayout(true);
+        peoplePanel.setDividerLocation(250);
+        peoplePanel.setDividerSize(10);
+        tabbedPane.addTab("④准备目标人群", peoplePanel);
+        peopleManagePanel = new JPanel();
+        peopleManagePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        peoplePanel.setLeftComponent(peopleManagePanel);
+        peopleEditPanel = new JPanel();
+        peopleEditPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        peoplePanel.setRightComponent(peopleEditPanel);
+        taskPanel = new JPanel();
+        taskPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        tabbedPane.addTab("⑤推送任务", taskPanel);
     }
 
     /**
@@ -164,7 +170,10 @@ public void init() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
     /**
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.form
deleted file mode 100644
index 619b0b286..000000000
--- a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.form
+++ /dev/null
@@ -1,611 +0,0 @@
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.java deleted file mode 100644 index 55899d8d1..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.java +++ /dev/null @@ -1,438 +0,0 @@ -package com.fangxuele.tool.push.ui.form; - -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.PushData; -import com.fangxuele.tool.push.ui.listener.MemberListener; -import com.fangxuele.tool.push.util.UndoUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import lombok.Getter; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.util.ArrayList; -import java.util.Collections; - -/** - *
- * MemberForm
- * 
- * - * @author RememBerBer - * @since 2019/5/6. - */ -@Getter -public class MemberForm { - private JPanel memberPanelRight; - private JPanel memberTabUpPanel; - private JLabel memberTabCountLabel; - private JProgressBar memberTabImportProgressBar; - private JButton clearImportButton; - private JPanel memberTabDownPanel; - private JLabel importFromFileLabel; - private JTextField memberFilePathField; - private JButton importFromFileButton; - private JButton memberImportExploreButton; - private JPanel memberTabCenterPanel; - private JButton importFromSqlButton; - private JButton memberImportTagButton; - private JComboBox memberImportTagComboBox; - private JButton memberImportTagFreshButton; - private JButton memberImportTagRetainButton; - private JButton memberImportAllButton; - private JTable memberListTable; - private JPanel memberPanel; - private JButton selectAllButton; - private JButton importSelectedButton; - private JButton deleteButton; - private JTextField searchTextField; - private JButton searchButton; - private JButton exportButton; - private JPanel importFromWeixinPanel; - private JCheckBox importOptionOpenIdCheckBox; - private JCheckBox importOptionBasicInfoCheckBox; - private JCheckBox importOptionAvatarCheckBox; - private JPanel importOptionPanel; - private JButton clearDbCacheButton; - private JComboBox wxCpTagsComboBox; - private JPanel importFromWxCpPanel; - private JButton wxCpImportAllButton; - private JButton wxCpTagsRefreshButton; - private JButton wxCpTagsImportButton; - private JComboBox wxCpDeptsComboBox; - private JButton wxCpDeptsImportButton; - private JButton wxCpDeptsRefreshButton; - private JPanel importWayPanel; - private JTextArea importFromSqlTextArea; - private JScrollPane memberImportScrollPane; - private JPanel importFromNumPanel; - private JLabel 数量Label; - private JTextField importNumTextField; - private JButton importFromNumButton; - private JSplitPane splitPane; - private JButton dingImportAllButton; - private JPanel importFromDingPanel; - private JButton dingDeptsImportButton; - private JComboBox dingDeptsComboBox; - private JButton dingDeptsRefreshButton; - - private static MemberForm memberForm; - - private MemberForm() { - UndoUtil.register(this); - } - - public static MemberForm getInstance() { - if (memberForm == null) { - memberForm = new MemberForm(); - } - return memberForm; - } - - /** - * 初始化导入用户tab - */ - public static void init() { - memberForm = getInstance(); - - memberForm.getSplitPane().setDividerLocation((int) (App.mainFrame.getWidth() * 0.6)); - - memberForm.getMemberImportScrollPane().getVerticalScrollBar().setUnitIncrement(15); - memberForm.getMemberImportScrollPane().getVerticalScrollBar().setDoubleBuffered(true); - - memberForm.getMemberTabImportProgressBar().setVisible(false); - memberForm.getImportFromSqlTextArea().setText(App.config.getMemberSql()); - memberForm.getMemberFilePathField().setText(App.config.getMemberFilePath()); - - if ("Darcula(推荐)".equals(App.config.getTheme())) { - Color bgColor = new Color(43, 43, 43); - memberForm.getImportFromSqlTextArea().setBackground(bgColor); - Color foreColor = new Color(187, 187, 187); - memberForm.getImportFromSqlTextArea().setForeground(foreColor); - } - } - - /** - * 清除 - */ - public static void clearMember() { - memberForm = getInstance(); - - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - PushData.allUser.clear(); - memberForm.getMemberTabCountLabel().setText("0"); - - String[] headerNames = {"数据"}; - DefaultTableModel model = new DefaultTableModel(null, headerNames); - memberForm.getMemberListTable().setModel(model); - - MemberListener.tagUserSet = null; - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - memberPanel = new JPanel(); - memberPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - memberPanel.setMinimumSize(new Dimension(-1, -1)); - memberPanel.setOpaque(true); - memberPanel.setPreferredSize(new Dimension(-1, -1)); - splitPane = new JSplitPane(); - splitPane.setContinuousLayout(true); - splitPane.setDividerLocation(800); - splitPane.setDividerSize(4); - splitPane.setDoubleBuffered(true); - splitPane.setLastDividerLocation(800); - memberPanel.add(splitPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); - panel1.setMinimumSize(new Dimension(-1, -1)); - panel1.setPreferredSize(new Dimension(-1, -1)); - splitPane.setLeftComponent(panel1); - final JScrollPane scrollPane1 = new JScrollPane(); - panel1.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - memberListTable = new JTable(); - memberListTable.setGridColor(new Color(-12236470)); - memberListTable.setMinimumSize(new Dimension(30, 30)); - memberListTable.setRowHeight(36); - scrollPane1.setViewportView(memberListTable); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(1, 5, new Insets(5, 5, 5, 0), -1, -1)); - panel1.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - selectAllButton = new JButton(); - selectAllButton.setIcon(new ImageIcon(getClass().getResource("/icon/selectall_dark.png"))); - selectAllButton.setText("全选"); - panel2.add(selectAllButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importSelectedButton = new JButton(); - importSelectedButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - importSelectedButton.setText("导入"); - panel2.add(importSelectedButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - exportButton = new JButton(); - exportButton.setIcon(new ImageIcon(getClass().getResource("/icon/export_dark.png"))); - exportButton.setText("导出"); - panel2.add(exportButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - deleteButton = new JButton(); - deleteButton.setIcon(new ImageIcon(getClass().getResource("/icon/remove.png"))); - deleteButton.setText("删除"); - panel2.add(deleteButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - panel2.add(spacer1, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(1, 2, new Insets(5, 5, 0, 5), -1, -1)); - panel1.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - searchTextField = new JTextField(); - panel3.add(searchTextField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - searchButton = new JButton(); - searchButton.setIcon(new ImageIcon(getClass().getResource("/icon/find_dark.png"))); - searchButton.setText("搜索"); - panel3.add(searchButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel4 = new JPanel(); - panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - panel4.setMinimumSize(new Dimension(-1, -1)); - panel4.setPreferredSize(new Dimension(-1, -1)); - splitPane.setRightComponent(panel4); - memberPanelRight = new JPanel(); - memberPanelRight.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); - panel4.add(memberPanelRight, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - memberTabUpPanel = new JPanel(); - memberTabUpPanel.setLayout(new GridLayoutManager(2, 4, new Insets(0, 5, 5, 0), -1, -1)); - memberPanelRight.add(memberTabUpPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - memberTabCountLabel = new JLabel(); - Font memberTabCountLabelFont = this.$$$getFont$$$(null, -1, 72, memberTabCountLabel.getFont()); - if (memberTabCountLabelFont != null) memberTabCountLabel.setFont(memberTabCountLabelFont); - memberTabCountLabel.setForeground(new Color(-276358)); - memberTabCountLabel.setText("0"); - memberTabUpPanel.add(memberTabCountLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - memberTabImportProgressBar = new JProgressBar(); - memberTabUpPanel.add(memberTabImportProgressBar, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer2 = new Spacer(); - memberTabUpPanel.add(spacer2, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JLabel label1 = new JLabel(); - label1.setText("已导入"); - memberTabUpPanel.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - clearImportButton = new JButton(); - clearImportButton.setText("清除"); - memberTabUpPanel.add(clearImportButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - memberImportScrollPane = new JScrollPane(); - memberPanelRight.add(memberImportScrollPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - importWayPanel = new JPanel(); - importWayPanel.setLayout(new GridLayoutManager(7, 1, new Insets(8, 0, 0, 0), -1, -1)); - importWayPanel.setMinimumSize(new Dimension(-1, -1)); - importWayPanel.setPreferredSize(new Dimension(150, 600)); - memberImportScrollPane.setViewportView(importWayPanel); - memberTabDownPanel = new JPanel(); - memberTabDownPanel.setLayout(new GridLayoutManager(2, 3, new Insets(8, 15, 0, 5), -1, -1)); - importWayPanel.add(memberTabDownPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - memberTabDownPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "通过文件导入", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, memberTabDownPanel.getFont()), null)); - importFromFileLabel = new JLabel(); - importFromFileLabel.setHorizontalAlignment(11); - importFromFileLabel.setHorizontalTextPosition(4); - importFromFileLabel.setText("文件路径(*.txt,*.csv,*.xlsx)"); - memberTabDownPanel.add(importFromFileLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - memberFilePathField = new JTextField(); - memberTabDownPanel.add(memberFilePathField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - memberImportExploreButton = new JButton(); - memberImportExploreButton.setText("..."); - memberTabDownPanel.add(memberImportExploreButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importFromFileButton = new JButton(); - importFromFileButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - importFromFileButton.setText("导入"); - memberTabDownPanel.add(importFromFileButton, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - memberTabCenterPanel = new JPanel(); - memberTabCenterPanel.setLayout(new GridLayoutManager(2, 1, new Insets(8, 15, 0, 5), -1, -1)); - importWayPanel.add(memberTabCenterPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - memberTabCenterPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "通过SQL导入", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, memberTabCenterPanel.getFont()), null)); - importFromSqlButton = new JButton(); - importFromSqlButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - importFromSqlButton.setText("导入"); - memberTabCenterPanel.add(importFromSqlButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importFromSqlTextArea = new JTextArea(); - memberTabCenterPanel.add(importFromSqlTextArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(40, 50), null, 0, false)); - importFromWeixinPanel = new JPanel(); - importFromWeixinPanel.setLayout(new GridLayoutManager(4, 3, new Insets(0, 15, 0, 5), -1, -1)); - importWayPanel.add(importFromWeixinPanel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - importFromWeixinPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "通过微信公众平台导入", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, importFromWeixinPanel.getFont()), null)); - memberImportTagComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); - memberImportTagComboBox.setModel(defaultComboBoxModel1); - importFromWeixinPanel.add(memberImportTagComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - memberImportAllButton = new JButton(); - Font memberImportAllButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportAllButton.getFont()); - if (memberImportAllButtonFont != null) memberImportAllButton.setFont(memberImportAllButtonFont); - memberImportAllButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - memberImportAllButton.setText("导入所有关注公众号的用户"); - importFromWeixinPanel.add(memberImportAllButton, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - memberImportTagFreshButton = new JButton(); - Font memberImportTagFreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagFreshButton.getFont()); - if (memberImportTagFreshButtonFont != null) memberImportTagFreshButton.setFont(memberImportTagFreshButtonFont); - memberImportTagFreshButton.setIcon(new ImageIcon(getClass().getResource("/icon/refresh.png"))); - memberImportTagFreshButton.setText("刷新"); - importFromWeixinPanel.add(memberImportTagFreshButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - memberImportTagButton = new JButton(); - Font memberImportTagButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagButton.getFont()); - if (memberImportTagButtonFont != null) memberImportTagButton.setFont(memberImportTagButtonFont); - memberImportTagButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - memberImportTagButton.setText("导入选择的标签分组-取并集"); - importFromWeixinPanel.add(memberImportTagButton, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - memberImportTagRetainButton = new JButton(); - Font memberImportTagRetainButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagRetainButton.getFont()); - if (memberImportTagRetainButtonFont != null) - memberImportTagRetainButton.setFont(memberImportTagRetainButtonFont); - memberImportTagRetainButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - memberImportTagRetainButton.setText("导入选择的标签分组-取交集"); - importFromWeixinPanel.add(memberImportTagRetainButton, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("标签分组"); - importFromWeixinPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importFromWxCpPanel = new JPanel(); - importFromWxCpPanel.setLayout(new GridLayoutManager(3, 4, new Insets(8, 15, 0, 5), -1, -1)); - importWayPanel.add(importFromWxCpPanel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - importFromWxCpPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "通过企业通讯录导入", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, importFromWxCpPanel.getFont()), null)); - wxCpTagsComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); - wxCpTagsComboBox.setModel(defaultComboBoxModel2); - importFromWxCpPanel.add(wxCpTagsComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - wxCpDeptsComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel3 = new DefaultComboBoxModel(); - wxCpDeptsComboBox.setModel(defaultComboBoxModel3); - importFromWxCpPanel.add(wxCpDeptsComboBox, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - wxCpImportAllButton = new JButton(); - Font wxCpImportAllButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, wxCpImportAllButton.getFont()); - if (wxCpImportAllButtonFont != null) wxCpImportAllButton.setFont(wxCpImportAllButtonFont); - wxCpImportAllButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - wxCpImportAllButton.setText("导入通讯录中所有用户"); - importFromWxCpPanel.add(wxCpImportAllButton, new GridConstraints(2, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - wxCpTagsRefreshButton = new JButton(); - Font wxCpTagsRefreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, wxCpTagsRefreshButton.getFont()); - if (wxCpTagsRefreshButtonFont != null) wxCpTagsRefreshButton.setFont(wxCpTagsRefreshButtonFont); - wxCpTagsRefreshButton.setIcon(new ImageIcon(getClass().getResource("/icon/refresh.png"))); - wxCpTagsRefreshButton.setText("刷新"); - importFromWxCpPanel.add(wxCpTagsRefreshButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wxCpDeptsRefreshButton = new JButton(); - Font wxCpDeptsRefreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, wxCpDeptsRefreshButton.getFont()); - if (wxCpDeptsRefreshButtonFont != null) wxCpDeptsRefreshButton.setFont(wxCpDeptsRefreshButtonFont); - wxCpDeptsRefreshButton.setIcon(new ImageIcon(getClass().getResource("/icon/refresh.png"))); - wxCpDeptsRefreshButton.setText("刷新"); - importFromWxCpPanel.add(wxCpDeptsRefreshButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("按标签导入"); - importFromWxCpPanel.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("按部门导入"); - importFromWxCpPanel.add(label4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wxCpTagsImportButton = new JButton(); - wxCpTagsImportButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - wxCpTagsImportButton.setText("导入"); - importFromWxCpPanel.add(wxCpTagsImportButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wxCpDeptsImportButton = new JButton(); - wxCpDeptsImportButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - wxCpDeptsImportButton.setText("导入"); - importFromWxCpPanel.add(wxCpDeptsImportButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importFromDingPanel = new JPanel(); - importFromDingPanel.setLayout(new GridLayoutManager(2, 4, new Insets(8, 15, 0, 5), -1, -1)); - importWayPanel.add(importFromDingPanel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - importFromDingPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "通过钉钉通讯录导入", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, importFromDingPanel.getFont()), null)); - dingDeptsComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel4 = new DefaultComboBoxModel(); - dingDeptsComboBox.setModel(defaultComboBoxModel4); - importFromDingPanel.add(dingDeptsComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - dingImportAllButton = new JButton(); - Font dingImportAllButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, dingImportAllButton.getFont()); - if (dingImportAllButtonFont != null) dingImportAllButton.setFont(dingImportAllButtonFont); - dingImportAllButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - dingImportAllButton.setText("导入通讯录中所有用户"); - importFromDingPanel.add(dingImportAllButton, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - dingDeptsRefreshButton = new JButton(); - Font dingDeptsRefreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, dingDeptsRefreshButton.getFont()); - if (dingDeptsRefreshButtonFont != null) dingDeptsRefreshButton.setFont(dingDeptsRefreshButtonFont); - dingDeptsRefreshButton.setIcon(new ImageIcon(getClass().getResource("/icon/refresh.png"))); - dingDeptsRefreshButton.setText("刷新"); - importFromDingPanel.add(dingDeptsRefreshButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label5 = new JLabel(); - label5.setText("按部门导入"); - importFromDingPanel.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - dingDeptsImportButton = new JButton(); - dingDeptsImportButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - dingDeptsImportButton.setText("导入"); - importFromDingPanel.add(dingDeptsImportButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importOptionPanel = new JPanel(); - importOptionPanel.setLayout(new GridLayoutManager(1, 5, new Insets(0, 15, 0, 0), -1, -1)); - importWayPanel.add(importOptionPanel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - importOptionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-276358)), "导入选项", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, importOptionPanel.getFont()), new Color(-276358))); - importOptionOpenIdCheckBox = new JCheckBox(); - importOptionOpenIdCheckBox.setEnabled(false); - importOptionOpenIdCheckBox.setSelected(true); - importOptionOpenIdCheckBox.setText("openId"); - importOptionPanel.add(importOptionOpenIdCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer3 = new Spacer(); - importOptionPanel.add(spacer3, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - importOptionBasicInfoCheckBox = new JCheckBox(); - importOptionBasicInfoCheckBox.setText("昵称、性别等基本信息"); - importOptionBasicInfoCheckBox.setToolTipText("每获取一条信息会花费一次每日接口调用量"); - importOptionPanel.add(importOptionBasicInfoCheckBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importOptionAvatarCheckBox = new JCheckBox(); - importOptionAvatarCheckBox.setText("头像"); - importOptionAvatarCheckBox.setToolTipText("勾选会导致左侧列表甚至WePush变卡哦"); - importOptionPanel.add(importOptionAvatarCheckBox, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - clearDbCacheButton = new JButton(); - clearDbCacheButton.setText("清空本地缓存"); - importOptionPanel.add(clearDbCacheButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importFromNumPanel = new JPanel(); - importFromNumPanel.setLayout(new GridLayoutManager(1, 3, new Insets(8, 15, 0, 5), -1, -1)); - importWayPanel.add(importFromNumPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - importFromNumPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "没有变量,直接按数量发送", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, importFromNumPanel.getFont()), null)); - 数量Label = new JLabel(); - 数量Label.setHorizontalAlignment(11); - 数量Label.setHorizontalTextPosition(4); - 数量Label.setText("数量"); - importFromNumPanel.add(数量Label, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importNumTextField = new JTextField(); - importFromNumPanel.add(importNumTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - importFromNumButton = new JButton(); - importFromNumButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); - importFromNumButton.setText("导入"); - importFromNumPanel.add(importFromNumButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - } - - /** - * @noinspection ALL - */ - private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { - if (currentFont == null) return null; - String resultName; - if (fontName == null) { - resultName = currentFont.getName(); - } else { - Font testFont = new Font(fontName, Font.PLAIN, 10); - if (testFont.canDisplay('a') && testFont.canDisplay('1')) { - resultName = fontName; - } else { - resultName = currentFont.getName(); - } - } - return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return memberPanel; - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.form index 26171393b..0945ffc72 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.form @@ -9,7 +9,7 @@ - + @@ -21,7 +21,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -104,7 +104,6 @@ - @@ -113,7 +112,6 @@ - @@ -122,7 +120,6 @@ - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java index e9e93cf22..67f30761e 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java @@ -1,16 +1,18 @@ package com.fangxuele.tool.push.ui.form; -import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.ui.form.msg.*; import com.fangxuele.tool.push.util.UndoUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import lombok.Getter; -import org.apache.commons.lang3.StringUtils; import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.*; +import java.util.Locale; /** *
@@ -50,23 +52,17 @@ public static MessageEditForm getInstance() {
     /**
      * 初始化消息tab
      */
-    public static void init(String selectedMsgName) {
+    public static void init(Integer msgId) {
         messageEditForm = getInstance();
         // 设置滚动条速度
         messageEditForm.getMsgEditScrollPane().getVerticalScrollBar().setUnitIncrement(15);
         messageEditForm.getMsgEditScrollPane().getVerticalScrollBar().setDoubleBuffered(true);
 
-        String msgName;
-        if (StringUtils.isEmpty(selectedMsgName)) {
-            msgName = App.config.getMsgName();
-        } else {
-            msgName = selectedMsgName;
-        }
+        MsgFormFactory.getMsgForm().init(msgId);
 
-        messageEditForm.getMsgNameField().setText(msgName);
-        messageEditForm.getPreviewUserField().setText(App.config.getPreviewUser());
-
-        MsgFormFactory.getMsgForm().init(msgName);
+        messageEditForm.getMsgSaveButton().setIcon(new FlatSVGIcon("icon/save.svg"));
+        messageEditForm.getPreviewMsgButton().setIcon(new FlatSVGIcon("icon/send.svg"));
+        messageEditForm.getPreviewUserHelpLabel().setIcon(new FlatSVGIcon("icon/help.svg"));
     }
 
     /**
@@ -80,14 +76,14 @@ public static void switchMsgType(int msgType) {
         GridConstraints gridConstraintsRow0 = new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false);
         GridConstraints gridConstraintsRow1 = new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false);
 
-        MsgFormFactory.getMsgForm().init(null);
         switch (msgType) {
             case MessageTypeEnum.MP_TEMPLATE_CODE:
                 messageEditForm.getMsgEditorPanel().add(MpTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
                 break;
-            case MessageTypeEnum.MA_TEMPLATE_CODE:
-                messageEditForm.getMsgEditorPanel().add(MaTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
+            case MessageTypeEnum.MP_SUBSCRIBE_CODE:
+                messageEditForm.getMsgEditorPanel().add(MpSubscribeMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
                 break;
+            case MessageTypeEnum.MA_TEMPLATE_CODE:
             case MessageTypeEnum.MA_SUBSCRIBE_CODE:
                 messageEditForm.getMsgEditorPanel().add(MaSubscribeMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
                 break;
@@ -101,7 +97,7 @@ public static void switchMsgType(int msgType) {
                 break;
             case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE:
                 messageEditForm.getMsgEditorPanel().setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
-                messageEditForm.getMsgEditorPanel().add(MaTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
+                messageEditForm.getMsgEditorPanel().add(MaSubscribeMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
                 messageEditForm.getMsgEditorPanel().add(MpTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow1);
                 break;
             case MessageTypeEnum.ALI_YUN_CODE:
@@ -110,6 +106,9 @@ public static void switchMsgType(int msgType) {
             case MessageTypeEnum.TX_YUN_CODE:
                 messageEditForm.getMsgEditorPanel().add(TxYunMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
                 break;
+            case MessageTypeEnum.TX_YUN_3_CODE:
+                messageEditForm.getMsgEditorPanel().add(TxYun3MsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
+                break;
             case MessageTypeEnum.QI_NIU_YUN_CODE:
                 messageEditForm.getMsgEditorPanel().add(QiNiuYunMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0);
                 break;
@@ -140,6 +139,10 @@ public static void switchMsgType(int msgType) {
             default:
                 break;
         }
+
+        messageEditForm.getMsgSaveButton().setIcon(new FlatSVGIcon("icon/save.svg"));
+        messageEditForm.getPreviewMsgButton().setIcon(new FlatSVGIcon("icon/send.svg"));
+        messageEditForm.getPreviewUserHelpLabel().setIcon(new FlatSVGIcon("icon/help.svg"));
     }
 
     {
@@ -160,16 +163,16 @@ public static void switchMsgType(int msgType) {
         final JPanel panel1 = new JPanel();
         panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         messageEditPanel = new JPanel();
-        messageEditPanel.setLayout(new GridLayoutManager(3, 1, new Insets(6, 2, 0, 5), -1, -1));
+        messageEditPanel.setLayout(new GridLayoutManager(3, 1, new Insets(10, 0, 10, 10), -1, -1));
         messageEditPanel.setMaximumSize(new Dimension(-1, -1));
         messageEditPanel.setMinimumSize(new Dimension(-1, -1));
         messageEditPanel.setPreferredSize(new Dimension(-1, -1));
         panel1.add(messageEditPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         final JPanel panel2 = new JPanel();
-        panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 5, 10, 5), -1, -1));
+        panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
         messageEditPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         final JPanel panel3 = new JPanel();
-        panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 10, 0), -1, -1));
+        panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         panel2.add(panel3, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         msgTypeName = new JLabel();
         Font msgTypeNameFont = this.$$$getFont$$$(null, -1, 28, msgTypeName.getFont());
@@ -187,7 +190,7 @@ public static void switchMsgType(int msgType) {
         msgNameField.setToolTipText("给本次推送任务起个名字");
         panel2.add(msgNameField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         final JPanel panel4 = new JPanel();
-        panel4.setLayout(new GridLayoutManager(1, 5, new Insets(0, 5, 5, 5), -1, -1));
+        panel4.setLayout(new GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1));
         messageEditPanel.add(panel4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         previewMemberLabel = new JLabel();
         previewMemberLabel.setText("预览用户");
@@ -197,15 +200,12 @@ public static void switchMsgType(int msgType) {
         previewUserField.setToolTipText("多个以半角分号分隔");
         panel4.add(previewUserField, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         previewMsgButton = new JButton();
-        previewMsgButton.setIcon(new ImageIcon(getClass().getResource("/icon/send.png")));
         previewMsgButton.setText("预览");
         panel4.add(previewMsgButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         msgSaveButton = new JButton();
-        msgSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png")));
         msgSaveButton.setText("保存");
         panel4.add(msgSaveButton, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         previewUserHelpLabel = new JLabel();
-        previewUserHelpLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png")));
         previewUserHelpLabel.setText("");
         panel4.add(previewUserHelpLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         msgEditScrollPane = new JScrollPane();
@@ -233,7 +233,10 @@ public static void switchMsgType(int msgType) {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.form
index f87cf3e2c..ed149b965 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.form
@@ -8,8 +8,8 @@
     
     
     
-      
-        
+      
+        
         
           
         
@@ -22,7 +22,7 @@
         
           
             
-              
+              
             
             
             
@@ -38,9 +38,9 @@
             
           
           
-            
+            
             
-              
+              
             
             
             
@@ -50,7 +50,6 @@
                   
                 
                 
-                  
                   
                 
               
@@ -65,12 +64,27 @@
                 
                 
                   
-                  
                   
                 
               
             
           
+          
+            
+            
+              
+            
+            
+            
+            
+              
+                
+                  
+                
+                
+              
+            
+          
         
       
     
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java
index 4ff951689..3ae61bfd6 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java
@@ -1,31 +1,15 @@
 package com.fangxuele.tool.push.ui.form;
 
 import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.dao.TMsgDingMapper;
-import com.fangxuele.tool.push.dao.TMsgHttpMapper;
-import com.fangxuele.tool.push.dao.TMsgKefuMapper;
-import com.fangxuele.tool.push.dao.TMsgKefuPriorityMapper;
-import com.fangxuele.tool.push.dao.TMsgMaSubscribeMapper;
-import com.fangxuele.tool.push.dao.TMsgMaTemplateMapper;
-import com.fangxuele.tool.push.dao.TMsgMailMapper;
-import com.fangxuele.tool.push.dao.TMsgMpTemplateMapper;
-import com.fangxuele.tool.push.dao.TMsgSmsMapper;
-import com.fangxuele.tool.push.dao.TMsgWxCpMapper;
-import com.fangxuele.tool.push.dao.TMsgWxUniformMapper;
-import com.fangxuele.tool.push.domain.TMsgDing;
-import com.fangxuele.tool.push.domain.TMsgHttp;
-import com.fangxuele.tool.push.domain.TMsgKefu;
-import com.fangxuele.tool.push.domain.TMsgKefuPriority;
-import com.fangxuele.tool.push.domain.TMsgMaSubscribe;
-import com.fangxuele.tool.push.domain.TMsgMaTemplate;
-import com.fangxuele.tool.push.domain.TMsgMail;
-import com.fangxuele.tool.push.domain.TMsgMpTemplate;
-import com.fangxuele.tool.push.domain.TMsgSms;
-import com.fangxuele.tool.push.domain.TMsgWxCp;
-import com.fangxuele.tool.push.domain.TMsgWxUniform;
-import com.fangxuele.tool.push.logic.MessageTypeEnum;
+import com.fangxuele.tool.push.dao.TAccountMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TAccount;
+import com.fangxuele.tool.push.domain.TMsg;
+import com.fangxuele.tool.push.ui.form.msg.MsgFormFactory;
 import com.fangxuele.tool.push.util.JTableUtil;
 import com.fangxuele.tool.push.util.MybatisUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
+import com.google.common.collect.Maps;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import com.intellij.uiDesigner.core.Spacer;
@@ -35,6 +19,7 @@
 import javax.swing.table.DefaultTableModel;
 import java.awt.*;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 
@@ -51,20 +36,18 @@ public class MessageManageForm {
     private JTable msgHistable;
     private JButton msgHisTableDeleteButton;
     private JButton createMsgButton;
+    private JComboBox accountComboBox;
+    private JPanel panel1;
 
     private static MessageManageForm messageManageForm;
 
-    private static TMsgKefuMapper msgKefuMapper = MybatisUtil.getSqlSession().getMapper(TMsgKefuMapper.class);
-    private static TMsgKefuPriorityMapper msgKefuPriorityMapper = MybatisUtil.getSqlSession().getMapper(TMsgKefuPriorityMapper.class);
-    private static TMsgWxUniformMapper wxUniformMapper = MybatisUtil.getSqlSession().getMapper(TMsgWxUniformMapper.class);
-    private static TMsgMaTemplateMapper msgMaTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaTemplateMapper.class);
-    private static TMsgMaSubscribeMapper msgMaSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaSubscribeMapper.class);
-    private static TMsgMpTemplateMapper msgMpTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpTemplateMapper.class);
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
-    private static TMsgMailMapper msgMailMapper = MybatisUtil.getSqlSession().getMapper(TMsgMailMapper.class);
-    private static TMsgWxCpMapper msgWxCpMapper = MybatisUtil.getSqlSession().getMapper(TMsgWxCpMapper.class);
-    private static TMsgHttpMapper msgHttpMapper = MybatisUtil.getSqlSession().getMapper(TMsgHttpMapper.class);
-    private static TMsgDingMapper msgDingMapper = MybatisUtil.getSqlSession().getMapper(TMsgDingMapper.class);
+    public static Map accountMap;
+
+    private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class);
+
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
+
+    public static boolean accountSwitchComboBoxListenIgnore = false;
 
     private MessageManageForm() {
     }
@@ -81,8 +64,34 @@ public static MessageManageForm getInstance() {
      */
     public static void init() {
         messageManageForm = getInstance();
+
+        messageManageForm.getCreateMsgButton().setIcon(new FlatSVGIcon("icon/add.svg"));
+        messageManageForm.getMsgHisTableDeleteButton().setIcon(new FlatSVGIcon("icon/remove.svg"));
+
+        initAccountComboBox();
+
+        initMessageList();
+
+        MessageEditForm.getInstance().getMsgNameField().setText("");
+        MsgFormFactory.getMsgForm().clearAllField();
+    }
+
+    private static void initAccountComboBox() {
+        accountMap = Maps.newHashMap();
+        messageManageForm.getAccountComboBox().removeAllItems();
+        int msgType = App.config.getMsgType();
+        List tAccountList = accountMapper.selectByMsgType(msgType);
+        for (TAccount tAccount : tAccountList) {
+            String accountName = tAccount.getAccountName();
+            Integer accountId = tAccount.getId();
+            messageManageForm.getAccountComboBox().addItem(accountName);
+            accountMap.put(accountName, accountId);
+        }
+    }
+
+    public static void initMessageList() {
         // 历史消息管理
-        String[] headerNames = {"消息名称"};
+        String[] headerNames = {"消息名称", "ID"};
         DefaultTableModel model = new DefaultTableModel(null, headerNames);
         messageManageForm.getMsgHistable().setModel(model);
         // 隐藏表头
@@ -90,86 +99,22 @@ public static void init() {
 
         int msgType = App.config.getMsgType();
 
+        String selectedAccountName = (String) messageManageForm.getAccountComboBox().getSelectedItem();
+        Integer selectedAccountId = accountMap.get(selectedAccountName);
+
         Object[] data;
 
-        if (msgType == MessageTypeEnum.KEFU_CODE) {
-            List tMsgKefuList = msgKefuMapper.selectByMsgType(msgType);
-            for (TMsgKefu tMsgKefu : tMsgKefuList) {
-                data = new Object[1];
-                data[0] = tMsgKefu.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.KEFU_PRIORITY_CODE) {
-            List tMsgKefuPriorityList = msgKefuPriorityMapper.selectByMsgType(msgType);
-            for (TMsgKefuPriority tMsgKefuPriority : tMsgKefuPriorityList) {
-                data = new Object[1];
-                data[0] = tMsgKefuPriority.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE) {
-            List tMsgWxUniformList = wxUniformMapper.selectByMsgType(msgType);
-            for (TMsgWxUniform tMsgWxUniform : tMsgWxUniformList) {
-                data = new Object[1];
-                data[0] = tMsgWxUniform.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.MA_TEMPLATE_CODE) {
-            List tMsgMaTemplateList = msgMaTemplateMapper.selectByMsgType(msgType);
-            for (TMsgMaTemplate tMsgMaTemplate : tMsgMaTemplateList) {
-                data = new Object[1];
-                data[0] = tMsgMaTemplate.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) {
-            List tMsgMaSubscribeList = msgMaSubscribeMapper.selectByMsgType(msgType);
-            for (TMsgMaSubscribe tMsgMaSubscribe : tMsgMaSubscribeList) {
-                data = new Object[1];
-                data[0] = tMsgMaSubscribe.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE) {
-            List tMsgMpTemplateList = msgMpTemplateMapper.selectByMsgType(msgType);
-            for (TMsgMpTemplate tMsgMpTemplate : tMsgMpTemplateList) {
-                data = new Object[1];
-                data[0] = tMsgMpTemplate.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.EMAIL_CODE) {
-            List tMsgMailList = msgMailMapper.selectByMsgType(msgType);
-            for (TMsgMail tMsgMail : tMsgMailList) {
-                data = new Object[1];
-                data[0] = tMsgMail.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.WX_CP_CODE) {
-            List tMsgWxCpList = msgWxCpMapper.selectByMsgType(msgType);
-            for (TMsgWxCp tMsgWxCp : tMsgWxCpList) {
-                data = new Object[1];
-                data[0] = tMsgWxCp.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.HTTP_CODE) {
-            List tMsgHttpList = msgHttpMapper.selectByMsgType(msgType);
-            for (TMsgHttp tMsgHttp : tMsgHttpList) {
-                data = new Object[1];
-                data[0] = tMsgHttp.getMsgName();
-                model.addRow(data);
-            }
-        } else if (msgType == MessageTypeEnum.DING_CODE) {
-            List tMsgDingList = msgDingMapper.selectByMsgType(msgType);
-            for (TMsgDing tMsgDing : tMsgDingList) {
-                data = new Object[1];
-                data[0] = tMsgDing.getMsgName();
-                model.addRow(data);
-            }
-        } else {
-            List tMsgSmsList = msgSmsMapper.selectByMsgType(msgType);
-            for (TMsgSms tMsgSms : tMsgSmsList) {
-                data = new Object[1];
-                data[0] = tMsgSms.getMsgName();
-                model.addRow(data);
-            }
+        List tMsgList = msgMapper.selectByMsgTypeAndAccountId(msgType, selectedAccountId);
+        for (TMsg tMsg : tMsgList) {
+            data = new Object[2];
+            data[0] = tMsg.getMsgName();
+            data[1] = tMsg.getId();
+            model.addRow(data);
         }
+
+        // 隐藏id列
+        JTableUtil.hideColumn(messageManageForm.getMsgHistable(), 1);
+
     }
 
     {
@@ -187,34 +132,37 @@ public static void init() {
      * @noinspection ALL
      */
     private void $$$setupUI$$$() {
-        final JPanel panel1 = new JPanel();
-        panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        final JPanel panel2 = new JPanel();
+        panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         messageManagePanel = new JPanel();
-        messageManagePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
+        messageManagePanel.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 0), -1, -1));
         messageManagePanel.setMaximumSize(new Dimension(-1, -1));
         messageManagePanel.setMinimumSize(new Dimension(-1, -1));
         messageManagePanel.setPreferredSize(new Dimension(280, -1));
-        panel1.add(messageManagePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+        panel2.add(messageManagePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         final JScrollPane scrollPane1 = new JScrollPane();
-        messageManagePanel.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+        messageManagePanel.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
         msgHistable = new JTable();
         msgHistable.setGridColor(new Color(-12236470));
         msgHistable.setRowHeight(36);
         msgHistable.setShowVerticalLines(false);
         scrollPane1.setViewportView(msgHistable);
-        final JPanel panel2 = new JPanel();
-        panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 5, 5, 0), -1, -1));
-        messageManagePanel.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+        final JPanel panel3 = new JPanel();
+        panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
+        messageManagePanel.add(panel3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         msgHisTableDeleteButton = new JButton();
-        msgHisTableDeleteButton.setIcon(new ImageIcon(getClass().getResource("/icon/remove.png")));
         msgHisTableDeleteButton.setText("删除");
-        panel2.add(msgHisTableDeleteButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel3.add(msgHisTableDeleteButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final Spacer spacer1 = new Spacer();
-        panel2.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
+        panel3.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
         createMsgButton = new JButton();
         createMsgButton.setEnabled(true);
-        createMsgButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         createMsgButton.setText("新建");
-        panel2.add(createMsgButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel3.add(createMsgButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel1 = new JPanel();
+        panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+        messageManagePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+        accountComboBox = new JComboBox();
+        panel1.add(accountComboBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form
index 0a61b8c9e..61978af88 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form
@@ -1,9 +1,9 @@
 
 
- - + + - + @@ -17,10 +17,10 @@ - + - - + + @@ -36,10 +36,19 @@ - + + + + + + + + + + @@ -47,7 +56,7 @@ - + @@ -55,7 +64,7 @@ - + @@ -63,7 +72,7 @@ - + @@ -72,7 +81,7 @@ - + @@ -80,15 +89,23 @@ - + + + + + + + + + - + @@ -96,7 +113,7 @@ - + @@ -105,7 +122,7 @@ - + @@ -114,7 +131,7 @@ - + @@ -123,7 +140,7 @@ - + @@ -132,7 +149,7 @@ - + @@ -141,16 +158,15 @@ - + - - + @@ -159,7 +175,7 @@ - + @@ -182,7 +198,7 @@ - + @@ -191,7 +207,7 @@ - + @@ -200,7 +216,7 @@ - + @@ -209,7 +225,7 @@ - + @@ -218,7 +234,7 @@ - + @@ -227,7 +243,7 @@ - + @@ -237,8 +253,8 @@ - - + + @@ -247,7 +263,7 @@ - + @@ -255,14 +271,25 @@ - + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java index 734aa7655..9d09bcebe 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java @@ -2,12 +2,14 @@ import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.logic.MessageTypeEnum; +import com.formdev.flatlaf.extras.FlatSVGIcon; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; import lombok.Getter; import javax.swing.*; +import javax.swing.border.TitledBorder; import java.awt.*; /** @@ -46,6 +48,8 @@ public class MessageTypeForm { private JRadioButton bdYunRadioButton; private JRadioButton wxUniformMessageRadioButton; private JRadioButton maSubscribeRadioButton; + private JRadioButton mpSubscribeRadioButton; + private JRadioButton txYun3RadioButton; private static MessageTypeForm messageTypeForm; @@ -75,6 +79,9 @@ public static void init() { case MessageTypeEnum.MP_TEMPLATE_CODE: messageTypeForm.getMpTemplateRadioButton().setSelected(true); break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + messageTypeForm.getMpSubscribeRadioButton().setSelected(true); + break; case MessageTypeEnum.MA_TEMPLATE_CODE: messageTypeForm.getMaTemplateRadioButton().setSelected(true); break; @@ -123,17 +130,24 @@ public static void init() { case MessageTypeEnum.BD_YUN_CODE: messageTypeForm.getBdYunRadioButton().setSelected(true); break; + case MessageTypeEnum.TX_YUN_3_CODE: + messageTypeForm.getTxYun3RadioButton().setSelected(true); + break; default: } + AccountEditForm.switchMainPanel(); + AccountManageForm.init(); + AccountEditForm.init(null); initMessageEditFormLayOut(msgType); - initMemberFormLayOut(msgType); MessageEditForm.switchMsgType(msgType); MessageEditForm.getInstance().getMsgTypeName().setText(MessageTypeEnum.getName(msgType)); MessageManageForm.init(); - MemberForm.init(); - PushHisForm.init(); - ScheduleForm.init(); + MessageEditForm.getInstance().getMsgNameField().setText(""); + PeopleManageForm.init(); + PeopleEditForm.init(null); + + messageTypeForm.getKefuPriorityTipsLabel().setIcon(new FlatSVGIcon("icon/help.svg")); } private static void initMessageEditFormLayOut(int msgType) { @@ -146,38 +160,6 @@ private static void initMessageEditFormLayOut(int msgType) { } } - private static void initMemberFormLayOut(int msgType) { - Component[] components = MemberForm.getInstance().getImportWayPanel().getComponents(); - for (Component component : components) { - if (component instanceof JPanel) { - component.setVisible(false); - } - } - MemberForm.getInstance().getMemberTabDownPanel().setVisible(true); - MemberForm.getInstance().getMemberTabCenterPanel().setVisible(true); - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.MA_TEMPLATE_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { - MemberForm.getInstance().getImportFromWeixinPanel().setVisible(true); - MemberForm.getInstance().getImportOptionPanel().setVisible(true); - } - if (msgType == MessageTypeEnum.WX_CP_CODE) { - MemberForm.getInstance().getImportFromWxCpPanel().setVisible(true); - } - if (msgType == MessageTypeEnum.DING_CODE) { - MemberForm.getInstance().getImportFromDingPanel().setVisible(true); - } - - if (msgType == MessageTypeEnum.HTTP_CODE) { - MainWindow.getInstance().getTabbedPane().setTitleAt(3, "③准备消息变量"); - MemberForm.getInstance().getImportFromNumPanel().setVisible(true); - PushForm.getInstance().getSaveResponseBodyCheckBox().setVisible(true); - } else { - MainWindow.getInstance().getTabbedPane().setTitleAt(3, "③准备目标用户"); - PushForm.getInstance().getSaveResponseBodyCheckBox().setVisible(false); - } - } - /** * 清除所有radio选中状态 */ @@ -208,74 +190,81 @@ public static void clearAllSelected() { */ private void $$$setupUI$$$() { messageTypePanel = new JPanel(); - messageTypePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + messageTypePanel.setLayout(new GridLayoutManager(2, 2, new Insets(10, 10, 10, 10), -1, -1)); messageTypePanel.setAutoscrolls(false); messageTypeScrollPane = new JScrollPane(); messageTypeScrollPane.setAutoscrolls(true); messageTypePanel.add(messageTypeScrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + messageTypeScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); msgTypeListPanel = new JPanel(); - msgTypeListPanel.setLayout(new GridLayoutManager(22, 3, new Insets(20, 20, 0, 0), -1, -1)); + msgTypeListPanel.setLayout(new GridLayoutManager(24, 3, new Insets(10, 0, 0, 0), -1, -1)); msgTypeListPanel.setAutoscrolls(true); messageTypeScrollPane.setViewportView(msgTypeListPanel); mpTemplateRadioButton = new JRadioButton(); mpTemplateRadioButton.setEnabled(true); mpTemplateRadioButton.setText("公众号-模板消息"); msgTypeListPanel.add(mpTemplateRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpSubscribeRadioButton = new JRadioButton(); + mpSubscribeRadioButton.setEnabled(true); + mpSubscribeRadioButton.setText("公众号-订阅通知"); + msgTypeListPanel.add(mpSubscribeRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); maTemplateRadioButton = new JRadioButton(); maTemplateRadioButton.setEnabled(false); maTemplateRadioButton.setText("小程序-模板消息"); - msgTypeListPanel.add(maTemplateRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(maTemplateRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); maSubscribeRadioButton = new JRadioButton(); maSubscribeRadioButton.setText("小程序-订阅消息"); - msgTypeListPanel.add(maSubscribeRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(maSubscribeRadioButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); kefuRadioButton = new JRadioButton(); kefuRadioButton.setText("公众号-客服消息"); - msgTypeListPanel.add(kefuRadioButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(kefuRadioButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); kefuPriorityRadioButton = new JRadioButton(); kefuPriorityRadioButton.setText("公众号-客服消息优先"); kefuPriorityRadioButton.setToolTipText("优先尝试发送客服消息,如果失败则发送模板消息"); - msgTypeListPanel.add(kefuPriorityRadioButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(kefuPriorityRadioButton, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); aliYunRadioButton = new JRadioButton(); aliYunRadioButton.setText("阿里云短信"); - msgTypeListPanel.add(aliYunRadioButton, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(aliYunRadioButton, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); txYunRadioButton = new JRadioButton(); txYunRadioButton.setText("腾讯云短信"); - msgTypeListPanel.add(txYunRadioButton, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(txYunRadioButton, new GridConstraints(11, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + txYun3RadioButton = new JRadioButton(); + txYun3RadioButton.setText("腾讯云短信3.0"); + msgTypeListPanel.add(txYun3RadioButton, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); yunPianRadioButton = new JRadioButton(); yunPianRadioButton.setText("云片网短信"); - msgTypeListPanel.add(yunPianRadioButton, new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(yunPianRadioButton, new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 网易云信短信RadioButton = new JRadioButton(); 网易云信短信RadioButton.setEnabled(false); 网易云信短信RadioButton.setText("网易云信短信"); - msgTypeListPanel.add(网易云信短信RadioButton, new GridConstraints(17, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(网易云信短信RadioButton, new GridConstraints(19, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 榛子云短信RadioButton = new JRadioButton(); 榛子云短信RadioButton.setEnabled(false); 榛子云短信RadioButton.setText("榛子云短信"); - msgTypeListPanel.add(榛子云短信RadioButton, new GridConstraints(18, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(榛子云短信RadioButton, new GridConstraints(20, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); luosimao短信RadioButton = new JRadioButton(); luosimao短信RadioButton.setEnabled(false); luosimao短信RadioButton.setText("Luosimao短信"); - msgTypeListPanel.add(luosimao短信RadioButton, new GridConstraints(19, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(luosimao短信RadioButton, new GridConstraints(21, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 极光短信RadioButton = new JRadioButton(); 极光短信RadioButton.setEnabled(false); 极光短信RadioButton.setText("极光短信"); - msgTypeListPanel.add(极光短信RadioButton, new GridConstraints(20, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(极光短信RadioButton, new GridConstraints(22, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 极光推送RadioButton = new JRadioButton(); 极光推送RadioButton.setEnabled(false); 极光推送RadioButton.setText("极光推送"); - msgTypeListPanel.add(极光推送RadioButton, new GridConstraints(21, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(极光推送RadioButton, new GridConstraints(23, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); kefuPriorityTipsLabel = new JLabel(); - kefuPriorityTipsLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); kefuPriorityTipsLabel.setText(""); - msgTypeListPanel.add(kefuPriorityTipsLabel, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(kefuPriorityTipsLabel, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); eMailRadioButton = new JRadioButton(); eMailRadioButton.setEnabled(true); eMailRadioButton.setText("E-Mail(BETA)"); - msgTypeListPanel.add(eMailRadioButton, new GridConstraints(16, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(eMailRadioButton, new GridConstraints(18, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); wxCpRadioButton = new JRadioButton(); wxCpRadioButton.setEnabled(true); wxCpRadioButton.setText("企业号/企业微信"); - msgTypeListPanel.add(wxCpRadioButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(wxCpRadioButton, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); httpRadioButton = new JRadioButton(); httpRadioButton.setEnabled(true); httpRadioButton.setText("HTTP请求"); @@ -285,35 +274,39 @@ public static void clearAllSelected() { dingRadioButton = new JRadioButton(); dingRadioButton.setEnabled(true); dingRadioButton.setText("钉钉"); - msgTypeListPanel.add(dingRadioButton, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(dingRadioButton, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); hwYunRadioButton = new JRadioButton(); hwYunRadioButton.setEnabled(true); hwYunRadioButton.setText("华为云短信(BETA)"); - msgTypeListPanel.add(hwYunRadioButton, new GridConstraints(11, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(hwYunRadioButton, new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); bdYunRadioButton = new JRadioButton(); bdYunRadioButton.setEnabled(true); bdYunRadioButton.setText("百度云短信(BETA)"); - msgTypeListPanel.add(bdYunRadioButton, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(bdYunRadioButton, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); upYunRadioButton = new JRadioButton(); upYunRadioButton.setEnabled(true); upYunRadioButton.setText("又拍云短信(BETA)"); - msgTypeListPanel.add(upYunRadioButton, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(upYunRadioButton, new GridConstraints(16, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); qiniuRadioButton = new JRadioButton(); qiniuRadioButton.setEnabled(true); qiniuRadioButton.setText("七牛云短信(BETA)"); - msgTypeListPanel.add(qiniuRadioButton, new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(qiniuRadioButton, new GridConstraints(17, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); wxUniformMessageRadioButton = new JRadioButton(); wxUniformMessageRadioButton.setText("小程序-统一服务消息(BETA)"); - msgTypeListPanel.add(wxUniformMessageRadioButton, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(wxUniformMessageRadioButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(2, 1, new Insets(8, 8, 8, 0), -1, -1)); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(10, 0, 0, 0), -1, -1)); messageTypePanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("WePush目前仅是各类消息官方SDK的一种实现,"); - panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label2 = new JLabel(); label2.setText("使用前请仔细查看该消息平台官网的使用规则和开发文档,尤其是发送频率限制等,避免造成不必要的麻烦"); - panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel1.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JSeparator separator1 = new JSeparator(); + panel1.add(separator1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + messageTypePanel.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); } /** diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PeopleEditForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleEditForm.form new file mode 100644 index 000000000..4820a01bd --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleEditForm.form @@ -0,0 +1,210 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PeopleEditForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleEditForm.java new file mode 100644 index 000000000..473abd670 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleEditForm.java @@ -0,0 +1,279 @@ +package com.fangxuele.tool.push.ui.form; + +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleImportConfigMapper; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.domain.TPeopleImportConfig; +import com.fangxuele.tool.push.logic.MessageTypeEnum; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.ui.listener.PeopleManageListener; +import com.fangxuele.tool.push.util.JTableUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.util.List; + +/** + * PeopleEditForm + */ +@Getter +public class PeopleEditForm { + private JPanel mainPanel; + private JTextField searchTextField; + private JButton searchButton; + private JTable memberListTable; + private JButton clearAllButton; + private JButton importButton; + private JButton exportButton; + private JButton deleteButton; + private JPanel memberTabUpPanel; + private JProgressBar memberTabImportProgressBar; + private JLabel memberTabCountLabel; + private JLabel peopleNameLabel; + private JLabel peopleAccountLabel; + private JLabel peopleMsgTypeLabel; + private JLabel lastImportWayLabel; + + private static PeopleEditForm peopleEditForm; + + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + private static TPeopleImportConfigMapper peopleImportConfigMapper = MybatisUtil.getSqlSession().getMapper(TPeopleImportConfigMapper.class); + + private PeopleEditForm() { + UndoUtil.register(this); + } + + public static PeopleEditForm getInstance() { + if (peopleEditForm == null) { + peopleEditForm = new PeopleEditForm(); + peopleEditForm.getClearAllButton().setIcon(new FlatSVGIcon("icon/clear.svg")); + peopleEditForm.getDeleteButton().setIcon(new FlatSVGIcon("icon/remove.svg")); + peopleEditForm.getImportButton().setIcon(new FlatSVGIcon("icon/import.svg")); + peopleEditForm.getExportButton().setIcon(new FlatSVGIcon("icon/export.svg")); + peopleEditForm.getSearchButton().setIcon(new FlatSVGIcon("icon/find.svg")); + } + return peopleEditForm; + } + + /** + * 初始化tab + */ + public static void init(String selectedPeopleName) { + peopleEditForm = getInstance(); + peopleEditForm.getMemberTabImportProgressBar().setVisible(false); + + // 设置滚动条速度 +// peopleEditForm.getAccountEditScrollPane().getVerticalScrollBar().setUnitIncrement(15); +// peopleEditForm.getAccountEditScrollPane().getVerticalScrollBar().setDoubleBuffered(true); + clearAll(); + } + + /** + * 初始化人群数据列表 + * + * @param peopleId + */ + public static void initDataTable(int peopleId) { + + // -----init Info + + TPeople tPeople = peopleMapper.selectByPrimaryKey(peopleId); + if (tPeople != null) { + // peopleName + String peopleName = tPeople.getPeopleName(); + peopleEditForm.getPeopleNameLabel().setText(peopleName); + + // count + Long totalCount = peopleDataMapper.countByPeopleId(peopleId); + if (totalCount != null) { + peopleEditForm.getMemberTabCountLabel().setText(String.valueOf(totalCount)); + } + + // account + Integer accountId = tPeople.getAccountId(); + TAccount tAccount = accountMapper.selectByPrimaryKey(accountId); + if (tAccount != null) { + peopleEditForm.getPeopleAccountLabel().setText(tAccount.getAccountName()); + } + + // msgType + Integer msgType = tPeople.getMsgType(); + String msgTypeName = MessageTypeEnum.getName(msgType); + peopleEditForm.getPeopleMsgTypeLabel().setText(msgTypeName); + + // 上一次导入方式 + TPeopleImportConfig tPeopleImportConfig = peopleImportConfigMapper.selectByPeopleId(peopleId); + if (tPeopleImportConfig != null) { + peopleEditForm.getLastImportWayLabel().setText(PeopleImportWayEnum.getName(Integer.parseInt(tPeopleImportConfig.getLastWay()))); + } + } + + // -----init Table + List peopleDataList = peopleDataMapper.selectByPeopleIdLimit20(peopleId); + initPeopleDataTable(peopleDataList); + } + + public static void initPeopleDataTable(List peopleDataList) { + JTable memberListTable = peopleEditForm.getMemberListTable(); + + // 人群数据列表 + String[] headerNames = {"PIN", "VarData", "id"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + memberListTable.setModel(model); + // 隐藏表头 +// JTableUtil.hideTableHeader(memberListTable); + + Object[] data; + + for (TPeopleData peopleData : peopleDataList) { + data = new Object[3]; + data[0] = peopleData.getPin(); + data[1] = peopleData.getVarData(); + data[2] = peopleData.getId(); + model.addRow(data); + } + // 隐藏id列 + JTableUtil.hideColumn(memberListTable, 2); + // 设置列宽 + TableColumnModel tableColumnModel = memberListTable.getColumnModel(); + tableColumnModel.getColumn(0).setPreferredWidth(peopleEditForm.getImportButton().getWidth() * 3); + tableColumnModel.getColumn(0).setMaxWidth(peopleEditForm.getImportButton().getWidth() * 3); + } + + public static void clearAll() { + PeopleManageListener.selectedPeopleId = null; + + peopleEditForm.getPeopleNameLabel().setText("-"); + peopleEditForm.getMemberTabCountLabel().setText("-"); + peopleEditForm.getPeopleAccountLabel().setText("-"); + peopleEditForm.getPeopleMsgTypeLabel().setText("-"); + peopleEditForm.getLastImportWayLabel().setText("-"); + + // 人群数据列表 + JTable memberListTable = peopleEditForm.getMemberListTable(); + String[] headerNames = {"PIN", "VarData", "id"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + memberListTable.setModel(model); + + // 隐藏id列 + JTableUtil.hideColumn(memberListTable, 2); + // 设置列宽 + TableColumnModel tableColumnModel = memberListTable.getColumnModel(); + tableColumnModel.getColumn(0).setPreferredWidth(peopleEditForm.getImportButton().getWidth() * 3); + tableColumnModel.getColumn(0).setMaxWidth(peopleEditForm.getImportButton().getWidth() * 3); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(4, 1, new Insets(10, 0, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + searchTextField = new JTextField(); + panel1.add(searchTextField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + searchButton = new JButton(); + searchButton.setText("搜索"); + panel1.add(searchButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JScrollPane scrollPane1 = new JScrollPane(); + mainPanel.add(scrollPane1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + memberListTable = new JTable(); + memberListTable.setGridColor(new Color(-12236470)); + memberListTable.setMinimumSize(new Dimension(30, 30)); + memberListTable.setRowHeight(36); + scrollPane1.setViewportView(memberListTable); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + clearAllButton = new JButton(); + clearAllButton.setText("清空"); + panel2.add(clearAllButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + importButton = new JButton(); + importButton.setText("导入"); + panel2.add(importButton, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + exportButton = new JButton(); + exportButton.setText("导出"); + panel2.add(exportButton, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + deleteButton = new JButton(); + deleteButton.setText("删除"); + panel2.add(deleteButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("注:列表仅展示20条数据,查看更多请导出"); + panel2.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberTabUpPanel = new JPanel(); + memberTabUpPanel.setLayout(new GridLayoutManager(6, 3, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(memberTabUpPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + memberTabImportProgressBar = new JProgressBar(); + memberTabUpPanel.add(memberTabImportProgressBar, new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + memberTabUpPanel.add(spacer2, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("人群数量:"); + memberTabUpPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("人群名称:"); + memberTabUpPanel.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + peopleNameLabel = new JLabel(); + peopleNameLabel.setText("-"); + memberTabUpPanel.add(peopleNameLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("所属账号:"); + memberTabUpPanel.add(label4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + peopleAccountLabel = new JLabel(); + peopleAccountLabel.setText("-"); + memberTabUpPanel.add(peopleAccountLabel, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + peopleMsgTypeLabel = new JLabel(); + peopleMsgTypeLabel.setText("-"); + memberTabUpPanel.add(peopleMsgTypeLabel, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + lastImportWayLabel = new JLabel(); + lastImportWayLabel.setText("-"); + memberTabUpPanel.add(lastImportWayLabel, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("所属消息类型:"); + memberTabUpPanel.add(label5, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("上次导入方式:"); + memberTabUpPanel.add(label6, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberTabCountLabel = new JLabel(); + memberTabCountLabel.setText("-"); + memberTabUpPanel.add(memberTabCountLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PeopleManageForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleManageForm.form new file mode 100644 index 000000000..a5dfd2573 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleManageForm.form @@ -0,0 +1,82 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PeopleManageForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleManageForm.java new file mode 100644 index 000000000..a8716025a --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/PeopleManageForm.java @@ -0,0 +1,154 @@ +package com.fangxuele.tool.push.ui.form; + +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.util.JTableUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.google.common.collect.Maps; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.*; +import java.util.List; +import java.util.Map; + +/** + *
+ * AccountManageForm
+ * 
+ * + * @author RememBerBer + * @since 2021/3/10. + */ +@Getter +public class PeopleManageForm { + + private JPanel peopleManagePanel; + private JTable peopleListTable; + private JButton deleteButton; + private JButton createPeopleButton; + private JComboBox accountComboBox; + + private static PeopleManageForm peopleManageForm; + + public static Map accountMap; + + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + + private PeopleManageForm() { + } + + public static PeopleManageForm getInstance() { + if (peopleManageForm == null) { + peopleManageForm = new PeopleManageForm(); + } + return peopleManageForm; + } + + /** + * 初始化消息列表 + */ + public static void init() { + peopleManageForm = getInstance(); + peopleManageForm.getDeleteButton().setIcon(new FlatSVGIcon("icon/remove.svg")); + peopleManageForm.getCreatePeopleButton().setIcon(new FlatSVGIcon("icon/add.svg")); + + initAccountComboBox(); + initPeopleList(); + } + + private static void initAccountComboBox() { + accountMap = Maps.newHashMap(); + peopleManageForm.getAccountComboBox().removeAllItems(); + int msgType = App.config.getMsgType(); + List tAccountList = accountMapper.selectByMsgType(msgType); + for (TAccount tAccount : tAccountList) { + String accountName = tAccount.getAccountName(); + Integer accountId = tAccount.getId(); + peopleManageForm.getAccountComboBox().addItem(accountName); + accountMap.put(accountName, accountId); + } + } + + public static void initPeopleList() { + // 人群列表 + String[] headerNames = {"人群名称", "id"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + peopleManageForm.getPeopleListTable().setModel(model); + // 隐藏表头 + JTableUtil.hideTableHeader(peopleManageForm.getPeopleListTable()); + + int msgType = App.config.getMsgType(); + String selectedAccountName = (String) peopleManageForm.getAccountComboBox().getSelectedItem(); + Integer selectedAccountId = accountMap.get(selectedAccountName); + + Object[] data; + + List tPeopleList = peopleMapper.selectByMsgTypeAndAccountId(String.valueOf(msgType), selectedAccountId); + for (TPeople tPeople : tPeopleList) { + data = new Object[2]; + data[0] = tPeople.getPeopleName(); + data[1] = tPeople.getId(); + model.addRow(data); + } + // 隐藏id列 + JTableUtil.hideColumn(peopleManageForm.getPeopleListTable(), 1); + + PeopleEditForm.clearAll(); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + peopleManagePanel = new JPanel(); + peopleManagePanel.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 0), -1, -1)); + peopleManagePanel.setMaximumSize(new Dimension(-1, -1)); + peopleManagePanel.setMinimumSize(new Dimension(-1, -1)); + peopleManagePanel.setPreferredSize(new Dimension(280, -1)); + panel1.add(peopleManagePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JScrollPane scrollPane1 = new JScrollPane(); + peopleManagePanel.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + peopleListTable = new JTable(); + peopleListTable.setGridColor(new Color(-12236470)); + peopleListTable.setRowHeight(36); + peopleListTable.setShowVerticalLines(false); + scrollPane1.setViewportView(peopleListTable); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + peopleManagePanel.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + deleteButton = new JButton(); + deleteButton.setText("删除"); + panel2.add(deleteButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + createPeopleButton = new JButton(); + createPeopleButton.setEnabled(true); + createPeopleButton.setText("新建"); + panel2.add(createPeopleButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + accountComboBox = new JComboBox(); + peopleManagePanel.add(accountComboBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PushForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/PushForm.form deleted file mode 100644 index 6b74d5340..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/PushForm.form +++ /dev/null @@ -1,402 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PushForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/PushForm.java deleted file mode 100644 index a8a9c8f08..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/PushForm.java +++ /dev/null @@ -1,298 +0,0 @@ -package com.fangxuele.tool.push.ui.form; - -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.util.UndoUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import lombok.Getter; - -import javax.swing.*; -import java.awt.*; - -/** - *
- * PushForm
- * 
- * - * @author RememBerBer - * @since 2019/5/6. - */ -@Getter -public class PushForm { - private JPanel pushPanel; - private JPanel pushUpPanel; - private JLabel pushSuccessCount; - private JLabel pushFailCount; - private JLabel pushTotalProgressLabel; - private JProgressBar pushTotalProgressBar; - private JLabel pushLastTimeLabel; - private JLabel pushLeftTimeLabel; - private JLabel jvmMemoryLabel; - private JLabel availableProcessorLabel; - private JLabel pushTotalCountLabel; - private JLabel pushMsgName; - private JLabel scheduleDetailLabel; - private JPanel pushDownPanel; - private JPanel pushControlPanel; - private JTextField maxThreadPoolTextField; - private JTextField threadCountTextField; - private JButton ScheduleRunButton; - private JButton pushStopButton; - private JButton pushStartButton; - private JCheckBox dryRunCheckBox; - private JPanel pushCenterPanel; - private JTextArea pushConsoleTextArea; - private JTable pushThreadTable; - private JLabel countPerThread; - private JSlider threadCountSlider; - private JLabel threadTipsLabel; - private JLabel dryRunHelpLabel; - private JCheckBox saveResponseBodyCheckBox; - private JLabel tpsLabel; - - private static PushForm pushForm; - - private PushForm() { - UndoUtil.register(this); - } - - public static PushForm getInstance() { - if (pushForm == null) { - pushForm = new PushForm(); - } - return pushForm; - } - - /** - * 初始化推送tab - */ - public static void init() { - pushForm = getInstance(); - pushForm.getPushMsgName().setText(App.config.getMsgName()); - pushForm.getMaxThreadPoolTextField().setText(String.valueOf(App.config.getMaxThreadPool())); - pushForm.getThreadCountTextField().setText(String.valueOf(App.config.getThreadCount())); - pushForm.getThreadCountSlider().setMaximum(App.config.getMaxThreadPool()); - pushForm.getThreadCountSlider().setValue(App.config.getThreadCount()); - pushForm.getDryRunCheckBox().setSelected(App.config.isDryRun()); - - if ("Darcula(推荐)".equals(App.config.getTheme())) { - Color bgColor = new Color(43, 43, 43); - pushForm.getPushConsoleTextArea().setBackground(bgColor); - Color foreColor = new Color(187, 187, 187); - pushForm.getPushConsoleTextArea().setForeground(foreColor); - } - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - pushPanel = new JPanel(); - pushPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 2, 0, 2), -1, -1)); - panel1.add(pushPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - pushUpPanel = new JPanel(); - pushUpPanel.setLayout(new GridLayoutManager(7, 10, new Insets(0, 0, 0, 0), -1, -1)); - pushPanel.add(pushUpPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - pushSuccessCount = new JLabel(); - Font pushSuccessCountFont = this.$$$getFont$$$(null, -1, 72, pushSuccessCount.getFont()); - if (pushSuccessCountFont != null) pushSuccessCount.setFont(pushSuccessCountFont); - pushSuccessCount.setForeground(new Color(-13587376)); - pushSuccessCount.setText("0"); - pushUpPanel.add(pushSuccessCount, new GridConstraints(0, 0, 7, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushFailCount = new JLabel(); - Font pushFailCountFont = this.$$$getFont$$$(null, -1, 72, pushFailCount.getFont()); - if (pushFailCountFont != null) pushFailCount.setFont(pushFailCountFont); - pushFailCount.setForeground(new Color(-2200483)); - pushFailCount.setText("0"); - pushUpPanel.add(pushFailCount, new GridConstraints(0, 2, 7, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushTotalProgressLabel = new JLabel(); - pushTotalProgressLabel.setText("总进度"); - pushUpPanel.add(pushTotalProgressLabel, new GridConstraints(6, 8, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushTotalProgressBar = new JProgressBar(); - pushTotalProgressBar.setStringPainted(true); - pushUpPanel.add(pushTotalProgressBar, new GridConstraints(6, 9, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label1 = new JLabel(); - label1.setText("成功"); - pushUpPanel.add(label1, new GridConstraints(2, 1, 3, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("失败"); - pushUpPanel.add(label2, new GridConstraints(2, 3, 3, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JSeparator separator1 = new JSeparator(); - separator1.setOrientation(1); - pushUpPanel.add(separator1, new GridConstraints(0, 4, 7, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - pushLastTimeLabel = new JLabel(); - pushLastTimeLabel.setEnabled(true); - Font pushLastTimeLabelFont = this.$$$getFont$$$("Microsoft YaHei UI Light", -1, 36, pushLastTimeLabel.getFont()); - if (pushLastTimeLabelFont != null) pushLastTimeLabel.setFont(pushLastTimeLabelFont); - pushLastTimeLabel.setForeground(new Color(-6710887)); - pushLastTimeLabel.setText("0s"); - pushUpPanel.add(pushLastTimeLabel, new GridConstraints(0, 6, 3, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setHorizontalAlignment(0); - label3.setHorizontalTextPosition(0); - label3.setText("耗时"); - pushUpPanel.add(label3, new GridConstraints(0, 5, 3, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JSeparator separator2 = new JSeparator(); - separator2.setOrientation(1); - pushUpPanel.add(separator2, new GridConstraints(0, 7, 7, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - jvmMemoryLabel = new JLabel(); - jvmMemoryLabel.setText("JVM内存占用:--"); - pushUpPanel.add(jvmMemoryLabel, new GridConstraints(4, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - availableProcessorLabel = new JLabel(); - availableProcessorLabel.setText("可用处理器核心:--"); - pushUpPanel.add(availableProcessorLabel, new GridConstraints(3, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushTotalCountLabel = new JLabel(); - pushTotalCountLabel.setText("消息总数:0"); - pushUpPanel.add(pushTotalCountLabel, new GridConstraints(1, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushMsgName = new JLabel(); - Font pushMsgNameFont = this.$$$getFont$$$(null, -1, 24, pushMsgName.getFont()); - if (pushMsgNameFont != null) pushMsgName.setFont(pushMsgNameFont); - pushMsgName.setForeground(new Color(-276358)); - pushMsgName.setText("消息标题"); - pushUpPanel.add(pushMsgName, new GridConstraints(0, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - scheduleDetailLabel = new JLabel(); - scheduleDetailLabel.setForeground(new Color(-276358)); - scheduleDetailLabel.setText(""); - pushUpPanel.add(scheduleDetailLabel, new GridConstraints(5, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - countPerThread = new JLabel(); - countPerThread.setText("每个线程平均分配:0"); - pushUpPanel.add(countPerThread, new GridConstraints(2, 8, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("预计剩余"); - pushUpPanel.add(label4, new GridConstraints(3, 5, 3, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushLeftTimeLabel = new JLabel(); - Font pushLeftTimeLabelFont = this.$$$getFont$$$("Microsoft YaHei UI Light", -1, 36, pushLeftTimeLabel.getFont()); - if (pushLeftTimeLabelFont != null) pushLeftTimeLabel.setFont(pushLeftTimeLabelFont); - pushLeftTimeLabel.setForeground(new Color(-6710887)); - pushLeftTimeLabel.setText("0s"); - pushUpPanel.add(pushLeftTimeLabel, new GridConstraints(3, 6, 3, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label5 = new JLabel(); - label5.setText("TPS"); - pushUpPanel.add(label5, new GridConstraints(6, 5, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - tpsLabel = new JLabel(); - tpsLabel.setText("0"); - pushUpPanel.add(tpsLabel, new GridConstraints(6, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushDownPanel = new JPanel(); - pushDownPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - pushPanel.add(pushDownPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - pushControlPanel = new JPanel(); - pushControlPanel.setLayout(new GridLayoutManager(1, 13, new Insets(0, 0, 0, 0), -1, -1)); - pushDownPanel.add(pushControlPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label6 = new JLabel(); - label6.setText("最大线程池"); - pushControlPanel.add(label6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - maxThreadPoolTextField = new JTextField(); - maxThreadPoolTextField.setHorizontalAlignment(10); - maxThreadPoolTextField.setMargin(new Insets(2, 5, 2, 5)); - maxThreadPoolTextField.setRequestFocusEnabled(true); - maxThreadPoolTextField.setToolTipText("输入结束后请按回车键确认"); - pushControlPanel.add(maxThreadPoolTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(60, -1), null, 0, false)); - final JLabel label7 = new JLabel(); - label7.setText("线程数"); - label7.setToolTipText("当前版本受http连接池限制建议不要设置过多线程,推荐100以内"); - pushControlPanel.add(label7, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - threadCountTextField = new JTextField(); - threadCountTextField.setEditable(false); - threadCountTextField.setFocusable(false); - threadCountTextField.setRequestFocusEnabled(false); - threadCountTextField.setToolTipText("当前版本受http连接池限制建议不要设置过多线程,推荐100以内"); - pushControlPanel.add(threadCountTextField, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(60, -1), null, 0, false)); - ScheduleRunButton = new JButton(); - ScheduleRunButton.setIcon(new ImageIcon(getClass().getResource("/icon/clock.png"))); - ScheduleRunButton.setText("按计划执行"); - pushControlPanel.add(ScheduleRunButton, new GridConstraints(0, 10, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushStopButton = new JButton(); - pushStopButton.setEnabled(false); - pushStopButton.setIcon(new ImageIcon(getClass().getResource("/icon/suspend.png"))); - pushStopButton.setText("停止"); - pushControlPanel.add(pushStopButton, new GridConstraints(0, 11, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushStartButton = new JButton(); - pushStartButton.setIcon(new ImageIcon(getClass().getResource("/icon/run@2x.png"))); - pushStartButton.setText("开始"); - pushControlPanel.add(pushStartButton, new GridConstraints(0, 12, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - dryRunCheckBox = new JCheckBox(); - dryRunCheckBox.setText("空跑"); - dryRunCheckBox.setToolTipText("空跑勾选时不会真实发送消息"); - pushControlPanel.add(dryRunCheckBox, new GridConstraints(0, 8, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - pushControlPanel.add(spacer1, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - threadCountSlider = new JSlider(); - threadCountSlider.setDoubleBuffered(true); - threadCountSlider.setExtent(0); - threadCountSlider.setFocusCycleRoot(false); - threadCountSlider.setFocusTraversalPolicyProvider(false); - threadCountSlider.setFocusable(false); - threadCountSlider.setInverted(false); - threadCountSlider.setMajorTickSpacing(10); - threadCountSlider.setMinimum(1); - threadCountSlider.setMinorTickSpacing(5); - threadCountSlider.setOpaque(false); - threadCountSlider.setOrientation(0); - threadCountSlider.setPaintLabels(false); - threadCountSlider.setPaintTicks(true); - threadCountSlider.setPaintTrack(true); - threadCountSlider.setRequestFocusEnabled(false); - threadCountSlider.setSnapToTicks(false); - threadCountSlider.setValueIsAdjusting(false); - pushControlPanel.add(threadCountSlider, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - threadTipsLabel = new JLabel(); - threadTipsLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); - threadTipsLabel.setText(""); - pushControlPanel.add(threadTipsLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - dryRunHelpLabel = new JLabel(); - dryRunHelpLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); - dryRunHelpLabel.setText(""); - pushControlPanel.add(dryRunHelpLabel, new GridConstraints(0, 9, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - saveResponseBodyCheckBox = new JCheckBox(); - saveResponseBodyCheckBox.setText("保存请求返回的Body"); - pushControlPanel.add(saveResponseBodyCheckBox, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushCenterPanel = new JPanel(); - pushCenterPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); - pushPanel.add(pushCenterPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - final JScrollPane scrollPane1 = new JScrollPane(); - pushCenterPanel.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - pushConsoleTextArea = new JTextArea(); - scrollPane1.setViewportView(pushConsoleTextArea); - final JScrollPane scrollPane2 = new JScrollPane(); - pushCenterPanel.add(scrollPane2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - pushThreadTable = new JTable(); - pushThreadTable.setGridColor(new Color(-12236470)); - pushThreadTable.setRowHeight(36); - pushThreadTable.setShowVerticalLines(false); - scrollPane2.setViewportView(pushThreadTable); - } - - /** - * @noinspection ALL - */ - private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { - if (currentFont == null) return null; - String resultName; - if (fontName == null) { - resultName = currentFont.getName(); - } else { - Font testFont = new Font(fontName, Font.PLAIN, 10); - if (testFont.canDisplay('a') && testFont.canDisplay('1')) { - resultName = fontName; - } else { - resultName = currentFont.getName(); - } - } - return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PushHisForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/PushHisForm.form deleted file mode 100644 index a7986ee75..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/PushHisForm.form +++ /dev/null @@ -1,185 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/PushHisForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/PushHisForm.java deleted file mode 100644 index 21ef2cd22..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/PushHisForm.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.fangxuele.tool.push.ui.form; - -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TPushHistoryMapper; -import com.fangxuele.tool.push.domain.TPushHistory; -import com.fangxuele.tool.push.util.JTableUtil; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.fangxuele.tool.push.util.UndoUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import lombok.Getter; - -import javax.swing.*; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.util.List; - -/** - *
- * PushHisForm
- * 
- * - * @author RememBerBer - * @since 2019/5/6. - */ -@Getter -public class PushHisForm { - private JPanel pushHisPanel; - private JButton pushHisLeftDeleteButton; - private JButton pushHisExportButton; - private JTable pushHisLeftTable; - private JLabel pushHisCountLabel; - private JButton pushHisCopyButton; - private JTextArea pushHisTextArea; - private JButton resendFromHisButton; - private JSplitPane splitPane; - private JPanel rightPanel; - private JProgressBar progressBar; - private JScrollPane contentScrollPane; - private JPanel contentControllPanel; - - private static PushHisForm pushHisForm; - - private static TPushHistoryMapper pushHistoryMapper = MybatisUtil.getSqlSession().getMapper(TPushHistoryMapper.class); - - private PushHisForm() { - UndoUtil.register(this); - } - - public static PushHisForm getInstance() { - if (pushHisForm == null) { - pushHisForm = new PushHisForm(); - } - return pushHisForm; - } - - /** - * 初始化推送历史tab - */ - public static void init() { - pushHisForm = getInstance(); - - if ("Darcula(推荐)".equals(App.config.getTheme())) { - Color bgColor = new Color(43, 43, 43); - pushHisForm.getPushHisTextArea().setBackground(bgColor); - Color foreColor = new Color(187, 187, 187); - pushHisForm.getPushHisTextArea().setForeground(foreColor); - } - - pushHisForm.getSplitPane().setDividerLocation((int) (App.mainFrame.getWidth() * 0.38)); - initHisLeftTable(); - - } - - private static void initHisLeftTable() { - // 导入历史管理 - String[] headerNames = {"消息名称", "状态", "时间", "id"}; - DefaultTableModel model = new DefaultTableModel(null, headerNames); - pushHisForm.getPushHisLeftTable().setModel(model); - - DefaultTableCellRenderer hr = (DefaultTableCellRenderer) pushHisForm.getPushHisLeftTable().getTableHeader() - .getDefaultRenderer(); - // 表头列名居左 - hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); - - List pushHistoryList = pushHistoryMapper.selectByMsgType(App.config.getMsgType()); - Object[] data; - for (TPushHistory tPushHistory : pushHistoryList) { - data = new Object[4]; - data[0] = tPushHistory.getMsgName(); - data[1] = tPushHistory.getResult(); - data[2] = tPushHistory.getCreateTime(); - data[3] = tPushHistory.getId(); - model.addRow(data); - } - - // 隐藏id列 - JTableUtil.hideColumn(pushHisForm.getPushHisLeftTable(), 3); - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - pushHisPanel = new JPanel(); - pushHisPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - panel1.add(pushHisPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - splitPane = new JSplitPane(); - splitPane.setContinuousLayout(true); - splitPane.setDividerLocation(620); - splitPane.setDividerSize(4); - splitPane.setDoubleBuffered(true); - splitPane.setInheritsPopupMenu(false); - splitPane.setLastDividerLocation(620); - splitPane.setResizeWeight(0.0); - pushHisPanel.add(splitPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false)); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); - panel2.setMinimumSize(new Dimension(100, 24)); - panel2.setPreferredSize(new Dimension(740, 24)); - splitPane.setLeftComponent(panel2); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(1, 4, new Insets(5, 5, 5, 0), -1, -1)); - panel2.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - panel3.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - pushHisLeftDeleteButton = new JButton(); - pushHisLeftDeleteButton.setIcon(new ImageIcon(getClass().getResource("/icon/remove.png"))); - pushHisLeftDeleteButton.setText("删除"); - panel3.add(pushHisLeftDeleteButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushHisExportButton = new JButton(); - pushHisExportButton.setIcon(new ImageIcon(getClass().getResource("/icon/export_dark.png"))); - pushHisExportButton.setText("导出"); - panel3.add(pushHisExportButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - resendFromHisButton = new JButton(); - resendFromHisButton.setIcon(new ImageIcon(getClass().getResource("/icon/refresh.png"))); - resendFromHisButton.setText("重发"); - panel3.add(resendFromHisButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JScrollPane scrollPane1 = new JScrollPane(); - panel2.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - pushHisLeftTable = new JTable(); - pushHisLeftTable.setAlignmentX(0.5f); - pushHisLeftTable.setAutoResizeMode(2); - pushHisLeftTable.setDoubleBuffered(true); - pushHisLeftTable.setGridColor(new Color(-12236470)); - pushHisLeftTable.setIntercellSpacing(new Dimension(1, 1)); - pushHisLeftTable.setRowHeight(36); - pushHisLeftTable.setShowVerticalLines(false); - scrollPane1.setViewportView(pushHisLeftTable); - rightPanel = new JPanel(); - rightPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); - splitPane.setRightComponent(rightPanel); - contentControllPanel = new JPanel(); - contentControllPanel.setLayout(new GridLayoutManager(1, 3, new Insets(5, 10, 5, 5), -1, -1)); - rightPanel.add(contentControllPanel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final Spacer spacer2 = new Spacer(); - contentControllPanel.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - pushHisCountLabel = new JLabel(); - pushHisCountLabel.setText(""); - contentControllPanel.add(pushHisCountLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - pushHisCopyButton = new JButton(); - pushHisCopyButton.setText("复制"); - contentControllPanel.add(pushHisCopyButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - contentScrollPane = new JScrollPane(); - rightPanel.add(contentScrollPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - pushHisTextArea = new JTextArea(); - pushHisTextArea.setEditable(false); - contentScrollPane.setViewportView(pushHisTextArea); - progressBar = new JProgressBar(); - progressBar.setBorderPainted(true); - progressBar.setString("Loading"); - progressBar.setStringPainted(true); - progressBar.setVisible(false); - rightPanel.add(progressBar, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - } -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.form deleted file mode 100644 index 0d614d720..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.form +++ /dev/null @@ -1,212 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.java deleted file mode 100644 index 3dcf565ba..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.fangxuele.tool.push.ui.form; - -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.MessageTypeEnum; -import com.fangxuele.tool.push.util.UndoUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import lombok.Getter; - -import javax.swing.*; -import java.awt.*; - -/** - *
- * ScheduleForm
- * 
- * - * @author RememBerBer - * @since 2019/5/6. - */ -@Getter -public class ScheduleForm { - private JPanel schedulePanel; - private JRadioButton runAtThisTimeRadioButton; - private JTextField startAtThisTimeTextField; - private JRadioButton runPerDayRadioButton; - private JTextField startPerDayTextField; - private JRadioButton runPerWeekRadioButton; - private JButton scheduleSaveButton; - private JComboBox schedulePerWeekComboBox; - private JTextField startPerWeekTextField; - private JCheckBox reimportCheckBox; - private JComboBox reimportComboBox; - private JCheckBox sendPushResultCheckBox; - private JTextField mailResultToTextField; - private JRadioButton cronRadioButton; - private JTextField cronTextField; - private JLabel cronHelpLabel; - private JLabel cronOnlineLabel; - - private static ScheduleForm scheduleForm; - - private ScheduleForm() { - UndoUtil.register(this); - } - - public static ScheduleForm getInstance() { - if (scheduleForm == null) { - scheduleForm = new ScheduleForm(); - } - return scheduleForm; - } - - /** - * 初始化计划任务tab - */ - public static void init() { - scheduleForm = getInstance(); - // 开始 - scheduleForm.getRunAtThisTimeRadioButton().setSelected(App.config.isRadioStartAt()); - scheduleForm.getStartAtThisTimeTextField().setText(App.config.getTextStartAt()); - - //每天 - scheduleForm.getRunPerDayRadioButton().setSelected(App.config.isRadioPerDay()); - scheduleForm.getStartPerDayTextField().setText(App.config.getTextPerDay()); - - // 每周 - scheduleForm.getRunPerWeekRadioButton().setSelected(App.config.isRadioPerWeek()); - scheduleForm.getSchedulePerWeekComboBox().setSelectedItem(App.config.getTextPerWeekWeek()); - scheduleForm.getStartPerWeekTextField().setText(App.config.getTextPerWeekTime()); - - // Cron - scheduleForm.getCronRadioButton().setSelected(App.config.isRadioCron()); - scheduleForm.getCronTextField().setText(App.config.getTextCron()); - - fillReimportComboBox(); - scheduleForm.getReimportCheckBox().setSelected(App.config.isNeedReimport()); - scheduleForm.getReimportComboBox().setSelectedItem(App.config.getReimportWay()); - - scheduleForm.getSendPushResultCheckBox().setSelected(App.config.isSendPushResult()); - scheduleForm.getMailResultToTextField().setText(App.config.getMailResultTos()); - } - - /** - * 重新导入下拉框填充 - */ - public static void fillReimportComboBox() { - scheduleForm.getReimportComboBox().removeAllItems(); - scheduleForm.getReimportComboBox().addItem("通过SQL导入"); - scheduleForm.getReimportComboBox().addItem("通过文件导入"); - int msgType = App.config.getMsgType(); - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.MA_TEMPLATE_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { - scheduleForm.getReimportComboBox().addItem("导入所有关注公众号的用户"); - } else if (msgType == MessageTypeEnum.WX_CP_CODE) { - scheduleForm.getReimportComboBox().addItem("导入企业通讯录中所有用户"); - } - } - - public static int getDayOfWeek(String week) { - int dayOfWeek; - switch (week) { - case "一": - dayOfWeek = 2; - break; - case "二": - dayOfWeek = 3; - break; - case "三": - dayOfWeek = 4; - break; - case "四": - dayOfWeek = 5; - break; - case "五": - dayOfWeek = 6; - break; - case "六": - dayOfWeek = 7; - break; - case "日": - dayOfWeek = 1; - break; - default: - dayOfWeek = 0; - } - return dayOfWeek; - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - schedulePanel = new JPanel(); - schedulePanel.setLayout(new GridLayoutManager(9, 8, new Insets(10, 10, 10, 10), -1, -1)); - panel1.add(schedulePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - runAtThisTimeRadioButton = new JRadioButton(); - runAtThisTimeRadioButton.setText("在此时间开始推送:"); - schedulePanel.add(runAtThisTimeRadioButton, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer1 = new Spacer(); - schedulePanel.add(spacer1, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final Spacer spacer2 = new Spacer(); - schedulePanel.add(spacer2, new GridConstraints(8, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - startAtThisTimeTextField = new JTextField(); - startAtThisTimeTextField.setText(""); - schedulePanel.add(startAtThisTimeTextField, new GridConstraints(0, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - runPerDayRadioButton = new JRadioButton(); - runPerDayRadioButton.setText("每天固定时间开始推送:"); - schedulePanel.add(runPerDayRadioButton, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - startPerDayTextField = new JTextField(); - schedulePanel.add(startPerDayTextField, new GridConstraints(1, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - runPerWeekRadioButton = new JRadioButton(); - runPerWeekRadioButton.setText("每周固定时间开始推送:"); - schedulePanel.add(runPerWeekRadioButton, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label1 = new JLabel(); - label1.setText("yyyy-MM-dd HH:mm:ss"); - schedulePanel.add(label1, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("HH:mm:ss"); - schedulePanel.add(label2, new GridConstraints(1, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("HH:mm:ss"); - schedulePanel.add(label3, new GridConstraints(2, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - scheduleSaveButton = new JButton(); - scheduleSaveButton.setHorizontalAlignment(0); - scheduleSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - scheduleSaveButton.setText("保存"); - schedulePanel.add(scheduleSaveButton, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("每周"); - schedulePanel.add(label4, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label5 = new JLabel(); - label5.setText("的"); - schedulePanel.add(label5, new GridConstraints(2, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - schedulePerWeekComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); - defaultComboBoxModel1.addElement("一"); - defaultComboBoxModel1.addElement("二"); - defaultComboBoxModel1.addElement("三"); - defaultComboBoxModel1.addElement("四"); - defaultComboBoxModel1.addElement("五"); - defaultComboBoxModel1.addElement("六"); - defaultComboBoxModel1.addElement("日"); - schedulePerWeekComboBox.setModel(defaultComboBoxModel1); - schedulePanel.add(schedulePerWeekComboBox, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - startPerWeekTextField = new JTextField(); - schedulePanel.add(startPerWeekTextField, new GridConstraints(2, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - reimportCheckBox = new JCheckBox(); - reimportCheckBox.setText("开始执行时重新导入目标用户"); - schedulePanel.add(reimportCheckBox, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - reimportComboBox = new JComboBox(); - schedulePanel.add(reimportComboBox, new GridConstraints(4, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - sendPushResultCheckBox = new JCheckBox(); - sendPushResultCheckBox.setText("将推送结果发送邮件给(多个以分号分隔):"); - schedulePanel.add(sendPushResultCheckBox, new GridConstraints(5, 0, 1, 8, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mailResultToTextField = new JTextField(); - schedulePanel.add(mailResultToTextField, new GridConstraints(6, 0, 1, 8, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - cronRadioButton = new JRadioButton(); - cronRadioButton.setText("按Cron表达式触发推送:"); - schedulePanel.add(cronRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - cronTextField = new JTextField(); - schedulePanel.add(cronTextField, new GridConstraints(3, 2, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - cronOnlineLabel = new JLabel(); - cronOnlineLabel.setText("在线Cron表达式生成器"); - schedulePanel.add(cronOnlineLabel, new GridConstraints(3, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - cronHelpLabel = new JLabel(); - cronHelpLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); - cronHelpLabel.setText(""); - schedulePanel.add(cronHelpLabel, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - } -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.form deleted file mode 100644 index fc74f3ebe..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.form +++ /dev/null @@ -1,1818 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.java deleted file mode 100644 index 137668fd7..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.java +++ /dev/null @@ -1,1036 +0,0 @@ -package com.fangxuele.tool.push.ui.form; - -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TWxAccountMapper; -import com.fangxuele.tool.push.domain.TWxAccount; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.fangxuele.tool.push.util.UndoUtil; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import lombok.Getter; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import java.awt.*; -import java.util.List; - -/** - *
- * SettingForm
- * 
- * - * @author RememBerBer - * @since 2019/5/6. - */ -@Getter -public class SettingForm { - private JPanel settingPanel; - private JScrollPane settingScrollPane; - private JTextField wechatAppIdTextField; - private JPasswordField wechatAppSecretPasswordField; - private JPasswordField wechatTokenPasswordField; - private JPasswordField wechatAesKeyPasswordField; - private JButton settingMpInfoSaveButton; - private JTextField mysqlUrlTextField; - private JTextField mysqlUserTextField; - private JPasswordField mysqlPasswordField; - private JButton settingTestDbLinkButton; - private JButton settingDbInfoSaveButton; - private JComboBox settingThemeComboBox; - private JComboBox settingFontNameComboBox; - private JComboBox settingFontSizeComboBox; - private JButton settingAppearanceSaveButton; - private JCheckBox autoCheckUpdateCheckBox; - private JTextField aliyunSignTextField; - private JPasswordField aliyunAccessKeySecretTextField; - private JButton settingAliyunSaveButton; - private JTextField aliyunAccessKeyIdTextField; - private JTextField miniAppAppIdTextField; - private JPasswordField miniAppAppSecretPasswordField; - private JPasswordField miniAppTokenPasswordField; - private JPasswordField miniAppAesKeyPasswordField; - private JButton settingMaInfoSaveButton; - private JTextField txyunSignTextField; - private JPasswordField txyunAppKeyTextField; - private JButton settingTxyunSaveButton; - private JTextField txyunAppIdTextField; - private JPasswordField yunpianApiKeyTextField; - private JButton settingYunpianSaveButton; - private JButton mpAccountManageButton; - private JButton maAccountManageButton; - private JComboBox mpAccountSwitchComboBox; - private JComboBox maAccountSwitchComboBox; - private JCheckBox mpUseProxyCheckBox; - private JTextField mpProxyHostTextField; - private JTextField mpProxyPortTextField; - private JTextField mpProxyUserNameTextField; - private JTextField mpProxyPasswordTextField; - private JPanel mpProxyPanel; - private JCheckBox maUseProxyCheckBox; - private JTextField maProxyHostTextField; - private JTextField maProxyPortTextField; - private JTextField maProxyUserNameTextField; - private JTextField maProxyPasswordTextField; - private JPanel maProxyPanel; - private JButton saveMailButton; - private JCheckBox mailStartTLSCheckBox; - private JCheckBox mailSSLCheckBox; - private JTextField mailHostTextField; - private JTextField mailPortTextField; - private JTextField mailFromTextField; - private JTextField mailUserTextField; - private JPasswordField mailPasswordField; - private JButton testMailButton; - private JTextField wxCpCorpIdTextField; - private JButton wxCpSaveButton; - private JButton wxCpAppManageButton; - private JPanel httpProxyPanel; - private JButton httpSaveButton; - private JTextField httpProxyPortTextField; - private JTextField httpProxyPasswordTextField; - private JTextField httpProxyUserTextField; - private JTextField httpProxyHostTextField; - private JCheckBox httpUseProxyCheckBox; - private JCheckBox useOutSideAccessTokenCheckBox; - private JTextField atExpiresInTextField; - private JPanel mpOutSideAccessTokenPanel; - private JTextField accessTokenTextField; - private JTextField atApiUrlTextField; - private JRadioButton manualAtRadioButton; - private JRadioButton apiAtRadioButton; - private JLabel outSideAtTipsLabel; - private JLabel manualAtTipsLabel; - private JLabel apiAtTipsLabel; - private JButton dingAppManageButton; - private JButton hwSaveButton; - private JTextField hwAppKeyTextField; - private JPasswordField hwAppSecretPasswordField; - private JTextField hwAccessUrlTextField; - private JTextField hwSignatureTextField; - private JTextField hwSenderCodeTextField; - private JPasswordField bdSecretAccessKeyPasswordField; - private JButton bdSaveButton; - private JTextField bdAccessKeyIdTextField; - private JTextField bdEndPointTextField; - private JTextField bdInvokeIdTextField; - private JTextField upAuthorizationTokenTextField; - private JButton upSaveButton; - private JTextField qiniuAccessKeyTextField; - private JButton qiniuSaveButton; - private JTextField qiniuSecretKeyTextField; - private JCheckBox useTrayCheckBox; - - private static SettingForm settingForm; - private static TWxAccountMapper wxAccountMapper = MybatisUtil.getSqlSession().getMapper(TWxAccountMapper.class); - - /** - * 多账号切换账号类型:公众号 - */ - public static final String WX_ACCOUNT_TYPE_MP = "mp"; - - /** - * 多账号切换账号类型:小程序 - */ - public static final String WX_ACCOUNT_TYPE_MA = "ma"; - - private SettingForm() { - UndoUtil.register(this); - } - - public static SettingForm getInstance() { - if (settingForm == null) { - settingForm = new SettingForm(); - } - return settingForm; - } - - /** - * 初始化设置tab - */ - public static void init() { - settingForm = getInstance(); - - settingForm.getSettingScrollPane().getVerticalScrollBar().setUnitIncrement(16); - settingForm.getSettingScrollPane().getVerticalScrollBar().setDoubleBuffered(true); - - // 常规 - settingForm.getAutoCheckUpdateCheckBox().setSelected(App.config.isAutoCheckUpdate()); - settingForm.getUseTrayCheckBox().setSelected(App.config.isUseTray()); - - // 微信公众号 - settingForm.getMpAccountSwitchComboBox().setSelectedItem(App.config.getWechatMpName()); - settingForm.getWechatAppIdTextField().setText(App.config.getWechatAppId()); - settingForm.getWechatAppSecretPasswordField().setText(App.config.getWechatAppSecret()); - settingForm.getWechatTokenPasswordField().setText(App.config.getWechatToken()); - settingForm.getWechatAesKeyPasswordField().setText(App.config.getWechatAesKey()); - - settingForm.getMpUseProxyCheckBox().setSelected(App.config.isMpUseProxy()); - settingForm.getMpProxyHostTextField().setText(App.config.getMpProxyHost()); - settingForm.getMpProxyPortTextField().setText(App.config.getMpProxyPort()); - settingForm.getMpProxyUserNameTextField().setText(App.config.getMpProxyUserName()); - settingForm.getMpProxyPasswordTextField().setText(App.config.getMpProxyPassword()); - - settingForm.getUseOutSideAccessTokenCheckBox().setSelected(App.config.isMpUseOutSideAt()); - settingForm.getManualAtRadioButton().setSelected(App.config.isMpManualAt()); - settingForm.getApiAtRadioButton().setSelected(App.config.isMpApiAt()); - settingForm.getAccessTokenTextField().setText(App.config.getMpAt()); - settingForm.getAtExpiresInTextField().setText(App.config.getMpAtExpiresIn()); - settingForm.getAtApiUrlTextField().setText(App.config.getMpAtApiUrl()); - - // 微信小程序 - settingForm.getMaAccountSwitchComboBox().setSelectedItem(App.config.getMiniAppName()); - settingForm.getMiniAppAppIdTextField().setText(App.config.getMiniAppAppId()); - settingForm.getMiniAppAppSecretPasswordField().setText(App.config.getMiniAppAppSecret()); - settingForm.getMiniAppTokenPasswordField().setText(App.config.getMiniAppToken()); - settingForm.getMiniAppAesKeyPasswordField().setText(App.config.getMiniAppAesKey()); - - settingForm.getMaUseProxyCheckBox().setSelected(App.config.isMaUseProxy()); - settingForm.getMaProxyHostTextField().setText(App.config.getMaProxyHost()); - settingForm.getMaProxyPortTextField().setText(App.config.getMaProxyPort()); - settingForm.getMaProxyUserNameTextField().setText(App.config.getMaProxyUserName()); - settingForm.getMaProxyPasswordTextField().setText(App.config.getMaProxyPassword()); - - initSwitchMultiAccount(); - - // 企业号 - settingForm.getWxCpCorpIdTextField().setText(App.config.getWxCpCorpId()); - - // 阿里云短信 - settingForm.getAliyunAccessKeyIdTextField().setText(App.config.getAliyunAccessKeyId()); - settingForm.getAliyunAccessKeySecretTextField().setText(App.config.getAliyunAccessKeySecret()); - settingForm.getAliyunSignTextField().setText(App.config.getAliyunSign()); - - // 腾讯云短信 - settingForm.getTxyunAppIdTextField().setText(App.config.getTxyunAppId()); - settingForm.getTxyunAppKeyTextField().setText(App.config.getTxyunAppKey()); - settingForm.getTxyunSignTextField().setText(App.config.getTxyunSign()); - - // 华为云短信 - settingForm.getHwAppKeyTextField().setText(App.config.getHwAppKey()); - settingForm.getHwAppSecretPasswordField().setText(App.config.getHwAppSecretPassword()); - settingForm.getHwAccessUrlTextField().setText(App.config.getHwAccessUrl()); - settingForm.getHwSenderCodeTextField().setText(App.config.getHwSenderCode()); - settingForm.getHwSignatureTextField().setText(App.config.getHwSignature()); - - // 百度云短信 - settingForm.getBdAccessKeyIdTextField().setText(App.config.getBdAccessKeyId()); - settingForm.getBdSecretAccessKeyPasswordField().setText(App.config.getBdSecretAccessKey()); - settingForm.getBdEndPointTextField().setText(App.config.getBdEndPoint()); - settingForm.getBdInvokeIdTextField().setText(App.config.getBdInvokeId()); - - // 又拍云短信 - settingForm.getUpAuthorizationTokenTextField().setText(App.config.getUpAuthorizationToken()); - - // 七牛云短信 - settingForm.getQiniuAccessKeyTextField().setText(App.config.getQiniuAccessKey()); - settingForm.getQiniuSecretKeyTextField().setText(App.config.getQiniuSecretKey()); - - // 云片网短信 - settingForm.getYunpianApiKeyTextField().setText(App.config.getYunpianApiKey()); - - // HTTP请求 - settingForm.getHttpUseProxyCheckBox().setSelected(App.config.isHttpUseProxy()); - settingForm.getHttpProxyHostTextField().setText(App.config.getHttpProxyHost()); - settingForm.getHttpProxyPortTextField().setText(App.config.getHttpProxyPort()); - settingForm.getHttpProxyUserTextField().setText(App.config.getHttpProxyUserName()); - settingForm.getHttpProxyPasswordTextField().setText(App.config.getHttpProxyPassword()); - - // E-Mail - settingForm.getMailHostTextField().setText(App.config.getMailHost()); - settingForm.getMailPortTextField().setText(App.config.getMailPort()); - settingForm.getMailFromTextField().setText(App.config.getMailFrom()); - settingForm.getMailUserTextField().setText(App.config.getMailUser()); - settingForm.getMailPasswordField().setText(App.config.getMailPassword()); - settingForm.getMailStartTLSCheckBox().setSelected(App.config.isMailUseStartTLS()); - settingForm.getMailSSLCheckBox().setSelected(App.config.isMailUseSSL()); - - // MySQL - settingForm.getMysqlUrlTextField().setText(App.config.getMysqlUrl()); - settingForm.getMysqlUserTextField().setText(App.config.getMysqlUser()); - settingForm.getMysqlPasswordField().setText(App.config.getMysqlPassword()); - - // 外观 - getSysFontList(); - settingForm.getSettingThemeComboBox().setSelectedItem(App.config.getTheme()); - settingForm.getSettingFontNameComboBox().setSelectedItem(App.config.getFont()); - settingForm.getSettingFontSizeComboBox().setSelectedItem(String.valueOf(App.config.getFontSize())); - - toggleMpProxyPanel(); - toggleMpOutSideAccessTokenPanel(); - toggleMaProxyPanel(); - toggleHttpProxyPanel(); - } - - /** - * 获取系统字体列表 - */ - private static void getSysFontList() { - settingForm = getInstance(); - - settingForm.getSettingFontNameComboBox().removeAllItems(); - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - String[] fonts = ge.getAvailableFontFamilyNames(); - for (String font : fonts) { - if (StringUtils.isNotBlank(font)) { - settingForm.getSettingFontNameComboBox().addItem(font); - } - } - } - - /** - * 初始化多账号切换 - */ - public static void initSwitchMultiAccount() { - settingForm = getInstance(); - - // 多账号切换-公众号 - settingForm.getMpAccountSwitchComboBox().removeAllItems(); - List wxAccountList = wxAccountMapper.selectByAccountType(WX_ACCOUNT_TYPE_MP); - for (TWxAccount tWxAccount : wxAccountList) { - settingForm.getMpAccountSwitchComboBox().addItem(tWxAccount.getAccountName()); - } - settingForm.getMpAccountSwitchComboBox().setSelectedItem(App.config.getWechatMpName()); - // 多账号切换-小程序 - settingForm.getMaAccountSwitchComboBox().removeAllItems(); - wxAccountList = wxAccountMapper.selectByAccountType(WX_ACCOUNT_TYPE_MA); - for (TWxAccount tWxAccount : wxAccountList) { - settingForm.getMaAccountSwitchComboBox().addItem(tWxAccount.getAccountName()); - } - settingForm.getMaAccountSwitchComboBox().setSelectedItem(App.config.getMiniAppName()); - } - - /** - * 切换公众号代理设置面板显示/隐藏 - */ - public static void toggleMpProxyPanel() { - settingForm = getInstance(); - - boolean mpUseProxy = settingForm.getMpUseProxyCheckBox().isSelected(); - if (mpUseProxy) { - settingForm.getMpProxyPanel().setVisible(true); - } else { - settingForm.getMpProxyPanel().setVisible(false); - } - } - - /** - * 切换小程序代理设置面板显示/隐藏 - */ - public static void toggleMaProxyPanel() { - settingForm = getInstance(); - - boolean maUseProxy = settingForm.getMaUseProxyCheckBox().isSelected(); - if (maUseProxy) { - settingForm.getMaProxyPanel().setVisible(true); - } else { - settingForm.getMaProxyPanel().setVisible(false); - } - } - - /** - * 切换HTTP代理设置面板显示/隐藏 - */ - public static void toggleHttpProxyPanel() { - settingForm = getInstance(); - - boolean httpUseProxy = settingForm.getHttpUseProxyCheckBox().isSelected(); - if (httpUseProxy) { - settingForm.getHttpProxyPanel().setVisible(true); - } else { - settingForm.getHttpProxyPanel().setVisible(false); - } - } - - /** - * 切换使用外部AccessToken面板显示/隐藏 - */ - public static void toggleMpOutSideAccessTokenPanel() { - settingForm = getInstance(); - - boolean useOutSideAccessToken = settingForm.getUseOutSideAccessTokenCheckBox().isSelected(); - if (useOutSideAccessToken) { - settingForm.getMpOutSideAccessTokenPanel().setVisible(true); - } else { - settingForm.getMpOutSideAccessTokenPanel().setVisible(false); - } - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - settingPanel = new JPanel(); - settingPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - Font settingPanelFont = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, settingPanel.getFont()); - if (settingPanelFont != null) settingPanel.setFont(settingPanelFont); - panel1.add(settingPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingScrollPane = new JScrollPane(); - settingPanel.add(settingScrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); - settingScrollPane.setViewportView(panel2); - final Spacer spacer1 = new Spacer(); - panel2.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridLayoutManager(16, 1, new Insets(40, 60, 0, 330), -1, -1)); - panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(600, -1), null, 0, false)); - final JPanel panel4 = new JPanel(); - panel4.setLayout(new GridLayoutManager(2, 1, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "常规", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel4.getFont()), null)); - autoCheckUpdateCheckBox = new JCheckBox(); - autoCheckUpdateCheckBox.setText("启动时自动检查更新"); - panel4.add(autoCheckUpdateCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - useTrayCheckBox = new JCheckBox(); - useTrayCheckBox.setText("显示系统托盘图标"); - panel4.add(useTrayCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel5 = new JPanel(); - panel5.setLayout(new GridLayoutManager(6, 3, new Insets(15, 15, 10, 0), -1, -1)); - Font panel5Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel5.getFont()); - if (panel5Font != null) panel5.setFont(panel5Font); - panel3.add(panel5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "微信公众号", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel5.getFont()), null)); - final JPanel panel6 = new JPanel(); - panel6.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel5.add(panel6, new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingMpInfoSaveButton = new JButton(); - settingMpInfoSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - settingMpInfoSaveButton.setText("保存"); - panel6.add(settingMpInfoSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer2 = new Spacer(); - panel6.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - mpAccountManageButton = new JButton(); - mpAccountManageButton.setIcon(new ImageIcon(getClass().getResource("/icon/feature.png"))); - mpAccountManageButton.setText("多账号管理"); - panel6.add(mpAccountManageButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpUseProxyCheckBox = new JCheckBox(); - mpUseProxyCheckBox.setText("使用HTTP代理"); - panel5.add(mpUseProxyCheckBox, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpProxyPanel = new JPanel(); - mpProxyPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 26, 0, 0), -1, -1)); - panel5.add(mpProxyPanel, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label1 = new JLabel(); - label1.setText("Host"); - mpProxyPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpProxyHostTextField = new JTextField(); - mpProxyPanel.add(mpProxyHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("端口"); - mpProxyPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpProxyPortTextField = new JTextField(); - mpProxyPanel.add(mpProxyPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("用户名"); - label3.setToolTipText("选填"); - mpProxyPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpProxyUserNameTextField = new JTextField(); - mpProxyUserNameTextField.setToolTipText("选填"); - mpProxyPanel.add(mpProxyUserNameTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("密码"); - label4.setToolTipText("选填"); - mpProxyPanel.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpProxyPasswordTextField = new JTextField(); - mpProxyPasswordTextField.setToolTipText("选填"); - mpProxyPanel.add(mpProxyPasswordTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - useOutSideAccessTokenCheckBox = new JCheckBox(); - useOutSideAccessTokenCheckBox.setText("使用外部AccessToken"); - panel5.add(useOutSideAccessTokenCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpOutSideAccessTokenPanel = new JPanel(); - mpOutSideAccessTokenPanel.setLayout(new GridLayoutManager(5, 4, new Insets(0, 26, 0, 0), -1, -1)); - panel5.add(mpOutSideAccessTokenPanel, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - manualAtRadioButton = new JRadioButton(); - manualAtRadioButton.setText("手动输入"); - mpOutSideAccessTokenPanel.add(manualAtRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - apiAtRadioButton = new JRadioButton(); - apiAtRadioButton.setText("通过接口获取"); - mpOutSideAccessTokenPanel.add(apiAtRadioButton, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel7 = new JPanel(); - panel7.setLayout(new GridLayoutManager(2, 2, new Insets(0, 25, 0, 0), -1, -1)); - mpOutSideAccessTokenPanel.add(panel7, new GridConstraints(1, 0, 2, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label5 = new JLabel(); - label5.setText("AccessToken"); - panel7.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - accessTokenTextField = new JTextField(); - panel7.add(accessTokenTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label6 = new JLabel(); - label6.setText("有效期(秒)"); - panel7.add(label6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - atExpiresInTextField = new JTextField(); - panel7.add(atExpiresInTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel8 = new JPanel(); - panel8.setLayout(new GridLayoutManager(1, 2, new Insets(0, 25, 0, 0), -1, -1)); - mpOutSideAccessTokenPanel.add(panel8, new GridConstraints(4, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label7 = new JLabel(); - label7.setText("接口url"); - label7.setToolTipText(""); - panel8.add(label7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - atApiUrlTextField = new JTextField(); - atApiUrlTextField.setToolTipText(""); - panel8.add(atApiUrlTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - manualAtTipsLabel = new JLabel(); - manualAtTipsLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); - manualAtTipsLabel.setText(""); - mpOutSideAccessTokenPanel.add(manualAtTipsLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer3 = new Spacer(); - mpOutSideAccessTokenPanel.add(spacer3, new GridConstraints(0, 2, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - apiAtTipsLabel = new JLabel(); - apiAtTipsLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); - apiAtTipsLabel.setText(""); - mpOutSideAccessTokenPanel.add(apiAtTipsLabel, new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer4 = new Spacer(); - mpOutSideAccessTokenPanel.add(spacer4, new GridConstraints(3, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - outSideAtTipsLabel = new JLabel(); - outSideAtTipsLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); - outSideAtTipsLabel.setText(""); - panel5.add(outSideAtTipsLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel9 = new JPanel(); - panel9.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel5.add(panel9, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label8 = new JLabel(); - label8.setText("AppID"); - panel9.add(label8, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wechatAppIdTextField = new JTextField(); - panel9.add(wechatAppIdTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label9 = new JLabel(); - label9.setText("AppSecret"); - panel9.add(label9, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wechatAppSecretPasswordField = new JPasswordField(); - panel9.add(wechatAppSecretPasswordField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label10 = new JLabel(); - label10.setText("Token"); - panel9.add(label10, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wechatTokenPasswordField = new JPasswordField(); - panel9.add(wechatTokenPasswordField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label11 = new JLabel(); - label11.setText("AES Key"); - panel9.add(label11, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wechatAesKeyPasswordField = new JPasswordField(); - panel9.add(wechatAesKeyPasswordField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label12 = new JLabel(); - label12.setText("切换账号"); - panel9.add(label12, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mpAccountSwitchComboBox = new JComboBox(); - panel9.add(mpAccountSwitchComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final Spacer spacer5 = new Spacer(); - panel5.add(spacer5, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel10 = new JPanel(); - panel10.setLayout(new GridLayoutManager(8, 2, new Insets(15, 15, 10, 0), -1, -1)); - Font panel10Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel10.getFont()); - if (panel10Font != null) panel10.setFont(panel10Font); - panel3.add(panel10, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel10.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "微信小程序", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel10.getFont()), null)); - final JLabel label13 = new JLabel(); - label13.setText("AppID"); - panel10.add(label13, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - miniAppAppIdTextField = new JTextField(); - panel10.add(miniAppAppIdTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label14 = new JLabel(); - label14.setText("AppSecret"); - panel10.add(label14, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - miniAppAppSecretPasswordField = new JPasswordField(); - panel10.add(miniAppAppSecretPasswordField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label15 = new JLabel(); - label15.setText("Token"); - panel10.add(label15, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - miniAppTokenPasswordField = new JPasswordField(); - miniAppTokenPasswordField.setText(""); - panel10.add(miniAppTokenPasswordField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label16 = new JLabel(); - label16.setText("AES Key"); - panel10.add(label16, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - miniAppAesKeyPasswordField = new JPasswordField(); - panel10.add(miniAppAesKeyPasswordField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel11 = new JPanel(); - panel11.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel10.add(panel11, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingMaInfoSaveButton = new JButton(); - settingMaInfoSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - settingMaInfoSaveButton.setText("保存"); - panel11.add(settingMaInfoSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer6 = new Spacer(); - panel11.add(spacer6, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - maAccountManageButton = new JButton(); - maAccountManageButton.setIcon(new ImageIcon(getClass().getResource("/icon/feature.png"))); - maAccountManageButton.setText("多账号管理"); - panel11.add(maAccountManageButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label17 = new JLabel(); - label17.setText("切换账号"); - panel10.add(label17, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - maAccountSwitchComboBox = new JComboBox(); - panel10.add(maAccountSwitchComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - maUseProxyCheckBox = new JCheckBox(); - maUseProxyCheckBox.setText("使用HTTP代理"); - panel10.add(maUseProxyCheckBox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - maProxyPanel = new JPanel(); - maProxyPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 26, 0, 0), -1, -1)); - panel10.add(maProxyPanel, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label18 = new JLabel(); - label18.setText("Host"); - maProxyPanel.add(label18, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - maProxyHostTextField = new JTextField(); - maProxyPanel.add(maProxyHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label19 = new JLabel(); - label19.setText("端口"); - maProxyPanel.add(label19, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label20 = new JLabel(); - label20.setText("用户名"); - maProxyPanel.add(label20, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label21 = new JLabel(); - label21.setText("密码"); - maProxyPanel.add(label21, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - maProxyPortTextField = new JTextField(); - maProxyPanel.add(maProxyPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - maProxyUserNameTextField = new JTextField(); - maProxyPanel.add(maProxyUserNameTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - maProxyPasswordTextField = new JTextField(); - maProxyPanel.add(maProxyPasswordTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel12 = new JPanel(); - panel12.setLayout(new GridLayoutManager(2, 2, new Insets(15, 15, 10, 0), -1, -1)); - Font panel12Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel12.getFont()); - if (panel12Font != null) panel12.setFont(panel12Font); - panel3.add(panel12, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel12.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "微信企业号/企业微信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel12.getFont()), null)); - final JLabel label22 = new JLabel(); - label22.setText("企业ID"); - panel12.add(label22, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - wxCpCorpIdTextField = new JTextField(); - panel12.add(wxCpCorpIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel13 = new JPanel(); - panel13.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel12.add(panel13, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - wxCpSaveButton = new JButton(); - wxCpSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - wxCpSaveButton.setText("保存"); - panel13.add(wxCpSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer7 = new Spacer(); - panel13.add(spacer7, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - wxCpAppManageButton = new JButton(); - wxCpAppManageButton.setText("应用管理"); - panel13.add(wxCpAppManageButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel14 = new JPanel(); - panel14.setLayout(new GridLayoutManager(1, 1, new Insets(15, 15, 10, 0), -1, -1)); - Font panel14Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel14.getFont()); - if (panel14Font != null) panel14.setFont(panel14Font); - panel3.add(panel14, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel14.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "钉钉", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel14.getFont()), null)); - final JPanel panel15 = new JPanel(); - panel15.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel14.add(panel15, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final Spacer spacer8 = new Spacer(); - panel15.add(spacer8, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - dingAppManageButton = new JButton(); - dingAppManageButton.setText("应用管理"); - panel15.add(dingAppManageButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel16 = new JPanel(); - panel16.setLayout(new GridLayoutManager(4, 2, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel16, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel16.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "阿里云短信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel16.getFont()), null)); - final JLabel label23 = new JLabel(); - label23.setText("AccessKeyId"); - panel16.add(label23, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label24 = new JLabel(); - label24.setText("AccessKeySecret"); - panel16.add(label24, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label25 = new JLabel(); - label25.setText("短信签名"); - panel16.add(label25, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - aliyunSignTextField = new JTextField(); - panel16.add(aliyunSignTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - aliyunAccessKeySecretTextField = new JPasswordField(); - panel16.add(aliyunAccessKeySecretTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel17 = new JPanel(); - panel17.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel16.add(panel17, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingAliyunSaveButton = new JButton(); - settingAliyunSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - settingAliyunSaveButton.setText("保存"); - panel17.add(settingAliyunSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer9 = new Spacer(); - panel17.add(spacer9, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - aliyunAccessKeyIdTextField = new JTextField(); - panel16.add(aliyunAccessKeyIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JPanel panel18 = new JPanel(); - panel18.setLayout(new GridLayoutManager(4, 2, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel18, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel18.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "腾讯云短信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel18.getFont()), null)); - final JLabel label26 = new JLabel(); - label26.setText("AppId"); - panel18.add(label26, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label27 = new JLabel(); - label27.setText("AppKey"); - panel18.add(label27, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label28 = new JLabel(); - label28.setText("短信签名"); - panel18.add(label28, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - txyunSignTextField = new JTextField(); - panel18.add(txyunSignTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - txyunAppKeyTextField = new JPasswordField(); - txyunAppKeyTextField.setText(""); - panel18.add(txyunAppKeyTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel19 = new JPanel(); - panel19.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel18.add(panel19, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingTxyunSaveButton = new JButton(); - settingTxyunSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - settingTxyunSaveButton.setText("保存"); - panel19.add(settingTxyunSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer10 = new Spacer(); - panel19.add(spacer10, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - txyunAppIdTextField = new JTextField(); - panel18.add(txyunAppIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JPanel panel20 = new JPanel(); - panel20.setLayout(new GridLayoutManager(6, 2, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel20, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel20.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "华为云短信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel20.getFont()), null)); - final JLabel label29 = new JLabel(); - label29.setText("AppKey"); - panel20.add(label29, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label30 = new JLabel(); - label30.setText("AppSecret"); - panel20.add(label30, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label31 = new JLabel(); - label31.setText("APP接入地址"); - panel20.add(label31, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label32 = new JLabel(); - label32.setText("短信签名通道号"); - panel20.add(label32, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label33 = new JLabel(); - label33.setText("短信签名"); - panel20.add(label33, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - hwAccessUrlTextField = new JTextField(); - panel20.add(hwAccessUrlTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - hwSenderCodeTextField = new JTextField(); - panel20.add(hwSenderCodeTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - hwSignatureTextField = new JTextField(); - panel20.add(hwSignatureTextField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - hwAppSecretPasswordField = new JPasswordField(); - hwAppSecretPasswordField.setText(""); - panel20.add(hwAppSecretPasswordField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel21 = new JPanel(); - panel21.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel20.add(panel21, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - hwSaveButton = new JButton(); - hwSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - hwSaveButton.setText("保存"); - panel21.add(hwSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer11 = new Spacer(); - panel21.add(spacer11, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - hwAppKeyTextField = new JTextField(); - panel20.add(hwAppKeyTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JPanel panel22 = new JPanel(); - panel22.setLayout(new GridLayoutManager(5, 2, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel22, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel22.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "百度云短信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel22.getFont()), null)); - final JLabel label34 = new JLabel(); - label34.setText("AccessKeyID"); - panel22.add(label34, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label35 = new JLabel(); - label35.setText("SecretAccessKey"); - panel22.add(label35, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label36 = new JLabel(); - label36.setText("SMS服务域名"); - panel22.add(label36, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label37 = new JLabel(); - label37.setText("签名的调用ID"); - panel22.add(label37, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - bdEndPointTextField = new JTextField(); - panel22.add(bdEndPointTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - bdInvokeIdTextField = new JTextField(); - panel22.add(bdInvokeIdTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - bdSecretAccessKeyPasswordField = new JPasswordField(); - bdSecretAccessKeyPasswordField.setText(""); - panel22.add(bdSecretAccessKeyPasswordField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel23 = new JPanel(); - panel23.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel22.add(panel23, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - bdSaveButton = new JButton(); - bdSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - bdSaveButton.setText("保存"); - panel23.add(bdSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer12 = new Spacer(); - panel23.add(spacer12, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - bdAccessKeyIdTextField = new JTextField(); - panel22.add(bdAccessKeyIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JPanel panel24 = new JPanel(); - panel24.setLayout(new GridLayoutManager(2, 2, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel24, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel24.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "又拍云短信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel24.getFont()), null)); - final JLabel label38 = new JLabel(); - label38.setText("授权token"); - panel24.add(label38, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel25 = new JPanel(); - panel25.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel24.add(panel25, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - upSaveButton = new JButton(); - upSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - upSaveButton.setText("保存"); - panel25.add(upSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer13 = new Spacer(); - panel25.add(spacer13, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - upAuthorizationTokenTextField = new JTextField(); - panel24.add(upAuthorizationTokenTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JPanel panel26 = new JPanel(); - panel26.setLayout(new GridLayoutManager(3, 3, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel26, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel26.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "七牛云短信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel26.getFont()), null)); - final JLabel label39 = new JLabel(); - label39.setText("AcessKey"); - panel26.add(label39, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label40 = new JLabel(); - label40.setText("SecretKey"); - panel26.add(label40, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel27 = new JPanel(); - panel27.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel26.add(panel27, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - qiniuSaveButton = new JButton(); - qiniuSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - qiniuSaveButton.setText("保存"); - panel27.add(qiniuSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer14 = new Spacer(); - panel27.add(spacer14, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - qiniuAccessKeyTextField = new JTextField(); - panel26.add(qiniuAccessKeyTextField, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - qiniuSecretKeyTextField = new JTextField(); - panel26.add(qiniuSecretKeyTextField, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JPanel panel28 = new JPanel(); - panel28.setLayout(new GridLayoutManager(2, 2, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel28, new GridConstraints(11, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel28.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "云片网短信", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel28.getFont()), null)); - final JLabel label41 = new JLabel(); - label41.setText("ApiKey"); - panel28.add(label41, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - yunpianApiKeyTextField = new JPasswordField(); - yunpianApiKeyTextField.setText(""); - panel28.add(yunpianApiKeyTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JPanel panel29 = new JPanel(); - panel29.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel28.add(panel29, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingYunpianSaveButton = new JButton(); - settingYunpianSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - settingYunpianSaveButton.setText("保存"); - panel29.add(settingYunpianSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer15 = new Spacer(); - panel29.add(spacer15, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel30 = new JPanel(); - panel30.setLayout(new GridLayoutManager(8, 2, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel30, new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel30.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "E-Mail", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel30.getFont()), null)); - final JLabel label42 = new JLabel(); - label42.setText("邮件服务器的SMTP地址"); - panel30.add(label42, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label43 = new JLabel(); - label43.setText("邮件服务器的SMTP端口"); - panel30.add(label43, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label44 = new JLabel(); - label44.setText("发件人(邮箱地址)"); - panel30.add(label44, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label45 = new JLabel(); - label45.setText("用户名"); - label45.setToolTipText("如果使用foxmail邮箱,此处为qq号"); - panel30.add(label45, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label46 = new JLabel(); - label46.setText("密码"); - panel30.add(label46, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel31 = new JPanel(); - panel31.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel30.add(panel31, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - saveMailButton = new JButton(); - saveMailButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - saveMailButton.setText("保存"); - panel31.add(saveMailButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer16 = new Spacer(); - panel31.add(spacer16, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - testMailButton = new JButton(); - testMailButton.setIcon(new ImageIcon(getClass().getResource("/icon/arrow_right.png"))); - testMailButton.setText("测试"); - panel31.add(testMailButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mailStartTLSCheckBox = new JCheckBox(); - mailStartTLSCheckBox.setText("使用STARTTLS安全连接"); - panel30.add(mailStartTLSCheckBox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mailSSLCheckBox = new JCheckBox(); - mailSSLCheckBox.setText("使用SSL安全连接"); - panel30.add(mailSSLCheckBox, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mailHostTextField = new JTextField(); - panel30.add(mailHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - mailPortTextField = new JTextField(); - panel30.add(mailPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - mailFromTextField = new JTextField(); - panel30.add(mailFromTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - mailUserTextField = new JTextField(); - panel30.add(mailUserTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - mailPasswordField = new JPasswordField(); - panel30.add(mailPasswordField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel32 = new JPanel(); - panel32.setLayout(new GridLayoutManager(4, 4, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel32, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel32.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "MySQL数据库", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel32.getFont()), null)); - final JLabel label47 = new JLabel(); - label47.setText("数据库地址"); - panel32.add(label47, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mysqlUrlTextField = new JTextField(); - panel32.add(mysqlUrlTextField, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JLabel label48 = new JLabel(); - label48.setText("用户名"); - panel32.add(label48, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mysqlUserTextField = new JTextField(); - panel32.add(mysqlUserTextField, new GridConstraints(1, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label49 = new JLabel(); - label49.setText("密码"); - panel32.add(label49, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - mysqlPasswordField = new JPasswordField(); - panel32.add(mysqlPasswordField, new GridConstraints(2, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JPanel panel33 = new JPanel(); - panel33.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel32.add(panel33, new GridConstraints(3, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingTestDbLinkButton = new JButton(); - settingTestDbLinkButton.setIcon(new ImageIcon(getClass().getResource("/icon/arrow_right.png"))); - settingTestDbLinkButton.setText("测试连接"); - panel33.add(settingTestDbLinkButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer17 = new Spacer(); - panel33.add(spacer17, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - settingDbInfoSaveButton = new JButton(); - settingDbInfoSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - settingDbInfoSaveButton.setText("保存"); - panel33.add(settingDbInfoSaveButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel34 = new JPanel(); - panel34.setLayout(new GridLayoutManager(4, 3, new Insets(15, 15, 10, 0), -1, -1)); - panel3.add(panel34, new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel34.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "外观", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel34.getFont()), null)); - final JLabel label50 = new JLabel(); - label50.setText("主题风格"); - panel34.add(label50, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - settingThemeComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); - defaultComboBoxModel1.addElement("Darcula(推荐)"); - defaultComboBoxModel1.addElement("BeautyEye"); - defaultComboBoxModel1.addElement("系统默认"); - settingThemeComboBox.setModel(defaultComboBoxModel1); - panel34.add(settingThemeComboBox, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); - final JLabel label51 = new JLabel(); - label51.setText("字体"); - panel34.add(label51, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - settingFontNameComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel(); - defaultComboBoxModel2.addElement("Microsoft YaHei"); - defaultComboBoxModel2.addElement("Microsoft YaHei Light"); - defaultComboBoxModel2.addElement("Microsoft YaHei UI"); - defaultComboBoxModel2.addElement("Microsoft YaHei UI Light"); - settingFontNameComboBox.setModel(defaultComboBoxModel2); - panel34.add(settingFontNameComboBox, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label52 = new JLabel(); - label52.setText("字号"); - panel34.add(label52, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - settingFontSizeComboBox = new JComboBox(); - final DefaultComboBoxModel defaultComboBoxModel3 = new DefaultComboBoxModel(); - defaultComboBoxModel3.addElement("5"); - defaultComboBoxModel3.addElement("6"); - defaultComboBoxModel3.addElement("7"); - defaultComboBoxModel3.addElement("8"); - defaultComboBoxModel3.addElement("9"); - defaultComboBoxModel3.addElement("10"); - defaultComboBoxModel3.addElement("11"); - defaultComboBoxModel3.addElement("12"); - defaultComboBoxModel3.addElement("13"); - defaultComboBoxModel3.addElement("14"); - defaultComboBoxModel3.addElement("15"); - defaultComboBoxModel3.addElement("16"); - defaultComboBoxModel3.addElement("17"); - defaultComboBoxModel3.addElement("18"); - defaultComboBoxModel3.addElement("19"); - defaultComboBoxModel3.addElement("20"); - defaultComboBoxModel3.addElement("21"); - defaultComboBoxModel3.addElement("22"); - defaultComboBoxModel3.addElement("23"); - defaultComboBoxModel3.addElement("24"); - defaultComboBoxModel3.addElement("25"); - defaultComboBoxModel3.addElement("26"); - settingFontSizeComboBox.setModel(defaultComboBoxModel3); - panel34.add(settingFontSizeComboBox, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel35 = new JPanel(); - panel35.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel34.add(panel35, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - settingAppearanceSaveButton = new JButton(); - settingAppearanceSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - settingAppearanceSaveButton.setText("保存"); - panel35.add(settingAppearanceSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer18 = new Spacer(); - panel35.add(spacer18, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel36 = new JPanel(); - panel36.setLayout(new GridLayoutManager(3, 1, new Insets(15, 15, 10, 0), -1, -1)); - Font panel36Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel36.getFont()); - if (panel36Font != null) panel36.setFont(panel36Font); - panel3.add(panel36, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel36.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "HTTP请求", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel36.getFont()), null)); - final JPanel panel37 = new JPanel(); - panel37.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel36.add(panel37, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - httpSaveButton = new JButton(); - httpSaveButton.setIcon(new ImageIcon(getClass().getResource("/icon/menu-saveall_dark.png"))); - httpSaveButton.setText("保存"); - panel37.add(httpSaveButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final Spacer spacer19 = new Spacer(); - panel37.add(spacer19, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - httpUseProxyCheckBox = new JCheckBox(); - httpUseProxyCheckBox.setText("使用HTTP代理"); - panel36.add(httpUseProxyCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - httpProxyPanel = new JPanel(); - httpProxyPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 26, 0, 0), -1, -1)); - panel36.add(httpProxyPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label53 = new JLabel(); - label53.setText("Host"); - httpProxyPanel.add(label53, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - httpProxyHostTextField = new JTextField(); - httpProxyPanel.add(httpProxyHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label54 = new JLabel(); - label54.setText("端口"); - httpProxyPanel.add(label54, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label55 = new JLabel(); - label55.setText("用户名"); - httpProxyPanel.add(label55, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label56 = new JLabel(); - label56.setText("密码"); - httpProxyPanel.add(label56, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - httpProxyPortTextField = new JTextField(); - httpProxyPanel.add(httpProxyPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - httpProxyUserTextField = new JTextField(); - httpProxyPanel.add(httpProxyUserTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - httpProxyPasswordTextField = new JTextField(); - httpProxyPanel.add(httpProxyPasswordTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - } - - /** - * @noinspection ALL - */ - private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { - if (currentFont == null) return null; - String resultName; - if (fontName == null) { - resultName = currentFont.getName(); - } else { - Font testFont = new Font(fontName, Font.PLAIN, 10); - if (testFont.canDisplay('a') && testFont.canDisplay('1')) { - resultName = fontName; - } else { - resultName = currentFont.getName(); - } - } - return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/TaskForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/TaskForm.form new file mode 100644 index 000000000..30846f671 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/TaskForm.form @@ -0,0 +1,392 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/TaskForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/TaskForm.java new file mode 100644 index 000000000..b8425789a --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/TaskForm.java @@ -0,0 +1,475 @@ +package com.fangxuele.tool.push.ui.form; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.cron.pattern.CronPattern; +import cn.hutool.cron.pattern.CronPatternUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.domain.TTask; +import com.fangxuele.tool.push.domain.TTaskHis; +import com.fangxuele.tool.push.logic.*; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.util.JTableUtil; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.lang3.time.DateUtils; + +import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.table.DefaultTableModel; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +/** + *
+ * 推送任务
+ * 
+ * + * @author Zhou Bo + * @since 2021/5/14. + */ +@Getter +public class TaskForm { + private JPanel mainPanel; + private JTable taskListTable; + private JButton newTaskButton; + private JScrollPane taskListScrollPane; + private JButton deleteButton; + private JButton modifyButton; + private JButton startDryRunButton; + private JButton startButton; + private JTable taskHisListTable; + private JButton stopButton; + private JButton hisDeleteButton; + private JButton taskHisDetailButton; + private JLabel jvmMemoryLabel; + private JLabel availableProcessorLabel; + private JLabel scheduleDetailLabel; + private JPanel pushUpPanel; + private JLabel taskTitle; + private JSplitPane mainSplitPane; + private JLabel msgTypeLabel; + private JLabel msgNameLabel; + private JLabel peopleNameLabel; + private JLabel schedulePlanDetailLabel; + private JLabel plan1Label; + private JLabel plan2Label; + private JLabel plan3Label; + private JLabel plan4Label; + private JLabel plan5Label; + private JLabel planToContinueLabel; + private JLabel modeLabel; + private JLabel threadCntLabel; + + private static TaskForm taskForm; + + private static TTaskMapper taskMapper = MybatisUtil.getSqlSession().getMapper(TTaskMapper.class); + private static TTaskHisMapper taskHisMapper = MybatisUtil.getSqlSession().getMapper(TTaskHisMapper.class); + private static TTaskExtMapper taskExtMapper = MybatisUtil.getSqlSession().getMapper(TTaskExtMapper.class); + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + private TaskForm() { + UndoUtil.register(this); + } + + public static TaskForm getInstance() { + if (taskForm == null) { + taskForm = new TaskForm(); + } + return taskForm; + } + + public static void init() { + taskForm = getInstance(); + + hidePlanLabel(); + + taskForm.getDeleteButton().setIcon(new FlatSVGIcon("icon/remove.svg")); + taskForm.getHisDeleteButton().setIcon(new FlatSVGIcon("icon/remove.svg")); + taskForm.getStartButton().setIcon(new FlatSVGIcon("icon/send.svg")); + taskForm.getNewTaskButton().setIcon(new FlatSVGIcon("icon/add.svg")); + taskForm.getModifyButton().setIcon(new FlatSVGIcon("icon/modify.svg")); + taskForm.getStartDryRunButton().setIcon(new FlatSVGIcon("icon/debug.svg")); + taskForm.getTaskHisDetailButton().setIcon(new FlatSVGIcon("icon/detail.svg")); + taskForm.getStopButton().setIcon(new FlatSVGIcon("icon/stop.svg")); + + taskForm.getTaskListTable().setRowHeight(UiConsts.TABLE_ROW_HEIGHT); + taskForm.getTaskHisListTable().setRowHeight(UiConsts.TABLE_ROW_HEIGHT); + JTableUtil.setTableHeaderLeftAlignment(taskForm.getTaskListTable()); + JTableUtil.setTableHeaderLeftAlignment(taskForm.getTaskHisListTable()); + taskForm.getTaskListTable().setShowHorizontalLines(true); + taskForm.getTaskHisListTable().setShowHorizontalLines(true); + taskForm.getTaskListTable().setShowVerticalLines(true); + taskForm.getTaskHisListTable().setShowVerticalLines(true); + taskForm.getMainSplitPane().setDividerLocation((int) (App.mainFrame.getWidth() / 2)); + + initTaskListTable(); + + // 每秒钟刷新一次 + new Timer(1000, e -> { + // 可用处理器核心 + taskForm.getAvailableProcessorLabel().setText("可用处理器核心:" + Runtime.getRuntime().availableProcessors()); + // JVM内存占用 + taskForm.getJvmMemoryLabel().setText("JVM内存占用:" + FileUtil.readableFileSize(Runtime.getRuntime().totalMemory()) + "/" + FileUtil.readableFileSize(Runtime.getRuntime().maxMemory())); + }).start(); + } + + public static void initTaskListTable() { + JTable taskListTable = taskForm.getTaskListTable(); + + // 任务数据列表 + String[] headerNames = {"id", "任务名称", "消息类型", "周期", "消息名称", "人群"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + taskListTable.setModel(model); + + taskListTable.getTableHeader().setReorderingAllowed(false); + + Object[] data; + + List taskList = taskExtMapper.selectAll(); + for (TTask task : taskList) { + data = new Object[6]; + data[0] = task.getId(); + data[1] = task.getTitle(); + data[2] = MessageTypeEnum.getName(task.getMsgType()); + data[3] = getTaskType(task); + data[4] = getMsgName(task.getMessageId()); + data[5] = peopleMapper.selectByPrimaryKey(task.getPeopleId()).getPeopleName(); + model.addRow(data); + } + // 隐藏id列 + JTableUtil.hideColumn(taskListTable, 0); + + // 设置列宽 +// TableColumnModel tableColumnModel = taskListTable.getColumnModel(); +// tableColumnModel.getColumn(3).setMaxWidth(60); + + // 如果有数据,则默认选中第一行 + if (taskListTable.getRowCount() > 0) { + taskListTable.setRowSelectionInterval(0, 0); + initTaskHisListTable((Integer) taskListTable.getValueAt(0, 0)); + + TTask tTask = taskList.get(0); + + fillSchedulePlan(tTask); + } else { + JTable taskHisListTable = taskForm.getTaskHisListTable(); + // 清空任务历史列表 + String[] headerNames2 = {"id", "是否空跑", "开始时间", "结束时间", "总量", "成功", "失败", "状态"}; + DefaultTableModel model2 = new DefaultTableModel(null, headerNames2); + taskHisListTable.setModel(model2); + } + } + + public static void fillSchedulePlan(TTask tTask) { + taskForm.getTaskTitle().setText(tTask.getTitle()); + taskForm.getMsgNameLabel().setText("消息名称:" + getMsgName(tTask.getMessageId())); + taskForm.getMsgTypeLabel().setText("消息类型:" + MessageTypeEnum.getName(tTask.getMsgType())); + taskForm.getPeopleNameLabel().setText("人群:" + peopleMapper.selectByPrimaryKey(tTask.getPeopleId()).getPeopleName()); + taskForm.getModeLabel().setText("模式:" + TaskModeEnum.getDescByCode(tTask.getTaskMode())); + taskForm.getThreadCntLabel().setText("线程数:" + tTask.getThreadCnt()); + + if (tTask.getTaskPeriod() == TaskTypeEnum.SCHEDULE_TASK_CODE && StringUtils.isNotBlank(tTask.getCron())) { + List latest5RunTimeList = Lists.newArrayList(); + Date now = new Date(); + for (int i = 0; i < 5; i++) { + if (PeriodTypeEnum.RUN_AT_THIS_TIME_TASK_CODE == tTask.getPeriodType()) { + latest5RunTimeList.add(tTask.getPeriodTime()); + break; + } + if (PeriodTypeEnum.RUN_PER_DAY_TASK_CODE == tTask.getPeriodType()) { + Date date = CronPatternUtil.nextDateAfter(new CronPattern(tTask.getCron()), DateUtils.addDays(now, i), true); + latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); + continue; + } + if (PeriodTypeEnum.RUN_PER_WEEK_TASK_CODE == tTask.getPeriodType()) { + Date date = CronPatternUtil.nextDateAfter(new CronPattern(tTask.getCron()), DateUtils.addDays(now, i * 7), true); + latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); + continue; + } + if (PeriodTypeEnum.CRON_TASK_CODE == tTask.getPeriodType()) { + Date date = CronPatternUtil.nextDateAfter(new CronPattern(tTask.getCron()), DateUtils.addDays(now, i), true); + latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); + continue; + } + } + taskForm.getSchedulePlanDetailLabel().setText("执行计划:"); + if (latest5RunTimeList.size() > 0) { + taskForm.getPlan1Label().setText(latest5RunTimeList.get(0) == null ? "" : latest5RunTimeList.get(0)); + } + if (latest5RunTimeList.size() > 1) { + taskForm.getPlan2Label().setText(latest5RunTimeList.get(1) == null ? "" : latest5RunTimeList.get(1)); + } + if (latest5RunTimeList.size() > 2) { + taskForm.getPlan3Label().setText(latest5RunTimeList.get(2) == null ? "" : latest5RunTimeList.get(2)); + } + if (latest5RunTimeList.size() > 3) { + taskForm.getPlan4Label().setText(latest5RunTimeList.get(3) == null ? "" : latest5RunTimeList.get(3)); + } + if (latest5RunTimeList.size() > 4) { + taskForm.getPlan5Label().setText(latest5RunTimeList.get(4) == null ? "" : latest5RunTimeList.get(4)); + } + taskForm.getPlanToContinueLabel().setText("……"); + } else { + taskForm.getSchedulePlanDetailLabel().setText("执行计划:无"); + hidePlanLabel(); + } + } + + private static void hidePlanLabel() { + taskForm.getPlan1Label().setText(""); + taskForm.getPlan2Label().setText(""); + taskForm.getPlan3Label().setText(""); + taskForm.getPlan4Label().setText(""); + taskForm.getPlan5Label().setText(""); + taskForm.getPlanToContinueLabel().setText(""); + } + + private static String getTaskType(TTask task) { + if (TaskTypeEnum.SCHEDULE_TASK.getCode() == task.getTaskPeriod()) { + return task.getCron(); + } else { + return TaskTypeEnum.getDescByCode(task.getTaskPeriod()); + } + } + + private static String getMsgName(Integer messageId) { + String msgName = msgMapper.selectByPrimaryKey(messageId).getMsgName(); + return msgName; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1)); + mainSplitPane = new JSplitPane(); + mainSplitPane.setContinuousLayout(true); + mainSplitPane.setDividerLocation(516); + mainSplitPane.setDoubleBuffered(true); + mainPanel.add(mainSplitPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainSplitPane.setLeftComponent(panel1); + taskListScrollPane = new JScrollPane(); + panel1.add(taskListScrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + taskListTable = new JTable(); + taskListTable.setDragEnabled(false); + taskListScrollPane.setViewportView(taskListTable); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + newTaskButton = new JButton(); + newTaskButton.setText("新建"); + panel2.add(newTaskButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + deleteButton = new JButton(); + deleteButton.setText("删除"); + panel2.add(deleteButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + modifyButton = new JButton(); + modifyButton.setText("修改"); + panel2.add(modifyButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + startDryRunButton = new JButton(); + startDryRunButton.setText("空跑测试"); + panel2.add(startDryRunButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + startButton = new JButton(); + startButton.setText("立即执行"); + panel2.add(startButton, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel2.add(spacer1, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainSplitPane.setRightComponent(panel3); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(panel4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + pushUpPanel = new JPanel(); + pushUpPanel.setLayout(new GridLayoutManager(1, 5, new Insets(5, 5, 5, 5), -1, -1)); + panel4.add(pushUpPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JSeparator separator1 = new JSeparator(); + separator1.setOrientation(1); + pushUpPanel.add(separator1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); + pushUpPanel.add(panel5, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + jvmMemoryLabel = new JLabel(); + jvmMemoryLabel.setText("JVM内存占用:--"); + panel5.add(jvmMemoryLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + availableProcessorLabel = new JLabel(); + availableProcessorLabel.setText("可用处理器核心:--"); + panel5.add(availableProcessorLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + scheduleDetailLabel = new JLabel(); + scheduleDetailLabel.setForeground(new Color(-276358)); + scheduleDetailLabel.setText(""); + panel5.add(scheduleDetailLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel5.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(7, 1, new Insets(0, 0, 0, 0), -1, -1)); + pushUpPanel.add(panel6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + taskTitle = new JLabel(); + Font taskTitleFont = this.$$$getFont$$$(null, -1, 24, taskTitle.getFont()); + if (taskTitleFont != null) taskTitle.setFont(taskTitleFont); + taskTitle.setForeground(new Color(-276358)); + taskTitle.setText("任务标题"); + panel6.add(taskTitle, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel6.add(spacer3, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + msgTypeLabel = new JLabel(); + msgTypeLabel.setText("消息类型:"); + panel6.add(msgTypeLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgNameLabel = new JLabel(); + msgNameLabel.setText("消息名称:"); + panel6.add(msgNameLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + peopleNameLabel = new JLabel(); + peopleNameLabel.setText("人群:"); + panel6.add(peopleNameLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + modeLabel = new JLabel(); + modeLabel.setText("模式:"); + panel6.add(modeLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + threadCntLabel = new JLabel(); + threadCntLabel.setText("线程数:"); + panel6.add(threadCntLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new GridLayoutManager(8, 1, new Insets(0, 0, 0, 0), -1, -1)); + pushUpPanel.add(panel7, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + schedulePlanDetailLabel = new JLabel(); + schedulePlanDetailLabel.setText("执行计划:"); + panel7.add(schedulePlanDetailLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel7.add(spacer4, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + plan1Label = new JLabel(); + plan1Label.setText(""); + panel7.add(plan1Label, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + plan2Label = new JLabel(); + plan2Label.setText(""); + panel7.add(plan2Label, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + plan3Label = new JLabel(); + plan3Label.setText(""); + panel7.add(plan3Label, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + plan4Label = new JLabel(); + plan4Label.setText(""); + panel7.add(plan4Label, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + plan5Label = new JLabel(); + plan5Label.setText(""); + panel7.add(plan5Label, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + planToContinueLabel = new JLabel(); + planToContinueLabel.setText("……"); + panel7.add(planToContinueLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JSeparator separator2 = new JSeparator(); + separator2.setOrientation(1); + pushUpPanel.add(separator2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel3.add(panel8, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JScrollPane scrollPane1 = new JScrollPane(); + panel8.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + taskHisListTable = new JTable(); + scrollPane1.setViewportView(taskHisListTable); + final JPanel panel9 = new JPanel(); + panel9.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + panel8.add(panel9, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + stopButton = new JButton(); + stopButton.setText("停止"); + panel9.add(stopButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + hisDeleteButton = new JButton(); + hisDeleteButton.setText("删除"); + panel9.add(hisDeleteButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + panel9.add(spacer5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + taskHisDetailButton = new JButton(); + taskHisDetailButton.setText("详情"); + panel9.add(taskHisDetailButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + + public static void initTaskHisListTable(Integer selectedTaskId) { + JTable taskHisListTable = taskForm.getTaskHisListTable(); + + // 任务数据列表 + String[] headerNames = {"id", "是否空跑", "开始时间", "结束时间", "总量", "成功", "失败", "状态"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + taskHisListTable.setModel(model); + + taskHisListTable.getTableHeader().setReorderingAllowed(false); + + Object[] data; + + List taskHisList = taskHisMapper.selectByTaskId(selectedTaskId); + for (TTaskHis taskHis : taskHisList) { + data = new Object[8]; + data[0] = taskHis.getId(); + data[1] = taskHis.getDryRun() == 1 ? "空跑" : "否"; + data[2] = taskHis.getStartTime(); + data[3] = taskHis.getEndTime(); + data[4] = taskHis.getTotalCnt(); + data[5] = taskHis.getSuccessCnt(); + data[6] = taskHis.getFailCnt(); + data[7] = TaskStatusEnum.getDescByCode(taskHis.getStatus()); + model.addRow(data); + } + // 隐藏id列 + JTableUtil.hideColumn(taskHisListTable, 0); + // 设置列宽 +// TableColumnModel tableColumnModel = taskHisListTable.getColumnModel(); +// tableColumnModel.getColumn(1).setMaxWidth(50); +// tableColumnModel.getColumn(6).setMaxWidth(50); + + // 如果有数据,则默认选中第一行 + if (taskHisListTable.getRowCount() > 0) { + taskHisListTable.setRowSelectionInterval(0, 0); + } + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/UserCaseForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/UserCaseForm.java index 6342ed2f1..657394f38 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/UserCaseForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/UserCaseForm.java @@ -14,11 +14,14 @@ import javax.imageio.ImageIO; import javax.swing.*; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; import java.util.List; +import java.util.Locale; /** *
@@ -160,7 +163,10 @@ public static void init() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
     /**
@@ -169,4 +175,5 @@ public static void init() {
     public JComponent $$$getRootComponent$$$() {
         return userCasePanel;
     }
+
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/AccountFormFactory.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/AccountFormFactory.java
new file mode 100644
index 000000000..dbc2ad520
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/AccountFormFactory.java
@@ -0,0 +1,97 @@
+package com.fangxuele.tool.push.ui.form.account;
+
+import com.fangxuele.tool.push.App;
+import com.fangxuele.tool.push.logic.MessageTypeEnum;
+
+import javax.swing.*;
+
+/**
+ * 
+ * 账号编辑form界面工厂类
+ * 
+ * + * @author Zhou Bo + * @since 2021/3/11. + */ +public class AccountFormFactory { + /** + * 根据消息类型获取对应的账号编辑form界面Form + * + * @return IMsgSender + */ + public static IAccountForm getAccountForm() { + IAccountForm iAccountForm = null; + switch (App.config.getMsgType()) { + case MessageTypeEnum.MP_TEMPLATE_CODE: + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + case MessageTypeEnum.KEFU_CODE: + case MessageTypeEnum.KEFU_PRIORITY_CODE: + iAccountForm = WxMpAccountForm.getInstance(); + break; + case MessageTypeEnum.MA_SUBSCRIBE_CODE: + case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE: + iAccountForm = WxMaAccountForm.getInstance(); + break; + case MessageTypeEnum.ALI_YUN_CODE: + iAccountForm = AliYunAccountForm.getInstance(); + break; + case MessageTypeEnum.TX_YUN_CODE: + iAccountForm = TxYunAccountForm.getInstance(); + break; + case MessageTypeEnum.TX_YUN_3_CODE: + iAccountForm = TxYun3AccountForm.getInstance(); + break; + case MessageTypeEnum.HW_YUN_CODE: + iAccountForm = HwYunAccountForm.getInstance(); + break; + case MessageTypeEnum.YUN_PIAN_CODE: + iAccountForm = YunPianAccountForm.getInstance(); + break; + case MessageTypeEnum.EMAIL_CODE: + iAccountForm = EmailAccountForm.getInstance(); + break; + case MessageTypeEnum.WX_CP_CODE: + iAccountForm = WxCpAccountForm.getInstance(); + break; + case MessageTypeEnum.HTTP_CODE: + iAccountForm = HttpAccountForm.getInstance(); + break; + case MessageTypeEnum.DING_CODE: + iAccountForm = DingAccountForm.getInstance(); + break; + case MessageTypeEnum.BD_YUN_CODE: + iAccountForm = BdYunAccountForm.getInstance(); + break; + case MessageTypeEnum.UP_YUN_CODE: + iAccountForm = UpYunAccountForm.getInstance(); + break; + case MessageTypeEnum.QI_NIU_YUN_CODE: + iAccountForm = QiniuYunAccountForm.getInstance(); + break; + default: + break; + } + return iAccountForm; + } + + /** + * 根据消息类型获取对应的账号编辑form界面Panel + * + * @return + */ + public static JPanel getAccountMainPanel() { + return getAccountForm().getMainPanel(); + } + + /** + * 根据消息类型获取对应的账号编辑form界面Panel并初始化 + * + * @return + */ + public static JPanel getAccountMainPanelAndInit(String accountName) { + IAccountForm accountForm = getAccountForm(); + accountForm.clear(); + accountForm.init(accountName); + return accountForm.getMainPanel(); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/AliYunAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/AliYunAccountForm.form new file mode 100644 index 000000000..702b4839f --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/AliYunAccountForm.form @@ -0,0 +1,77 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/AliYunAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/AliYunAccountForm.java new file mode 100644 index 000000000..47c5aa192 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/AliYunAccountForm.java @@ -0,0 +1,212 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.http.HttpClientConfig; +import com.aliyuncs.profile.DefaultProfile; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.AliYunAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.AliYunMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +@Slf4j +public class AliYunAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField signTextField; + private JTextField accessKeyIdTextField; + private JTextField accessKeySecretTextField; + + private static AliYunAccountForm wxMpAccountForm; + + /** + * 阿里云短信client + */ + public volatile static IAcsClient iAcsClient; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + AliYunAccountForm instance = getInstance(); + AliYunAccountConfig aliYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), AliYunAccountConfig.class); + instance.getAccessKeyIdTextField().setText(aliYunAccountConfig.getAccessKeyId()); + instance.getAccessKeySecretTextField().setText(aliYunAccountConfig.getAccessKeySecret()); + instance.getSignTextField().setText(aliYunAccountConfig.getSign()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + AliYunAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + AliYunAccountConfig aliYunAccountConfig = new AliYunAccountConfig(); + aliYunAccountConfig.setAccessKeyId(instance.getAccessKeyIdTextField().getText()); + aliYunAccountConfig.setAccessKeySecret(instance.getAccessKeySecretTextField().getText()); + aliYunAccountConfig.setSign(instance.getSignTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(aliYunAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + AliYunMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static AliYunAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new AliYunAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + /** + * 获取阿里云短信发送客户端 + * + * @return IAcsClient + */ + private static IAcsClient getAliyunIAcsClient(String accountName) { + invalidAccount(); + + if (iAcsClient == null) { + synchronized (AliYunMsgSender.class) { + if (iAcsClient == null) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + if (tAccount == null) { + log.error("未获取到对应的微信公众号账号配置:{}", accountName); + } + + AliYunAccountConfig aliYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), AliYunAccountConfig.class); + + String aliyunAccessKeyId = aliYunAccountConfig.getAccessKeyId(); + String aliyunAccessKeySecret = aliYunAccountConfig.getAccessKeySecret(); + + // 创建DefaultAcsClient实例并初始化 + DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", aliyunAccessKeyId, aliyunAccessKeySecret); + + // 多个SDK client共享一个连接池,此处设置该连接池的参数, + // 比如每个host的最大连接数,超时时间等 + HttpClientConfig clientConfig = HttpClientConfig.getDefault(); + clientConfig.setMaxRequestsPerHost(App.config.getMaxThreads()); + clientConfig.setConnectionTimeoutMillis(10000L); + + profile.setHttpClientConfig(clientConfig); + iAcsClient = new DefaultAcsClient(profile); + } + } + } + return iAcsClient; + } + + public static void invalidAccount() { + iAcsClient = null; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("AccessKeyId"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("AccessKeySecret"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("短信签名"); + panel1.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + signTextField = new JTextField(); + panel1.add(signTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + accessKeyIdTextField = new JTextField(); + panel1.add(accessKeyIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + accessKeySecretTextField = new JTextField(); + panel1.add(accessKeySecretTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/BdYunAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/BdYunAccountForm.form new file mode 100644 index 000000000..b39ee06cf --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/BdYunAccountForm.form @@ -0,0 +1,93 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/BdYunAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/BdYunAccountForm.java new file mode 100644 index 000000000..a8ffe09f5 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/BdYunAccountForm.java @@ -0,0 +1,219 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.baidubce.auth.DefaultBceCredentials; +import com.baidubce.services.sms.SmsClient; +import com.baidubce.services.sms.SmsClientConfiguration; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.BdYunAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.BdYunMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +@Slf4j +public class BdYunAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField bdEndPointTextField; + private JTextField bdInvokeIdTextField; + private JTextField bdAccessKeyIdTextField; + private JTextField bdSecretAccessKeyTextField; + + private static BdYunAccountForm wxMpAccountForm; + + /** + * 百度云短信SmsClient + */ + public volatile static SmsClient smsClient; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + BdYunAccountForm instance = getInstance(); + BdYunAccountConfig bdYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), BdYunAccountConfig.class); + instance.getBdEndPointTextField().setText(bdYunAccountConfig.getBdEndPoint()); + instance.getBdInvokeIdTextField().setText(bdYunAccountConfig.getBdInvokeId()); + instance.getBdSecretAccessKeyTextField().setText(bdYunAccountConfig.getBdSecretAccessKey()); + instance.getBdAccessKeyIdTextField().setText(bdYunAccountConfig.getBdAccessKeyId()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + BdYunAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + BdYunAccountConfig bdYunAccountConfig = new BdYunAccountConfig(); + bdYunAccountConfig.setBdEndPoint(instance.getBdEndPointTextField().getText()); + bdYunAccountConfig.setBdInvokeId(instance.getBdInvokeIdTextField().getText()); + bdYunAccountConfig.setBdSecretAccessKey(instance.getBdSecretAccessKeyTextField().getText()); + bdYunAccountConfig.setBdAccessKeyId(instance.getBdAccessKeyIdTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(bdYunAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + BdYunMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static BdYunAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new BdYunAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + /** + * 获取百度云短信发送客户端 + * + * @return SmsClient + */ + private static SmsClient getBdYunSmsClient(String accountName) { + invalidAccount(); + + if (smsClient == null) { + synchronized (BdYunMsgSender.class) { + if (smsClient == null) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + if (tAccount == null) { + log.error("未获取到对应的微信公众号账号配置:{}", accountName); + } + + BdYunAccountConfig bdYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), BdYunAccountConfig.class); + + // SMS服务域名,可根据环境选择具体域名 + String endPoint = bdYunAccountConfig.getBdEndPoint(); + // 发送账号安全认证的Access Key ID + String accessKeyId = bdYunAccountConfig.getBdAccessKeyId(); + // 发送账号安全认证的Secret Access Key + String secretAccessKy = bdYunAccountConfig.getBdSecretAccessKey(); + + // ak、sk等config + SmsClientConfiguration config = new SmsClientConfiguration(); + config.setCredentials(new DefaultBceCredentials(accessKeyId, secretAccessKy)); + config.setEndpoint(endPoint); + + // 实例化发送客户端 + smsClient = new SmsClient(config); + } + } + } + return smsClient; + } + + public static void invalidAccount() { + smsClient = null; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("AccessKeyID"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("SecretAccessKey"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("SMS服务域名"); + panel1.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("签名的调用ID"); + panel1.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + bdEndPointTextField = new JTextField(); + panel1.add(bdEndPointTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + bdInvokeIdTextField = new JTextField(); + panel1.add(bdInvokeIdTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + bdAccessKeyIdTextField = new JTextField(); + panel1.add(bdAccessKeyIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + bdSecretAccessKeyTextField = new JTextField(); + panel1.add(bdSecretAccessKeyTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/DingAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/DingAccountForm.form new file mode 100644 index 000000000..19adce88f --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/DingAccountForm.form @@ -0,0 +1,92 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/DingAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/DingAccountForm.java new file mode 100644 index 000000000..639d2daa7 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/DingAccountForm.java @@ -0,0 +1,181 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.cache.impl.TimedCache; +import cn.hutool.json.JSONUtil; +import com.dingtalk.api.DefaultDingTalkClient; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.DingAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.DingMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +@Slf4j +public class DingAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField appSecretTextField; + private JTextField appNameTextField; + private JTextField agentIdTextField; + private JTextField appKeyTextField; + + private static DingAccountForm wxMpAccountForm; + + public volatile static DefaultDingTalkClient defaultDingTalkClient; + public volatile static DefaultDingTalkClient robotClient; + public static TimedCache accessTokenTimedCache; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + DingAccountForm instance = getInstance(); + DingAccountConfig dingAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), DingAccountConfig.class); + instance.getAppSecretTextField().setText(dingAccountConfig.getAppSecret()); + instance.getAppNameTextField().setText(dingAccountConfig.getAppName()); + instance.getAgentIdTextField().setText(dingAccountConfig.getAgentId()); + instance.getAppKeyTextField().setText(dingAccountConfig.getAppKey()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + DingAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + DingAccountConfig dingAccountConfig = new DingAccountConfig(); + dingAccountConfig.setAppSecret(instance.getAppSecretTextField().getText()); + dingAccountConfig.setAppName(instance.getAppNameTextField().getText()); + dingAccountConfig.setAgentId(instance.getAgentIdTextField().getText()); + dingAccountConfig.setAppKey(instance.getAppKeyTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(dingAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + DingMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static DingAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new DingAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + public static void invalidAccount() { + accessTokenTimedCache = null; + defaultDingTalkClient = null; + robotClient = null; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("应用名称"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("AgentId"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("Appkey"); + panel1.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("AppSecret"); + panel1.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + appNameTextField = new JTextField(); + panel1.add(appNameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + agentIdTextField = new JTextField(); + panel1.add(agentIdTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + appKeyTextField = new JTextField(); + panel1.add(appKeyTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + appSecretTextField = new JTextField(); + panel1.add(appSecretTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/dialog/SwitchWxAccountDialog.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/EmailAccountForm.form similarity index 55% rename from src/main/java/com/fangxuele/tool/push/ui/dialog/SwitchWxAccountDialog.form rename to src/main/java/com/fangxuele/tool/push/ui/form/account/EmailAccountForm.form index 979010e0b..70255fa5d 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/dialog/SwitchWxAccountDialog.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/EmailAccountForm.form @@ -1,119 +1,123 @@ -
- - + + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + - + - + - + - - - - - + + - + - - - - - - - - - - - + - + - + - + - - - - - - - - - + - + - + - + - + - - - - - - - - - + - - - - - - - - - + @@ -121,52 +125,24 @@ - + - - - - - - - - - + - - - - - - + - + + + - - - + - - - - - - - - - - - - - - - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/EmailAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/EmailAccountForm.java new file mode 100644 index 000000000..3ce6d50d0 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/EmailAccountForm.java @@ -0,0 +1,218 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.EmailAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.MailMsgSender; +import com.fangxuele.tool.push.ui.dialog.MailTestDialog; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +public class EmailAccountForm implements IAccountForm { + private JPanel mainPanel; + private JCheckBox mailStartTLSCheckBox; + private JCheckBox mailSSLCheckBox; + private JTextField mailHostTextField; + private JTextField mailPortTextField; + private JTextField mailFromTextField; + private JTextField mailUserTextField; + private JButton testMailButton; + private JTextField mailPasswordField; + + private static EmailAccountForm emailAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + EmailAccountForm instance = getInstance(); + EmailAccountConfig emailAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), EmailAccountConfig.class); + + instance.getMailStartTLSCheckBox().setSelected(emailAccountConfig.isMailStartTLS()); + instance.getMailSSLCheckBox().setSelected(emailAccountConfig.isMailSSL()); + instance.getMailHostTextField().setText(emailAccountConfig.getMailHost()); + instance.getMailPortTextField().setText(emailAccountConfig.getMailPort()); + instance.getMailFromTextField().setText(emailAccountConfig.getMailFrom()); + instance.getMailUserTextField().setText(emailAccountConfig.getMailUser()); + instance.getMailPasswordField().setText(emailAccountConfig.getMailPassword()); + } + testMailButton.setIcon(new FlatSVGIcon("icon/test.svg")); + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + EmailAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + EmailAccountConfig emailAccountConfig = new EmailAccountConfig(); + emailAccountConfig.setMailStartTLS(instance.getMailStartTLSCheckBox().isSelected()); + emailAccountConfig.setMailSSL(instance.getMailSSLCheckBox().isSelected()); + emailAccountConfig.setMailHost(instance.getMailHostTextField().getText()); + emailAccountConfig.setMailPort(instance.getMailPortTextField().getText()); + emailAccountConfig.setMailFrom(instance.getMailFromTextField().getText()); + emailAccountConfig.setMailUser(instance.getMailUserTextField().getText()); + emailAccountConfig.setMailPassword(instance.getMailPasswordField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(emailAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + MailMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static EmailAccountForm getInstance() { + if (emailAccountForm == null) { + emailAccountForm = new EmailAccountForm(); + + // E-Mail测试 + emailAccountForm.getTestMailButton().addActionListener(e -> { + + EmailAccountConfig emailAccountConfig = new EmailAccountConfig(); + emailAccountConfig.setMailHost(emailAccountForm.getMailHostTextField().getText()); + emailAccountConfig.setMailPort(emailAccountForm.getMailPortTextField().getText()); + emailAccountConfig.setMailFrom(emailAccountForm.getMailFromTextField().getText()); + emailAccountConfig.setMailUser(emailAccountForm.getMailUserTextField().getText()); + emailAccountConfig.setMailPassword(emailAccountForm.getMailPasswordField().getText()); + emailAccountConfig.setMailStartTLS(emailAccountForm.getMailStartTLSCheckBox().isSelected()); + emailAccountConfig.setMailSSL(emailAccountForm.getMailSSLCheckBox().isSelected()); + + MailTestDialog mailTestDialog = new MailTestDialog(emailAccountConfig); + mailTestDialog.pack(); + mailTestDialog.setVisible(true); + }); + } + UndoUtil.register(emailAccountForm); + return emailAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(9, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(8, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("邮件服务器的SMTP地址"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("邮件服务器的SMTP端口"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("发件人(邮箱地址)"); + panel1.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("用户名"); + label4.setToolTipText("如果使用foxmail邮箱,此处为qq号"); + panel1.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("密码"); + panel1.add(label5, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + testMailButton = new JButton(); + testMailButton.setText("测试"); + panel2.add(testMailButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mailStartTLSCheckBox = new JCheckBox(); + mailStartTLSCheckBox.setText("使用STARTTLS安全连接"); + panel1.add(mailStartTLSCheckBox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mailSSLCheckBox = new JCheckBox(); + mailSSLCheckBox.setText("使用SSL安全连接"); + panel1.add(mailSSLCheckBox, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mailHostTextField = new JTextField(); + panel1.add(mailHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailPortTextField = new JTextField(); + panel1.add(mailPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailFromTextField = new JTextField(); + panel1.add(mailFromTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailUserTextField = new JTextField(); + panel1.add(mailUserTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + mailPasswordField = new JTextField(); + panel1.add(mailPasswordField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/HttpAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/HttpAccountForm.form new file mode 100644 index 000000000..9501cce77 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/HttpAccountForm.form @@ -0,0 +1,124 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/HttpAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/HttpAccountForm.java new file mode 100644 index 000000000..5c0605036 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/HttpAccountForm.java @@ -0,0 +1,226 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.HttpAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.HttpMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.util.Locale; + +@Getter +public class HttpAccountForm implements IAccountForm { + private JPanel mainPanel; + private JCheckBox httpUseProxyCheckBox; + private JPanel httpProxyPanel; + private JTextField httpProxyHostTextField; + private JTextField httpProxyPortTextField; + private JTextField httpProxyUserTextField; + private JTextField httpProxyPasswordTextField; + + private static HttpAccountForm wxMpAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + HttpAccountForm instance = getInstance(); + HttpAccountConfig httpAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), HttpAccountConfig.class); + instance.getHttpUseProxyCheckBox().setSelected(httpAccountConfig.isUseProxy()); + instance.getHttpProxyHostTextField().setText(httpAccountConfig.getProxyHost()); + instance.getHttpProxyPortTextField().setText(httpAccountConfig.getProxyPort()); + instance.getHttpProxyUserTextField().setText(httpAccountConfig.getProxyUserName()); + instance.getHttpProxyPasswordTextField().setText(httpAccountConfig.getProxyPassword()); + + toggleHttpProxyPanel(); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + HttpAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + HttpAccountConfig httpAccountConfig = new HttpAccountConfig(); + httpAccountConfig.setUseProxy(instance.getHttpUseProxyCheckBox().isSelected()); + httpAccountConfig.setProxyHost(instance.getHttpProxyHostTextField().getText()); + httpAccountConfig.setProxyPort(instance.getHttpProxyPortTextField().getText()); + httpAccountConfig.setProxyUserName(instance.getHttpProxyUserTextField().getText()); + httpAccountConfig.setProxyPassword(instance.getHttpProxyPasswordTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(httpAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + HttpMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static HttpAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new HttpAccountForm(); + + wxMpAccountForm.getHttpUseProxyCheckBox().addChangeListener(e -> wxMpAccountForm.toggleHttpProxyPanel()); + + wxMpAccountForm.toggleHttpProxyPanel(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + /** + * 切换HTTP代理设置面板显示/隐藏 + */ + public void toggleHttpProxyPanel() { + boolean httpUseProxy = httpUseProxyCheckBox.isSelected(); + if (httpUseProxy) { + httpProxyPanel.setVisible(true); + } else { + httpProxyPanel.setVisible(false); + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + Font panel2Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel2.getFont()); + if (panel2Font != null) panel2.setFont(panel2Font); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel2.getFont()), null)); + httpUseProxyCheckBox = new JCheckBox(); + httpUseProxyCheckBox.setText("使用HTTP代理"); + panel2.add(httpUseProxyCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + httpProxyPanel = new JPanel(); + httpProxyPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 26, 0, 0), -1, -1)); + panel2.add(httpProxyPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("Host"); + httpProxyPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + httpProxyHostTextField = new JTextField(); + httpProxyPanel.add(httpProxyHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("端口"); + httpProxyPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("用户名"); + httpProxyPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("密码"); + httpProxyPanel.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + httpProxyPortTextField = new JTextField(); + httpProxyPanel.add(httpProxyPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + httpProxyUserTextField = new JTextField(); + httpProxyPanel.add(httpProxyUserTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + httpProxyPasswordTextField = new JTextField(); + httpProxyPanel.add(httpProxyPasswordTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/HwYunAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/HwYunAccountForm.form new file mode 100644 index 000000000..76d56d938 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/HwYunAccountForm.form @@ -0,0 +1,109 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/HwYunAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/HwYunAccountForm.java new file mode 100644 index 000000000..fd4bda587 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/HwYunAccountForm.java @@ -0,0 +1,176 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.HwYunAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.AliYunMsgSender; +import com.fangxuele.tool.push.logic.msgsender.HwYunMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +public class HwYunAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField accessUrlTextField; + private JTextField senderCodeTextField; + private JTextField signatureTextField; + private JTextField appKeyTextField; + private JTextField appSecretTextField; + + private static HwYunAccountForm wxMpAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + HwYunAccountForm instance = getInstance(); + HwYunAccountConfig hwYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), HwYunAccountConfig.class); + instance.getAccessUrlTextField().setText(hwYunAccountConfig.getAccessUrl()); + instance.getSenderCodeTextField().setText(hwYunAccountConfig.getSenderCode()); + instance.getSignatureTextField().setText(hwYunAccountConfig.getSignature()); + instance.getAppSecretTextField().setText(hwYunAccountConfig.getAppSecret()); + instance.getAppKeyTextField().setText(hwYunAccountConfig.getAppKey()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + HwYunAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + HwYunAccountConfig hwYunAccountConfig = new HwYunAccountConfig(); + hwYunAccountConfig.setAccessUrl(instance.getAccessUrlTextField().getText()); + hwYunAccountConfig.setSenderCode(instance.getSenderCodeTextField().getText()); + hwYunAccountConfig.setSignature(instance.getSignatureTextField().getText()); + hwYunAccountConfig.setAppSecret(instance.getAppSecretTextField().getText()); + hwYunAccountConfig.setAppKey(instance.getAppKeyTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(hwYunAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + HwYunMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static HwYunAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new HwYunAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(6, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("AppKey"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("AppSecret"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("APP接入地址"); + panel1.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("短信签名通道号"); + panel1.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("短信签名"); + panel1.add(label5, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + accessUrlTextField = new JTextField(); + panel1.add(accessUrlTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + senderCodeTextField = new JTextField(); + panel1.add(senderCodeTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + signatureTextField = new JTextField(); + panel1.add(signatureTextField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + appKeyTextField = new JTextField(); + panel1.add(appKeyTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + appSecretTextField = new JTextField(); + panel1.add(appSecretTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/IAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/IAccountForm.java new file mode 100644 index 000000000..32d7848ac --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/IAccountForm.java @@ -0,0 +1,46 @@ +package com.fangxuele.tool.push.ui.form.account; + +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.util.MybatisUtil; + +import javax.swing.*; + +/** + *
+ * 账号编辑form界面接口
+ * 
+ * + * @author Zhou Bo + * @since 2021/3/10. + */ +public interface IAccountForm { + + TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + + /** + * 初始化界面 + * + * @param accountName + */ + void init(String accountName); + + /** + * 保存 + * + * @param accountName + */ + void save(String accountName); + + /** + * 清空表单 + */ + void clear(); + + /** + * 获取主面板 + * + * @return + */ + JPanel getMainPanel(); + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/QiniuYunAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/QiniuYunAccountForm.form new file mode 100644 index 000000000..8863abdfe --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/QiniuYunAccountForm.form @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/QiniuYunAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/QiniuYunAccountForm.java new file mode 100644 index 000000000..ca9d2d6eb --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/QiniuYunAccountForm.java @@ -0,0 +1,151 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.QiniuYunAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.QiNiuYunMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +public class QiniuYunAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField accessKeyTextField; + private JTextField secretKeyTextField; + + private static QiniuYunAccountForm wxMpAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + QiniuYunAccountForm instance = getInstance(); + QiniuYunAccountConfig qiniuYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), QiniuYunAccountConfig.class); + instance.getAccessKeyTextField().setText(qiniuYunAccountConfig.getAccessKey()); + instance.getSecretKeyTextField().setText(qiniuYunAccountConfig.getSecretKey()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + QiniuYunAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + QiniuYunAccountConfig qiniuYunAccountConfig = new QiniuYunAccountConfig(); + qiniuYunAccountConfig.setAccessKey(instance.getAccessKeyTextField().getText()); + qiniuYunAccountConfig.setSecretKey(instance.getSecretKeyTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(qiniuYunAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + QiNiuYunMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static QiniuYunAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new QiniuYunAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("AcessKey"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("SecretKey"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + accessKeyTextField = new JTextField(); + panel1.add(accessKeyTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + secretKeyTextField = new JTextField(); + panel1.add(secretKeyTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYun3AccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYun3AccountForm.form new file mode 100644 index 000000000..3b6e71883 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYun3AccountForm.form @@ -0,0 +1,131 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYun3AccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYun3AccountForm.java new file mode 100644 index 000000000..1b1da0a65 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYun3AccountForm.java @@ -0,0 +1,189 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.TxYun3AccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.TxYunMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +public class TxYun3AccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField signTextField; + private JTextField secretIdTextField; + private JTextField secretKeyTextField; + private JTextField endPointTextField; + private JTextField regionTextField; + private JTextField sdkAppIdTextField; + + private static TxYun3AccountForm txYun3AccountForm; + + @Override + public void init(String accountName) { + TxYun3AccountForm instance = getInstance(); + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + TxYun3AccountConfig txYun3AccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), TxYun3AccountConfig.class); + instance.getSignTextField().setText(txYun3AccountConfig.getSign()); + instance.getSecretIdTextField().setText(txYun3AccountConfig.getSecretId()); + instance.getSecretKeyTextField().setText(txYun3AccountConfig.getSecretKey()); + instance.getEndPointTextField().setText(txYun3AccountConfig.getEndPoint()); + instance.getRegionTextField().setText(txYun3AccountConfig.getRegion()); + instance.getSdkAppIdTextField().setText(txYun3AccountConfig.getSdkAppId()); + } else { + instance.getEndPointTextField().setText("sms.tencentcloudapi.com"); + instance.getRegionTextField().setText("ap-guangzhou"); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + TxYun3AccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + TxYun3AccountConfig txYun3AccountConfig = new TxYun3AccountConfig(); + txYun3AccountConfig.setSign(instance.getSignTextField().getText()); + txYun3AccountConfig.setSecretId(instance.getSecretIdTextField().getText()); + txYun3AccountConfig.setSecretKey(instance.getSecretKeyTextField().getText()); + txYun3AccountConfig.setEndPoint(instance.getEndPointTextField().getText()); + txYun3AccountConfig.setRegion(instance.getRegionTextField().getText()); + txYun3AccountConfig.setSdkAppId(instance.getSdkAppIdTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(txYun3AccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + TxYunMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static TxYun3AccountForm getInstance() { + if (txYun3AccountForm == null) { + txYun3AccountForm = new TxYun3AccountForm(); + } + UndoUtil.register(txYun3AccountForm); + return txYun3AccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("SecretId"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("SecretKey"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("Endpoint"); + panel1.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("Region"); + panel1.add(label4, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("短信签名"); + panel1.add(label5, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + signTextField = new JTextField(); + panel1.add(signTextField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + secretIdTextField = new JTextField(); + panel1.add(secretIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + secretKeyTextField = new JTextField(); + panel1.add(secretKeyTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + endPointTextField = new JTextField(); + endPointTextField.setText("sms.tencentcloudapi.com"); + panel1.add(endPointTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + regionTextField = new JTextField(); + regionTextField.setText("ap-guangzhou"); + panel1.add(regionTextField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + sdkAppIdTextField = new JTextField(); + sdkAppIdTextField.setText(""); + panel1.add(sdkAppIdTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("SdkAppId"); + panel1.add(label6, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYunAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYunAccountForm.form new file mode 100644 index 000000000..47f85073e --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYunAccountForm.form @@ -0,0 +1,77 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYunAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYunAccountForm.java new file mode 100644 index 000000000..533360da8 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/TxYunAccountForm.java @@ -0,0 +1,159 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.TxYunAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.TxYunMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +public class TxYunAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField signTextField; + private JTextField appIdTextField; + private JTextField appKeyTextField; + + private static TxYunAccountForm wxMpAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + TxYunAccountForm instance = getInstance(); + TxYunAccountConfig txYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), TxYunAccountConfig.class); + instance.getSignTextField().setText(txYunAccountConfig.getSign()); + instance.getAppIdTextField().setText(txYunAccountConfig.getAppId()); + instance.getAppKeyTextField().setText(txYunAccountConfig.getAppKey()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + TxYunAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + TxYunAccountConfig txYunAccountConfig = new TxYunAccountConfig(); + txYunAccountConfig.setSign(instance.getSignTextField().getText()); + txYunAccountConfig.setAppKey(instance.getAppKeyTextField().getText()); + txYunAccountConfig.setAppId(instance.getAppIdTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(txYunAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + TxYunMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static TxYunAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new TxYunAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("AppId"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("AppKey"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("短信签名"); + panel1.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + signTextField = new JTextField(); + panel1.add(signTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + appIdTextField = new JTextField(); + panel1.add(appIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + appKeyTextField = new JTextField(); + panel1.add(appKeyTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/UpYunAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/UpYunAccountForm.form new file mode 100644 index 000000000..1f808b968 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/UpYunAccountForm.form @@ -0,0 +1,45 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/UpYunAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/UpYunAccountForm.java new file mode 100644 index 000000000..70cd2b09e --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/UpYunAccountForm.java @@ -0,0 +1,143 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.UpYunAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.UpYunMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +public class UpYunAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField authorizationTokenTextField; + + private static UpYunAccountForm wxMpAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + UpYunAccountForm instance = getInstance(); + UpYunAccountConfig upYunAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), UpYunAccountConfig.class); + instance.getAuthorizationTokenTextField().setText(upYunAccountConfig.getAuthorizationToken()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + UpYunAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + UpYunAccountConfig upYunAccountConfig = new UpYunAccountConfig(); + upYunAccountConfig.setAuthorizationToken(instance.getAuthorizationTokenTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(upYunAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + UpYunMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static UpYunAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new UpYunAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("授权token"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + authorizationTokenTextField = new JTextField(); + panel1.add(authorizationTokenTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/WxCpAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxCpAccountForm.form new file mode 100644 index 000000000..a07f2bc18 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxCpAccountForm.form @@ -0,0 +1,116 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/WxCpAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxCpAccountForm.java new file mode 100644 index 000000000..976e6c74a --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxCpAccountForm.java @@ -0,0 +1,208 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.WxCpAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.WxCpMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.cp.api.WxCpService; +import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +@Slf4j +public class WxCpAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField corpIdTextField; + private JTextField appNameTextField; + private JTextField agentIdTextField; + private JTextField secretTextField; + private JCheckBox privateDepCheckBox; + private JTextField baseApiUrlTextField; + private JLabel baseApiUrlLabel; + + private static WxCpAccountForm wxCpAccountForm; + + public volatile static WxCpDefaultConfigImpl wxCpConfigStorage; + public volatile static WxCpService wxCpService; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + WxCpAccountForm instance = getInstance(); + WxCpAccountConfig wxCpAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), WxCpAccountConfig.class); + instance.getCorpIdTextField().setText(wxCpAccountConfig.getCorpId()); + instance.getAppNameTextField().setText(wxCpAccountConfig.getAppName()); + instance.getAgentIdTextField().setText(wxCpAccountConfig.getAgentId()); + instance.getSecretTextField().setText(wxCpAccountConfig.getSecret()); + instance.getPrivateDepCheckBox().setSelected(wxCpAccountConfig.getPrivateDep()); + instance.getBaseApiUrlTextField().setText(wxCpAccountConfig.getBaseApiUrl()); + if (wxCpAccountConfig.getPrivateDep()) { + instance.getBaseApiUrlTextField().setVisible(true); + instance.getBaseApiUrlLabel().setVisible(true); + } else { + instance.getBaseApiUrlTextField().setVisible(false); + instance.getBaseApiUrlLabel().setVisible(false); + } + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + WxCpAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + WxCpAccountConfig wxCpAccountConfig = new WxCpAccountConfig(); + wxCpAccountConfig.setCorpId(instance.getCorpIdTextField().getText()); + wxCpAccountConfig.setAppName(instance.getAppNameTextField().getText()); + wxCpAccountConfig.setAgentId(instance.getAgentIdTextField().getText()); + wxCpAccountConfig.setSecret(instance.getSecretTextField().getText()); + wxCpAccountConfig.setPrivateDep(instance.getPrivateDepCheckBox().isSelected()); + wxCpAccountConfig.setBaseApiUrl(instance.getBaseApiUrlTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(wxCpAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + WxCpMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static WxCpAccountForm getInstance() { + if (wxCpAccountForm == null) { + wxCpAccountForm = new WxCpAccountForm(); + wxCpAccountForm.getPrivateDepCheckBox().setSelected(false); + wxCpAccountForm.getBaseApiUrlTextField().setVisible(false); + wxCpAccountForm.getBaseApiUrlLabel().setVisible(false); + wxCpAccountForm.getPrivateDepCheckBox().addChangeListener(e -> { + if (wxCpAccountForm.getPrivateDepCheckBox().isSelected()) { + wxCpAccountForm.getBaseApiUrlTextField().setVisible(true); + wxCpAccountForm.getBaseApiUrlLabel().setVisible(true); + } else { + wxCpAccountForm.getBaseApiUrlTextField().setVisible(false); + wxCpAccountForm.getBaseApiUrlLabel().setVisible(false); + } + }); + } + UndoUtil.register(wxCpAccountForm); + return wxCpAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("应用名称"); + panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + appNameTextField = new JTextField(); + panel1.add(appNameTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("AgentId"); + panel1.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + agentIdTextField = new JTextField(); + panel1.add(agentIdTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("Secret"); + panel1.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + secretTextField = new JTextField(); + panel1.add(secretTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("企业ID"); + panel1.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + corpIdTextField = new JTextField(); + panel1.add(corpIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + privateDepCheckBox = new JCheckBox(); + privateDepCheckBox.setText("私有化部署"); + panel1.add(privateDepCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + baseApiUrlTextField = new JTextField(); + panel1.add(baseApiUrlTextField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + baseApiUrlLabel = new JLabel(); + baseApiUrlLabel.setText("私有BaseApiUrl"); + panel1.add(baseApiUrlLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMaAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMaAccountForm.form new file mode 100644 index 000000000..340736edb --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMaAccountForm.form @@ -0,0 +1,198 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMaAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMaAccountForm.java new file mode 100644 index 000000000..6050d42e2 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMaAccountForm.java @@ -0,0 +1,263 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.WxMaAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.WxMaSubscribeMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.util.Locale; + +@Getter +public class WxMaAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField appIdTextField; + private JTextField appSecretTextField; + private JTextField tokenTextField; + private JTextField aesKeyTextField; + private JCheckBox maUseProxyCheckBox; + private JPanel maProxyPanel; + private JTextField maProxyHostTextField; + private JTextField maProxyPortTextField; + private JTextField maProxyUserNameTextField; + private JTextField maProxyPasswordTextField; + + private static WxMaAccountForm wxMpAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + WxMaAccountForm instance = getInstance(); + WxMaAccountConfig wxMaAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), WxMaAccountConfig.class); + instance.getAppIdTextField().setText(wxMaAccountConfig.getAppId()); + instance.getAppSecretTextField().setText(wxMaAccountConfig.getAppSecret()); + instance.getTokenTextField().setText(wxMaAccountConfig.getToken()); + instance.getAesKeyTextField().setText(wxMaAccountConfig.getAesKey()); + instance.getMaUseProxyCheckBox().setSelected(wxMaAccountConfig.isMaUseProxy()); + instance.getMaProxyHostTextField().setText(wxMaAccountConfig.getMaProxyHost()); + instance.getMaProxyPortTextField().setText(wxMaAccountConfig.getMaProxyPort()); + instance.getMaProxyUserNameTextField().setText(wxMaAccountConfig.getMaProxyUserName()); + instance.getMaProxyPasswordTextField().setText(wxMaAccountConfig.getMaProxyPassword()); + + toggleMaProxyPanel(); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + + WxMaAccountForm instance = getInstance(); + + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(App.config.getMsgType()); + tAccount1.setAccountName(accountName); + + WxMaAccountConfig wxMaAccountConfig = new WxMaAccountConfig(); + wxMaAccountConfig.setAppId(instance.getAppIdTextField().getText()); + wxMaAccountConfig.setAppSecret(instance.getAppSecretTextField().getText()); + wxMaAccountConfig.setToken(instance.getTokenTextField().getText()); + wxMaAccountConfig.setAesKey(instance.getAesKeyTextField().getText()); + wxMaAccountConfig.setMaUseProxy(instance.getMaUseProxyCheckBox().isSelected()); + wxMaAccountConfig.setMaProxyHost(instance.getMaProxyHostTextField().getText()); + wxMaAccountConfig.setMaProxyPort(instance.getMaProxyPortTextField().getText()); + wxMaAccountConfig.setMaProxyUserName(instance.getMaProxyUserNameTextField().getText()); + wxMaAccountConfig.setMaProxyPassword(instance.getMaProxyPasswordTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(wxMaAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + WxMaSubscribeMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static WxMaAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new WxMaAccountForm(); + + wxMpAccountForm.toggleMaProxyPanel(); + + wxMpAccountForm.getMaUseProxyCheckBox().addChangeListener(e -> wxMpAccountForm.toggleMaProxyPanel()); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + /** + * 切换小程序代理设置面板显示/隐藏 + */ + public void toggleMaProxyPanel() { + boolean maUseProxy = maUseProxyCheckBox.isSelected(); + if (maUseProxy) { + maProxyPanel.setVisible(true); + } else { + maProxyPanel.setVisible(false); + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("AppId"); + panel2.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + appIdTextField = new JTextField(); + panel2.add(appIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("Token"); + panel2.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + tokenTextField = new JTextField(); + panel2.add(tokenTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("AppSecret"); + panel2.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + appSecretTextField = new JTextField(); + panel2.add(appSecretTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("AES Key"); + panel2.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + aesKeyTextField = new JTextField(); + panel2.add(aesKeyTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + Font panel3Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel3.getFont()); + if (panel3Font != null) panel3.setFont(panel3Font); + panel1.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel3.getFont()), null)); + maUseProxyCheckBox = new JCheckBox(); + maUseProxyCheckBox.setText("使用HTTP代理"); + panel3.add(maUseProxyCheckBox, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + maProxyPanel = new JPanel(); + maProxyPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 26, 0, 0), -1, -1)); + panel3.add(maProxyPanel, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("Host"); + maProxyPanel.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + maProxyHostTextField = new JTextField(); + maProxyPanel.add(maProxyHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("端口"); + maProxyPanel.add(label6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setText("用户名"); + maProxyPanel.add(label7, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setText("密码"); + maProxyPanel.add(label8, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + maProxyPortTextField = new JTextField(); + maProxyPanel.add(maProxyPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + maProxyUserNameTextField = new JTextField(); + maProxyPanel.add(maProxyUserNameTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + maProxyPasswordTextField = new JTextField(); + maProxyPanel.add(maProxyPasswordTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMpAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMpAccountForm.form new file mode 100644 index 000000000..e6e80fffb --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMpAccountForm.form @@ -0,0 +1,348 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMpAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMpAccountForm.java new file mode 100644 index 000000000..660eca627 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/WxMpAccountForm.java @@ -0,0 +1,489 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.WxMpAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender; +import com.fangxuele.tool.push.ui.UiConsts; +import com.fangxuele.tool.push.ui.dialog.CommonTipsDialog; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Locale; + +@Getter +@Slf4j +public class WxMpAccountForm implements IAccountForm { + private JPanel mainPanel; + private JTextField appIdTextField; + private JTextField appSecretTextField; + private JTextField tokenTextField; + private JTextField aesKeyTextField; + private JCheckBox mpUseProxyCheckBox; + private JPanel mpProxyPanel; + private JTextField mpProxyHostTextField; + private JTextField mpProxyPortTextField; + private JTextField mpProxyUserNameTextField; + private JTextField mpProxyPasswordTextField; + private JCheckBox useOutSideAccessTokenCheckBox; + private JPanel mpOutSideAccessTokenPanel; + private JRadioButton manualAtRadioButton; + private JRadioButton apiAtRadioButton; + private JTextField accessTokenTextField; + private JTextField atExpiresInTextField; + private JTextField atApiUrlTextField; + private JLabel manualAtTipsLabel; + private JLabel apiAtTipsLabel; + private JLabel outSideAtTipsLabel; + + private static WxMpAccountForm wxMpAccountForm; + + public volatile static WxMpDefaultConfigImpl wxMpConfigStorage; + public volatile static WxMpService wxMpService; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + WxMpAccountForm instance = getInstance(); + WxMpAccountConfig wxMpAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), WxMpAccountConfig.class); + instance.getAppIdTextField().setText(wxMpAccountConfig.getAppId()); + instance.getAppSecretTextField().setText(wxMpAccountConfig.getAppSecret()); + instance.getTokenTextField().setText(wxMpAccountConfig.getToken()); + instance.getAesKeyTextField().setText(wxMpAccountConfig.getAesKey()); + instance.getMpUseProxyCheckBox().setSelected(wxMpAccountConfig.isMpUseProxy()); + instance.getMpProxyHostTextField().setText(wxMpAccountConfig.getMpProxyHost()); + instance.getMpProxyPortTextField().setText(wxMpAccountConfig.getMpProxyPort()); + instance.getMpProxyUserNameTextField().setText(wxMpAccountConfig.getMpProxyUserName()); + instance.getMpProxyPasswordTextField().setText(wxMpAccountConfig.getMpProxyPassword()); + instance.getUseOutSideAccessTokenCheckBox().setSelected(wxMpAccountConfig.isMpUseOutSideAt()); + instance.getManualAtRadioButton().setSelected(wxMpAccountConfig.isMpManualAt()); + instance.getApiAtRadioButton().setSelected(wxMpAccountConfig.isMpApiAt()); + instance.getAccessTokenTextField().setText(wxMpAccountConfig.getMpAt()); + instance.getAtExpiresInTextField().setText(wxMpAccountConfig.getMpAtExpiresIn()); + instance.getAtApiUrlTextField().setText(wxMpAccountConfig.getMpAtApiUrl()); + + toggleMpProxyPanel(); + toggleMpOutSideAccessTokenPanel(); + } + + apiAtTipsLabel.setIcon(new FlatSVGIcon("icon/help.svg")); + manualAtTipsLabel.setIcon(new FlatSVGIcon("icon/help.svg")); + outSideAtTipsLabel.setIcon(new FlatSVGIcon("icon/help.svg")); + + } + + /** + * 切换公众号代理设置面板显示/隐藏 + */ + public void toggleMpProxyPanel() { + boolean mpUseProxy = mpUseProxyCheckBox.isSelected(); + if (mpUseProxy) { + mpProxyPanel.setVisible(true); + } else { + mpProxyPanel.setVisible(false); + } + } + + /** + * 切换使用外部AccessToken面板显示/隐藏 + */ + public void toggleMpOutSideAccessTokenPanel() { + boolean useOutSideAccessToken = useOutSideAccessTokenCheckBox.isSelected(); + if (useOutSideAccessToken) { + mpOutSideAccessTokenPanel.setVisible(true); + } else { + mpOutSideAccessTokenPanel.setVisible(false); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + + WxMpAccountForm instance = getInstance(); + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(App.config.getMsgType()); + tAccount1.setAccountName(accountName); + + WxMpAccountConfig wxMpAccountConfig = new WxMpAccountConfig(); + wxMpAccountConfig.setAppId(instance.getAppIdTextField().getText()); + wxMpAccountConfig.setAppSecret(instance.getAppSecretTextField().getText()); + wxMpAccountConfig.setToken(instance.getTokenTextField().getText()); + wxMpAccountConfig.setAesKey(instance.getAesKeyTextField().getText()); + wxMpAccountConfig.setMpUseProxy(instance.getMpUseProxyCheckBox().isSelected()); + wxMpAccountConfig.setMpProxyHost(instance.getMpProxyHostTextField().getText()); + wxMpAccountConfig.setMpProxyPort(instance.getMpProxyPortTextField().getText()); + wxMpAccountConfig.setMpProxyUserName(instance.getMpProxyUserNameTextField().getText()); + wxMpAccountConfig.setMpProxyPassword(instance.getMpProxyPasswordTextField().getText()); + wxMpAccountConfig.setMpUseOutSideAt(instance.getUseOutSideAccessTokenCheckBox().isSelected()); + wxMpAccountConfig.setMpManualAt(instance.getManualAtRadioButton().isSelected()); + wxMpAccountConfig.setMpApiAt(instance.getApiAtRadioButton().isSelected()); + wxMpAccountConfig.setMpAt(instance.getAccessTokenTextField().getText()); + wxMpAccountConfig.setMpAtExpiresIn(instance.getAtExpiresInTextField().getText()); + wxMpAccountConfig.setMpAtApiUrl(instance.getAtApiUrlTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(wxMpAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + WxMpTemplateMsgSender.removeAccount(tAccount.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static WxMpAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new WxMpAccountForm(); + UndoUtil.register(wxMpAccountForm); + + wxMpAccountForm.getMpUseProxyCheckBox().addChangeListener(e -> wxMpAccountForm.toggleMpProxyPanel()); + wxMpAccountForm.getUseOutSideAccessTokenCheckBox().addChangeListener(e -> wxMpAccountForm.toggleMpOutSideAccessTokenPanel()); + wxMpAccountForm.getManualAtRadioButton().addChangeListener(e -> { + boolean isSelected = wxMpAccountForm.getManualAtRadioButton().isSelected(); + if (isSelected) { + wxMpAccountForm.getApiAtRadioButton().setSelected(false); + } + }); + wxMpAccountForm.getApiAtRadioButton().addChangeListener(e -> { + boolean isSelected = wxMpAccountForm.getApiAtRadioButton().isSelected(); + if (isSelected) { + wxMpAccountForm.getManualAtRadioButton().setSelected(false); + } + }); + + wxMpAccountForm.getOutSideAtTipsLabel().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + CommonTipsDialog dialog = new CommonTipsDialog(); + + StringBuilder tipsBuilder = new StringBuilder(); + tipsBuilder.append("

什么场景下需要使用外部AccessToken?

"); + tipsBuilder.append("

调用腾讯公众号接口需要AccessToken,上面配置的AppID、AppSecret等正是为了获得AccessToken;

"); + tipsBuilder.append("

由于有些企业已经开发了微信公众号相关的服务,不必再次通过上面的AppID等配置再次获取;

"); + tipsBuilder.append("

而且每次获取都会使之前的失效,加上每个公众号每天获取的次数有限;

"); + tipsBuilder.append("

建议每天使用WePush频率很高的时候可以使用此功能

"); + tipsBuilder.append("

反之,可不用设置

"); + + dialog.setHtmlText(tipsBuilder.toString()); + dialog.pack(); + dialog.setVisible(true); + + super.mousePressed(e); + } + + @Override + public void mouseEntered(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setCursor(new Cursor(Cursor.HAND_CURSOR)); + label.setIcon(UiConsts.HELP_FOCUSED_ICON); + super.mouseEntered(e); + } + + @Override + public void mouseExited(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setIcon(UiConsts.HELP_ICON); + super.mouseExited(e); + } + }); + wxMpAccountForm.getManualAtTipsLabel().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + CommonTipsDialog dialog = new CommonTipsDialog(); + + StringBuilder tipsBuilder = new StringBuilder(); + tipsBuilder.append("

这是什么?

"); + tipsBuilder.append("

手动填写AccessToken和过期时间

"); + tipsBuilder.append("

建议仅在临时使用一次WePush且使用时间不会很长的时候才使用

"); + tipsBuilder.append("

请向您所在企业的开发人员索取,注意保密

"); + + dialog.setHtmlText(tipsBuilder.toString()); + dialog.pack(); + dialog.setVisible(true); + + super.mousePressed(e); + } + + @Override + public void mouseEntered(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setCursor(new Cursor(Cursor.HAND_CURSOR)); + label.setIcon(UiConsts.HELP_FOCUSED_ICON); + super.mouseEntered(e); + } + + @Override + public void mouseExited(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setIcon(UiConsts.HELP_ICON); + super.mouseExited(e); + } + }); + wxMpAccountForm.getApiAtTipsLabel().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + CommonTipsDialog dialog = new CommonTipsDialog(); + + StringBuilder tipsBuilder = new StringBuilder(); + tipsBuilder.append("

这是什么?

"); + tipsBuilder.append("

如果企业已经开发了微信公众号相关的服务,建议使用此项;

"); + tipsBuilder.append("

向您所在企业的开发人员索取该接口;

"); + tipsBuilder.append("

接口使用GET请求,返回格式:

"); + tipsBuilder.append("

{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}

"); + tipsBuilder.append("

请一定注意接口安全性,且服务端应按照失效时间进行缓存

"); + tipsBuilder.append("

例如在接口上添加密钥相关的参数:

"); + tipsBuilder.append("

示例:http://mydomain.com/wechat/getAccessToken?secret=jad76^j2#SY

"); + + dialog.setHtmlText(tipsBuilder.toString()); + dialog.pack(); + dialog.setVisible(true); + + super.mousePressed(e); + } + + @Override + public void mouseEntered(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setCursor(new Cursor(Cursor.HAND_CURSOR)); + label.setIcon(UiConsts.HELP_FOCUSED_ICON); + super.mouseEntered(e); + } + + @Override + public void mouseExited(MouseEvent e) { + JLabel label = (JLabel) e.getComponent(); + label.setIcon(UiConsts.HELP_ICON); + super.mouseExited(e); + } + }); + + wxMpAccountForm.toggleMpProxyPanel(); + wxMpAccountForm.toggleMpOutSideAccessTokenPanel(); + } + + return wxMpAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("AppId"); + panel2.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + appIdTextField = new JTextField(); + panel2.add(appIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("Token"); + panel2.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + tokenTextField = new JTextField(); + panel2.add(tokenTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("AppSecret"); + panel2.add(label3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + appSecretTextField = new JTextField(); + panel2.add(appSecretTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("AES Key"); + panel2.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + aesKeyTextField = new JTextField(); + panel2.add(aesKeyTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(4, 3, new Insets(0, 0, 0, 0), -1, -1)); + Font panel3Font = this.$$$getFont$$$("Microsoft YaHei UI", -1, -1, panel3.getFont()); + if (panel3Font != null) panel3.setFont(panel3Font); + panel1.add(panel3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel3.getFont()), null)); + mpUseProxyCheckBox = new JCheckBox(); + mpUseProxyCheckBox.setText("使用HTTP代理"); + panel3.add(mpUseProxyCheckBox, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpProxyPanel = new JPanel(); + mpProxyPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 26, 0, 0), -1, -1)); + panel3.add(mpProxyPanel, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("Host"); + mpProxyPanel.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpProxyHostTextField = new JTextField(); + mpProxyPanel.add(mpProxyHostTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setText("端口"); + mpProxyPanel.add(label6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpProxyPortTextField = new JTextField(); + mpProxyPanel.add(mpProxyPortTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setText("用户名"); + label7.setToolTipText("选填"); + mpProxyPanel.add(label7, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpProxyUserNameTextField = new JTextField(); + mpProxyUserNameTextField.setToolTipText("选填"); + mpProxyPanel.add(mpProxyUserNameTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setText("密码"); + label8.setToolTipText("选填"); + mpProxyPanel.add(label8, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpProxyPasswordTextField = new JTextField(); + mpProxyPasswordTextField.setToolTipText("选填"); + mpProxyPanel.add(mpProxyPasswordTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + useOutSideAccessTokenCheckBox = new JCheckBox(); + useOutSideAccessTokenCheckBox.setText("使用外部AccessToken"); + panel3.add(useOutSideAccessTokenCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpOutSideAccessTokenPanel = new JPanel(); + mpOutSideAccessTokenPanel.setLayout(new GridLayoutManager(4, 4, new Insets(0, 26, 0, 0), -1, -1)); + panel3.add(mpOutSideAccessTokenPanel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + manualAtRadioButton = new JRadioButton(); + manualAtRadioButton.setText("手动输入"); + mpOutSideAccessTokenPanel.add(manualAtRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + apiAtRadioButton = new JRadioButton(); + apiAtRadioButton.setText("通过接口获取"); + mpOutSideAccessTokenPanel.add(apiAtRadioButton, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(2, 2, new Insets(0, 25, 0, 0), -1, -1)); + mpOutSideAccessTokenPanel.add(panel4, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label9 = new JLabel(); + label9.setText("AccessToken"); + panel4.add(label9, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + accessTokenTextField = new JTextField(); + panel4.add(accessTokenTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label10 = new JLabel(); + label10.setText("有效期(秒)"); + panel4.add(label10, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + atExpiresInTextField = new JTextField(); + panel4.add(atExpiresInTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(1, 2, new Insets(0, 25, 0, 0), -1, -1)); + mpOutSideAccessTokenPanel.add(panel5, new GridConstraints(3, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final JLabel label11 = new JLabel(); + label11.setText("接口url"); + label11.setToolTipText(""); + panel5.add(label11, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + atApiUrlTextField = new JTextField(); + atApiUrlTextField.setToolTipText(""); + panel5.add(atApiUrlTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + manualAtTipsLabel = new JLabel(); + manualAtTipsLabel.setText(""); + mpOutSideAccessTokenPanel.add(manualAtTipsLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + mpOutSideAccessTokenPanel.add(spacer2, new GridConstraints(0, 2, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + apiAtTipsLabel = new JLabel(); + apiAtTipsLabel.setText(""); + mpOutSideAccessTokenPanel.add(apiAtTipsLabel, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + mpOutSideAccessTokenPanel.add(spacer3, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + outSideAtTipsLabel = new JLabel(); + outSideAtTipsLabel.setText(""); + panel3.add(outSideAtTipsLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel3.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/YunPianAccountForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/account/YunPianAccountForm.form new file mode 100644 index 000000000..5ee43c6f5 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/YunPianAccountForm.form @@ -0,0 +1,47 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/account/YunPianAccountForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/account/YunPianAccountForm.java new file mode 100644 index 000000000..de19c5a87 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/account/YunPianAccountForm.java @@ -0,0 +1,144 @@ +package com.fangxuele.tool.push.ui.form.account; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.bean.account.YunPianAccountConfig; +import com.fangxuele.tool.push.domain.TAccount; +import com.fangxuele.tool.push.logic.msgsender.YunPianMsgSender; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.fangxuele.tool.push.util.UndoUtil; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.*; + +@Getter +public class YunPianAccountForm implements IAccountForm { + private JPanel mainPanel; + private JPasswordField apiKeyTextField; + + private static YunPianAccountForm wxMpAccountForm; + + @Override + public void init(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + + YunPianAccountForm instance = getInstance(); + YunPianAccountConfig yunPianAccountConfig = JSONUtil.toBean(tAccount.getAccountConfig(), YunPianAccountConfig.class); + instance.getApiKeyTextField().setText(yunPianAccountConfig.getApiKey()); + } + } + + @Override + public void save(String accountName) { + if (StringUtils.isNotEmpty(accountName)) { + TAccount tAccount = accountMapper.selectByMsgTypeAndAccountName(App.config.getMsgType(), accountName); + YunPianAccountForm instance = getInstance(); + int msgType = App.config.getMsgType(); + + boolean existSameAccount = false; + + if (tAccount != null) { + existSameAccount = true; + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameAccount) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的账号,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameAccount || isCover == JOptionPane.YES_OPTION) { + + String now = SqliteUtil.nowDateForSqlite(); + + TAccount tAccount1 = new TAccount(); + tAccount1.setMsgType(msgType); + tAccount1.setAccountName(accountName); + + YunPianAccountConfig yunPianAccountConfig = new YunPianAccountConfig(); + yunPianAccountConfig.setApiKey(instance.getApiKeyTextField().getText()); + + tAccount1.setAccountConfig(JSONUtil.toJsonStr(yunPianAccountConfig)); + + tAccount1.setModifiedTime(now); + + if (existSameAccount) { + accountMapper.updateByMsgTypeAndAccountName(tAccount1); + YunPianMsgSender.removeAccount(tAccount1.getId()); + } else { + tAccount1.setCreateTime(now); + accountMapper.insertSelective(tAccount1); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + + } + } + + @Override + public void clear() { + UIUtil.clearForm(getInstance()); + } + + @Override + public JPanel getMainPanel() { + return mainPanel; + } + + public static YunPianAccountForm getInstance() { + if (wxMpAccountForm == null) { + wxMpAccountForm = new YunPianAccountForm(); + } + UndoUtil.register(wxMpAccountForm); + return wxMpAccountForm; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 5, 0, 0), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("ApiKey"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + apiKeyTextField = new JPasswordField(); + apiKeyTextField.setText(""); + panel1.add(apiKeyTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, -1), new Dimension(300, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.form index 920843be0..a1f41f83b 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.form @@ -24,7 +24,7 @@ - + @@ -51,7 +51,6 @@ - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.java index 1ebb62529..2a850f1bd 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/AliYunMsgForm.java @@ -1,15 +1,17 @@ package com.fangxuele.tool.push.ui.form.msg; -import com.fangxuele.tool.push.dao.TMsgSmsMapper; -import com.fangxuele.tool.push.dao.TTemplateDataMapper; +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.domain.TMsgSms; -import com.fangxuele.tool.push.domain.TTemplateData; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn; import com.fangxuele.tool.push.ui.form.MainWindow; import com.fangxuele.tool.push.ui.form.MessageEditForm; import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import lombok.Getter; @@ -17,13 +19,14 @@ import javax.swing.*; import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumnModel; +import javax.swing.text.StyleContext; import java.awt.*; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.*; /** *
@@ -48,10 +51,11 @@ public class AliYunMsgForm implements IMsgForm {
 
     private static AliYunMsgForm aliYunMsgForm;
 
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public AliYunMsgForm() {
+        templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+
         // 模板数据-添加 按钮事件
         templateMsgDataAddButton.addActionListener(e -> {
             String[] data = new String[2];
@@ -85,23 +89,31 @@ public AliYunMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.ALI_YUN_CODE, msgName);
-        Integer msgId = 0;
-        if (tMsgSmsList.size() > 0) {
-            TMsgSms tMsgSms = tMsgSmsList.get(0);
-            msgId = tMsgSms.getId();
+
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
             getInstance().getMsgTemplateIdTextField().setText(tMsgSms.getTemplateId());
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
 
         initTemplateDataTable();
         // 模板消息Data表
-        List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.ALI_YUN_CODE, msgId);
+        List templateDataList;
+        if (tMsg == null) {
+            templateDataList = new ArrayList<>();
+        } else {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
+            templateDataList = tMsgSms.getTemplateDataList();
+        }
         String[] headerNames = {"模板参数", "参数对应的值", "操作"};
         Object[][] cellData = new String[templateDataList.size()][headerNames.length];
         for (int i = 0; i < templateDataList.size(); i++) {
-            TTemplateData tTemplateData = templateDataList.get(i);
+            TemplateData tTemplateData = templateDataList.get(i);
             cellData[i][0] = tTemplateData.getName();
             cellData[i][1] = tTemplateData.getValue();
         }
@@ -119,14 +131,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.ALI_YUN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.ALI_YUN_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgSmsList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -141,25 +153,16 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgSms tMsgSms = new TMsgSms();
-            tMsgSms.setMsgType(MessageTypeEnum.ALI_YUN_CODE);
-            tMsgSms.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.ALI_YUN_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgSms.setTemplateId(templateId);
-            tMsgSms.setCreateTime(now);
-            tMsgSms.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms);
-            } else {
-                msgSmsMapper.insertSelective(tMsgSms);
-                msgId = tMsgSms.getId();
-            }
-
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.ALI_YUN_CODE, msgId);
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // 如果table为空,则初始化
             if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -170,19 +173,27 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.ALI_YUN_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataList.add(tTemplateData);
+            }
+
+            tMsgSms.setTemplateDataList(templateDataList);
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgSms));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -224,7 +235,8 @@ public static void initTemplateDataTable() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgTemplateIdTextField().setText("");
         getInstance().getTemplateDataNameTextField().setText("");
         getInstance().getTemplateDataValueTextField().setText("");
@@ -254,14 +266,13 @@ public static void clearAllField() {
         templateMsgDataPanel = new JPanel();
         templateMsgDataPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 0, 0, 0), -1, -1));
         templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
-        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, templateMsgDataPanel.getFont()), null));
+        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, templateMsgDataPanel.getFont()), null));
         templateDataNameTextField = new JTextField();
         templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的");
         templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateDataValueTextField = new JTextField();
         templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateMsgDataAddButton = new JButton();
-        templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         templateMsgDataAddButton.setText("");
         templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         templateMsgDataTable = new JTable();
@@ -306,7 +317,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.form
index 64e65decf..d74942b1c 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.form
@@ -24,7 +24,7 @@
               
             
             
-            
+            
               
             
             
@@ -51,7 +51,6 @@
                   
                 
                 
-                  
                   
                 
               
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.java
index 85d70ba54..4b29ab89d 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/BdYunMsgForm.java
@@ -1,15 +1,17 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgSmsMapper;
-import com.fangxuele.tool.push.dao.TTemplateDataMapper;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgSms;
-import com.fangxuele.tool.push.domain.TTemplateData;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
 import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import lombok.Getter;
@@ -17,13 +19,14 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableColumnModel;
+import javax.swing.text.StyleContext;
 import java.awt.*;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 
@@ -48,10 +51,11 @@ public class BdYunMsgForm implements IMsgForm {
 
     private static BdYunMsgForm bdYunMsgForm;
 
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public BdYunMsgForm() {
+        templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/help.svg"));
+
         // 模板数据-添加 按钮事件
         templateMsgDataAddButton.addActionListener(e -> {
             String[] data = new String[2];
@@ -86,23 +90,31 @@ public BdYunMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.BD_YUN_CODE, msgName);
-        Integer msgId = 0;
-        if (tMsgSmsList.size() > 0) {
-            TMsgSms tMsgSms = tMsgSmsList.get(0);
-            msgId = tMsgSms.getId();
+
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
             getInstance().getMsgTemplateIdTextField().setText(tMsgSms.getTemplateId());
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
 
         initTemplateDataTable();
         // 模板消息Data表
-        List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.BD_YUN_CODE, msgId);
+        List templateDataList;
+        if (tMsg == null) {
+            templateDataList = new ArrayList<>();
+        } else {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
+            templateDataList = tMsgSms.getTemplateDataList();
+        }
         String[] headerNames = {"模板参数", "参数对应的值", "操作"};
         Object[][] cellData = new String[templateDataList.size()][headerNames.length];
         for (int i = 0; i < templateDataList.size(); i++) {
-            TTemplateData tTemplateData = templateDataList.get(i);
+            TemplateData tTemplateData = templateDataList.get(i);
             cellData[i][0] = tTemplateData.getName();
             cellData[i][1] = tTemplateData.getValue();
         }
@@ -120,14 +132,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.BD_YUN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
+        TMsg msgSms = msgMapper.selectByUnique(MessageTypeEnum.BD_YUN_CODE, accountId, msgName);
+        if (msgSms != null) {
             existSameMsg = true;
-            msgId = tMsgSmsList.get(0).getId();
+            msgId = msgSms.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -142,25 +154,16 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgSms tMsgSms = new TMsgSms();
-            tMsgSms.setMsgType(MessageTypeEnum.BD_YUN_CODE);
-            tMsgSms.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.BD_YUN_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgSms.setTemplateId(templateId);
-            tMsgSms.setCreateTime(now);
-            tMsgSms.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms);
-            } else {
-                msgSmsMapper.insertSelective(tMsgSms);
-                msgId = tMsgSms.getId();
-            }
-
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.BD_YUN_CODE, msgId);
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // 如果table为空,则初始化
             if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -171,19 +174,27 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.BD_YUN_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataList.add(tTemplateData);
+            }
+
+            tMsgSms.setTemplateDataList(templateDataList);
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgSms));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -226,7 +237,8 @@ public static void initTemplateDataTable() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgTemplateIdTextField().setText("");
         getInstance().getTemplateDataNameTextField().setText("");
         getInstance().getTemplateDataValueTextField().setText("");
@@ -257,14 +269,13 @@ public static void clearAllField() {
         templateMsgDataPanel = new JPanel();
         templateMsgDataPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 0, 0, 0), -1, -1));
         templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
-        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
+        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
         templateDataNameTextField = new JTextField();
         templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的");
         templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateDataValueTextField = new JTextField();
         templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateMsgDataAddButton = new JButton();
-        templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         templateMsgDataAddButton.setText("");
         templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         templateMsgDataTable = new JTable();
@@ -309,7 +320,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.form
index eb1440d19..a709ed9f8 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.form
@@ -149,7 +149,7 @@
               
             
           
-          
+          
             
             
               
@@ -157,20 +157,6 @@
             
             
             
-              
-                
-                  
-                
-                
-              
-              
-                
-                  
-                
-                
-                  
-                
-              
               
                 
                   
@@ -189,7 +175,7 @@
               
               
                 
-                  
+                  
                     
                   
                 
@@ -200,7 +186,6 @@
                   
                 
                 
-                  
                   
                 
               
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.java
index cfc9716a4..a9c529488 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/DingMsgForm.java
@@ -1,18 +1,17 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
 import cn.hutool.json.JSONUtil;
-import com.fangxuele.tool.push.bean.DingMsg;
-import com.fangxuele.tool.push.dao.TDingAppMapper;
-import com.fangxuele.tool.push.dao.TMsgDingMapper;
-import com.fangxuele.tool.push.domain.TDingApp;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgDing;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.UiConsts;
 import com.fangxuele.tool.push.ui.dialog.CommonTipsDialog;
-import com.fangxuele.tool.push.ui.dialog.DingAppDialog;
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 import com.google.common.collect.Maps;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
@@ -21,11 +20,13 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.text.StyleContext;
 import java.awt.*;
 import java.awt.event.ItemEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Objects;
 
@@ -48,7 +49,6 @@ public class DingMsgForm implements IMsgForm {
     private JLabel urlLabel;
     private JTextField urlTextField;
     private JLabel contentLabel;
-    private JComboBox appNameComboBox;
     private JButton appManageButton;
     private JTextField titleTextField;
     private JTextArea contentTextArea;
@@ -63,26 +63,20 @@ public class DingMsgForm implements IMsgForm {
 
     private static DingMsgForm dingMsgForm;
 
-    private static TMsgDingMapper msgDingMapper = MybatisUtil.getSqlSession().getMapper(TMsgDingMapper.class);
-    private static TDingAppMapper dingAppMapper = MybatisUtil.getSqlSession().getMapper(TDingAppMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public static Map appNameToAgentIdMap = Maps.newHashMap();
     public static Map agentIdToAppNameMap = Maps.newHashMap();
 
     public DingMsgForm() {
+        webHookHelpLabel.setIcon(new FlatSVGIcon("icon/help.svg"));
+
         // 消息类型切换事件
         msgTypeComboBox.addItemListener(e -> {
             if (e.getStateChange() == ItemEvent.SELECTED) {
                 switchDingMsgType(e.getItem().toString());
             }
         });
-        appManageButton.addActionListener(e -> {
-            DingAppDialog dialog = new DingAppDialog();
-            dialog.renderTable();
-            dialog.pack();
-            dialog.setVisible(true);
-            initAppNameList();
-        });
 
         workRadioButton.addChangeListener(e -> {
             boolean isSelected = workRadioButton.isSelected();
@@ -119,58 +113,56 @@ public void mousePressed(MouseEvent e) {
             public void mouseEntered(MouseEvent e) {
                 JLabel label = (JLabel) e.getComponent();
                 label.setCursor(new Cursor(Cursor.HAND_CURSOR));
-                label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON));
+                label.setIcon(UiConsts.HELP_FOCUSED_ICON);
                 super.mouseEntered(e);
             }
 
             @Override
             public void mouseExited(MouseEvent e) {
                 JLabel label = (JLabel) e.getComponent();
-                label.setIcon(new ImageIcon(UiConsts.HELP_ICON));
+                label.setIcon(UiConsts.HELP_ICON);
                 super.mouseExited(e);
             }
         });
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        initAppNameList();
-        List tMsgDingList = msgDingMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.DING_CODE, msgName);
-        if (tMsgDingList.size() > 0) {
-            TMsgDing tMsgDing = tMsgDingList.get(0);
+
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        TMsgDing tMsgDing = JSONUtil.toBean(tMsg.getContent(), TMsgDing.class);
+        if (tMsgDing != null) {
             String dingMsgType = tMsgDing.getDingMsgType();
-            getInstance().getAppNameComboBox().setSelectedItem(agentIdToAppNameMap.get(tMsgDing.getAgentId()));
             getInstance().getMsgTypeComboBox().setSelectedItem(dingMsgType);
-            DingMsg dingMsg = JSONUtil.toBean(tMsgDing.getContent(), DingMsg.class);
-            getInstance().getContentTextArea().setText(dingMsg.getContent());
-            getInstance().getTitleTextField().setText(dingMsg.getTitle());
-            getInstance().getPicUrlTextField().setText(dingMsg.getPicUrl());
-            getInstance().getUrlTextField().setText(dingMsg.getUrl());
-            getInstance().getBtnTxtTextField().setText(dingMsg.getBtnTxt());
+            getInstance().getContentTextArea().setText(tMsgDing.getContent());
+            getInstance().getTitleTextField().setText(tMsgDing.getMsgTitle());
+            getInstance().getPicUrlTextField().setText(tMsgDing.getPicUrl());
+            getInstance().getUrlTextField().setText(tMsgDing.getUrl());
+            getInstance().getBtnTxtTextField().setText(tMsgDing.getBtnTxt());
             getInstance().getWebHookTextField().setText(tMsgDing.getWebHook());
 
             switchDingMsgType(dingMsgType);
 
             switchRadio(tMsgDing.getRadioType());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         } else {
             switchDingMsgType("文本消息");
         }
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         boolean existSameMsg = false;
 
-        if (getInstance().getAppNameComboBox().getSelectedItem() == null) {
-            JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请选择应用!", "成功",
-                    JOptionPane.ERROR_MESSAGE);
-            return;
-        }
-
-        List tMsgDingList = msgDingMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.DING_CODE, msgName);
-        if (tMsgDingList.size() > 0) {
+        Integer msgId = null;
+        TMsg msg = msgMapper.selectByUnique(MessageTypeEnum.DING_CODE, accountId, msgName);
+        if (msg != null) {
             existSameMsg = true;
+            msgId = msg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -192,21 +184,22 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg tMsg = new TMsg();
+            tMsg.setMsgType(MessageTypeEnum.DING_CODE);
+            tMsg.setAccountId(accountId);
+            tMsg.setMsgName(msgName);
             TMsgDing tMsgDing = new TMsgDing();
-            tMsgDing.setMsgType(MessageTypeEnum.DING_CODE);
-            tMsgDing.setMsgName(msgName);
-            tMsgDing.setAgentId(appNameToAgentIdMap.get(getInstance().getAppNameComboBox().getSelectedItem()));
             tMsgDing.setDingMsgType(dingMsgType);
-            DingMsg dingMsg = new DingMsg();
-            dingMsg.setContent(content);
-            dingMsg.setTitle(title);
-            dingMsg.setPicUrl(picUrl);
-            dingMsg.setUrl(url);
-            dingMsg.setBtnTxt(btnTxt);
-            dingMsg.setBtnUrl(btnUrl);
+            tMsgDing.setContent(content);
+            tMsgDing.setMsgTitle(title);
+            tMsgDing.setPicUrl(picUrl);
+            tMsgDing.setUrl(url);
+            tMsgDing.setBtnTxt(btnTxt);
+            tMsgDing.setBtnUrl(btnUrl);
 
-            tMsgDing.setContent(JSONUtil.toJsonStr(dingMsg));
-            tMsgDing.setModifiedTime(now);
+            tMsg.setModifiedTime(now);
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            tMsg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             if (getInstance().getWorkRadioButton().isSelected()) {
                 tMsgDing.setRadioType("work");
@@ -215,11 +208,14 @@ public void save(String msgName) {
             }
             tMsgDing.setWebHook(webHook);
 
+            tMsg.setContent(JSONUtil.toJsonStr(tMsgDing));
+
             if (existSameMsg) {
-                msgDingMapper.updateByMsgTypeAndMsgName(tMsgDing);
+                tMsg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(tMsg);
             } else {
-                tMsgDing.setCreateTime(now);
-                msgDingMapper.insertSelective(tMsgDing);
+                tMsg.setCreateTime(now);
+                msgMapper.insertSelective(tMsg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -234,19 +230,6 @@ public static DingMsgForm getInstance() {
         return dingMsgForm;
     }
 
-    /**
-     * 初始化应用名称列表
-     */
-    public static void initAppNameList() {
-        List tDingAppList = dingAppMapper.selectAll();
-        getInstance().getAppNameComboBox().removeAllItems();
-        for (TDingApp tDingApp : tDingAppList) {
-            appNameToAgentIdMap.put(tDingApp.getAppName(), tDingApp.getAgentId());
-            agentIdToAppNameMap.put(tDingApp.getAgentId(), tDingApp.getAppName());
-            getInstance().getAppNameComboBox().addItem(tDingApp.getAppName());
-        }
-    }
-
     /**
      * 根据消息类型转换界面显示
      *
@@ -327,7 +310,8 @@ private void switchRadio(String radioType) {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getContentTextArea().setText("");
         getInstance().getTitleTextField().setText("");
         getInstance().getPicUrlTextField().setText("");
@@ -403,13 +387,8 @@ public static void clearAllField() {
         btnURLLabel.setText("按钮URL");
         dingMsgPanel.add(btnURLLabel, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final JPanel panel2 = new JPanel();
-        panel2.setLayout(new GridLayoutManager(2, 4, new Insets(0, 0, 20, 0), -1, -1));
+        panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 20, 0), -1, -1));
         dingMsgPanel.add(panel2, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
-        appNameComboBox = new JComboBox();
-        panel2.add(appNameComboBox, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
-        appManageButton = new JButton();
-        appManageButton.setText("应用管理");
-        panel2.add(appManageButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         workRadioButton = new JRadioButton();
         workRadioButton.setText("工作通知消息");
         panel2.add(workRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
@@ -417,9 +396,8 @@ public static void clearAllField() {
         robotRadioButton.setText("群机器人消息");
         panel2.add(robotRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         webHookTextField = new JTextField();
-        panel2.add(webHookTextField, new GridConstraints(1, 2, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        panel2.add(webHookTextField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         webHookHelpLabel = new JLabel();
-        webHookHelpLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png")));
         webHookHelpLabel.setText("webhook");
         panel2.add(webHookHelpLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final Spacer spacer2 = new Spacer();
@@ -449,7 +427,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.form
index 6e2269ad0..ddff9b2c4 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.form
@@ -67,7 +67,7 @@
             
             
             
-              
+              
                 
                 
                   
@@ -77,7 +77,7 @@
                 
                   
                     
-                      
+                      
                         
                       
                     
@@ -85,7 +85,7 @@
                   
                   
                     
-                      
+                      
                         
                       
                     
@@ -93,16 +93,15 @@
                   
                   
                     
-                      
+                      
                     
                     
-                      
                       
                     
                   
                   
                     
-                      
+                      
                         
                       
                     
@@ -112,7 +111,7 @@
                   
                   
                     
-                      
+                      
                     
                     
                       
@@ -120,7 +119,7 @@
                   
                   
                     
-                      
+                      
                     
                     
                       
@@ -138,7 +137,7 @@
             
             
             
-              
+              
                 
                 
                   
@@ -148,7 +147,7 @@
                 
                   
                     
-                      
+                      
                         
                       
                     
@@ -156,7 +155,7 @@
                   
                   
                     
-                      
+                      
                         
                       
                     
@@ -164,16 +163,15 @@
                   
                   
                     
-                      
+                      
                     
                     
-                      
                       
                     
                   
                   
                     
-                      
+                      
                         
                       
                     
@@ -183,7 +181,7 @@
                   
                   
                     
-                      
+                      
                     
                     
                       
@@ -191,7 +189,7 @@
                   
                   
                     
-                      
+                      
                     
                     
                       
@@ -238,7 +236,6 @@
                       
                     
                     
-                      
                       
                     
                   
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.java
index a663a74ac..123925390 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HttpMsgForm.java
@@ -1,14 +1,17 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
 import cn.hutool.json.JSONUtil;
-import com.fangxuele.tool.push.App;
-import com.fangxuele.tool.push.dao.TMsgHttpMapper;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgHttp;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
+import com.fangxuele.tool.push.util.UIUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import com.intellij.uiDesigner.core.Spacer;
@@ -22,7 +25,6 @@
 import javax.swing.table.TableColumnModel;
 import java.awt.*;
 import java.awt.event.ItemEvent;
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -62,9 +64,13 @@ public class HttpMsgForm implements IMsgForm {
 
     private static HttpMsgForm httpMsgForm;
 
-    private static TMsgHttpMapper msgHttpMapper = MybatisUtil.getSqlSession().getMapper(TMsgHttpMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public HttpMsgForm() {
+        paramAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+        cookieAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+        headerAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+
         paramAddButton.addActionListener(e -> {
             String[] data = new String[2];
             data[0] = getInstance().getParamNameTextField().getText();
@@ -165,7 +171,7 @@ public HttpMsgForm() {
             }
         });
 
-        if ("Darcula(推荐)".equals(App.config.getTheme())) {
+        if (UIUtil.isDarkLaf()) {
             Color bgColor = new Color(43, 43, 43);
             bodyTextArea.setBackground(bgColor);
             Color foreColor = new Color(187, 187, 187);
@@ -174,92 +180,102 @@ public HttpMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List msgHttpList = msgHttpMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.HTTP_CODE, msgName);
-        if (msgHttpList.size() > 0) {
-            TMsgHttp tMsgHttp = msgHttpList.get(0);
-            getInstance().getMethodComboBox().setSelectedItem(tMsgHttp.getMethod());
-            getInstance().getUrlTextField().setText(tMsgHttp.getUrl());
-            getInstance().getBodyTextArea().setText(tMsgHttp.getBody());
-            getInstance().getBodyTypeComboBox().setSelectedItem(tMsgHttp.getBodyType());
-            switchMethod(tMsgHttp.getMethod());
-
-            // Params=====================================
-            initParamTable();
-            List params = JSONUtil.toList(JSONUtil.parseArray(tMsgHttp.getParams()), NameValueObject.class);
-            String[] headerNames = {"Name", "Value", ""};
-            Object[][] cellData = new String[params.size()][headerNames.length];
-            for (int i = 0; i < params.size(); i++) {
-                NameValueObject nameValueObject = params.get(i);
-                cellData[i][0] = nameValueObject.getName();
-                cellData[i][1] = nameValueObject.getValue();
-            }
-            DefaultTableModel model = new DefaultTableModel(cellData, headerNames);
-            getInstance().getParamTable().setModel(model);
-            TableColumnModel paramTableColumnModel = getInstance().getParamTable().getColumnModel();
-            paramTableColumnModel.getColumn(headerNames.length - 1).
-                    setCellRenderer(new TableInCellButtonColumn(getInstance().getParamTable(), headerNames.length - 1));
-            paramTableColumnModel.getColumn(headerNames.length - 1).
-                    setCellEditor(new TableInCellButtonColumn(getInstance().getParamTable(), headerNames.length - 1));
-
-            // 设置列宽
-            paramTableColumnModel.getColumn(2).setPreferredWidth(46);
-            paramTableColumnModel.getColumn(2).setMaxWidth(46);
-            // Headers=====================================
-            initHeaderTable();
-            List headers = JSONUtil.toList(JSONUtil.parseArray(tMsgHttp.getHeaders()), NameValueObject.class);
-            cellData = new String[headers.size()][headerNames.length];
-            for (int i = 0; i < headers.size(); i++) {
-                NameValueObject nameValueObject = headers.get(i);
-                cellData[i][0] = nameValueObject.getName();
-                cellData[i][1] = nameValueObject.getValue();
-            }
-            model = new DefaultTableModel(cellData, headerNames);
-            getInstance().getHeaderTable().setModel(model);
-            TableColumnModel headerTableColumnModel = getInstance().getHeaderTable().getColumnModel();
-            headerTableColumnModel.getColumn(headerNames.length - 1).
-                    setCellRenderer(new TableInCellButtonColumn(getInstance().getHeaderTable(), headerNames.length - 1));
-            headerTableColumnModel.getColumn(headerNames.length - 1).
-                    setCellEditor(new TableInCellButtonColumn(getInstance().getHeaderTable(), headerNames.length - 1));
-
-            // 设置列宽
-            headerTableColumnModel.getColumn(2).setPreferredWidth(46);
-            headerTableColumnModel.getColumn(2).setMaxWidth(46);
-            // Cookies=====================================
-            initCookieTable();
-            List cookies = JSONUtil.toList(JSONUtil.parseArray(tMsgHttp.getCookies()), CookieObject.class);
-            headerNames = new String[]{"Name", "Value", "Domain", "Path", "Expiry", ""};
-            cellData = new String[cookies.size()][headerNames.length];
-            for (int i = 0; i < cookies.size(); i++) {
-                CookieObject cookieObject = cookies.get(i);
-                cellData[i][0] = cookieObject.getName();
-                cellData[i][1] = cookieObject.getValue();
-                cellData[i][2] = cookieObject.getDomain();
-                cellData[i][3] = cookieObject.getPath();
-                cellData[i][4] = cookieObject.getExpiry();
-            }
-            model = new DefaultTableModel(cellData, headerNames);
-            getInstance().getCookieTable().setModel(model);
-            TableColumnModel cookieTableColumnModel = getInstance().getCookieTable().getColumnModel();
-            cookieTableColumnModel.getColumn(headerNames.length - 1).
-                    setCellRenderer(new TableInCellButtonColumn(getInstance().getCookieTable(), headerNames.length - 1));
-            cookieTableColumnModel.getColumn(headerNames.length - 1).
-                    setCellEditor(new TableInCellButtonColumn(getInstance().getCookieTable(), headerNames.length - 1));
-
-            // 设置列宽
-            cookieTableColumnModel.getColumn(5).setPreferredWidth(46);
-            cookieTableColumnModel.getColumn(5).setMaxWidth(46);
+
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+
+        if (tMsg == null) {
+            return;
+        }
+
+        TMsgHttp tMsgHttp = JSONUtil.toBean(tMsg.getContent(), TMsgHttp.class);
+
+        getInstance().getMethodComboBox().setSelectedItem(tMsgHttp.getMethod());
+        getInstance().getUrlTextField().setText(tMsgHttp.getUrl());
+        getInstance().getBodyTextArea().setText(tMsgHttp.getBody());
+        getInstance().getBodyTypeComboBox().setSelectedItem(tMsgHttp.getBodyType());
+        switchMethod(tMsgHttp.getMethod());
+
+        MessageEditForm messageEditForm = MessageEditForm.getInstance();
+        messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+        messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
+
+        // Params=====================================
+        initParamTable();
+        List params = JSONUtil.toList(JSONUtil.parseArray(tMsgHttp.getParams()), NameValueObject.class);
+        String[] headerNames = {"Name", "Value", ""};
+        Object[][] cellData = new String[params.size()][headerNames.length];
+        for (int i = 0; i < params.size(); i++) {
+            NameValueObject nameValueObject = params.get(i);
+            cellData[i][0] = nameValueObject.getName();
+            cellData[i][1] = nameValueObject.getValue();
         }
+        DefaultTableModel model = new DefaultTableModel(cellData, headerNames);
+        getInstance().getParamTable().setModel(model);
+        TableColumnModel paramTableColumnModel = getInstance().getParamTable().getColumnModel();
+        paramTableColumnModel.getColumn(headerNames.length - 1).
+                setCellRenderer(new TableInCellButtonColumn(getInstance().getParamTable(), headerNames.length - 1));
+        paramTableColumnModel.getColumn(headerNames.length - 1).
+                setCellEditor(new TableInCellButtonColumn(getInstance().getParamTable(), headerNames.length - 1));
+
+        // 设置列宽
+        paramTableColumnModel.getColumn(2).setPreferredWidth(46);
+        paramTableColumnModel.getColumn(2).setMaxWidth(46);
+        // Headers=====================================
+        initHeaderTable();
+        List headers = JSONUtil.toList(JSONUtil.parseArray(tMsgHttp.getHeaders()), NameValueObject.class);
+        cellData = new String[headers.size()][headerNames.length];
+        for (int i = 0; i < headers.size(); i++) {
+            NameValueObject nameValueObject = headers.get(i);
+            cellData[i][0] = nameValueObject.getName();
+            cellData[i][1] = nameValueObject.getValue();
+        }
+        model = new DefaultTableModel(cellData, headerNames);
+        getInstance().getHeaderTable().setModel(model);
+        TableColumnModel headerTableColumnModel = getInstance().getHeaderTable().getColumnModel();
+        headerTableColumnModel.getColumn(headerNames.length - 1).
+                setCellRenderer(new TableInCellButtonColumn(getInstance().getHeaderTable(), headerNames.length - 1));
+        headerTableColumnModel.getColumn(headerNames.length - 1).
+                setCellEditor(new TableInCellButtonColumn(getInstance().getHeaderTable(), headerNames.length - 1));
+
+        // 设置列宽
+        headerTableColumnModel.getColumn(2).setPreferredWidth(46);
+        headerTableColumnModel.getColumn(2).setMaxWidth(46);
+        // Cookies=====================================
+        initCookieTable();
+        List cookies = JSONUtil.toList(JSONUtil.parseArray(tMsgHttp.getCookies()), CookieObject.class);
+        headerNames = new String[]{"Name", "Value", "Domain", "Path", "Expiry", ""};
+        cellData = new String[cookies.size()][headerNames.length];
+        for (int i = 0; i < cookies.size(); i++) {
+            CookieObject cookieObject = cookies.get(i);
+            cellData[i][0] = cookieObject.getName();
+            cellData[i][1] = cookieObject.getValue();
+            cellData[i][2] = cookieObject.getDomain();
+            cellData[i][3] = cookieObject.getPath();
+            cellData[i][4] = cookieObject.getExpiry();
+        }
+        model = new DefaultTableModel(cellData, headerNames);
+        getInstance().getCookieTable().setModel(model);
+        TableColumnModel cookieTableColumnModel = getInstance().getCookieTable().getColumnModel();
+        cookieTableColumnModel.getColumn(headerNames.length - 1).
+                setCellRenderer(new TableInCellButtonColumn(getInstance().getCookieTable(), headerNames.length - 1));
+        cookieTableColumnModel.getColumn(headerNames.length - 1).
+                setCellEditor(new TableInCellButtonColumn(getInstance().getCookieTable(), headerNames.length - 1));
+
+        // 设置列宽
+        cookieTableColumnModel.getColumn(5).setPreferredWidth(46);
+        cookieTableColumnModel.getColumn(5).setMaxWidth(46);
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         boolean existSameMsg = false;
-
-        List tMsgHttpList = msgHttpMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.HTTP_CODE, msgName);
-        if (tMsgHttpList.size() > 0) {
+        Integer msgId = null;
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.HTTP_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -276,15 +292,19 @@ public void save(String msgName) {
             String bodyType = (String) getInstance().getBodyTypeComboBox().getSelectedItem();
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgHttp tMsgHttp = new TMsgHttp();
-            tMsgHttp.setMsgType(MessageTypeEnum.HTTP_CODE);
-            tMsgHttp.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.HTTP_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgHttp.setMethod(method);
             tMsgHttp.setUrl(url);
             tMsgHttp.setBody(body);
             tMsgHttp.setBodyType(bodyType);
-            tMsgHttp.setCreateTime(now);
-            tMsgHttp.setModifiedTime(now);
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // =============params
             // 如果table为空,则初始化
@@ -349,10 +369,12 @@ public void save(String msgName) {
             }
             tMsgHttp.setCookies(JSONUtil.toJsonStr(cookies));
 
+            msg.setContent(JSONUtil.toJsonStr(tMsgHttp));
             if (existSameMsg) {
-                msgHttpMapper.updateByMsgTypeAndMsgName(tMsgHttp);
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
             } else {
-                msgHttpMapper.insertSelective(tMsgHttp);
+                msgMapper.insertSelective(msg);
             }
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
                     JOptionPane.INFORMATION_MESSAGE);
@@ -370,7 +392,8 @@ public static HttpMsgForm getInstance() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMethodComboBox().setSelectedIndex(0);
         getInstance().getUrlTextField().setText("");
         getInstance().getParamNameTextField().setText("");
@@ -480,8 +503,7 @@ public static void initCookieTable() {
 
     @Getter
     @Setter
-    public static class NameValueObject implements Serializable {
-        private static final long serialVersionUID = -3828939498243146605L;
+    public static class NameValueObject {
 
         private String name;
 
@@ -490,9 +512,7 @@ public static class NameValueObject implements Serializable {
 
     @Getter
     @Setter
-    public static class CookieObject implements Serializable {
-
-        private static final long serialVersionUID = 810193087944524307L;
+    public static class CookieObject {
 
         private String name;
 
@@ -547,48 +567,46 @@ public static class CookieObject implements Serializable {
         panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         tabbedPane1.addTab("Params", panel2);
         final JPanel panel3 = new JPanel();
-        panel3.setLayout(new GridLayoutManager(3, 5, new Insets(5, 5, 0, 0), -1, -1));
+        panel3.setLayout(new GridLayoutManager(3, 3, new Insets(5, 5, 0, 0), -1, -1));
         panel2.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         paramNameTextField = new JTextField();
-        panel3.add(paramNameTextField, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        panel3.add(paramNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         paramValueTextField = new JTextField();
-        panel3.add(paramValueTextField, new GridConstraints(1, 2, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        panel3.add(paramValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         paramAddButton = new JButton();
-        paramAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         paramAddButton.setText("");
-        panel3.add(paramAddButton, new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel3.add(paramAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         paramTable = new JTable();
         paramTable.setRowHeight(36);
-        panel3.add(paramTable, new GridConstraints(2, 0, 1, 5, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
+        panel3.add(paramTable, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
         final JLabel label2 = new JLabel();
         label2.setText("Name");
-        panel3.add(label2, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel3.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final JLabel label3 = new JLabel();
         label3.setText("Value");
-        panel3.add(label3, new GridConstraints(0, 2, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
+        panel3.add(label3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
         final JPanel panel4 = new JPanel();
         panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         tabbedPane1.addTab("Headers", panel4);
         final JPanel panel5 = new JPanel();
-        panel5.setLayout(new GridLayoutManager(3, 5, new Insets(5, 5, 0, 0), -1, -1));
+        panel5.setLayout(new GridLayoutManager(3, 3, new Insets(5, 5, 0, 0), -1, -1));
         panel4.add(panel5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         headerNameTextField = new JTextField();
-        panel5.add(headerNameTextField, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        panel5.add(headerNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         headerValueTextField5 = new JTextField();
-        panel5.add(headerValueTextField5, new GridConstraints(1, 2, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        panel5.add(headerValueTextField5, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         headerAddButton = new JButton();
-        headerAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         headerAddButton.setText("");
-        panel5.add(headerAddButton, new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel5.add(headerAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         headerTable = new JTable();
         headerTable.setRowHeight(36);
-        panel5.add(headerTable, new GridConstraints(2, 0, 1, 5, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
+        panel5.add(headerTable, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
         final JLabel label4 = new JLabel();
         label4.setText("Name");
-        panel5.add(label4, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        panel5.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final JLabel label5 = new JLabel();
         label5.setText("Value");
-        panel5.add(label5, new GridConstraints(0, 2, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
+        panel5.add(label5, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
         final JPanel panel6 = new JPanel();
         panel6.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         tabbedPane1.addTab("Cookies", panel6);
@@ -600,7 +618,6 @@ public static class CookieObject implements Serializable {
         cookieValueTextField = new JTextField();
         panel7.add(cookieValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         cookieAddButton = new JButton();
-        cookieAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         cookieAddButton.setText("");
         panel7.add(cookieAddButton, new GridConstraints(1, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         cookieTable = new JTable();
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.form
index 8f092d9d4..622e75aab 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.form
@@ -24,7 +24,7 @@
               
             
             
-            
+            
               
             
             
@@ -51,7 +51,6 @@
                   
                 
                 
-                  
                   
                 
               
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.java
index 0a5d51323..82046b641 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/HwYunMsgForm.java
@@ -1,15 +1,17 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgSmsMapper;
-import com.fangxuele.tool.push.dao.TTemplateDataMapper;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgSms;
-import com.fangxuele.tool.push.domain.TTemplateData;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
 import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import lombok.Getter;
@@ -17,13 +19,14 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableColumnModel;
+import javax.swing.text.StyleContext;
 import java.awt.*;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 
@@ -48,10 +51,10 @@ public class HwYunMsgForm implements IMsgForm {
 
     private static HwYunMsgForm hwYunMsgForm;
 
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public HwYunMsgForm() {
+        templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
         // 模板数据-添加 按钮事件
         templateMsgDataAddButton.addActionListener(e -> {
             String[] data = new String[2];
@@ -86,23 +89,31 @@ public HwYunMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.HW_YUN_CODE, msgName);
-        Integer msgId = 0;
-        if (tMsgSmsList.size() > 0) {
-            TMsgSms tMsgSms = tMsgSmsList.get(0);
-            msgId = tMsgSms.getId();
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
             getInstance().getMsgTemplateIdTextField().setText(tMsgSms.getTemplateId());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
 
         initTemplateDataTable();
         // 模板消息Data表
-        List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.HW_YUN_CODE, msgId);
+        List templateDataList;
+        if (tMsg == null) {
+            templateDataList = new ArrayList<>();
+        } else {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
+            templateDataList = tMsgSms.getTemplateDataList();
+        }
         String[] headerNames = {"模板参数", "参数对应的值", "操作"};
         Object[][] cellData = new String[templateDataList.size()][headerNames.length];
         for (int i = 0; i < templateDataList.size(); i++) {
-            TTemplateData tTemplateData = templateDataList.get(i);
+            TemplateData tTemplateData = templateDataList.get(i);
             cellData[i][0] = tTemplateData.getName();
             cellData[i][1] = tTemplateData.getValue();
         }
@@ -120,14 +131,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.HW_YUN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.HW_YUN_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgSmsList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -142,25 +153,16 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgSms tMsgSms = new TMsgSms();
-            tMsgSms.setMsgType(MessageTypeEnum.HW_YUN_CODE);
-            tMsgSms.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.HW_YUN_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgSms.setTemplateId(templateId);
-            tMsgSms.setCreateTime(now);
-            tMsgSms.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms);
-            } else {
-                msgSmsMapper.insertSelective(tMsgSms);
-                msgId = tMsgSms.getId();
-            }
-
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.HW_YUN_CODE, msgId);
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // 如果table为空,则初始化
             if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -171,19 +173,26 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.HW_YUN_CODE);
-                tTemplateData.setMsgId(msgId);
-                tTemplateData.setName(name);
-                tTemplateData.setValue(value);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
+                TemplateData templateData = new TemplateData();
+                templateData.setName(name);
+                templateData.setValue(value);
+
+                templateDataList.add(templateData);
+            }
+
+            tMsgSms.setTemplateDataList(templateDataList);
 
-                templateDataMapper.insert(tTemplateData);
+            msg.setContent(JSONUtil.toJsonStr(tMsgSms));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -226,7 +235,8 @@ public static void initTemplateDataTable() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgTemplateIdTextField().setText("");
         getInstance().getTemplateDataNameTextField().setText("");
         getInstance().getTemplateDataValueTextField().setText("");
@@ -257,14 +267,13 @@ public static void clearAllField() {
         templateMsgDataPanel = new JPanel();
         templateMsgDataPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 0, 0, 0), -1, -1));
         templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
-        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
+        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
         templateDataNameTextField = new JTextField();
         templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的");
         templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateDataValueTextField = new JTextField();
         templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateMsgDataAddButton = new JButton();
-        templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         templateMsgDataAddButton.setText("");
         templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         templateMsgDataTable = new JTable();
@@ -309,7 +318,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/IMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/IMsgForm.java
index 0efabafec..2dc43f638 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/IMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/IMsgForm.java
@@ -12,14 +12,16 @@ public interface IMsgForm {
     /**
      * 初始化界面
      *
-     * @param msgName
+     * @param msgId
      */
-    void init(String msgName);
+    void init(Integer msgId);
 
     /**
      * 保存消息
      *
      * @param msgName
      */
-    void save(String msgName);
+    void save(Integer accountId, String msgName);
+
+    void clearAllField();
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.form
index 77a3f4e20..bc73c62bf 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.form
@@ -3,12 +3,12 @@
   
     
     
-      
+      
     
     
     
     
-      
+      
         
         
           
@@ -29,7 +29,7 @@
           
           
             
-              
+              
             
           
           
@@ -40,6 +40,7 @@
               
                 
                 
+                
               
             
           
@@ -104,6 +105,34 @@
               
             
           
+          
+            
+              
+            
+            
+              
+              
+            
+          
+          
+            
+              
+            
+            
+              
+              
+            
+          
+          
+            
+              
+            
+            
+              
+              
+              
+            
+          
           
             
               
@@ -112,6 +141,22 @@
             
             
           
+          
+            
+              
+                
+              
+            
+            
+          
+          
+            
+              
+                
+              
+            
+            
+          
           
             
               
@@ -128,6 +173,32 @@
             
             
           
+          
+            
+            
+              
+            
+            
+            
+            
+              
+                
+                  
+                    
+                  
+                
+                
+              
+              
+                
+                  
+                
+                
+                  
+                
+              
+            
+          
         
       
     
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.java
index 8638e19a9..8a0beb8c4 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuMsgForm.java
@@ -1,21 +1,34 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgKefuMapper;
+import cn.binarywang.wx.miniapp.constant.WxMaConstants;
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.Log;
+import cn.hutool.log.LogFactory;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgKefu;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
+import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender;
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import com.intellij.uiDesigner.core.Spacer;
 import lombok.Getter;
+import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileNameExtensionFilter;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.text.StyleContext;
 import java.awt.*;
 import java.awt.event.ItemEvent;
-import java.util.List;
+import java.io.File;
+import java.util.Locale;
 import java.util.Objects;
 
 /**
@@ -41,10 +54,19 @@ public class KefuMsgForm implements IMsgForm {
     private JTextField msgKefuUrlTextField;
     private JLabel contentLabel;
     private JTextArea contentTextArea;
+    private JLabel kefuMsgAppidLabel;
+    private JTextField msgKefuAppidTextField;
+    private JTextField msgKefuPagepathTextField;
+    private JLabel kefuMsgPagepathLabel;
+    private JTextField msgKefuThumbMediaIdTextField;
+    private JLabel kefuMsgThumbMediaIdLabel;
+    private JButton uploadImageButton;
+    private JPanel thumbMediaPanel;
 
+    private static final Log logger = LogFactory.get();
     private static KefuMsgForm kefuMsgForm;
 
-    private static TMsgKefuMapper msgKefuMapper = MybatisUtil.getSqlSession().getMapper(TMsgKefuMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public KefuMsgForm() {
         // 客服消息类型切换事件
@@ -53,38 +75,66 @@ public KefuMsgForm() {
                 switchKefuMsgType(e.getItem().toString());
             }
         });
+        uploadImageButton.addActionListener(e -> {
+            JFileChooser fileChooser = new JFileChooser();
+            FileFilter filter = new FileNameExtensionFilter("*.bmp,*.gif,*.jpeg,*.jpg,*.png", "bmp", "gif", "jpeg", "jpg", "png", "BMP", "GIF", "JPEG", "JPG", "PNG");
+            fileChooser.setFileFilter(filter);
+
+            int approve = fileChooser.showOpenDialog(MessageEditForm.getInstance().getMsgEditorPanel());
+            if (approve == JFileChooser.APPROVE_OPTION) {
+                try {
+                    File selectedFile = fileChooser.getSelectedFile();
+                    WxMediaUploadResult wxMediaUploadResult = WxMpTemplateMsgSender.getWxMpService().getMaterialService().mediaUpload(WxMaConstants.MediaType.IMAGE, selectedFile);
+                    msgKefuThumbMediaIdTextField.setText(wxMediaUploadResult.getMediaId());
+                } catch (Exception e1) {
+                    JOptionPane.showMessageDialog(kefuMsgPanel, "上传失败!\n\n" + e1.getMessage(), "失败",
+                            JOptionPane.ERROR_MESSAGE);
+                    logger.error(e1);
+                }
+            }
+        });
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgKefuList = msgKefuMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.KEFU_CODE, msgName);
-        if (tMsgKefuList.size() > 0) {
-            TMsgKefu tMsgKefu = tMsgKefuList.get(0);
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgKefu tMsgKefu = JSONUtil.toBean(tMsg.getContent(), TMsgKefu.class);
             String kefuMsgType = tMsgKefu.getKefuMsgType();
             getInstance().getMsgKefuMsgTypeComboBox().setSelectedItem(kefuMsgType);
             if ("文本消息".equals(kefuMsgType)) {
                 getInstance().getContentTextArea().setText(tMsgKefu.getContent());
             } else if ("图文消息".equals(kefuMsgType)) {
                 getInstance().getMsgKefuMsgTitleTextField().setText(tMsgKefu.getTitle());
+            } else if ("小程序卡片消息".equals(kefuMsgType)) {
+                getInstance().getMsgKefuMsgTitleTextField().setText(tMsgKefu.getTitle());
+                getInstance().getMsgKefuAppidTextField().setText(tMsgKefu.getAppId());
+                getInstance().getMsgKefuPagepathTextField().setText(tMsgKefu.getPagePath());
+                getInstance().getMsgKefuThumbMediaIdTextField().setText(tMsgKefu.getThumbMediaId());
             }
             getInstance().getMsgKefuPicUrlTextField().setText(tMsgKefu.getImgUrl());
             getInstance().getMsgKefuDescTextField().setText(tMsgKefu.getDescribe());
             getInstance().getMsgKefuUrlTextField().setText(tMsgKefu.getUrl());
 
             switchKefuMsgType(kefuMsgType);
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         } else {
             switchKefuMsgType("图文消息");
         }
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         boolean existSameMsg = false;
-
-        List tMsgKefuList = msgKefuMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.KEFU_CODE, msgName);
-        if (tMsgKefuList.size() > 0) {
+        Integer msgId = null;
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.KEFU_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -101,12 +151,17 @@ public void save(String msgName) {
             String kefuPicUrl = getInstance().getMsgKefuPicUrlTextField().getText();
             String kefuDesc = getInstance().getMsgKefuDescTextField().getText();
             String kefuUrl = getInstance().getMsgKefuUrlTextField().getText();
+            String kefuAppId = getInstance().getMsgKefuAppidTextField().getText();
+            String kefuPagePath = getInstance().getMsgKefuPagepathTextField().getText();
+            String kefuThumbMediaId = getInstance().getMsgKefuThumbMediaIdTextField().getText();
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgKefu tMsgKefu = new TMsgKefu();
-            tMsgKefu.setMsgType(MessageTypeEnum.KEFU_CODE);
-            tMsgKefu.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.KEFU_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgKefu.setKefuMsgType(kefuMsgType);
             tMsgKefu.setContent(kefuMsgContent);
             tMsgKefu.setTitle(kefuMsgTitle);
@@ -114,12 +169,20 @@ public void save(String msgName) {
             tMsgKefu.setDescribe(kefuDesc);
             tMsgKefu.setUrl(kefuUrl);
             tMsgKefu.setModifiedTime(now);
+            tMsgKefu.setAppId(kefuAppId);
+            tMsgKefu.setPagePath(kefuPagePath);
+            tMsgKefu.setThumbMediaId(kefuThumbMediaId);
 
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            tMsgKefu.setPreviewUser(messageEditForm.getPreviewUserField().getText());
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgKefu));
             if (existSameMsg) {
-                msgKefuMapper.updateByMsgTypeAndMsgName(tMsgKefu);
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
             } else {
                 tMsgKefu.setCreateTime(now);
-                msgKefuMapper.insertSelective(tMsgKefu);
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -140,21 +203,28 @@ public static KefuMsgForm getInstance() {
      * @param msgType 消息类型
      */
     public static void switchKefuMsgType(String msgType) {
+        getInstance().getContentLabel().setVisible(false);
+        getInstance().getContentTextArea().setVisible(false);
+        getInstance().getKefuMsgDescLabel().setVisible(false);
+        getInstance().getMsgKefuDescTextField().setVisible(false);
+        getInstance().getKefuMsgPicUrlLabel().setVisible(false);
+        getInstance().getMsgKefuPicUrlTextField().setVisible(false);
+        getInstance().getKefuMsgUrlLabel().setVisible(false);
+        getInstance().getMsgKefuUrlTextField().setVisible(false);
+        getInstance().getKefuMsgTitleLabel().setVisible(false);
+        getInstance().getMsgKefuMsgTitleTextField().setVisible(false);
+        getInstance().getKefuMsgAppidLabel().setVisible(false);
+        getInstance().getMsgKefuAppidTextField().setVisible(false);
+        getInstance().getKefuMsgPagepathLabel().setVisible(false);
+        getInstance().getMsgKefuPagepathTextField().setVisible(false);
+        getInstance().getKefuMsgThumbMediaIdLabel().setVisible(false);
+        getInstance().getThumbMediaPanel().setVisible(false);
         switch (msgType) {
             case "文本消息":
+                getInstance().getContentLabel().setVisible(true);
                 getInstance().getContentTextArea().setVisible(true);
-                getInstance().getKefuMsgDescLabel().setVisible(false);
-                getInstance().getMsgKefuDescTextField().setVisible(false);
-                getInstance().getKefuMsgPicUrlLabel().setVisible(false);
-                getInstance().getMsgKefuPicUrlTextField().setVisible(false);
-                getInstance().getKefuMsgUrlLabel().setVisible(false);
-                getInstance().getMsgKefuUrlTextField().setVisible(false);
-                getInstance().getKefuMsgTitleLabel().setVisible(false);
-                getInstance().getMsgKefuMsgTitleTextField().setVisible(false);
                 break;
             case "图文消息":
-                getInstance().getContentLabel().setVisible(false);
-                getInstance().getContentTextArea().setVisible(false);
                 getInstance().getKefuMsgDescLabel().setVisible(true);
                 getInstance().getMsgKefuDescTextField().setVisible(true);
                 getInstance().getKefuMsgPicUrlLabel().setVisible(true);
@@ -164,6 +234,16 @@ public static void switchKefuMsgType(String msgType) {
                 getInstance().getKefuMsgTitleLabel().setVisible(true);
                 getInstance().getMsgKefuMsgTitleTextField().setVisible(true);
                 break;
+            case "小程序卡片消息":
+                getInstance().getKefuMsgTitleLabel().setVisible(true);
+                getInstance().getMsgKefuMsgTitleTextField().setVisible(true);
+                getInstance().getKefuMsgAppidLabel().setVisible(true);
+                getInstance().getMsgKefuAppidTextField().setVisible(true);
+                getInstance().getKefuMsgPagepathLabel().setVisible(true);
+                getInstance().getMsgKefuPagepathTextField().setVisible(true);
+                getInstance().getKefuMsgThumbMediaIdLabel().setVisible(true);
+                getInstance().getThumbMediaPanel().setVisible(true);
+                break;
             default:
                 break;
         }
@@ -172,12 +252,16 @@ public static void switchKefuMsgType(String msgType) {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getContentTextArea().setText("");
         getInstance().getMsgKefuMsgTitleTextField().setText("");
         getInstance().getMsgKefuPicUrlTextField().setText("");
         getInstance().getMsgKefuDescTextField().setText("");
         getInstance().getMsgKefuUrlTextField().setText("");
+        getInstance().getMsgKefuAppidTextField().setText("");
+        getInstance().getMsgKefuPagepathTextField().setText("");
+        getInstance().getMsgKefuThumbMediaIdTextField().setText("");
     }
 
     {
@@ -198,18 +282,19 @@ public static void clearAllField() {
         final JPanel panel1 = new JPanel();
         panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         kefuMsgPanel = new JPanel();
-        kefuMsgPanel.setLayout(new GridLayoutManager(7, 2, new Insets(10, 15, 0, 0), -1, -1));
+        kefuMsgPanel.setLayout(new GridLayoutManager(10, 2, new Insets(10, 15, 0, 0), -1, -1));
         panel1.add(kefuMsgPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
         kefuMsgPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "客服消息编辑", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, kefuMsgPanel.getFont()), null));
         kefuMsgTypeLabel = new JLabel();
         kefuMsgTypeLabel.setText("消息类型");
         kefuMsgPanel.add(kefuMsgTypeLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final Spacer spacer1 = new Spacer();
-        kefuMsgPanel.add(spacer1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+        kefuMsgPanel.add(spacer1, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
         msgKefuMsgTypeComboBox = new JComboBox();
         final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
         defaultComboBoxModel1.addElement("图文消息");
         defaultComboBoxModel1.addElement("文本消息");
+        defaultComboBoxModel1.addElement("小程序卡片消息");
         msgKefuMsgTypeComboBox.setModel(defaultComboBoxModel1);
         kefuMsgPanel.add(msgKefuMsgTypeComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         kefuMsgTitleLabel = new JLabel();
@@ -230,18 +315,43 @@ public static void clearAllField() {
         kefuMsgUrlLabel = new JLabel();
         kefuMsgUrlLabel.setText("跳转URL");
         kefuMsgPanel.add(kefuMsgUrlLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        kefuMsgAppidLabel = new JLabel();
+        kefuMsgAppidLabel.setText("小程序appid");
+        kefuMsgPanel.add(kefuMsgAppidLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        kefuMsgPagepathLabel = new JLabel();
+        kefuMsgPagepathLabel.setText("小程序页面路径");
+        kefuMsgPanel.add(kefuMsgPagepathLabel, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        kefuMsgThumbMediaIdLabel = new JLabel();
+        kefuMsgThumbMediaIdLabel.setText("卡片图片的媒体ID");
+        kefuMsgThumbMediaIdLabel.setToolTipText("thumb_media_id");
+        kefuMsgPanel.add(kefuMsgThumbMediaIdLabel, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         msgKefuUrlTextField = new JTextField();
         kefuMsgPanel.add(msgKefuUrlTextField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        msgKefuAppidTextField = new JTextField();
+        kefuMsgPanel.add(msgKefuAppidTextField, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        msgKefuPagepathTextField = new JTextField();
+        kefuMsgPanel.add(msgKefuPagepathTextField, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         contentLabel = new JLabel();
         contentLabel.setText("内容");
         kefuMsgPanel.add(contentLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         contentTextArea = new JTextArea();
         kefuMsgPanel.add(contentTextArea, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
+        thumbMediaPanel = new JPanel();
+        thumbMediaPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
+        kefuMsgPanel.add(thumbMediaPanel, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+        msgKefuThumbMediaIdTextField = new JTextField();
+        thumbMediaPanel.add(msgKefuThumbMediaIdTextField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        uploadImageButton = new JButton();
+        uploadImageButton.setText("上传图片");
+        thumbMediaPanel.add(uploadImageButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         kefuMsgTypeLabel.setLabelFor(msgKefuMsgTypeComboBox);
         kefuMsgTitleLabel.setLabelFor(msgKefuMsgTitleTextField);
         kefuMsgPicUrlLabel.setLabelFor(msgKefuPicUrlTextField);
         kefuMsgDescLabel.setLabelFor(msgKefuDescTextField);
         kefuMsgUrlLabel.setLabelFor(msgKefuUrlTextField);
+        kefuMsgAppidLabel.setLabelFor(msgKefuAppidTextField);
+        kefuMsgPagepathLabel.setLabelFor(msgKefuPagepathTextField);
+        kefuMsgThumbMediaIdLabel.setLabelFor(msgKefuThumbMediaIdTextField);
     }
 
     /**
@@ -260,7 +370,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuPriorityMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuPriorityMsgForm.java
index f18a78362..3734987bd 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuPriorityMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/KefuPriorityMsgForm.java
@@ -1,18 +1,22 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgKefuPriorityMapper;
-import com.fangxuele.tool.push.dao.TTemplateDataMapper;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgKefuPriority;
-import com.fangxuele.tool.push.domain.TTemplateData;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
 
 import javax.swing.*;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableColumnModel;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -26,29 +30,36 @@
  */
 public class KefuPriorityMsgForm implements IMsgForm {
 
-    private static TMsgKefuPriorityMapper msgKefuPriorityMapper = MybatisUtil.getSqlSession().getMapper(TMsgKefuPriorityMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     private static KefuPriorityMsgForm kefuPriorityMsgForm;
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgKefuPriorityList = msgKefuPriorityMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.KEFU_PRIORITY_CODE, msgName);
-        if (tMsgKefuPriorityList.size() > 0) {
-            TMsgKefuPriority tMsgKefuPriority = tMsgKefuPriorityList.get(0);
-            Integer msgId = tMsgKefuPriority.getId();
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgKefuPriority tMsgKefuPriority = JSONUtil.toBean(tMsg.getContent(), TMsgKefuPriority.class);
             MpTemplateMsgForm.getInstance().getMsgTemplateIdTextField().setText(tMsgKefuPriority.getTemplateId());
             MpTemplateMsgForm.getInstance().getMsgTemplateUrlTextField().setText(tMsgKefuPriority.getUrl());
             MpTemplateMsgForm.getInstance().getMsgTemplateMiniAppidTextField().setText(tMsgKefuPriority.getMaAppid());
             MpTemplateMsgForm.getInstance().getMsgTemplateMiniPagePathTextField().setText(tMsgKefuPriority.getMaPagePath());
 
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
+
             String kefuMsgType = tMsgKefuPriority.getKefuMsgType();
             KefuMsgForm.getInstance().getMsgKefuMsgTypeComboBox().setSelectedItem(kefuMsgType);
             if ("文本消息".equals(kefuMsgType)) {
-                KefuMsgForm.getInstance().getContentTextArea().setText(tMsgKefuPriority.getContent());
+                KefuMsgForm.getInstance().getContentTextArea().setText(tMsg.getContent());
             } else if ("图文消息".equals(kefuMsgType)) {
                 KefuMsgForm.getInstance().getMsgKefuMsgTitleTextField().setText(tMsgKefuPriority.getTitle());
+            } else if ("小程序卡片消息".equals(kefuMsgType)) {
+                KefuMsgForm.getInstance().getMsgKefuMsgTitleTextField().setText(tMsgKefuPriority.getTitle());
+                KefuMsgForm.getInstance().getMsgKefuAppidTextField().setText(tMsgKefuPriority.getAppId());
+                KefuMsgForm.getInstance().getMsgKefuPagepathTextField().setText(tMsgKefuPriority.getPagePath());
+                KefuMsgForm.getInstance().getMsgKefuThumbMediaIdTextField().setText(tMsgKefuPriority.getThumbMediaId());
             }
             KefuMsgForm.getInstance().getMsgKefuPicUrlTextField().setText(tMsgKefuPriority.getImgUrl());
             KefuMsgForm.getInstance().getMsgKefuDescTextField().setText(tMsgKefuPriority.getDescribe());
@@ -56,13 +67,12 @@ public void init(String msgName) {
 
             KefuMsgForm.switchKefuMsgType(kefuMsgType);
 
-            MpTemplateMsgForm.selectedMsgTemplateId = tMsgKefuPriority.getTemplateId();
             // 模板消息Data表
-            List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.KEFU_PRIORITY_CODE, msgId);
+            List templateDataList = tMsgKefuPriority.getTemplateDataList();
             String[] headerNames = {"Name", "Value", "Color", "操作"};
             Object[][] cellData = new String[templateDataList.size()][headerNames.length];
             for (int i = 0; i < templateDataList.size(); i++) {
-                TTemplateData tTemplateData = templateDataList.get(i);
+                TemplateData tTemplateData = templateDataList.get(i);
                 cellData[i][0] = tTemplateData.getName();
                 cellData[i][1] = tTemplateData.getValue();
                 cellData[i][2] = tTemplateData.getColor();
@@ -87,14 +97,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgKefuPriorityList = msgKefuPriorityMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.KEFU_PRIORITY_CODE, msgName);
-        if (tMsgKefuPriorityList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.KEFU_PRIORITY_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgKefuPriorityList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -113,14 +123,19 @@ public void save(String msgName) {
             String kefuPicUrl = KefuMsgForm.getInstance().getMsgKefuPicUrlTextField().getText();
             String kefuDesc = KefuMsgForm.getInstance().getMsgKefuDescTextField().getText();
             String kefuUrl = KefuMsgForm.getInstance().getMsgKefuUrlTextField().getText();
+            String kefuAppId = KefuMsgForm.getInstance().getMsgKefuAppidTextField().getText();
+            String kefuPagePath = KefuMsgForm.getInstance().getMsgKefuPagepathTextField().getText();
+            String kefuThumbMediaId = KefuMsgForm.getInstance().getMsgKefuThumbMediaIdTextField().getText();
             String templateMiniAppid = MpTemplateMsgForm.getInstance().getMsgTemplateMiniAppidTextField().getText();
             String templateMiniPagePath = MpTemplateMsgForm.getInstance().getMsgTemplateMiniPagePathTextField().getText();
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgKefuPriority tMsgKefuPriority = new TMsgKefuPriority();
-            tMsgKefuPriority.setMsgType(MessageTypeEnum.KEFU_PRIORITY_CODE);
-            tMsgKefuPriority.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.KEFU_PRIORITY_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgKefuPriority.setTemplateId(templateId);
             tMsgKefuPriority.setUrl(templateUrl);
             tMsgKefuPriority.setMaAppid(templateMiniAppid);
@@ -131,21 +146,13 @@ public void save(String msgName) {
             tMsgKefuPriority.setImgUrl(kefuPicUrl);
             tMsgKefuPriority.setDescribe(kefuDesc);
             tMsgKefuPriority.setKefuUrl(kefuUrl);
-            tMsgKefuPriority.setCreateTime(now);
-            tMsgKefuPriority.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgKefuPriorityMapper.updateByMsgTypeAndMsgName(tMsgKefuPriority);
-            } else {
-                msgKefuPriorityMapper.insertSelective(tMsgKefuPriority);
-                msgId = tMsgKefuPriority.getId();
-            }
-
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.KEFU_PRIORITY_CODE, msgId);
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
+            tMsgKefuPriority.setAppId(kefuAppId);
+            tMsgKefuPriority.setPagePath(kefuPagePath);
+            tMsgKefuPriority.setThumbMediaId(kefuThumbMediaId);
 
             // 如果table为空,则初始化
             if (MpTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -156,21 +163,27 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) MpTemplateMsgForm.getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
                 String color = ((String) tableModel.getValueAt(i, 2)).trim();
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.KEFU_PRIORITY_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
                 tTemplateData.setColor(color);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataList.add(tTemplateData);
+            }
+            tMsgKefuPriority.setTemplateDataList(templateDataList);
+
+            msg.setContent(JSON.toJSONString(tMsgKefuPriority));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -188,8 +201,9 @@ public static KefuPriorityMsgForm getInstance() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
-        KefuMsgForm.clearAllField();
-        MpTemplateMsgForm.clearAllField();
+    @Override
+    public void clearAllField() {
+        KefuMsgForm.getInstance().clearAllField();
+        MpTemplateMsgForm.getInstance().clearAllField();
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.form
index add8fc073..6696e2929 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.form
@@ -24,7 +24,7 @@
               
             
             
-            
+            
               
             
             
@@ -61,7 +61,6 @@
                   
                 
                 
-                  
                   
                 
               
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.java
index 72c46a0fb..23de9527c 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaSubscribeMsgForm.java
@@ -1,15 +1,17 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgMaSubscribeMapper;
-import com.fangxuele.tool.push.dao.TTemplateDataMapper;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgMaSubscribe;
-import com.fangxuele.tool.push.domain.TTemplateData;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
 import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import lombok.Getter;
@@ -17,13 +19,14 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableColumnModel;
+import javax.swing.text.StyleContext;
 import java.awt.*;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 
@@ -52,10 +55,11 @@ public class MaSubscribeMsgForm implements IMsgForm {
 
     private static MaSubscribeMsgForm maSubscribeMsgForm;
 
-    private static TMsgMaSubscribeMapper msgMaSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaSubscribeMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public MaSubscribeMsgForm() {
+        templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+
         // 模板数据-添加 按钮事件
         templateMsgDataAddButton.addActionListener(e -> {
             String[] data = new String[3];
@@ -96,24 +100,32 @@ public MaSubscribeMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgMaSubscribeList = msgMaSubscribeMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MA_SUBSCRIBE_CODE, msgName);
-        Integer msgId = 0;
-        if (tMsgMaSubscribeList.size() > 0) {
-            TMsgMaSubscribe tMsgMaSubscribe = tMsgMaSubscribeList.get(0);
-            msgId = tMsgMaSubscribe.getId();
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgMaSubscribe tMsgMaSubscribe = JSONUtil.toBean(tMsg.getContent(), TMsgMaSubscribe.class);
             getInstance().getMsgTemplateIdTextField().setText(tMsgMaSubscribe.getTemplateId());
             getInstance().getMsgTemplateUrlTextField().setText(tMsgMaSubscribe.getPage());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
 
         initTemplateDataTable();
         // 模板消息Data表
-        List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.MA_SUBSCRIBE_CODE, msgId);
+        List templateDataList;
+        if (tMsg == null) {
+            templateDataList = new ArrayList<>();
+        } else {
+            TMsgMaSubscribe tMsgMaSubscribe = JSONUtil.toBean(tMsg.getContent(), TMsgMaSubscribe.class);
+            templateDataList = tMsgMaSubscribe.getTemplateDataList();
+        }
         String[] headerNames = {"Name", "Value", "Color", "操作"};
         Object[][] cellData = new String[templateDataList.size()][headerNames.length];
         for (int i = 0; i < templateDataList.size(); i++) {
-            TTemplateData tTemplateData = templateDataList.get(i);
+            TemplateData tTemplateData = templateDataList.get(i);
             cellData[i][0] = tTemplateData.getName();
             cellData[i][1] = tTemplateData.getValue();
             cellData[i][2] = tTemplateData.getColor();
@@ -132,14 +144,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgMaSubscribeList = msgMaSubscribeMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MA_SUBSCRIBE_CODE, msgName);
-        if (tMsgMaSubscribeList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.MA_SUBSCRIBE_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgMaSubscribeList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -155,27 +167,18 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgMaSubscribe tMsgMaSubscribe = new TMsgMaSubscribe();
-            tMsgMaSubscribe.setMsgType(MessageTypeEnum.MA_SUBSCRIBE_CODE);
-            tMsgMaSubscribe.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.MA_SUBSCRIBE_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgMaSubscribe.setTemplateId(templateId);
             tMsgMaSubscribe.setPage(templateUrl);
-            tMsgMaSubscribe.setCreateTime(now);
-            tMsgMaSubscribe.setModifiedTime(now);
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
 
-            if (existSameMsg) {
-                msgMaSubscribeMapper.updateByMsgTypeAndMsgName(tMsgMaSubscribe);
-            } else {
-                msgMaSubscribeMapper.insertSelective(tMsgMaSubscribe);
-                msgId = tMsgMaSubscribe.getId();
-            }
-
-            // 保存模板数据
-
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.MA_SUBSCRIBE_CODE, msgId);
-            }
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // 如果table为空,则初始化
             if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -186,21 +189,28 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
                 String color = ((String) tableModel.getValueAt(i, 2)).trim();
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.MA_SUBSCRIBE_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
                 tTemplateData.setColor(color);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataList.add(tTemplateData);
+            }
+
+            tMsgMaSubscribe.setTemplateDataList(templateDataList);
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgMaSubscribe));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -242,7 +252,8 @@ public static void initTemplateDataTable() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgTemplateIdTextField().setText("");
         getInstance().getMsgTemplateUrlTextField().setText("");
         getInstance().getTemplateDataNameTextField().setText("");
@@ -275,7 +286,7 @@ public static void clearAllField() {
         templateMsgDataPanel = new JPanel();
         templateMsgDataPanel.setLayout(new GridLayoutManager(3, 4, new Insets(10, 0, 0, 0), -1, -1));
         templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
-        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
+        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
         templateDataNameTextField = new JTextField();
         templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的");
         templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
@@ -285,7 +296,6 @@ public static void clearAllField() {
         templateDataColorTextField.setToolTipText("示例值:FF0000");
         templateMsgDataPanel.add(templateDataColorTextField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateMsgDataAddButton = new JButton();
-        templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         templateMsgDataAddButton.setText("");
         templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         templateMsgDataTable = new JTable();
@@ -341,7 +351,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.form
index d1bd249d7..647d4099a 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.form
@@ -59,7 +59,7 @@
           
         
         
-          
+          
         
       
       
@@ -68,17 +68,9 @@
         
         
           
-          
+          
         
       
-      
-        
-          
-            
-          
-        
-        
-      
       
         
           
@@ -95,6 +87,21 @@
           
         
       
+      
+        
+          
+            
+          
+        
+        
+        
+        
+          
+            
+            
+          
+        
+      
     
   
 
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.java
index 9a5865186..8e954d9f7 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MailMsgForm.java
@@ -1,6 +1,8 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgMailMapper;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgMail;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.form.MainWindow;
@@ -10,6 +12,7 @@
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
 
 import javax.swing.*;
 import java.awt.*;
@@ -19,6 +22,7 @@
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -34,29 +38,30 @@ public class MailMsgForm implements IMsgForm {
 
     private JPanel mailPanel;
     private JTextField mailTitleTextField;
-    private JTextField mailFilesTextField;
     private JEditorPane mailContentPane;
     private JButton fileExploreButton;
     private JLabel uEditorLabel;
     private JTextField mailCcTextField;
+    private JTextArea mailFilesTextArea;
 
     private static MailMsgForm mailMsgForm;
-    private static TMsgMailMapper msgMailMapper = MybatisUtil.getSqlSession().getMapper(TMsgMailMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public MailMsgForm() {
         fileExploreButton.addActionListener(e -> {
-            File beforeFile = new File(mailFilesTextField.getText());
             JFileChooser fileChooser;
 
-            if (beforeFile.exists()) {
-                fileChooser = new JFileChooser(beforeFile);
+            if (getAttachmentFiles().size() > 0 && getAttachmentFiles().get(0).exists()) {
+                fileChooser = new JFileChooser(getAttachmentFiles().get(0));
             } else {
                 fileChooser = new JFileChooser();
             }
 
+            fileChooser.setMultiSelectionEnabled(true);
+
             int approve = fileChooser.showOpenDialog(MessageEditForm.getInstance().getMsgEditorPanel());
             if (approve == JFileChooser.APPROVE_OPTION) {
-                mailFilesTextField.setText(fileChooser.getSelectedFile().getAbsolutePath());
+                appendAttachmentFilePath(fileChooser);
             }
         });
         uEditorLabel.addMouseListener(new MouseAdapter() {
@@ -64,7 +69,7 @@ public MailMsgForm() {
             public void mousePressed(MouseEvent e) {
                 Desktop desktop = Desktop.getDesktop();
                 try {
-                    desktop.browse(new URI("https://ueditor.baidu.com/website/onlinedemo.html"));
+                    desktop.browse(new URI("http://kindeditor.net/demo.php"));
                 } catch (IOException | URISyntaxException e1) {
                     e1.printStackTrace();
                 }
@@ -80,25 +85,30 @@ public void mouseEntered(MouseEvent e) {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgMailList = msgMailMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.EMAIL_CODE, msgName);
-        if (tMsgMailList.size() > 0) {
-            TMsgMail tMsgMail = tMsgMailList.get(0);
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgMail tMsgMail = JSONUtil.toBean(tMsg.getContent(), TMsgMail.class);
             getInstance().getMailTitleTextField().setText(tMsgMail.getTitle());
             getInstance().getMailCcTextField().setText(tMsgMail.getCc());
-            getInstance().getMailFilesTextField().setText(tMsgMail.getFiles());
+            getInstance().getMailFilesTextArea().setText(tMsgMail.getFiles());
             getInstance().getMailContentPane().setText(tMsgMail.getContent());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         boolean existSameMsg = false;
-
-        List tMsgMailList = msgMailMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.EMAIL_CODE, msgName);
-        if (tMsgMailList.size() > 0) {
+        Integer msgId = null;
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.EMAIL_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -110,25 +120,32 @@ public void save(String msgName) {
         if (!existSameMsg || isCover == JOptionPane.YES_OPTION) {
             String mailTitle = getInstance().getMailTitleTextField().getText();
             String mailCc = getInstance().getMailCcTextField().getText();
-            String mailFiles = getInstance().getMailFilesTextField().getText();
+            String mailFiles = getInstance().getMailFilesTextArea().getText();
             String mailContent = getInstance().getMailContentPane().getText();
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgMail tMsgMail = new TMsgMail();
-            tMsgMail.setMsgType(MessageTypeEnum.EMAIL_CODE);
-            tMsgMail.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.EMAIL_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgMail.setTitle(mailTitle);
             tMsgMail.setCc(mailCc);
             tMsgMail.setFiles(mailFiles);
             tMsgMail.setContent(mailContent);
-            tMsgMail.setCreateTime(now);
-            tMsgMail.setModifiedTime(now);
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
 
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgMail));
             if (existSameMsg) {
-                msgMailMapper.updateByMsgTypeAndMsgName(tMsgMail);
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
             } else {
-                msgMailMapper.insertSelective(tMsgMail);
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -136,6 +153,39 @@ public void save(String msgName) {
         }
     }
 
+    /**
+     * 获取附件文件数组
+     *
+     * @return
+     */
+    public List getAttachmentFiles() {
+        List files = new ArrayList<>();
+        String text = mailFilesTextArea.getText();
+        String[] strings = text.split("\\n");
+        for (String string : strings) {
+            string = string.trim();
+            if (StringUtils.isNotEmpty(string)) {
+                files.add(new File(string));
+            }
+        }
+        return files;
+    }
+
+    /**
+     * 添加附件文件路径到附件文本域
+     *
+     * @param fileChooser
+     */
+    public void appendAttachmentFilePath(JFileChooser fileChooser) {
+        File[] selectedFiles = fileChooser.getSelectedFiles();
+        for (File selectedFile : selectedFiles) {
+            if (StringUtils.isNotBlank(mailFilesTextArea.getText())) {
+                mailFilesTextArea.append("\n");
+            }
+            mailFilesTextArea.append(selectedFile.getAbsolutePath());
+        }
+    }
+
     public static MailMsgForm getInstance() {
         if (mailMsgForm == null) {
             mailMsgForm = new MailMsgForm();
@@ -146,10 +196,11 @@ public static MailMsgForm getInstance() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMailTitleTextField().setText("");
         getInstance().getMailCcTextField().setText("");
-        getInstance().getMailFilesTextField().setText("");
+        getInstance().getMailFilesTextArea().setText("");
         getInstance().getMailContentPane().setText("");
     }
 
@@ -188,19 +239,21 @@ public static void clearAllField() {
         label3.setText("邮件正文(HTML)");
         mailPanel.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         uEditorLabel = new JLabel();
-        uEditorLabel.setText("使用UEditor编辑HTML");
+        uEditorLabel.setText("使用KindEditor编辑HTML");
         mailPanel.add(uEditorLabel, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         fileExploreButton = new JButton();
         fileExploreButton.setHorizontalAlignment(0);
-        fileExploreButton.setText("浏览");
+        fileExploreButton.setText("添加附件");
         mailPanel.add(fileExploreButton, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
-        mailFilesTextField = new JTextField();
-        mailPanel.add(mailFilesTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         mailCcTextField = new JTextField();
         mailPanel.add(mailCcTextField, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         final JLabel label4 = new JLabel();
         label4.setText("抄送");
         mailPanel.add(label4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        final JScrollPane scrollPane1 = new JScrollPane();
+        mailPanel.add(scrollPane1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(-1, 60), null, 0, false));
+        mailFilesTextArea = new JTextArea();
+        scrollPane1.setViewportView(mailFilesTextArea);
     }
 
     /**
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaTemplateMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.form
similarity index 66%
rename from src/main/java/com/fangxuele/tool/push/ui/form/msg/MaTemplateMsgForm.form
rename to src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.form
index 31f59c5d0..4e1bb6d90 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaTemplateMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.form
@@ -1,9 +1,9 @@
 
-
+ - + @@ -14,7 +14,7 @@ - + @@ -24,15 +24,13 @@ - + - - - + @@ -40,17 +38,13 @@ - - - + - - - + @@ -61,7 +55,6 @@ - @@ -105,9 +98,17 @@ + + + + + + + + - + @@ -117,7 +118,7 @@ - + @@ -126,7 +127,7 @@ - + @@ -134,7 +135,7 @@ - + @@ -143,29 +144,86 @@ - + - + - + - - + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.java new file mode 100644 index 000000000..c10fe4ba0 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.java @@ -0,0 +1,594 @@ +package com.fangxuele.tool.push.ui.form.msg; + +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; +import com.fangxuele.tool.push.domain.TMsgMpSubscribe; +import com.fangxuele.tool.push.logic.MessageTypeEnum; +import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender; +import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.ui.form.MessageEditForm; +import com.fangxuele.tool.push.ui.form.MessageManageForm; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.google.common.collect.Maps; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.util.List; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + *
+ * MpSubscribeMsgForm
+ * 
+ * + * @author Zhou Bo + * @since 2021/3/23. + */ +@Getter +@Slf4j +public class MpSubscribeMsgForm implements IMsgForm { + private JPanel templateMsgPanel; + private JLabel templateIdLabel; + private JTextField msgTemplateIdTextField; + private JLabel templateUrlLabel; + private JTextField msgTemplateUrlTextField; + private JPanel templateMsgDataPanel; + private JLabel templateMiniProgramAppidLabel; + private JTextField msgTemplateMiniAppidTextField; + private JLabel templateMiniProgramPagePathLabel; + private JTextField msgTemplateMiniPagePathTextField; + private JLabel templateMsgNameLabel; + private JTextField templateDataNameTextField; + private JLabel templateMsgValueLabel; + private JTextField templateDataValueTextField; + private JLabel templateMsgColorLabel; + private JTextField templateDataColorTextField; + private JButton templateMsgDataAddButton; + private JTable templateMsgDataTable; + private JComboBox templateListComboBox; + private JButton refreshTemplateListButton; + private JButton autoFillButton; + private JTextArea templateContentTextArea; + + private static MpSubscribeMsgForm mpSubscribeMsgForm; + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + /** + * 账号模板列表 + */ + public static List templateList; + + /** + * 模板账号map,key:templateId + */ + public static Map templateMap; + + /** + * (左侧列表中)所选消息对应的模板ID + */ + public static String selectedMsgTemplateId; + + /** + * 是否需要监听模板列表ComboBox + */ + public static boolean needListenTemplateListComboBox = false; + + private static final Pattern BRACE_PATTERN = Pattern.compile("\\{([^{}]+)\\}"); + + public MpSubscribeMsgForm() { + templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg")); + refreshTemplateListButton.setIcon(new FlatSVGIcon("icon/refresh.svg")); + + // 模板数据-添加 按钮事件 + templateMsgDataAddButton.addActionListener(e -> { + String[] data = new String[3]; + data[0] = getInstance().getTemplateDataNameTextField().getText(); + data[1] = getInstance().getTemplateDataValueTextField().getText(); + data[2] = getInstance().getTemplateDataColorTextField().getText(); + + if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { + initTemplateDataTable(); + } + + DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() + .getModel(); + int rowCount = tableModel.getRowCount(); + + Set keySet = new HashSet<>(); + String keyData; + for (int i = 0; i < rowCount; i++) { + keyData = (String) tableModel.getValueAt(i, 0); + keySet.add(keyData); + } + + if (StringUtils.isEmpty(data[0]) || StringUtils.isEmpty(data[1])) { + JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "Name或value不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else if (keySet.contains(data[0])) { + JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "Name不能重复!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else { + if (StringUtils.isEmpty(data[2])) { + data[2] = "#000000"; + } else if (!data[2].startsWith("#")) { + data[2] = "#" + data[2]; + } + tableModel.addRow(data); + } + }); + templateListComboBox.addItemListener(e -> { + if (needListenTemplateListComboBox && e.getStateChange() == ItemEvent.SELECTED) { + clearAllFieldExceptTemplateListAndContent(); + fillWxTemplateContentToField(); + } + }); + autoFillButton.addActionListener(e -> autoFillTemplateDataTable()); + refreshTemplateListButton.addActionListener(e -> { + initTemplateList(); + initTemplateDataTable(); + }); + } + + @Override + public void init(Integer msgId) { + MpSubscribeMsgForm mpTemplateMsgForm = getInstance(); + if (UIUtil.isDarkLaf()) { + Color bgColor = new Color(43, 43, 43); + mpTemplateMsgForm.getTemplateContentTextArea().setBackground(bgColor); + Color foreColor = new Color(187, 187, 187); + mpTemplateMsgForm.getTemplateContentTextArea().setForeground(foreColor); + } + + clearAllField(); + + TMsg tMsg = msgMapper.selectByPrimaryKey(msgId); + if (tMsg != null) { + TMsgMpSubscribe tMsgMpSubscribe = JSONUtil.toBean(tMsg.getContent(), TMsgMpSubscribe.class); + selectedMsgTemplateId = tMsgMpSubscribe.getTemplateId(); + initTemplateList(); + + mpTemplateMsgForm.getMsgTemplateIdTextField().setText(tMsgMpSubscribe.getTemplateId()); + mpTemplateMsgForm.getMsgTemplateUrlTextField().setText(tMsgMpSubscribe.getUrl()); + mpTemplateMsgForm.getMsgTemplateMiniAppidTextField().setText(tMsgMpSubscribe.getMaAppid()); + mpTemplateMsgForm.getMsgTemplateMiniPagePathTextField().setText(tMsgMpSubscribe.getMaPagePath()); + + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + messageEditForm.getMsgNameField().setText(tMsg.getMsgName()); + messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser()); + } else { + initTemplateList(); + } + + List templateDataList; + if (tMsg == null) { + templateDataList = new ArrayList<>(); + } else { + TMsgMpSubscribe tMsgMpSubscribe = JSONUtil.toBean(tMsg.getContent(), TMsgMpSubscribe.class); + templateDataList = tMsgMpSubscribe.getTemplateDataList(); + } + + if (templateDataList == null) { + templateDataList = new ArrayList<>(); + } + + initTemplateDataTable(); + fillTemplateDataTable(templateDataList); + } + + @Override + public void save(Integer accountId, String msgName) { + int msgId = 0; + boolean existSameMsg = false; + + TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.MP_SUBSCRIBE_CODE, accountId, msgName); + if (tMsg != null) { + existSameMsg = true; + msgId = tMsg.getId(); + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameMsg) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的历史消息,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameMsg || isCover == JOptionPane.YES_OPTION) { + String templateId = getInstance().getMsgTemplateIdTextField().getText(); + String templateUrl = getInstance().getMsgTemplateUrlTextField().getText(); + String templateMiniAppid = getInstance().getMsgTemplateMiniAppidTextField().getText(); + String templateMiniPagePath = getInstance().getMsgTemplateMiniPagePathTextField().getText(); + + String now = SqliteUtil.nowDateForSqlite(); + + TMsg msg = new TMsg(); + TMsgMpSubscribe tMsgMpSubscribe = new TMsgMpSubscribe(); + msg.setMsgType(MessageTypeEnum.MP_SUBSCRIBE_CODE); + msg.setAccountId(accountId); + msg.setMsgName(msgName); + tMsgMpSubscribe.setTemplateId(templateId); + tMsgMpSubscribe.setUrl(templateUrl); + tMsgMpSubscribe.setMaAppid(templateMiniAppid); + tMsgMpSubscribe.setMaPagePath(templateMiniPagePath); + msg.setCreateTime(now); + msg.setModifiedTime(now); + + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + msg.setPreviewUser(messageEditForm.getPreviewUserField().getText()); + + // 如果table为空,则初始化 + if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { + initTemplateDataTable(); + } + + // 逐行读取 + DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() + .getModel(); + int rowCount = tableModel.getRowCount(); + List templateDataList = new ArrayList<>(); + for (int i = 0; i < rowCount; i++) { + String name = (String) tableModel.getValueAt(i, 0); + String value = (String) tableModel.getValueAt(i, 1); + String color = ((String) tableModel.getValueAt(i, 2)).trim(); + + TemplateData tTemplateData = new TemplateData(); + tTemplateData.setName(name); + tTemplateData.setValue(value); + tTemplateData.setColor(color); + + templateDataList.add(tTemplateData); + } + + tMsgMpSubscribe.setTemplateDataList(templateDataList); + + msg.setContent(JSONUtil.toJsonStr(tMsgMpSubscribe)); + if (existSameMsg) { + msg.setId(msgId); + msgMapper.updateByPrimaryKeySelective(msg); + } else { + msgMapper.insertSelective(msg); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + } + + public static MpSubscribeMsgForm getInstance() { + if (mpSubscribeMsgForm == null) { + mpSubscribeMsgForm = new MpSubscribeMsgForm(); + } + return mpSubscribeMsgForm; + } + + /** + * 填充模板参数表Table(从数据库读取) + * + * @param templateDataList + */ + public static void fillTemplateDataTable(List templateDataList) { + // 模板消息Data表 + String[] headerNames = {"Name", "Value", "Color", "操作"}; + Object[][] cellData = new String[templateDataList.size()][headerNames.length]; + for (int i = 0; i < templateDataList.size(); i++) { + TemplateData tTemplateData = templateDataList.get(i); + cellData[i][0] = tTemplateData.getName(); + cellData[i][1] = tTemplateData.getValue(); + cellData[i][2] = tTemplateData.getColor(); + } + DefaultTableModel model = new DefaultTableModel(cellData, headerNames); + getInstance().getTemplateMsgDataTable().setModel(model); + TableColumnModel tableColumnModel = getInstance().getTemplateMsgDataTable().getColumnModel(); + tableColumnModel.getColumn(headerNames.length - 1). + setCellRenderer(new TableInCellButtonColumn(getInstance().getTemplateMsgDataTable(), headerNames.length - 1)); + tableColumnModel.getColumn(headerNames.length - 1). + setCellEditor(new TableInCellButtonColumn(getInstance().getTemplateMsgDataTable(), headerNames.length - 1)); + + // 设置列宽 + tableColumnModel.getColumn(3).setPreferredWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + tableColumnModel.getColumn(3).setMaxWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + } + + /** + * 初始化模板列表ComboBox + */ + public static void initTemplateList() { + needListenTemplateListComboBox = false; + try { + templateMap = Maps.newHashMap(); + + MessageManageForm messageManageForm = MessageManageForm.getInstance(); + String selectedAccountName = (String) messageManageForm.getAccountComboBox().getSelectedItem(); + if (StringUtils.isEmpty(selectedAccountName)) { + return; + } + Integer selectedAccountId = MessageManageForm.accountMap.get(selectedAccountName); + if (selectedAccountId == null) { + return; + } + + templateList = WxMpTemplateMsgSender.getWxMpService(selectedAccountId).getSubscribeMsgService().getTemplateList(); + getInstance().getTemplateListComboBox().removeAllItems(); + int selectedIndex = 0; + for (int i = 0; i < templateList.size(); i++) { + TemplateInfo templateInfo = templateList.get(i); + getInstance().getTemplateListComboBox().addItem(templateInfo.getTitle()); + templateMap.put(templateInfo.getPriTmplId(), templateInfo); + if (templateInfo.getPriTmplId().equals(selectedMsgTemplateId)) { + selectedIndex = i; + } + } + + if (getInstance().getTemplateListComboBox().getItemCount() > 0) { + getInstance().getTemplateListComboBox().setSelectedIndex(selectedIndex); + fillWxTemplateContentToField(); + } + + } catch (Exception e) { + log.error(e.toString()); + } + needListenTemplateListComboBox = true; + } + + /** + * 根据模板内容获取模板中的参数list + * + * @param templateContent 模板内容 + * @return params 模板中的参数 + */ + public static List getTemplateParams(String templateContent) { + List params = Lists.newArrayList(); + Matcher matcher = BRACE_PATTERN.matcher(templateContent); + while (matcher.find()) { + params.add(matcher.group(1).replace(".DATA", "")); + } + return params; + } + + /** + * 根据模板id填充模板列表中对应的WxTemplate内容到表单 + */ + public static void fillWxTemplateContentToField() { + TemplateInfo templateInfo = templateList.get(getInstance().getTemplateListComboBox().getSelectedIndex()); + if (templateInfo != null) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("-----------模板ID-----------\n").append(templateInfo.getPriTmplId()).append("\n"); + stringBuilder.append("\n----------模板标题----------\n").append(templateInfo.getTitle()).append("\n"); + int type = templateInfo.getType(); + String templateType = "未知"; + if (type == 2) { + templateType = "一次性订阅"; + } else if (type == 3) { + templateType = "长期订阅"; + } + stringBuilder.append("\n----------模板类型----------\n").append(templateType).append("\n"); + stringBuilder.append("\n----------模板内容----------\n").append(templateInfo.getContent()).append("\n"); + stringBuilder.append("\n----------模板示例----------\n").append(templateInfo.getExample()); + getInstance().getTemplateContentTextArea().setText(stringBuilder.toString()); + getInstance().getMsgTemplateIdTextField().setText(templateInfo.getPriTmplId()); + } + } + + /** + * 自动填充模板数据Table + */ + private static void autoFillTemplateDataTable() { + if (templateList != null) { + TemplateInfo templateInfo = templateList.get(getInstance().getTemplateListComboBox().getSelectedIndex()); + if (templateInfo != null) { + initTemplateDataTable(); + DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() + .getModel(); + List params = getTemplateParams(templateInfo.getContent()); + for (int i = 0; i < params.size(); i++) { + String param = params.get(i); + String[] data = new String[3]; + data[0] = param; + data[1] = "示例值" + (i + 1); + data[2] = "#000000"; + tableModel.addRow(data); + } + } + } + } + + /** + * 初始化模板消息数据table + */ + public static void initTemplateDataTable() { + JTable msgDataTable = getInstance().getTemplateMsgDataTable(); + String[] headerNames = {"Name", "Value", "Color", "操作"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + msgDataTable.setModel(model); + msgDataTable.updateUI(); + DefaultTableCellRenderer hr = (DefaultTableCellRenderer) msgDataTable.getTableHeader().getDefaultRenderer(); + // 表头列名居左 + hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); + + TableColumnModel tableColumnModel = msgDataTable.getColumnModel(); + tableColumnModel.getColumn(headerNames.length - 1). + setCellRenderer(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); + tableColumnModel.getColumn(headerNames.length - 1). + setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); + + // 设置列宽 + tableColumnModel.getColumn(3).setPreferredWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + tableColumnModel.getColumn(3).setMaxWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + } + + /** + * 清空所有界面字段 + */ + @Override + public void clearAllField() { + clearAllFieldExceptTemplateListAndContent(); + getInstance().getTemplateListComboBox().removeAllItems(); + getInstance().getTemplateContentTextArea().setText(""); + } + + /** + * 清空所有界面字段 + */ + public static void clearAllFieldExceptTemplateListAndContent() { + getInstance().getMsgTemplateIdTextField().setText(""); + getInstance().getMsgTemplateUrlTextField().setText(""); + getInstance().getMsgTemplateMiniAppidTextField().setText(""); + getInstance().getMsgTemplateMiniPagePathTextField().setText(""); + getInstance().getTemplateDataNameTextField().setText(""); + getInstance().getTemplateDataValueTextField().setText(""); + getInstance().getTemplateDataColorTextField().setText(""); + selectedMsgTemplateId = null; + initTemplateDataTable(); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + templateMsgPanel = new JPanel(); + templateMsgPanel.setLayout(new GridLayoutManager(2, 1, new Insets(10, 15, 0, 0), -1, -1)); + panel1.add(templateMsgPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + templateMsgPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "公众号-订阅通知编辑", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgPanel.getFont()), null)); + templateMsgDataPanel = new JPanel(); + templateMsgDataPanel.setLayout(new GridLayoutManager(3, 4, new Insets(10, 0, 0, 0), -1, -1)); + templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null)); + templateDataNameTextField = new JTextField(); + templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的"); + templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateDataValueTextField = new JTextField(); + templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateDataColorTextField = new JTextField(); + templateDataColorTextField.setToolTipText("示例值:FF0000"); + templateMsgDataPanel.add(templateDataColorTextField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgDataAddButton = new JButton(); + templateMsgDataAddButton.setText(""); + templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgDataTable = new JTable(); + templateMsgDataTable.setAutoCreateColumnsFromModel(true); + templateMsgDataTable.setAutoCreateRowSorter(true); + templateMsgDataTable.setGridColor(new Color(-12236470)); + templateMsgDataTable.setRowHeight(36); + templateMsgDataPanel.add(templateMsgDataTable, new GridConstraints(2, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + templateMsgNameLabel = new JLabel(); + templateMsgNameLabel.setText("name"); + templateMsgNameLabel.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的"); + templateMsgDataPanel.add(templateMsgNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgValueLabel = new JLabel(); + templateMsgValueLabel.setText("value"); + templateMsgDataPanel.add(templateMsgValueLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgColorLabel = new JLabel(); + templateMsgColorLabel.setText("color"); + templateMsgColorLabel.setToolTipText("示例值:FF0000"); + templateMsgDataPanel.add(templateMsgColorLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + autoFillButton = new JButton(); + autoFillButton.setText("自动填充"); + templateMsgDataPanel.add(autoFillButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(6, 3, new Insets(0, 0, 5, 0), -1, -1)); + templateMsgPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + templateIdLabel = new JLabel(); + templateIdLabel.setText("模板ID *"); + panel2.add(templateIdLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateIdTextField = new JTextField(); + panel2.add(msgTemplateIdTextField, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + templateUrlLabel = new JLabel(); + templateUrlLabel.setText("跳转URL"); + panel2.add(templateUrlLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateUrlTextField = new JTextField(); + panel2.add(msgTemplateUrlTextField, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + templateMiniProgramAppidLabel = new JLabel(); + templateMiniProgramAppidLabel.setText("小程序appid"); + templateMiniProgramAppidLabel.setToolTipText("非必填"); + panel2.add(templateMiniProgramAppidLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateMiniAppidTextField = new JTextField(); + msgTemplateMiniAppidTextField.setText(""); + msgTemplateMiniAppidTextField.setToolTipText("非必填"); + panel2.add(msgTemplateMiniAppidTextField, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + templateMiniProgramPagePathLabel = new JLabel(); + templateMiniProgramPagePathLabel.setText("小程序页面路径"); + templateMiniProgramPagePathLabel.setToolTipText("非必填"); + panel2.add(templateMiniProgramPagePathLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateMiniPagePathTextField = new JTextField(); + msgTemplateMiniPagePathTextField.setText(""); + msgTemplateMiniPagePathTextField.setToolTipText("非必填"); + panel2.add(msgTemplateMiniPagePathTextField, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("选择模板"); + panel2.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateListComboBox = new JComboBox(); + panel2.add(templateListComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + refreshTemplateListButton = new JButton(); + refreshTemplateListButton.setText("刷新"); + panel2.add(refreshTemplateListButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateContentTextArea = new JTextArea(); + templateContentTextArea.setEditable(false); + panel2.add(templateContentTextArea, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false)); + templateMsgNameLabel.setLabelFor(templateDataNameTextField); + templateMsgValueLabel.setLabelFor(templateDataValueTextField); + templateMsgColorLabel.setLabelFor(templateDataColorTextField); + templateIdLabel.setLabelFor(msgTemplateIdTextField); + templateUrlLabel.setLabelFor(msgTemplateUrlTextField); + templateMiniProgramAppidLabel.setLabelFor(msgTemplateMiniAppidTextField); + templateMiniProgramPagePathLabel.setLabelFor(msgTemplateMiniPagePathTextField); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.form index 7f1d81627..fb4efdb37 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.form @@ -24,7 +24,7 @@
- + @@ -55,7 +55,6 @@ - @@ -212,7 +211,6 @@ - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.java index 51e53ce2c..ea76a855f 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpTemplateMsgForm.java @@ -1,17 +1,20 @@ package com.fangxuele.tool.push.ui.form.msg; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TMsgMpTemplateMapper; -import com.fangxuele.tool.push.dao.TTemplateDataMapper; +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.domain.TMsgMpTemplate; -import com.fangxuele.tool.push.domain.TTemplateData; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender; import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn; import com.fangxuele.tool.push.ui.form.MainWindow; import com.fangxuele.tool.push.ui.form.MessageEditForm; +import com.fangxuele.tool.push.ui.form.MessageManageForm; import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; import com.google.common.collect.Maps; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; @@ -23,15 +26,15 @@ import javax.swing.*; import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumnModel; +import javax.swing.text.StyleContext; import java.awt.*; import java.awt.event.ItemEvent; -import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -71,9 +74,7 @@ public class MpTemplateMsgForm implements IMsgForm { private static MpTemplateMsgForm mpTemplateMsgForm; - private static TMsgMpTemplateMapper msgMpTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpTemplateMapper.class); - - private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class); + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); /** * 账号模板列表 @@ -98,6 +99,9 @@ public class MpTemplateMsgForm implements IMsgForm { private static final Pattern BRACE_PATTERN = Pattern.compile("\\{([^{}]+)\\}"); public MpTemplateMsgForm() { + templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg")); + refreshTemplateListButton.setIcon(new FlatSVGIcon("icon/refresh.svg")); + // 模板数据-添加 按钮事件 templateMsgDataAddButton.addActionListener(e -> { String[] data = new String[3]; @@ -137,7 +141,7 @@ public MpTemplateMsgForm() { }); templateListComboBox.addItemListener(e -> { if (needListenTemplateListComboBox && e.getStateChange() == ItemEvent.SELECTED) { - clearAllField(); + clearAllFieldExceptTemplateListAndContent(); fillWxTemplateContentToField(); } }); @@ -149,9 +153,9 @@ public MpTemplateMsgForm() { } @Override - public void init(String msgName) { + public void init(Integer msgId) { MpTemplateMsgForm mpTemplateMsgForm = getInstance(); - if ("Darcula(推荐)".equals(App.config.getTheme())) { + if (UIUtil.isDarkLaf()) { Color bgColor = new Color(43, 43, 43); mpTemplateMsgForm.getTemplateContentTextArea().setBackground(bgColor); Color foreColor = new Color(187, 187, 187); @@ -159,33 +163,48 @@ public void init(String msgName) { } clearAllField(); - Integer msgId = 0; - List tMsgMpTemplateList = msgMpTemplateMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MP_TEMPLATE_CODE, msgName); - if (tMsgMpTemplateList.size() > 0) { - TMsgMpTemplate tMsgMpTemplate = tMsgMpTemplateList.get(0); - msgId = tMsgMpTemplate.getId(); + + TMsg tMsg = msgMapper.selectByPrimaryKey(msgId); + if (tMsg != null) { + TMsgMpTemplate tMsgMpTemplate = JSONUtil.toBean(tMsg.getContent(), TMsgMpTemplate.class); + selectedMsgTemplateId = tMsgMpTemplate.getTemplateId(); + initTemplateList(); + mpTemplateMsgForm.getMsgTemplateIdTextField().setText(tMsgMpTemplate.getTemplateId()); mpTemplateMsgForm.getMsgTemplateUrlTextField().setText(tMsgMpTemplate.getUrl()); mpTemplateMsgForm.getMsgTemplateMiniAppidTextField().setText(tMsgMpTemplate.getMaAppid()); mpTemplateMsgForm.getMsgTemplateMiniPagePathTextField().setText(tMsgMpTemplate.getMaPagePath()); - selectedMsgTemplateId = tMsgMpTemplate.getTemplateId(); + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + messageEditForm.getMsgNameField().setText(tMsg.getMsgName()); + messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser()); + } else { + initTemplateList(); } - initTemplateList(); initTemplateDataTable(); - fillTemplateDataTable(msgId); + List templateDataList; + if (tMsg == null) { + templateDataList = new ArrayList<>(); + } else { + TMsgMpTemplate tMsgMpTemplate = JSONUtil.toBean(tMsg.getContent(), TMsgMpTemplate.class); + templateDataList = tMsgMpTemplate.getTemplateDataList(); + } + if (templateDataList == null) { + templateDataList = new ArrayList<>(); + } + fillTemplateDataTable(templateDataList); } @Override - public void save(String msgName) { + public void save(Integer accountId, String msgName) { int msgId = 0; boolean existSameMsg = false; - List tMsgMpTemplateList = msgMpTemplateMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MP_TEMPLATE_CODE, msgName); - if (tMsgMpTemplateList.size() > 0) { + TMsg tMsg = msgMapper.selectByUnique(accountId, MessageTypeEnum.MP_TEMPLATE_CODE, msgName); + if (tMsg != null) { existSameMsg = true; - msgId = tMsgMpTemplateList.get(0).getId(); + msgId = tMsg.getId(); } int isCover = JOptionPane.NO_OPTION; @@ -203,29 +222,20 @@ public void save(String msgName) { String now = SqliteUtil.nowDateForSqlite(); + TMsg msg = new TMsg(); TMsgMpTemplate tMsgMpTemplate = new TMsgMpTemplate(); - tMsgMpTemplate.setMsgType(MessageTypeEnum.MP_TEMPLATE_CODE); - tMsgMpTemplate.setMsgName(msgName); + msg.setMsgType(MessageTypeEnum.MP_TEMPLATE_CODE); + msg.setAccountId(accountId); + msg.setMsgName(msgName); tMsgMpTemplate.setTemplateId(templateId); tMsgMpTemplate.setUrl(templateUrl); tMsgMpTemplate.setMaAppid(templateMiniAppid); tMsgMpTemplate.setMaPagePath(templateMiniPagePath); - tMsgMpTemplate.setCreateTime(now); - tMsgMpTemplate.setModifiedTime(now); + msg.setCreateTime(now); + msg.setModifiedTime(now); - if (existSameMsg) { - msgMpTemplateMapper.updateByMsgTypeAndMsgName(tMsgMpTemplate); - } else { - msgMpTemplateMapper.insertSelective(tMsgMpTemplate); - msgId = tMsgMpTemplate.getId(); - } - - // 保存模板数据 - - // 如果是覆盖保存,则先清空之前的模板数据 - if (existSameMsg) { - templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.MP_TEMPLATE_CODE, msgId); - } + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + msg.setPreviewUser(messageEditForm.getPreviewUserField().getText()); // 如果table为空,则初始化 if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { @@ -236,21 +246,28 @@ public void save(String msgName) { DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() .getModel(); int rowCount = tableModel.getRowCount(); + List templateDataList = new ArrayList<>(); for (int i = 0; i < rowCount; i++) { String name = (String) tableModel.getValueAt(i, 0); String value = (String) tableModel.getValueAt(i, 1); String color = ((String) tableModel.getValueAt(i, 2)).trim(); - TTemplateData tTemplateData = new TTemplateData(); - tTemplateData.setMsgType(MessageTypeEnum.MP_TEMPLATE_CODE); - tTemplateData.setMsgId(msgId); + TemplateData tTemplateData = new TemplateData(); tTemplateData.setName(name); tTemplateData.setValue(value); tTemplateData.setColor(color); - tTemplateData.setCreateTime(now); - tTemplateData.setModifiedTime(now); - templateDataMapper.insert(tTemplateData); + templateDataList.add(tTemplateData); + } + + tMsgMpTemplate.setTemplateDataList(templateDataList); + + msg.setContent(JSONUtil.toJsonStr(tMsgMpTemplate)); + if (existSameMsg) { + msg.setId(msgId); + msgMapper.updateByPrimaryKeySelective(msg); + } else { + msgMapper.insertSelective(msg); } JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", @@ -268,15 +285,14 @@ public static MpTemplateMsgForm getInstance() { /** * 填充模板参数表Table(从数据库读取) * - * @param msgId + * @param templateDataList */ - public static void fillTemplateDataTable(Integer msgId) { + public static void fillTemplateDataTable(List templateDataList) { // 模板消息Data表 - List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.MP_TEMPLATE_CODE, msgId); String[] headerNames = {"Name", "Value", "Color", "操作"}; Object[][] cellData = new String[templateDataList.size()][headerNames.length]; for (int i = 0; i < templateDataList.size(); i++) { - TTemplateData tTemplateData = templateDataList.get(i); + TemplateData tTemplateData = templateDataList.get(i); cellData[i][0] = tTemplateData.getName(); cellData[i][1] = tTemplateData.getValue(); cellData[i][2] = tTemplateData.getColor(); @@ -301,7 +317,18 @@ public static void initTemplateList() { needListenTemplateListComboBox = false; try { templateMap = Maps.newHashMap(); - templateList = WxMpTemplateMsgSender.getWxMpService().getTemplateMsgService().getAllPrivateTemplate(); + + MessageManageForm messageManageForm = MessageManageForm.getInstance(); + String selectedAccountName = (String) messageManageForm.getAccountComboBox().getSelectedItem(); + if (StringUtils.isEmpty(selectedAccountName)) { + return; + } + Integer selectedAccountId = MessageManageForm.accountMap.get(selectedAccountName); + if (selectedAccountId == null) { + return; + } + + templateList = WxMpTemplateMsgSender.getWxMpService(selectedAccountId).getTemplateMsgService().getAllPrivateTemplate(); getInstance().getTemplateListComboBox().removeAllItems(); int selectedIndex = 0; for (int i = 0; i < templateList.size(); i++) { @@ -313,9 +340,11 @@ public static void initTemplateList() { } } - getInstance().getTemplateListComboBox().setSelectedIndex(selectedIndex); + if (getInstance().getTemplateListComboBox().getItemCount() > 0) { + getInstance().getTemplateListComboBox().setSelectedIndex(selectedIndex); + fillWxTemplateContentToField(); + } - fillWxTemplateContentToField(); } catch (Exception e) { log.error(e.toString()); } @@ -403,7 +432,17 @@ public static void initTemplateDataTable() { /** * 清空所有界面字段 */ - public static void clearAllField() { + @Override + public void clearAllField() { + clearAllFieldExceptTemplateListAndContent(); + getInstance().getTemplateListComboBox().removeAllItems(); + getInstance().getTemplateContentTextArea().setText(""); + } + + /** + * 清空所有界面字段 + */ + public static void clearAllFieldExceptTemplateListAndContent() { getInstance().getMsgTemplateIdTextField().setText(""); getInstance().getMsgTemplateUrlTextField().setText(""); getInstance().getMsgTemplateMiniAppidTextField().setText(""); @@ -439,7 +478,7 @@ public static void clearAllField() { templateMsgDataPanel = new JPanel(); templateMsgDataPanel.setLayout(new GridLayoutManager(3, 4, new Insets(10, 0, 0, 0), -1, -1)); templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null)); + templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null)); templateDataNameTextField = new JTextField(); templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的"); templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); @@ -449,7 +488,6 @@ public static void clearAllField() { templateDataColorTextField.setToolTipText("示例值:FF0000"); templateMsgDataPanel.add(templateDataColorTextField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); templateMsgDataAddButton = new JButton(); - templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png"))); templateMsgDataAddButton.setText(""); templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); templateMsgDataTable = new JTable(); @@ -507,7 +545,6 @@ public static void clearAllField() { templateListComboBox = new JComboBox(); panel2.add(templateListComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); refreshTemplateListButton = new JButton(); - refreshTemplateListButton.setIcon(new ImageIcon(getClass().getResource("/icon/refresh.png"))); refreshTemplateListButton.setText("刷新"); panel2.add(refreshTemplateListButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); templateContentTextArea = new JTextArea(); @@ -538,7 +575,10 @@ public static void clearAllField() { resultName = currentFont.getName(); } } - return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); } } diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java index 48c66ab5f..8498a45c6 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java @@ -25,8 +25,6 @@ public static IMsgForm getMsgForm() { iMsgForm = MpTemplateMsgForm.getInstance(); break; case MessageTypeEnum.MA_TEMPLATE_CODE: - iMsgForm = MaTemplateMsgForm.getInstance(); - break; case MessageTypeEnum.MA_SUBSCRIBE_CODE: iMsgForm = MaSubscribeMsgForm.getInstance(); break; @@ -40,7 +38,7 @@ public static IMsgForm getMsgForm() { break; case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE: iMsgForm = WxUniformMsgForm.getInstance(); - UndoUtil.register(MaTemplateMsgForm.getInstance()); + UndoUtil.register(MaSubscribeMsgForm.getInstance()); UndoUtil.register(MpTemplateMsgForm.getInstance()); break; case MessageTypeEnum.ALI_YUN_CODE: @@ -49,6 +47,9 @@ public static IMsgForm getMsgForm() { case MessageTypeEnum.TX_YUN_CODE: iMsgForm = TxYunMsgForm.getInstance(); break; + case MessageTypeEnum.TX_YUN_3_CODE: + iMsgForm = TxYun3MsgForm.getInstance(); + break; case MessageTypeEnum.QI_NIU_YUN_CODE: iMsgForm = QiNiuYunMsgForm.getInstance(); break; @@ -73,6 +74,9 @@ public static IMsgForm getMsgForm() { case MessageTypeEnum.BD_YUN_CODE: iMsgForm = BdYunMsgForm.getInstance(); break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + iMsgForm = MpSubscribeMsgForm.getInstance(); + break; case MessageTypeEnum.HTTP_CODE: default: iMsgForm = HttpMsgForm.getInstance(); diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.form index 7983ffd3e..f3f643f8b 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.form @@ -24,7 +24,7 @@ - + @@ -51,7 +51,6 @@ - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.java index 7b8a7bacf..92f03ad60 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/QiNiuYunMsgForm.java @@ -1,15 +1,17 @@ package com.fangxuele.tool.push.ui.form.msg; -import com.fangxuele.tool.push.dao.TMsgSmsMapper; -import com.fangxuele.tool.push.dao.TTemplateDataMapper; +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.domain.TMsgSms; -import com.fangxuele.tool.push.domain.TTemplateData; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn; import com.fangxuele.tool.push.ui.form.MainWindow; import com.fangxuele.tool.push.ui.form.MessageEditForm; import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import lombok.Getter; @@ -17,13 +19,14 @@ import javax.swing.*; import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumnModel; +import javax.swing.text.StyleContext; import java.awt.*; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.*; /** *
@@ -48,10 +51,11 @@ public class QiNiuYunMsgForm implements IMsgForm {
 
     private static QiNiuYunMsgForm qiNiuYunMsgForm;
 
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public QiNiuYunMsgForm() {
+        templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+
         // 模板数据-添加 按钮事件
         templateMsgDataAddButton.addActionListener(e -> {
             String[] data = new String[2];
@@ -86,23 +90,31 @@ public QiNiuYunMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.QI_NIU_YUN_CODE, msgName);
-        Integer msgId = 0;
-        if (tMsgSmsList.size() > 0) {
-            TMsgSms tMsgSms = tMsgSmsList.get(0);
-            msgId = tMsgSms.getId();
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
             getInstance().getMsgTemplateIdTextField().setText(tMsgSms.getTemplateId());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
 
         initTemplateDataTable();
         // 模板消息Data表
-        List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.QI_NIU_YUN_CODE, msgId);
+        List templateDataList;
+        if (tMsg == null) {
+            templateDataList = new ArrayList<>();
+        } else {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
+            templateDataList = tMsgSms.getTemplateDataList();
+        }
         String[] headerNames = {"模板参数", "参数对应的值", "操作"};
         Object[][] cellData = new String[templateDataList.size()][headerNames.length];
         for (int i = 0; i < templateDataList.size(); i++) {
-            TTemplateData tTemplateData = templateDataList.get(i);
+            TemplateData tTemplateData = templateDataList.get(i);
             cellData[i][0] = tTemplateData.getName();
             cellData[i][1] = tTemplateData.getValue();
         }
@@ -120,14 +132,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.QI_NIU_YUN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.QI_NIU_YUN_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgSmsList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -142,25 +154,16 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgSms tMsgSms = new TMsgSms();
-            tMsgSms.setMsgType(MessageTypeEnum.QI_NIU_YUN_CODE);
-            tMsgSms.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.QI_NIU_YUN_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgSms.setTemplateId(templateId);
-            tMsgSms.setCreateTime(now);
-            tMsgSms.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms);
-            } else {
-                msgSmsMapper.insertSelective(tMsgSms);
-                msgId = tMsgSms.getId();
-            }
-
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.QI_NIU_YUN_CODE, msgId);
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // 如果table为空,则初始化
             if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -171,19 +174,26 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.QI_NIU_YUN_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataList.add(tTemplateData);
+            }
+
+            tMsgSms.setTemplateDataList(templateDataList);
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgSms));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -226,7 +236,8 @@ public static void initTemplateDataTable() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgTemplateIdTextField().setText("");
         getInstance().getTemplateDataNameTextField().setText("");
         getInstance().getTemplateDataValueTextField().setText("");
@@ -257,14 +268,13 @@ public static void clearAllField() {
         templateMsgDataPanel = new JPanel();
         templateMsgDataPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 0, 0, 0), -1, -1));
         templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
-        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
+        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
         templateDataNameTextField = new JTextField();
         templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的");
         templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateDataValueTextField = new JTextField();
         templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateMsgDataAddButton = new JButton();
-        templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         templateMsgDataAddButton.setText("");
         templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         templateMsgDataTable = new JTable();
@@ -309,7 +319,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYun3MsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYun3MsgForm.form
new file mode 100644
index 000000000..2bb84d313
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYun3MsgForm.form
@@ -0,0 +1,120 @@
+
+
+  
+    
+    
+      
+    
+    
+    
+    
+      
+        
+        
+          
+        
+        
+        
+          
+        
+        
+          
+            
+            
+              
+            
+            
+            
+              
+            
+            
+              
+                
+                  
+                    
+                  
+                
+                
+                  
+                
+              
+              
+                
+                  
+                    
+                  
+                
+                
+              
+              
+                
+                  
+                
+                
+                  
+                
+              
+              
+                
+                  
+                
+                
+                  
+                  
+                  
+                  
+                
+              
+              
+                
+                  
+                
+                
+                  
+                  
+                  
+                
+              
+              
+                
+                  
+                
+                
+                  
+                  
+                
+              
+            
+          
+          
+            
+            
+              
+            
+            
+            
+            
+              
+                
+                  
+                
+                
+                  
+                  
+                
+              
+              
+                
+                  
+                    
+                  
+                
+                
+              
+            
+          
+        
+      
+    
+  
+
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaTemplateMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYun3MsgForm.java
similarity index 59%
rename from src/main/java/com/fangxuele/tool/push/ui/form/msg/MaTemplateMsgForm.java
rename to src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYun3MsgForm.java
index 8223a5c22..6bc6fc512 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MaTemplateMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYun3MsgForm.java
@@ -1,15 +1,17 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgMaTemplateMapper;
-import com.fangxuele.tool.push.dao.TTemplateDataMapper;
-import com.fangxuele.tool.push.domain.TMsgMaTemplate;
-import com.fangxuele.tool.push.domain.TTemplateData;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
+import com.fangxuele.tool.push.domain.TMsgSms;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
 import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import lombok.Getter;
@@ -17,53 +19,48 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableColumnModel;
+import javax.swing.text.StyleContext;
 import java.awt.*;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 
- * MaTemplateMsgForm
+ * TxYun3MsgForm
  * 
* * @author Zhou Bo - * @since 2019/6/3. + * @since 2023/9/4. */ @Getter -public class MaTemplateMsgForm implements IMsgForm { +public class TxYun3MsgForm implements IMsgForm { private JPanel templateMsgPanel; private JLabel templateIdLabel; private JTextField msgTemplateIdTextField; - private JLabel templateUrlLabel; - private JTextField msgTemplateUrlTextField; private JPanel templateMsgDataPanel; - private JLabel templateKeyWordLabel; - private JTextField msgTemplateKeyWordTextField; private JLabel templateMsgNameLabel; private JTextField templateDataNameTextField; private JLabel templateMsgValueLabel; private JTextField templateDataValueTextField; - private JLabel templateMsgColorLabel; - private JTextField templateDataColorTextField; private JButton templateMsgDataAddButton; private JTable templateMsgDataTable; - private static MaTemplateMsgForm maTemplateMsgForm; + private static TxYun3MsgForm txYun3MsgForm; - private static TMsgMaTemplateMapper msgMaTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaTemplateMapper.class); - private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class); + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + public TxYun3MsgForm() { + templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg")); - public MaTemplateMsgForm() { // 模板数据-添加 按钮事件 templateMsgDataAddButton.addActionListener(e -> { - String[] data = new String[3]; + String[] data = new String[2]; data[0] = getInstance().getTemplateDataNameTextField().getText(); data[1] = getInstance().getTemplateDataValueTextField().getText(); - data[2] = getInstance().getTemplateDataColorTextField().getText(); if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { initTemplateDataTable(); @@ -81,45 +78,45 @@ public MaTemplateMsgForm() { } if (StringUtils.isEmpty(data[0]) || StringUtils.isEmpty(data[1])) { - JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "Name或value不能为空!", "提示", + JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "模板参数和参数对应的值不能为空!", "提示", JOptionPane.INFORMATION_MESSAGE); } else if (keySet.contains(data[0])) { - JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "Name不能重复!", "提示", + JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "模板参数不能重复!", "提示", JOptionPane.INFORMATION_MESSAGE); } else { - if (StringUtils.isEmpty(data[2])) { - data[2] = "#000000"; - } else if (!data[2].startsWith("#")) { - data[2] = "#" + data[2]; - } tableModel.addRow(data); } }); } @Override - public void init(String msgName) { + public void init(Integer msgId) { clearAllField(); - List tMsgMaTemplateList = msgMaTemplateMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MA_TEMPLATE_CODE, msgName); - Integer msgId = 0; - if (tMsgMaTemplateList.size() > 0) { - TMsgMaTemplate tMsgMaTemplate = tMsgMaTemplateList.get(0); - msgId = tMsgMaTemplate.getId(); - getInstance().getMsgTemplateIdTextField().setText(tMsgMaTemplate.getTemplateId()); - getInstance().getMsgTemplateUrlTextField().setText(tMsgMaTemplate.getPage()); - getInstance().getMsgTemplateKeyWordTextField().setText(tMsgMaTemplate.getEmphasisKeyword()); + TMsg tMsg = msgMapper.selectByPrimaryKey(msgId); + if (tMsg != null) { + TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class); + getInstance().getMsgTemplateIdTextField().setText(tMsgSms.getTemplateId()); + + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + messageEditForm.getMsgNameField().setText(tMsg.getMsgName()); + messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser()); } initTemplateDataTable(); // 模板消息Data表 - List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.MA_TEMPLATE_CODE, msgId); - String[] headerNames = {"Name", "Value", "Color", "操作"}; + List templateDataList; + if (tMsg == null) { + templateDataList = new ArrayList<>(); + } else { + TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class); + templateDataList = tMsgSms.getTemplateDataList(); + } + String[] headerNames = {"模板参数", "参数对应的值", "操作"}; Object[][] cellData = new String[templateDataList.size()][headerNames.length]; for (int i = 0; i < templateDataList.size(); i++) { - TTemplateData tTemplateData = templateDataList.get(i); + TemplateData tTemplateData = templateDataList.get(i); cellData[i][0] = tTemplateData.getName(); cellData[i][1] = tTemplateData.getValue(); - cellData[i][2] = tTemplateData.getColor(); } DefaultTableModel model = new DefaultTableModel(cellData, headerNames); getInstance().getTemplateMsgDataTable().setModel(model); @@ -130,19 +127,19 @@ public void init(String msgName) { setCellEditor(new TableInCellButtonColumn(getInstance().getTemplateMsgDataTable(), headerNames.length - 1)); // 设置列宽 - tableColumnModel.getColumn(3).setPreferredWidth(46); - tableColumnModel.getColumn(3).setMaxWidth(46); + tableColumnModel.getColumn(2).setPreferredWidth(46); + tableColumnModel.getColumn(2).setMaxWidth(46); } @Override - public void save(String msgName) { + public void save(Integer accountId, String msgName) { int msgId = 0; boolean existSameMsg = false; - List tMsgMaTemplateList = msgMaTemplateMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MA_TEMPLATE_CODE, msgName); - if (tMsgMaTemplateList.size() > 0) { + TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.TX_YUN_3_CODE, accountId, msgName); + if (tMsg != null) { existSameMsg = true; - msgId = tMsgMaTemplateList.get(0).getId(); + msgId = tMsg.getId(); } int isCover = JOptionPane.NO_OPTION; @@ -154,33 +151,20 @@ public void save(String msgName) { if (!existSameMsg || isCover == JOptionPane.YES_OPTION) { String templateId = getInstance().getMsgTemplateIdTextField().getText(); - String templateUrl = getInstance().getMsgTemplateUrlTextField().getText(); - String templateKeyWord = getInstance().getMsgTemplateKeyWordTextField().getText(); String now = SqliteUtil.nowDateForSqlite(); - TMsgMaTemplate tMsgMaTemplate = new TMsgMaTemplate(); - tMsgMaTemplate.setMsgType(MessageTypeEnum.MA_TEMPLATE_CODE); - tMsgMaTemplate.setMsgName(msgName); - tMsgMaTemplate.setTemplateId(templateId); - tMsgMaTemplate.setPage(templateUrl); - tMsgMaTemplate.setEmphasisKeyword(templateKeyWord); - tMsgMaTemplate.setCreateTime(now); - tMsgMaTemplate.setModifiedTime(now); + TMsg msg = new TMsg(); + TMsgSms tMsgSms = new TMsgSms(); + msg.setMsgType(MessageTypeEnum.TX_YUN_3_CODE); + msg.setAccountId(accountId); + msg.setMsgName(msgName); + tMsgSms.setTemplateId(templateId); + msg.setCreateTime(now); + msg.setModifiedTime(now); - if (existSameMsg) { - msgMaTemplateMapper.updateByMsgTypeAndMsgName(tMsgMaTemplate); - } else { - msgMaTemplateMapper.insertSelective(tMsgMaTemplate); - msgId = tMsgMaTemplate.getId(); - } - - // 保存模板数据 - - // 如果是覆盖保存,则先清空之前的模板数据 - if (existSameMsg) { - templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.MA_TEMPLATE_CODE, msgId); - } + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + msg.setPreviewUser(messageEditForm.getPreviewUserField().getText()); // 如果table为空,则初始化 if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { @@ -191,33 +175,39 @@ public void save(String msgName) { DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() .getModel(); int rowCount = tableModel.getRowCount(); + List templateDataList = new ArrayList<>(); for (int i = 0; i < rowCount; i++) { String name = (String) tableModel.getValueAt(i, 0); String value = (String) tableModel.getValueAt(i, 1); - String color = ((String) tableModel.getValueAt(i, 2)).trim(); - TTemplateData tTemplateData = new TTemplateData(); - tTemplateData.setMsgType(MessageTypeEnum.MA_TEMPLATE_CODE); - tTemplateData.setMsgId(msgId); + TemplateData tTemplateData = new TemplateData(); tTemplateData.setName(name); tTemplateData.setValue(value); - tTemplateData.setColor(color); - tTemplateData.setCreateTime(now); - tTemplateData.setModifiedTime(now); - templateDataMapper.insert(tTemplateData); + templateDataList.add(tTemplateData); + } + + tMsgSms.setTemplateDataList(templateDataList); + + msg.setContent(JSONUtil.toJsonStr(tMsgSms)); + if (existSameMsg) { + msg.setId(msgId); + msgMapper.updateByPrimaryKeySelective(msg); + } else { + msgMapper.insertSelective(msg); } JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", JOptionPane.INFORMATION_MESSAGE); } + } - public static MaTemplateMsgForm getInstance() { - if (maTemplateMsgForm == null) { - maTemplateMsgForm = new MaTemplateMsgForm(); + public static TxYun3MsgForm getInstance() { + if (txYun3MsgForm == null) { + txYun3MsgForm = new TxYun3MsgForm(); } - return maTemplateMsgForm; + return txYun3MsgForm; } /** @@ -225,7 +215,7 @@ public static MaTemplateMsgForm getInstance() { */ public static void initTemplateDataTable() { JTable msgDataTable = getInstance().getTemplateMsgDataTable(); - String[] headerNames = {"Name", "Value", "Color", "操作"}; + String[] headerNames = {"模板参数", "参数对应的值", "操作"}; DefaultTableModel model = new DefaultTableModel(null, headerNames); msgDataTable.setModel(model); msgDataTable.updateUI(); @@ -240,20 +230,18 @@ public static void initTemplateDataTable() { setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); // 设置列宽 - tableColumnModel.getColumn(3).setPreferredWidth(46); - tableColumnModel.getColumn(3).setMaxWidth(46); + tableColumnModel.getColumn(2).setPreferredWidth(46); + tableColumnModel.getColumn(2).setMaxWidth(46); } /** * 清空所有界面字段 */ - public static void clearAllField() { + @Override + public void clearAllField() { getInstance().getMsgTemplateIdTextField().setText(""); - getInstance().getMsgTemplateUrlTextField().setText(""); - getInstance().getMsgTemplateKeyWordTextField().setText(""); getInstance().getTemplateDataNameTextField().setText(""); getInstance().getTemplateDataValueTextField().setText(""); - getInstance().getTemplateDataColorTextField().setText(""); initTemplateDataTable(); } @@ -275,66 +263,45 @@ public static void clearAllField() { final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); templateMsgPanel = new JPanel(); - templateMsgPanel.setLayout(new GridLayoutManager(2, 1, new Insets(10, 15, 0, 0), -1, -1)); + templateMsgPanel.setLayout(new GridLayoutManager(2, 1, new Insets(10, 5, 0, 0), -1, -1)); panel1.add(templateMsgPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - templateMsgPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "小程序-模板消息编辑", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgPanel.getFont()), null)); + templateMsgPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgPanel.getFont()), null)); templateMsgDataPanel = new JPanel(); - templateMsgDataPanel.setLayout(new GridLayoutManager(3, 4, new Insets(10, 0, 0, 0), -1, -1)); + templateMsgDataPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 0, 0, 0), -1, -1)); templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null)); + templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null)); templateDataNameTextField = new JTextField(); templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的"); templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); templateDataValueTextField = new JTextField(); templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - templateDataColorTextField = new JTextField(); - templateDataColorTextField.setToolTipText("示例值:FF0000"); - templateMsgDataPanel.add(templateDataColorTextField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); templateMsgDataAddButton = new JButton(); - templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png"))); templateMsgDataAddButton.setText(""); - templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); templateMsgDataTable = new JTable(); templateMsgDataTable.setAutoCreateColumnsFromModel(true); templateMsgDataTable.setAutoCreateRowSorter(true); templateMsgDataTable.setGridColor(new Color(-12236470)); templateMsgDataTable.setRowHeight(36); - templateMsgDataPanel.add(templateMsgDataTable, new GridConstraints(2, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + templateMsgDataPanel.add(templateMsgDataTable, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); templateMsgNameLabel = new JLabel(); - templateMsgNameLabel.setText("name"); + templateMsgNameLabel.setText("模板参数"); templateMsgNameLabel.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的"); templateMsgDataPanel.add(templateMsgNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); templateMsgValueLabel = new JLabel(); - templateMsgValueLabel.setText("value"); + templateMsgValueLabel.setText("参数对应的值"); templateMsgDataPanel.add(templateMsgValueLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - templateMsgColorLabel = new JLabel(); - templateMsgColorLabel.setText("color"); - templateMsgColorLabel.setToolTipText("示例值:FF0000"); - templateMsgDataPanel.add(templateMsgColorLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 5, 0), -1, -1)); + panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 5, 10, 5), -1, -1)); templateMsgPanel.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); templateIdLabel = new JLabel(); - templateIdLabel.setText("模板ID *"); + templateIdLabel.setText("短信模板ID *"); panel2.add(templateIdLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); msgTemplateIdTextField = new JTextField(); panel2.add(msgTemplateIdTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - templateUrlLabel = new JLabel(); - templateUrlLabel.setText("跳转URL"); - panel2.add(templateUrlLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - msgTemplateUrlTextField = new JTextField(); - panel2.add(msgTemplateUrlTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - templateKeyWordLabel = new JLabel(); - templateKeyWordLabel.setText("放大关键词"); - panel2.add(templateKeyWordLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - msgTemplateKeyWordTextField = new JTextField(); - panel2.add(msgTemplateKeyWordTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); templateMsgNameLabel.setLabelFor(templateDataNameTextField); templateMsgValueLabel.setLabelFor(templateDataValueTextField); - templateMsgColorLabel.setLabelFor(templateDataColorTextField); templateIdLabel.setLabelFor(msgTemplateIdTextField); - templateUrlLabel.setLabelFor(msgTemplateUrlTextField); - templateKeyWordLabel.setLabelFor(msgTemplateUrlTextField); } /** @@ -353,7 +320,10 @@ public static void clearAllField() { resultName = currentFont.getName(); } } - return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); } } diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.form index 93b9653e6..7f3b5bec0 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.form @@ -24,7 +24,7 @@ - + @@ -51,7 +51,6 @@ - diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.java index 142becf12..5af4d6c41 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/TxYunMsgForm.java @@ -1,15 +1,17 @@ package com.fangxuele.tool.push.ui.form.msg; -import com.fangxuele.tool.push.dao.TMsgSmsMapper; -import com.fangxuele.tool.push.dao.TTemplateDataMapper; +import cn.hutool.json.JSONUtil; +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.domain.TMsgSms; -import com.fangxuele.tool.push.domain.TTemplateData; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn; import com.fangxuele.tool.push.ui.form.MainWindow; import com.fangxuele.tool.push.ui.form.MessageEditForm; import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.SqliteUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import lombok.Getter; @@ -17,13 +19,14 @@ import javax.swing.*; import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumnModel; +import javax.swing.text.StyleContext; import java.awt.*; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.*; /** *
@@ -48,10 +51,11 @@ public class TxYunMsgForm implements IMsgForm {
 
     private static TxYunMsgForm txYunMsgForm;
 
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public TxYunMsgForm() {
+        templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+
         // 模板数据-添加 按钮事件
         templateMsgDataAddButton.addActionListener(e -> {
             String[] data = new String[2];
@@ -86,23 +90,31 @@ public TxYunMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.TX_YUN_CODE, msgName);
-        Integer msgId = 0;
-        if (tMsgSmsList.size() > 0) {
-            TMsgSms tMsgSms = tMsgSmsList.get(0);
-            msgId = tMsgSms.getId();
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
             getInstance().getMsgTemplateIdTextField().setText(tMsgSms.getTemplateId());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
 
         initTemplateDataTable();
         // 模板消息Data表
-        List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.TX_YUN_CODE, msgId);
+        List templateDataList;
+        if (tMsg == null) {
+            templateDataList = new ArrayList<>();
+        } else {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
+            templateDataList = tMsgSms.getTemplateDataList();
+        }
         String[] headerNames = {"模板参数", "参数对应的值", "操作"};
         Object[][] cellData = new String[templateDataList.size()][headerNames.length];
         for (int i = 0; i < templateDataList.size(); i++) {
-            TTemplateData tTemplateData = templateDataList.get(i);
+            TemplateData tTemplateData = templateDataList.get(i);
             cellData[i][0] = tTemplateData.getName();
             cellData[i][1] = tTemplateData.getValue();
         }
@@ -120,14 +132,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.TX_YUN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.TX_YUN_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgSmsList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -142,25 +154,17 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgSms tMsgSms = new TMsgSms();
-            tMsgSms.setMsgType(MessageTypeEnum.TX_YUN_CODE);
-            tMsgSms.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.TX_YUN_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgSms.setTemplateId(templateId);
-            tMsgSms.setCreateTime(now);
-            tMsgSms.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms);
-            } else {
-                msgSmsMapper.insertSelective(tMsgSms);
-                msgId = tMsgSms.getId();
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
 
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.TX_YUN_CODE, msgId);
-            }
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // 如果table为空,则初始化
             if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -171,19 +175,26 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.TX_YUN_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataList.add(tTemplateData);
+            }
+
+            tMsgSms.setTemplateDataList(templateDataList);
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgSms));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -226,7 +237,8 @@ public static void initTemplateDataTable() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgTemplateIdTextField().setText("");
         getInstance().getTemplateDataNameTextField().setText("");
         getInstance().getTemplateDataValueTextField().setText("");
@@ -257,14 +269,13 @@ public static void clearAllField() {
         templateMsgDataPanel = new JPanel();
         templateMsgDataPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 0, 0, 0), -1, -1));
         templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
-        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
+        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
         templateDataNameTextField = new JTextField();
         templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的");
         templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateDataValueTextField = new JTextField();
         templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateMsgDataAddButton = new JButton();
-        templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         templateMsgDataAddButton.setText("");
         templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         templateMsgDataTable = new JTable();
@@ -309,7 +320,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.form
index be24d6101..bada5d14a 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.form
@@ -24,7 +24,7 @@
               
             
             
-            
+            
               
             
             
@@ -51,7 +51,6 @@
                   
                 
                 
-                  
                   
                 
               
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.java
index bef0968aa..fb02ea99e 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/UpYunMsgForm.java
@@ -1,15 +1,17 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgSmsMapper;
-import com.fangxuele.tool.push.dao.TTemplateDataMapper;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgSms;
-import com.fangxuele.tool.push.domain.TTemplateData;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
 import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
+import com.formdev.flatlaf.extras.FlatSVGIcon;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import lombok.Getter;
@@ -17,13 +19,14 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableColumnModel;
+import javax.swing.text.StyleContext;
 import java.awt.*;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 
@@ -48,10 +51,11 @@ public class UpYunMsgForm implements IMsgForm {
 
     private static UpYunMsgForm upYunMsgForm;
 
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public UpYunMsgForm() {
+        templateMsgDataAddButton.setIcon(new FlatSVGIcon("icon/add.svg"));
+
         // 模板数据-添加 按钮事件
         templateMsgDataAddButton.addActionListener(e -> {
             String[] data = new String[2];
@@ -86,23 +90,31 @@ public UpYunMsgForm() {
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.UP_YUN_CODE, msgName);
-        Integer msgId = 0;
-        if (tMsgSmsList.size() > 0) {
-            TMsgSms tMsgSms = tMsgSmsList.get(0);
-            msgId = tMsgSms.getId();
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
             getInstance().getMsgTemplateIdTextField().setText(tMsgSms.getTemplateId());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
 
         initTemplateDataTable();
         // 模板消息Data表
-        List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.UP_YUN_CODE, msgId);
+        List templateDataList;
+        if (tMsg == null) {
+            templateDataList = new ArrayList<>();
+        } else {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
+            templateDataList = tMsgSms.getTemplateDataList();
+        }
         String[] headerNames = {"模板参数", "参数对应的值", "操作"};
         Object[][] cellData = new String[templateDataList.size()][headerNames.length];
         for (int i = 0; i < templateDataList.size(); i++) {
-            TTemplateData tTemplateData = templateDataList.get(i);
+            TemplateData tTemplateData = templateDataList.get(i);
             cellData[i][0] = tTemplateData.getName();
             cellData[i][1] = tTemplateData.getValue();
         }
@@ -120,14 +132,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.UP_YUN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.UP_YUN_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgSmsList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -142,25 +154,17 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgSms tMsgSms = new TMsgSms();
-            tMsgSms.setMsgType(MessageTypeEnum.UP_YUN_CODE);
-            tMsgSms.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.UP_YUN_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgSms.setTemplateId(templateId);
-            tMsgSms.setCreateTime(now);
-            tMsgSms.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms);
-            } else {
-                msgSmsMapper.insertSelective(tMsgSms);
-                msgId = tMsgSms.getId();
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
 
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.UP_YUN_CODE, msgId);
-            }
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // 如果table为空,则初始化
             if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
@@ -171,19 +175,26 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+            List templateDataList = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.UP_YUN_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataList.add(tTemplateData);
+            }
+
+            tMsgSms.setTemplateDataList(templateDataList);
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgSms));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -226,7 +237,8 @@ public static void initTemplateDataTable() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgTemplateIdTextField().setText("");
         getInstance().getTemplateDataNameTextField().setText("");
         getInstance().getTemplateDataValueTextField().setText("");
@@ -257,14 +269,13 @@ public static void clearAllField() {
         templateMsgDataPanel = new JPanel();
         templateMsgDataPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 0, 0, 0), -1, -1));
         templateMsgPanel.add(templateMsgDataPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
-        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"$ENTER$\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
+        templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "短信模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null));
         templateDataNameTextField = new JTextField();
         templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的");
         templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateDataValueTextField = new JTextField();
         templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         templateMsgDataAddButton = new JButton();
-        templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png")));
         templateMsgDataAddButton.setText("");
         templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         templateMsgDataTable = new JTable();
@@ -309,7 +320,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.form
index e894c81b2..67edf035f 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.form
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.form
@@ -8,7 +8,7 @@
     
     
     
-      
+      
         
         
           
@@ -20,7 +20,7 @@
         
           
             
-              
+              
             
             
               
@@ -29,12 +29,12 @@
           
           
             
-              
+              
             
           
           
             
-              
+              
             
             
               
@@ -47,7 +47,7 @@
           
           
             
-              
+              
             
             
               
@@ -56,7 +56,7 @@
           
           
             
-              
+              
             
             
               
@@ -65,7 +65,7 @@
           
           
             
-              
+              
                 
               
             
@@ -73,7 +73,7 @@
           
           
             
-              
+              
             
             
               
@@ -82,7 +82,7 @@
           
           
             
-              
+              
                 
               
             
@@ -90,7 +90,7 @@
           
           
             
-              
+              
             
             
               
@@ -99,7 +99,7 @@
           
           
             
-              
+              
                 
               
             
@@ -107,37 +107,15 @@
           
           
             
-              
+              
             
             
               
             
           
-          
-            
-              
-            
-            
-              
-            
-          
-          
-            
-              
-            
-            
-          
-          
-            
-              
-            
-            
-              
-            
-          
           
             
-              
+              
                 
                 
               
@@ -146,7 +124,7 @@
           
           
             
-              
+              
                 
               
             
@@ -154,7 +132,7 @@
           
           
             
-              
+              
             
             
               
@@ -163,7 +141,7 @@
           
           
             
-              
+              
                 
               
             
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.java
index efa32e7b9..479595f68 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxCpMsgForm.java
@@ -1,12 +1,12 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgWxCpMapper;
-import com.fangxuele.tool.push.dao.TWxCpAppMapper;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgWxCp;
-import com.fangxuele.tool.push.domain.TWxCpApp;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
-import com.fangxuele.tool.push.ui.dialog.WxCpAppDialog;
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
 import com.google.common.collect.Maps;
@@ -17,9 +17,11 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.text.StyleContext;
 import java.awt.*;
 import java.awt.event.ItemEvent;
-import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Objects;
 
@@ -45,7 +47,6 @@ public class WxCpMsgForm implements IMsgForm {
     private JLabel urlLabel;
     private JTextField urlTextField;
     private JLabel contentLabel;
-    private JComboBox appNameComboBox;
     private JButton appManageButton;
     private JTextArea contentTextArea;
     private JTextField btnTxtTextField;
@@ -53,8 +54,7 @@ public class WxCpMsgForm implements IMsgForm {
 
     private static WxCpMsgForm wxCpMsgForm;
 
-    private static TMsgWxCpMapper msgWxCpMapper = MybatisUtil.getSqlSession().getMapper(TMsgWxCpMapper.class);
-    private static TWxCpAppMapper wxCpAppMapper = MybatisUtil.getSqlSession().getMapper(TWxCpAppMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     public static Map appNameToAgentIdMap = Maps.newHashMap();
     public static Map agentIdToAppNameMap = Maps.newHashMap();
@@ -66,24 +66,15 @@ public WxCpMsgForm() {
                 switchCpMsgType(e.getItem().toString());
             }
         });
-        appManageButton.addActionListener(e -> {
-            WxCpAppDialog dialog = new WxCpAppDialog();
-            dialog.renderTable();
-            dialog.pack();
-            dialog.setVisible(true);
-            initAppNameList();
-        });
     }
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        initAppNameList();
-        List tMsgWxCpList = msgWxCpMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.WX_CP_CODE, msgName);
-        if (tMsgWxCpList.size() > 0) {
-            TMsgWxCp tMsgWxCp = tMsgWxCpList.get(0);
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgWxCp tMsgWxCp = JSONUtil.toBean(tMsg.getContent(), TMsgWxCp.class);
             String cpMsgType = tMsgWxCp.getCpMsgType();
-            getInstance().getAppNameComboBox().setSelectedItem(agentIdToAppNameMap.get(tMsgWxCp.getAgentId()));
             getInstance().getMsgTypeComboBox().setSelectedItem(cpMsgType);
             getInstance().getContentTextArea().setText(tMsgWxCp.getContent());
             getInstance().getTitleTextField().setText(tMsgWxCp.getTitle());
@@ -92,6 +83,10 @@ public void init(String msgName) {
             getInstance().getUrlTextField().setText(tMsgWxCp.getUrl());
             getInstance().getBtnTxtTextField().setText(tMsgWxCp.getBtnTxt());
 
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
+
             switchCpMsgType(cpMsgType);
         } else {
             switchCpMsgType("图文消息");
@@ -99,18 +94,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         boolean existSameMsg = false;
 
-        if (getInstance().getAppNameComboBox().getSelectedItem() == null) {
-            JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请选择应用!", "成功",
-                    JOptionPane.ERROR_MESSAGE);
-            return;
-        }
-
-        List tMsgWxCpList = msgWxCpMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.WX_CP_CODE, msgName);
-        if (tMsgWxCpList.size() > 0) {
+        Integer msgId = null;
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.WX_CP_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -131,10 +122,11 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgWxCp tMsgWxCp = new TMsgWxCp();
-            tMsgWxCp.setMsgType(MessageTypeEnum.WX_CP_CODE);
-            tMsgWxCp.setMsgName(msgName);
-            tMsgWxCp.setAgentId(appNameToAgentIdMap.get(getInstance().getAppNameComboBox().getSelectedItem()));
+            msg.setMsgType(MessageTypeEnum.WX_CP_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgWxCp.setCpMsgType(cpMsgType);
             tMsgWxCp.setContent(content);
             tMsgWxCp.setTitle(title);
@@ -142,13 +134,18 @@ public void save(String msgName) {
             tMsgWxCp.setDescribe(desc);
             tMsgWxCp.setUrl(url);
             tMsgWxCp.setBtnTxt(btnTxt);
-            tMsgWxCp.setModifiedTime(now);
+            msg.setModifiedTime(now);
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
+            msg.setContent(JSONUtil.toJsonStr(tMsgWxCp));
             if (existSameMsg) {
-                msgWxCpMapper.updateByMsgTypeAndMsgName(tMsgWxCp);
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
             } else {
-                tMsgWxCp.setCreateTime(now);
-                msgWxCpMapper.insertSelective(tMsgWxCp);
+                msg.setCreateTime(now);
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -163,19 +160,6 @@ public static WxCpMsgForm getInstance() {
         return wxCpMsgForm;
     }
 
-    /**
-     * 初始化应用名称列表
-     */
-    public static void initAppNameList() {
-        List tWxCpAppList = wxCpAppMapper.selectAll();
-        getInstance().getAppNameComboBox().removeAllItems();
-        for (TWxCpApp tWxCpApp : tWxCpAppList) {
-            appNameToAgentIdMap.put(tWxCpApp.getAppName(), tWxCpApp.getAgentId());
-            agentIdToAppNameMap.put(tWxCpApp.getAgentId(), tWxCpApp.getAppName());
-            getInstance().getAppNameComboBox().addItem(tWxCpApp.getAppName());
-        }
-    }
-
     /**
      * 根据消息类型转换界面显示
      *
@@ -233,13 +217,15 @@ public static void switchCpMsgType(String msgType) {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getContentTextArea().setText("");
         getInstance().getTitleTextField().setText("");
         getInstance().getPicUrlTextField().setText("");
         getInstance().getDescTextField().setText("");
         getInstance().getUrlTextField().setText("");
         getInstance().getBtnTxtTextField().setText("");
+        switchCpMsgType(msgTypeComboBox.getSelectedItem().toString());
     }
 
     {
@@ -260,14 +246,14 @@ public static void clearAllField() {
         final JPanel panel1 = new JPanel();
         panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
         wxCpMsgPanel = new JPanel();
-        wxCpMsgPanel.setLayout(new GridLayoutManager(9, 3, new Insets(10, 8, 0, 8), -1, -1));
+        wxCpMsgPanel.setLayout(new GridLayoutManager(8, 2, new Insets(10, 8, 0, 8), -1, -1));
         panel1.add(wxCpMsgPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
         wxCpMsgPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, wxCpMsgPanel.getFont()), null));
         msgTypeLabel = new JLabel();
         msgTypeLabel.setText("消息类型");
-        wxCpMsgPanel.add(msgTypeLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(msgTypeLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final Spacer spacer1 = new Spacer();
-        wxCpMsgPanel.add(spacer1, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+        wxCpMsgPanel.add(spacer1, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
         msgTypeComboBox = new JComboBox();
         final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
         defaultComboBoxModel1.addElement("图文消息");
@@ -275,47 +261,39 @@ public static void clearAllField() {
         defaultComboBoxModel1.addElement("文本卡片消息");
         defaultComboBoxModel1.addElement("markdown消息");
         msgTypeComboBox.setModel(defaultComboBoxModel1);
-        wxCpMsgPanel.add(msgTypeComboBox, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(msgTypeComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         titleLabel = new JLabel();
         titleLabel.setText("标题");
-        wxCpMsgPanel.add(titleLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(titleLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         picUrlLabel = new JLabel();
         picUrlLabel.setText("图片URL");
-        wxCpMsgPanel.add(picUrlLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(picUrlLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         picUrlTextField = new JTextField();
-        wxCpMsgPanel.add(picUrlTextField, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        wxCpMsgPanel.add(picUrlTextField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         descLabel = new JLabel();
         descLabel.setText("描述");
-        wxCpMsgPanel.add(descLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(descLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         descTextField = new JTextField();
-        wxCpMsgPanel.add(descTextField, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        wxCpMsgPanel.add(descTextField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         urlLabel = new JLabel();
         urlLabel.setText("跳转URL");
-        wxCpMsgPanel.add(urlLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(urlLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         urlTextField = new JTextField();
-        wxCpMsgPanel.add(urlTextField, new GridConstraints(6, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        wxCpMsgPanel.add(urlTextField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         contentLabel = new JLabel();
         contentLabel.setText("内容");
-        wxCpMsgPanel.add(contentLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
-        final JLabel label1 = new JLabel();
-        label1.setText("选择应用");
-        wxCpMsgPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
-        appNameComboBox = new JComboBox();
-        wxCpMsgPanel.add(appNameComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
-        appManageButton = new JButton();
-        appManageButton.setText("应用管理");
-        wxCpMsgPanel.add(appManageButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(contentLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         titleTextField = new JTextField();
-        wxCpMsgPanel.add(titleTextField, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(380, -1), new Dimension(380, -1), null, 0, false));
+        wxCpMsgPanel.add(titleTextField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(380, -1), new Dimension(380, -1), null, 0, false));
         contentTextArea = new JTextArea();
-        wxCpMsgPanel.add(contentTextArea, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
+        wxCpMsgPanel.add(contentTextArea, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
         btnTxtLabel = new JLabel();
         btnTxtLabel.setText("按钮文字");
         btnTxtLabel.setToolTipText("可不填。默认为“详情”, 不超过4个文字,超过自动截断");
-        wxCpMsgPanel.add(btnTxtLabel, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        wxCpMsgPanel.add(btnTxtLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         btnTxtTextField = new JTextField();
         btnTxtTextField.setToolTipText("可不填。默认为“详情”, 不超过4个文字,超过自动截断");
-        wxCpMsgPanel.add(btnTxtTextField, new GridConstraints(7, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
+        wxCpMsgPanel.add(btnTxtTextField, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
         msgTypeLabel.setLabelFor(msgTypeComboBox);
         titleLabel.setLabelFor(titleTextField);
         picUrlLabel.setLabelFor(picUrlTextField);
@@ -339,7 +317,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxUniformMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxUniformMsgForm.java
index bb1b91a84..208509a6b 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxUniformMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/WxUniformMsgForm.java
@@ -1,18 +1,22 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgWxUniformMapper;
-import com.fangxuele.tool.push.dao.TTemplateDataMapper;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.fangxuele.tool.push.bean.TemplateData;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgWxUniform;
-import com.fangxuele.tool.push.domain.TTemplateData;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn;
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
 
 import javax.swing.*;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableColumnModel;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -25,35 +29,35 @@
  */
 public class WxUniformMsgForm implements IMsgForm {
 
-    private static TMsgWxUniformMapper msgWxUniformMapper = MybatisUtil.getSqlSession().getMapper(TMsgWxUniformMapper.class);
-    private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class);
-
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
     private static WxUniformMsgForm wxUniformMsgForm;
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgWxUniformList = msgWxUniformMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE, msgName);
-        if (tMsgWxUniformList.size() > 0) {
-            TMsgWxUniform tMsgWxUniform = tMsgWxUniformList.get(0);
-            Integer msgId = tMsgWxUniform.getId();
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgWxUniform tMsgWxUniform = JSONUtil.toBean(tMsg.getContent(), TMsgWxUniform.class);
             MpTemplateMsgForm.getInstance().getMsgTemplateIdTextField().setText(tMsgWxUniform.getMpTemplateId());
             MpTemplateMsgForm.getInstance().getMsgTemplateUrlTextField().setText(tMsgWxUniform.getMpUrl());
             MpTemplateMsgForm.getInstance().getMsgTemplateMiniAppidTextField().setText(tMsgWxUniform.getMaAppid());
             MpTemplateMsgForm.getInstance().getMsgTemplateMiniPagePathTextField().setText(tMsgWxUniform.getMaPagePath());
 
-            MaTemplateMsgForm.getInstance().getMsgTemplateIdTextField().setText(tMsgWxUniform.getMaTemplateId());
-            MaTemplateMsgForm.getInstance().getMsgTemplateUrlTextField().setText(tMsgWxUniform.getPage());
-            MaTemplateMsgForm.getInstance().getMsgTemplateKeyWordTextField().setText(tMsgWxUniform.getEmphasisKeyword());
+            MaSubscribeMsgForm.getInstance().getMsgTemplateIdTextField().setText(tMsgWxUniform.getMaTemplateId());
+            MaSubscribeMsgForm.getInstance().getMsgTemplateUrlTextField().setText(tMsgWxUniform.getPage());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
 
             // -------------公众号模板数据开始
             MpTemplateMsgForm.selectedMsgTemplateId = tMsgWxUniform.getMpTemplateId();
             // 模板消息Data表
-            List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE * MessageTypeEnum.MP_TEMPLATE_CODE, msgId);
+            List templateDataList = tMsgWxUniform.getTemplateDataListMp();
             String[] headerNames = {"Name", "Value", "Color", "操作"};
             Object[][] cellData = new String[templateDataList.size()][headerNames.length];
             for (int i = 0; i < templateDataList.size(); i++) {
-                TTemplateData tTemplateData = templateDataList.get(i);
+                TemplateData tTemplateData = templateDataList.get(i);
                 cellData[i][0] = tTemplateData.getName();
                 cellData[i][1] = tTemplateData.getValue();
                 cellData[i][2] = tTemplateData.getColor();
@@ -74,22 +78,22 @@ public void init(String msgName) {
             // -------------公众号模板数据结束
 
             // -------------小程序模板数据开始
-            MaTemplateMsgForm.initTemplateDataTable();
+            MaSubscribeMsgForm.initTemplateDataTable();
             // 模板消息Data表
-            templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE * MessageTypeEnum.MA_TEMPLATE_CODE, msgId);
+            templateDataList = tMsgWxUniform.getTemplateDataListMa();
             for (int i = 0; i < templateDataList.size(); i++) {
-                TTemplateData tTemplateData = templateDataList.get(i);
+                TemplateData tTemplateData = templateDataList.get(i);
                 cellData[i][0] = tTemplateData.getName();
                 cellData[i][1] = tTemplateData.getValue();
                 cellData[i][2] = tTemplateData.getColor();
             }
             model = new DefaultTableModel(cellData, headerNames);
-            MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().setModel(model);
-            tableColumnModel = MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().getColumnModel();
+            MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable().setModel(model);
+            tableColumnModel = MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getColumnModel();
             tableColumnModel.getColumn(headerNames.length - 1).
-                    setCellRenderer(new TableInCellButtonColumn(MaTemplateMsgForm.getInstance().getTemplateMsgDataTable(), headerNames.length - 1));
+                    setCellRenderer(new TableInCellButtonColumn(MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable(), headerNames.length - 1));
             tableColumnModel.getColumn(headerNames.length - 1).
-                    setCellEditor(new TableInCellButtonColumn(MaTemplateMsgForm.getInstance().getTemplateMsgDataTable(), headerNames.length - 1));
+                    setCellEditor(new TableInCellButtonColumn(MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable(), headerNames.length - 1));
 
             // 设置列宽
             tableColumnModel.getColumn(3).setPreferredWidth(46);
@@ -101,14 +105,14 @@ public void init(String msgName) {
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         int msgId = 0;
         boolean existSameMsg = false;
 
-        List tMsgWxUniformList = msgWxUniformMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE, msgName);
-        if (tMsgWxUniformList.size() > 0) {
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
-            msgId = tMsgWxUniformList.get(0).getId();
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -124,38 +128,27 @@ public void save(String msgName) {
             String templateMiniAppid = MpTemplateMsgForm.getInstance().getMsgTemplateMiniAppidTextField().getText();
             String templateMiniPagePath = MpTemplateMsgForm.getInstance().getMsgTemplateMiniPagePathTextField().getText();
 
-            String maTemplateId = MaTemplateMsgForm.getInstance().getMsgTemplateIdTextField().getText();
-            String page = MaTemplateMsgForm.getInstance().getMsgTemplateUrlTextField().getText();
-            String templateKeyWord = MaTemplateMsgForm.getInstance().getMsgTemplateKeyWordTextField().getText();
+            String maTemplateId = MaSubscribeMsgForm.getInstance().getMsgTemplateIdTextField().getText();
+            String page = MaSubscribeMsgForm.getInstance().getMsgTemplateUrlTextField().getText();
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgWxUniform tMsgWxUniform = new TMsgWxUniform();
-            tMsgWxUniform.setMsgType(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE);
-            tMsgWxUniform.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgWxUniform.setMpTemplateId(mpTemplateId);
             tMsgWxUniform.setMaTemplateId(maTemplateId);
             tMsgWxUniform.setMpUrl(templateUrl);
             tMsgWxUniform.setMaAppid(templateMiniAppid);
             tMsgWxUniform.setMaPagePath(templateMiniPagePath);
             tMsgWxUniform.setPage(page);
-            tMsgWxUniform.setEmphasisKeyword(templateKeyWord);
-            tMsgWxUniform.setCreateTime(now);
-            tMsgWxUniform.setModifiedTime(now);
-
-            if (existSameMsg) {
-                msgWxUniformMapper.updateByMsgTypeAndMsgName(tMsgWxUniform);
-            } else {
-                msgWxUniformMapper.insertSelective(tMsgWxUniform);
-                msgId = tMsgWxUniform.getId();
-            }
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
 
-            // 保存模板数据
-            // 如果是覆盖保存,则先清空之前的模板数据
-            if (existSameMsg) {
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE * MessageTypeEnum.MP_TEMPLATE_CODE, msgId);
-                templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE * MessageTypeEnum.MA_TEMPLATE_CODE, msgId);
-            }
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
 
             // -------------公众号模板数据开始
             // 如果table为空,则初始化
@@ -167,50 +160,56 @@ public void save(String msgName) {
             DefaultTableModel tableModel = (DefaultTableModel) MpTemplateMsgForm.getInstance().getTemplateMsgDataTable()
                     .getModel();
             int rowCount = tableModel.getRowCount();
+            List templateDataListMp = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
                 String color = ((String) tableModel.getValueAt(i, 2)).trim();
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE * MessageTypeEnum.MP_TEMPLATE_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
                 tTemplateData.setColor(color);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataListMp.add(tTemplateData);
             }
             // -------------公众号模板数据结束
 
             // -------------小程序模板数据开始
             // 如果table为空,则初始化
-            if (MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
-                MaTemplateMsgForm.initTemplateDataTable();
+            if (MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
+                MaSubscribeMsgForm.initTemplateDataTable();
             }
 
             // 逐行读取
-            tableModel = (DefaultTableModel) MaTemplateMsgForm.getInstance().getTemplateMsgDataTable()
+            tableModel = (DefaultTableModel) MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable()
                     .getModel();
             rowCount = tableModel.getRowCount();
+            List templateDataListMa = new ArrayList<>();
             for (int i = 0; i < rowCount; i++) {
                 String name = (String) tableModel.getValueAt(i, 0);
                 String value = (String) tableModel.getValueAt(i, 1);
                 String color = ((String) tableModel.getValueAt(i, 2)).trim();
 
-                TTemplateData tTemplateData = new TTemplateData();
-                tTemplateData.setMsgType(MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE * MessageTypeEnum.MA_TEMPLATE_CODE);
-                tTemplateData.setMsgId(msgId);
+                TemplateData tTemplateData = new TemplateData();
                 tTemplateData.setName(name);
                 tTemplateData.setValue(value);
                 tTemplateData.setColor(color);
-                tTemplateData.setCreateTime(now);
-                tTemplateData.setModifiedTime(now);
 
-                templateDataMapper.insert(tTemplateData);
+                templateDataListMa.add(tTemplateData);
             }
+
+            tMsgWxUniform.setTemplateDataListMp(templateDataListMp);
+            tMsgWxUniform.setTemplateDataListMa(templateDataListMa);
+
+            msg.setContent(JSON.toJSONString(tMsgWxUniform));
+            if (existSameMsg) {
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
+            } else {
+                msgMapper.insertSelective(msg);
+            }
+
             // -------------小程序模板数据结束
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
                     JOptionPane.INFORMATION_MESSAGE);
@@ -227,8 +226,9 @@ public static WxUniformMsgForm getInstance() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
-        MaTemplateMsgForm.clearAllField();
-        MpTemplateMsgForm.clearAllField();
+    @Override
+    public void clearAllField() {
+        MaSubscribeMsgForm.getInstance().clearAllField();
+        MpTemplateMsgForm.getInstance().clearAllField();
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/YunpianMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/YunpianMsgForm.java
index 53d96bc86..d1c27ac3b 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/YunpianMsgForm.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/YunpianMsgForm.java
@@ -1,9 +1,12 @@
 package com.fangxuele.tool.push.ui.form.msg;
 
-import com.fangxuele.tool.push.dao.TMsgSmsMapper;
+import cn.hutool.json.JSONUtil;
+import com.fangxuele.tool.push.dao.TMsgMapper;
+import com.fangxuele.tool.push.domain.TMsg;
 import com.fangxuele.tool.push.domain.TMsgSms;
 import com.fangxuele.tool.push.logic.MessageTypeEnum;
 import com.fangxuele.tool.push.ui.form.MainWindow;
+import com.fangxuele.tool.push.ui.form.MessageEditForm;
 import com.fangxuele.tool.push.util.MybatisUtil;
 import com.fangxuele.tool.push.util.SqliteUtil;
 import com.intellij.uiDesigner.core.GridConstraints;
@@ -12,8 +15,10 @@
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.text.StyleContext;
 import java.awt.*;
-import java.util.List;
+import java.util.Locale;
 
 /**
  * 
@@ -30,25 +35,30 @@ public class YunpianMsgForm implements IMsgForm {
 
     private static YunpianMsgForm yunpianMsgForm;
 
-    private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class);
+    private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class);
 
     @Override
-    public void init(String msgName) {
+    public void init(Integer msgId) {
         clearAllField();
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.YUN_PIAN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
-            TMsgSms tMsgSms = tMsgSmsList.get(0);
+        TMsg tMsg = msgMapper.selectByPrimaryKey(msgId);
+        if (tMsg != null) {
+            TMsgSms tMsgSms = JSONUtil.toBean(tMsg.getContent(), TMsgSms.class);
             getInstance().getMsgYunpianMsgContentTextField().setText(tMsgSms.getContent());
+
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            messageEditForm.getMsgNameField().setText(tMsg.getMsgName());
+            messageEditForm.getPreviewUserField().setText(tMsg.getPreviewUser());
         }
     }
 
     @Override
-    public void save(String msgName) {
+    public void save(Integer accountId, String msgName) {
         boolean existSameMsg = false;
-
-        List tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.YUN_PIAN_CODE, msgName);
-        if (tMsgSmsList.size() > 0) {
+        Integer msgId = null;
+        TMsg tMsg = msgMapper.selectByUnique(MessageTypeEnum.YUN_PIAN_CODE, accountId, msgName);
+        if (tMsg != null) {
             existSameMsg = true;
+            msgId = tMsg.getId();
         }
 
         int isCover = JOptionPane.NO_OPTION;
@@ -62,17 +72,24 @@ public void save(String msgName) {
 
             String now = SqliteUtil.nowDateForSqlite();
 
+            TMsg msg = new TMsg();
             TMsgSms tMsgSms = new TMsgSms();
-            tMsgSms.setMsgType(MessageTypeEnum.YUN_PIAN_CODE);
-            tMsgSms.setMsgName(msgName);
+            msg.setMsgType(MessageTypeEnum.YUN_PIAN_CODE);
+            msg.setAccountId(accountId);
+            msg.setMsgName(msgName);
             tMsgSms.setContent(yunpianMsgContent);
-            tMsgSms.setCreateTime(now);
-            tMsgSms.setModifiedTime(now);
+            msg.setCreateTime(now);
+            msg.setModifiedTime(now);
 
+            MessageEditForm messageEditForm = MessageEditForm.getInstance();
+            msg.setPreviewUser(messageEditForm.getPreviewUserField().getText());
+
+            msg.setContent(JSONUtil.toJsonStr(tMsgSms));
             if (existSameMsg) {
-                msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms);
+                msg.setId(msgId);
+                msgMapper.updateByPrimaryKeySelective(msg);
             } else {
-                msgSmsMapper.insertSelective(tMsgSms);
+                msgMapper.insertSelective(msg);
             }
 
             JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功",
@@ -90,7 +107,8 @@ public static YunpianMsgForm getInstance() {
     /**
      * 清空所有界面字段
      */
-    public static void clearAllField() {
+    @Override
+    public void clearAllField() {
         getInstance().getMsgYunpianMsgContentTextField().setText("");
     }
 
@@ -137,7 +155,10 @@ public static void clearAllField() {
                 resultName = currentFont.getName();
             }
         }
-        return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
+        boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
+        Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
+        return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
     }
 
     /**
diff --git a/src/main/java/com/fangxuele/tool/push/ui/frame/HttpResultFrame.java b/src/main/java/com/fangxuele/tool/push/ui/frame/HttpResultFrame.java
index a24d9a643..4121a6858 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/frame/HttpResultFrame.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/frame/HttpResultFrame.java
@@ -1,15 +1,10 @@
 package com.fangxuele.tool.push.ui.frame;
 
-import com.apple.eawt.Application;
-import com.fangxuele.tool.push.ui.UiConsts;
 import com.fangxuele.tool.push.ui.form.HttpResultForm;
 import com.fangxuele.tool.push.util.ComponentUtil;
-import com.fangxuele.tool.push.util.SystemUtil;
-import com.google.common.collect.Lists;
 
 import javax.swing.*;
 import java.awt.*;
-import java.util.List;
 
 /**
  * 
@@ -29,22 +24,6 @@ public void init() {
         String title = "Http请求结果";
         this.setName(title);
         this.setTitle(title);
-        List images = Lists.newArrayList();
-        images.add(UiConsts.IMAGE_LOGO_1024);
-        images.add(UiConsts.IMAGE_LOGO_512);
-        images.add(UiConsts.IMAGE_LOGO_256);
-        images.add(UiConsts.IMAGE_LOGO_128);
-        images.add(UiConsts.IMAGE_LOGO_64);
-        images.add(UiConsts.IMAGE_LOGO_48);
-        images.add(UiConsts.IMAGE_LOGO_32);
-        images.add(UiConsts.IMAGE_LOGO_24);
-        images.add(UiConsts.IMAGE_LOGO_16);
-        this.setIconImages(images);
-        // Mac系统Dock图标
-        if (SystemUtil.isMacOs()) {
-            Application application = Application.getApplication();
-            application.setDockIconImage(UiConsts.IMAGE_LOGO_1024);
-        }
 
         ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.6, 0.66);
     }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java b/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java
index 96acec844..41c8367a8 100644
--- a/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java
+++ b/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java
@@ -1,23 +1,12 @@
 package com.fangxuele.tool.push.ui.frame;
 
 import cn.hutool.core.thread.ThreadUtil;
-import com.apple.eawt.Application;
 import com.fangxuele.tool.push.ui.UiConsts;
-import com.fangxuele.tool.push.ui.listener.AboutListener;
-import com.fangxuele.tool.push.ui.listener.BoostListener;
-import com.fangxuele.tool.push.ui.listener.FrameListener;
-import com.fangxuele.tool.push.ui.listener.HelpListener;
-import com.fangxuele.tool.push.ui.listener.MemberListener;
-import com.fangxuele.tool.push.ui.listener.MessageTypeListener;
-import com.fangxuele.tool.push.ui.listener.MsgEditListener;
-import com.fangxuele.tool.push.ui.listener.MsgManageListener;
-import com.fangxuele.tool.push.ui.listener.PushHisListener;
-import com.fangxuele.tool.push.ui.listener.PushListener;
-import com.fangxuele.tool.push.ui.listener.ScheduleListener;
-import com.fangxuele.tool.push.ui.listener.SettingListener;
-import com.fangxuele.tool.push.ui.listener.TabListener;
+import com.fangxuele.tool.push.ui.component.TopMenuBar;
+import com.fangxuele.tool.push.ui.listener.*;
 import com.fangxuele.tool.push.util.ComponentUtil;
 import com.fangxuele.tool.push.util.SystemUtil;
+import com.formdev.flatlaf.util.SystemInfo;
 import org.apache.commons.compress.utils.Lists;
 
 import javax.swing.*;
@@ -50,14 +39,18 @@ public void init() {
         images.add(UiConsts.IMAGE_LOGO_24);
         images.add(UiConsts.IMAGE_LOGO_16);
         this.setIconImages(images);
-        // Mac系统Dock图标
-        if (SystemUtil.isMacOs()) {
-            Application application = Application.getApplication();
-            application.setDockIconImage(UiConsts.IMAGE_LOGO_1024);
-            application.setEnabledAboutMenu(false);
-            application.setEnabledPreferencesMenu(false);
+
+        if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) {
+            this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true);
+            this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true);
+            this.getRootPane().putClientProperty("apple.awt.fullscreenable", true);
+            this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false);
         }
 
+        TopMenuBar topMenuBar = TopMenuBar.getInstance();
+        topMenuBar.init();
+        setJMenuBar(topMenuBar);
+
         ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.8, 0.88);
     }
 
@@ -65,17 +58,16 @@ public void init() {
      * 添加事件监听
      */
     public void addListeners() {
-        ThreadUtil.execute(MessageTypeListener::addListeners);
         ThreadUtil.execute(AboutListener::addListeners);
+        ThreadUtil.execute(MessageTypeListener::addListeners);
         ThreadUtil.execute(HelpListener::addListeners);
-        ThreadUtil.execute(PushHisListener::addListeners);
-        ThreadUtil.execute(SettingListener::addListeners);
-        ThreadUtil.execute(MsgEditListener::addListeners);
-        ThreadUtil.execute(MsgManageListener::addListeners);
-        ThreadUtil.execute(MemberListener::addListeners);
-        ThreadUtil.execute(PushListener::addListeners);
-        ThreadUtil.execute(BoostListener::addListeners);
-        ThreadUtil.execute(ScheduleListener::addListeners);
+        ThreadUtil.execute(AccountManageListener::addListeners);
+        ThreadUtil.execute(AccountEditListener::addListeners);
+        ThreadUtil.execute(MessageManageListener::addListeners);
+        ThreadUtil.execute(MessageEditListener::addListeners);
+        ThreadUtil.execute(PeopleManageListener::addListeners);
+        ThreadUtil.execute(PeopleEditListener::addListeners);
+        ThreadUtil.execute(TaskListener::addListeners);
         ThreadUtil.execute(TabListener::addListeners);
         ThreadUtil.execute(FrameListener::addListeners);
     }
diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/AccountEditListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/AccountEditListener.java
new file mode 100644
index 000000000..c57a72904
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/ui/listener/AccountEditListener.java
@@ -0,0 +1,48 @@
+package com.fangxuele.tool.push.ui.listener;
+
+import cn.hutool.log.Log;
+import cn.hutool.log.LogFactory;
+import com.fangxuele.tool.push.ui.form.*;
+import com.fangxuele.tool.push.ui.form.account.AccountFormFactory;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.swing.*;
+
+/**
+ * 
+ * 编辑账号tab相关事件监听
+ * 
+ * + * @author RememBerBer + * @since 2021/3/19. + */ +public class AccountEditListener { + private static final Log logger = LogFactory.get(); + + public static void addListeners() { + AccountEditForm accountEditForm = AccountEditForm.getInstance(); + + // 保存按钮事件 + accountEditForm.getAccountSaveButton().addActionListener(e -> { + String accountName = accountEditForm.getAccountNameField().getText(); + if (StringUtils.isBlank(accountName)) { + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "请填写账号名称!\n\n", "失败", + JOptionPane.ERROR_MESSAGE); + return; + } + + try { + AccountFormFactory.getAccountForm().save(accountName); + AccountManageForm.init(); + MessageManageForm.init(); + PeopleManageForm.init(); + } catch (Exception e1) { + JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + + }); + + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/AccountManageListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/AccountManageListener.java new file mode 100644 index 000000000..327706f44 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/AccountManageListener.java @@ -0,0 +1,87 @@ +package com.fangxuele.tool.push.ui.listener; + +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TAccountMapper; +import com.fangxuele.tool.push.ui.form.*; +import com.fangxuele.tool.push.util.MybatisUtil; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + *
+ * 编辑账号tab相关事件监听
+ * 
+ * + * @author RememBerBer + * @since 2021/3/18. + */ +public class AccountManageListener { + private static final Log logger = LogFactory.get(); + + private static TAccountMapper accountMapper = MybatisUtil.getSqlSession().getMapper(TAccountMapper.class); + + public static void addListeners() { + JTable accountListTable = AccountManageForm.getInstance().getAccountListTable(); + JSplitPane accountPanel = MainWindow.getInstance().getAccountPanel(); + + // 点击左侧表格事件 + accountListTable.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + int selectedRow = accountListTable.getSelectedRow(); + String selectedMsgName = accountListTable + .getValueAt(selectedRow, 0).toString(); + + AccountEditForm.init(selectedMsgName); + super.mousePressed(e); + } + }); + + // 账号管理-删除 + AccountManageForm.getInstance().getAccountListTableDeleteButton().addActionListener(e -> ThreadUtil.execute(() -> { + try { + int[] selectedRows = accountListTable.getSelectedRows(); + + if (selectedRows.length == 0) { + JOptionPane.showMessageDialog(accountPanel, "请至少选择一个!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else { + int isDelete = JOptionPane.showConfirmDialog(accountPanel, "确认删除?", "确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + DefaultTableModel tableModel = (DefaultTableModel) accountListTable + .getModel(); + int msgType = App.config.getMsgType(); + + for (int i = selectedRows.length; i > 0; i--) { + int selectedRow = accountListTable.getSelectedRow(); + String accountName = (String) tableModel.getValueAt(selectedRow, 0); + accountMapper.deleteByMsgTypeAndAccountName(msgType, accountName); + tableModel.removeRow(selectedRow); + } + AccountEditForm.init(null); + PeopleManageForm.init(); + } + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(accountPanel, "删除失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + })); + + // 编辑账号-新建 + AccountManageForm.getInstance().getCreateAccountButton().addActionListener(e -> { +// MessageTypeForm.init(); + AccountEditForm.clear(); + + AccountEditForm.getInstance().getAccountNameField().grabFocus(); + }); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/BoostListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/BoostListener.java deleted file mode 100644 index 565ca1a94..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/BoostListener.java +++ /dev/null @@ -1,369 +0,0 @@ -package com.fangxuele.tool.push.ui.listener; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.cron.CronUtil; -import cn.hutool.cron.pattern.CronPattern; -import cn.hutool.cron.pattern.CronPatternUtil; -import cn.hutool.cron.task.Task; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.BoostPushRunThread; -import com.fangxuele.tool.push.logic.MessageTypeEnum; -import com.fangxuele.tool.push.logic.PushControl; -import com.fangxuele.tool.push.logic.PushData; -import com.fangxuele.tool.push.ui.UiConsts; -import com.fangxuele.tool.push.ui.dialog.CommonTipsDialog; -import com.fangxuele.tool.push.ui.form.BoostForm; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.ScheduleForm; -import com.fangxuele.tool.push.util.ComponentUtil; -import org.apache.commons.compress.utils.Lists; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.commons.lang3.time.DateUtils; -import org.apache.http.HttpResponse; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Date; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -/** - *
- * 性能模式监听器
- * 
- * - * @author RememBerBer - * @since 2019/7/3. - */ -public class BoostListener { - - private static final Log logger = LogFactory.get(); - - private static ScheduledExecutorService serviceStartAt; - - private static ScheduledExecutorService serviceStartPerDay; - - private static ScheduledExecutorService serviceStartPerWeek; - - public static void addListeners() { - BoostForm boostForm = BoostForm.getInstance(); - boostForm.getBoostModeHelpLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - CommonTipsDialog dialog = new CommonTipsDialog(); - ComponentUtil.setPreferSizeAndLocateToCenter(dialog, 0.6, 0.7); - StringBuilder tipsBuilder = new StringBuilder(); - tipsBuilder.append("

什么是性能模式?

"); - tipsBuilder.append("

最大限度利用系统资源,提升性能,实验性地不断优化,以期获得更快速的批量推送效果

"); - tipsBuilder.append("

利用异步HTTP、NIO、协程等技术提高批量推送效率

"); - tipsBuilder.append("

不断学习使用新技术,优化无止境,不择手段地提升批量推送速度

"); - tipsBuilder.append("

一个人的力量有限,也希望更多技术大佬提供帮助和支持,一起挑战HTTP极限!

"); - tipsBuilder.append("

注意:性能模式下CPU、内存、网络连接资源占用过大," + - "执行期间如果出现机器卡顿、浏览器无法访问等属正常现象,推送结束即可自动恢复。

"); - - dialog.setHtmlText(tipsBuilder.toString()); - dialog.pack(); - dialog.setVisible(true); - - super.mousePressed(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); - super.mouseEntered(e); - } - - @Override - public void mouseExited(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); - super.mouseExited(e); - } - }); - - // 开始按钮事件 - boostForm.getStartButton().addActionListener((e) -> ThreadUtil.execute(() -> { - PushData.boostMode = true; - if (App.config.getMsgType() != MessageTypeEnum.MP_TEMPLATE_CODE) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "性能模式目前仅支持微信模板消息,后续逐步增加对其他消息类型的支持!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - if (PushControl.pushCheck()) { - int isPush = JOptionPane.showConfirmDialog(boostForm.getBoostPanel(), - "确定开始推送吗?\n\n推送消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - boostForm.getDryRunCheckBox().isSelected() + "\n", "确认推送?", - JOptionPane.YES_NO_OPTION); - if (isPush == JOptionPane.YES_OPTION) { - ThreadUtil.execute(new BoostPushRunThread()); - } - } - })); - - // 按计划执行按钮事件 - boostForm.getScheduledRunButton().addActionListener((e -> ThreadUtil.execute(() -> { - PushData.boostMode = true; - if (App.config.getMsgType() != MessageTypeEnum.MP_TEMPLATE_CODE) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "性能模式目前仅支持微信模板消息,后续逐步增加对其他消息类型的支持!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - if (PushControl.pushCheck()) { - - // 看是否存在设置的计划任务 - boolean existScheduleTask = false; - - // 定时开始 - if (App.config.isRadioStartAt()) { - long startAtMills = DateUtil.parse(App.config.getTextStartAt(), DatePattern.NORM_DATETIME_PATTERN).getTime(); - if (startAtMills < System.currentTimeMillis()) { - JOptionPane.showMessageDialog(boostForm.getBoostPanel(), "计划开始推送时间不能小于系统当前时间!\n\n请检查计划任务设置!\n\n", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - int isSchedulePush = JOptionPane.showConfirmDialog(boostForm.getBoostPanel(), - "将在" + - App.config.getTextStartAt() + - "推送\n\n消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - boostForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.scheduling = true; - // 按钮状态 - boostForm.getScheduledRunButton().setEnabled(false); - boostForm.getStartButton().setEnabled(false); - boostForm.getStopButton().setText("停止计划任务"); - boostForm.getStopButton().setEnabled(true); - - boostForm.getScheduledTaskLabel().setVisible(true); - boostForm.getScheduledTaskLabel().setText("计划任务执行中:将在" + - App.config.getTextStartAt() + - "开始推送"); - - serviceStartAt = Executors.newSingleThreadScheduledExecutor(); - serviceStartAt.schedule(new BoostPushRunThread(), startAtMills - System.currentTimeMillis(), TimeUnit.MILLISECONDS); - } - existScheduleTask = true; - } - - // 每天固定时间开始 - if (App.config.isRadioPerDay()) { - long startPerDayMills = DateUtil.parse(DateUtil.today() + " " + App.config.getTextPerDay(), DatePattern.NORM_DATETIME_PATTERN).getTime(); - - int isSchedulePush = JOptionPane.showConfirmDialog(boostForm.getBoostPanel(), - "将在每天" + - App.config.getTextPerDay() + - "推送\n\n消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - boostForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.fixRateScheduling = true; - // 按钮状态 - boostForm.getScheduledRunButton().setEnabled(false); - boostForm.getStartButton().setEnabled(false); - boostForm.getStopButton().setText("停止计划任务"); - boostForm.getStopButton().setEnabled(true); - - boostForm.getScheduledTaskLabel().setVisible(true); - boostForm.getScheduledTaskLabel().setText("计划任务执行中:将在每天" + - App.config.getTextPerDay() + - "开始推送"); - - serviceStartPerDay = Executors.newSingleThreadScheduledExecutor(); - long millisBetween = startPerDayMills - System.currentTimeMillis(); - long delay = millisBetween < 0 ? millisBetween + 24 * 60 * 60 * 1000 : millisBetween; - serviceStartPerDay.scheduleAtFixedRate(new BoostPushRunThread(), delay, 24 * 60 * 60 * 1000, TimeUnit.MILLISECONDS); - } - existScheduleTask = true; - } - - // 每周固定时间开始 - if (App.config.isRadioPerWeek()) { - - long todaySetMills = DateUtil.parse(DateUtil.today() + " " + App.config.getTextPerWeekTime(), DatePattern.NORM_DATETIME_PATTERN).getTime(); - int dayBetween = ScheduleForm.getDayOfWeek(App.config.getTextPerWeekWeek()) - DateUtil.thisDayOfWeek(); - long startPerWeekMills = dayBetween < 0 ? (dayBetween + 7) * 24 * 60 * 60 * 1000 : dayBetween * 24 * 60 * 60 * 1000; - - int isSchedulePush = JOptionPane.showConfirmDialog(boostForm.getBoostPanel(), - "将在每周" + App.config.getTextPerWeekWeek() + - App.config.getTextPerWeekTime() + - "推送\n\n消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - boostForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.scheduling = true; - PushData.fixRateScheduling = true; - // 按钮状态 - boostForm.getScheduledRunButton().setEnabled(false); - boostForm.getStartButton().setEnabled(false); - boostForm.getStopButton().setText("停止计划任务"); - boostForm.getStopButton().setEnabled(true); - - boostForm.getScheduledTaskLabel().setVisible(true); - boostForm.getScheduledTaskLabel().setText("计划任务执行中:将在每周" + - App.config.getTextPerWeekWeek() + - App.config.getTextPerWeekTime() + - "开始推送"); - - serviceStartPerWeek = Executors.newSingleThreadScheduledExecutor(); - long millisBetween = startPerWeekMills + todaySetMills - System.currentTimeMillis(); - long delay = millisBetween < 0 ? millisBetween + 7 * 24 * 60 * 60 * 1000 : millisBetween; - serviceStartPerWeek.scheduleAtFixedRate(new BoostPushRunThread(), delay, 7 * 24 * 60 * 60 * 1000, TimeUnit.MILLISECONDS); - } - existScheduleTask = true; - } - - // 按Cron表达式触发 - if (App.config.isRadioCron()) { - - List latest5RunTimeList = Lists.newArrayList(); - Date now = new Date(); - for (int i = 0; i < 5; i++) { - Date date = CronPatternUtil.nextDateAfter(new CronPattern(App.config.getTextCron()), DateUtils.addDays(now, i), true); - latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); - } - - int isSchedulePush = JOptionPane.showConfirmDialog(boostForm.getBoostPanel(), - "将按" + - App.config.getTextCron() + - "表达式触发推送\n\n" + - "最近5次运行时间:\n" + - String.join("\n", latest5RunTimeList) + - "\n\n消息名称:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n推送人数:" + PushData.allUser.size() + - "\n空跑模式:" + - boostForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.fixRateScheduling = true; - // 按钮状态 - boostForm.getScheduledRunButton().setEnabled(false); - boostForm.getStartButton().setEnabled(false); - boostForm.getStopButton().setText("停止计划任务"); - boostForm.getStopButton().setEnabled(true); - - boostForm.getScheduledTaskLabel().setVisible(true); - boostForm.getScheduledTaskLabel().setText("计划任务执行中,下一次执行时间:" + latest5RunTimeList.get(0)); - - // 支持秒级别定时任务 - CronUtil.setMatchSecond(true); - CronUtil.schedule(App.config.getTextCron(), (Task) () -> new BoostPushRunThread().start()); - CronUtil.start(); - } - existScheduleTask = true; - } - - if (!existScheduleTask) { - JOptionPane.showMessageDialog(boostForm.getBoostPanel(), "请先设置计划任务!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } - } - }))); - - // 停止按钮事件 - boostForm.getStopButton().addActionListener((e) -> { - ThreadUtil.execute(() -> { - if (PushData.scheduling) { - boostForm.getScheduledTaskLabel().setText(""); - if (serviceStartAt != null) { - serviceStartAt.shutdownNow(); - } - boostForm.getStartButton().setEnabled(true); - boostForm.getScheduledRunButton().setEnabled(true); - boostForm.getStopButton().setText("停止"); - boostForm.getStopButton().setEnabled(false); - boostForm.getStartButton().updateUI(); - boostForm.getScheduledRunButton().updateUI(); - boostForm.getStopButton().updateUI(); - boostForm.getScheduledTaskLabel().setVisible(false); - PushData.scheduling = false; - PushData.running = false; - } - - if (PushData.fixRateScheduling) { - boostForm.getScheduledTaskLabel().setText(""); - if (serviceStartPerDay != null) { - serviceStartPerDay.shutdownNow(); - } - if (serviceStartPerWeek != null) { - serviceStartPerWeek.shutdownNow(); - } - try { - CronUtil.stop(); - } catch (Exception e1) { - logger.warn(e1.toString()); - } - boostForm.getStartButton().setEnabled(true); - boostForm.getScheduledRunButton().setEnabled(true); - boostForm.getStopButton().setText("停止"); - boostForm.getStopButton().setEnabled(false); - boostForm.getStartButton().updateUI(); - boostForm.getScheduledRunButton().updateUI(); - boostForm.getStopButton().updateUI(); - boostForm.getScheduledTaskLabel().setVisible(false); - PushData.fixRateScheduling = false; - PushData.running = false; - } - - if (PushData.running) { - int isStop = JOptionPane.showConfirmDialog(boostForm.getBoostPanel(), - "确定停止当前的推送吗?", "确认停止?", - JOptionPane.YES_NO_OPTION); - if (isStop == JOptionPane.YES_OPTION) { - PushData.running = false; - boostForm.getStartButton().setEnabled(true); - boostForm.getScheduledRunButton().setEnabled(true); - boostForm.getStopButton().setText("停止"); - boostForm.getStopButton().setEnabled(false); - boostForm.getStartButton().updateUI(); - boostForm.getScheduledRunButton().updateUI(); - boostForm.getStopButton().updateUI(); - boostForm.getScheduledTaskLabel().setVisible(false); - } - } - for (Future httpResponseFuture : BoostPushRunThread.futureList) { - httpResponseFuture.cancel(true); - } - }); - }); - } - - static void refreshPushInfo() { - BoostForm boostForm = BoostForm.getInstance(); - // 总记录数 - long totalCount = PushData.allUser.size(); - boostForm.getMemberCountLabel().setText("消息总数:" + totalCount); - // 可用处理器核心 - boostForm.getProcessorCountLabel().setText("可用处理器核心:" + Runtime.getRuntime().availableProcessors()); - // JVM内存占用 - boostForm.getJvmMemoryLabel().setText("JVM内存占用:" + FileUtil.readableFileSize(Runtime.getRuntime().totalMemory()) + "/" + FileUtil.readableFileSize(Runtime.getRuntime().maxMemory())); - } -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java index 6e203e1dc..cbea3798d 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java @@ -2,13 +2,10 @@ import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.PushForm; import javax.swing.*; import java.awt.*; -import java.awt.event.KeyEvent; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; +import java.awt.event.*; import static com.fangxuele.tool.push.App.mainFrame; @@ -47,13 +44,9 @@ public void windowDeactivated(WindowEvent e) { @Override public void windowClosing(WindowEvent e) { - if (!PushForm.getInstance().getPushStartButton().isEnabled()) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getPushPanel(), - "有推送任务正在进行!\n\n为避免数据丢失,请先停止!\n\n", "Sorry~", - JOptionPane.WARNING_MESSAGE); - } else { + mainFrame.setExtendedState(JFrame.ICONIFIED); + if (!App.config.isCloseToTray()) { App.sqlSession.close(); - mainFrame.dispose(); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } @@ -65,6 +58,43 @@ public void windowClosed(WindowEvent e) { @Override public void windowActivated(WindowEvent e) { + if (App.config.isDefaultMaxWindow()) { + // 低分辨率下自动最大化窗口 + App.mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); + } + } + }); + + // 鼠标双击最大化/还原 + App.mainFrame.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 && !e.isConsumed()) { + if (App.mainFrame.getExtendedState() == JFrame.MAXIMIZED_BOTH) { + App.mainFrame.setExtendedState(JFrame.NORMAL); + } else { + App.mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); + } + } + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { } }); diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MemberListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MemberListener.java deleted file mode 100644 index cd3fe924d..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MemberListener.java +++ /dev/null @@ -1,1386 +0,0 @@ -package com.fangxuele.tool.push.ui.listener; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.file.FileReader; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.db.DbUtil; -import cn.hutool.db.Entity; -import cn.hutool.db.handler.EntityListHandler; -import cn.hutool.db.sql.SqlExecutor; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import cn.hutool.poi.excel.BigExcelWriter; -import cn.hutool.poi.excel.ExcelReader; -import cn.hutool.poi.excel.ExcelUtil; -import com.dingtalk.api.DefaultDingTalkClient; -import com.dingtalk.api.DingTalkClient; -import com.dingtalk.api.request.OapiDepartmentListRequest; -import com.dingtalk.api.request.OapiUserSimplelistRequest; -import com.dingtalk.api.response.OapiDepartmentListResponse; -import com.dingtalk.api.response.OapiUserSimplelistResponse; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TWxMpUserMapper; -import com.fangxuele.tool.push.domain.TWxMpUser; -import com.fangxuele.tool.push.logic.MessageTypeEnum; -import com.fangxuele.tool.push.logic.PushData; -import com.fangxuele.tool.push.logic.msgsender.DingMsgSender; -import com.fangxuele.tool.push.logic.msgsender.WxCpMsgSender; -import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender; -import com.fangxuele.tool.push.ui.component.TableInCellImageLabelRenderer; -import com.fangxuele.tool.push.ui.dialog.ExportDialog; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.MemberForm; -import com.fangxuele.tool.push.ui.form.msg.DingMsgForm; -import com.fangxuele.tool.push.ui.form.msg.WxCpMsgForm; -import com.fangxuele.tool.push.util.ConsoleUtil; -import com.fangxuele.tool.push.util.FileCharSetUtil; -import com.fangxuele.tool.push.util.HikariUtil; -import com.fangxuele.tool.push.util.JTableUtil; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.google.common.collect.Maps; -import com.opencsv.CSVReader; -import com.opencsv.CSVWriter; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.cp.bean.WxCpDepart; -import me.chanjar.weixin.cp.bean.WxCpTag; -import me.chanjar.weixin.cp.bean.WxCpUser; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import me.chanjar.weixin.mp.bean.result.WxMpUserList; -import me.chanjar.weixin.mp.bean.tag.WxTagListUser; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.apache.commons.compress.utils.Lists; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateFormatUtils; - -import javax.swing.*; -import javax.swing.filechooser.FileFilter; -import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.sql.Connection; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -/** - *
- * 准备目标数据tab相关事件监听
- * 
- * - * @author RememBerBer - * @since 2017/6/19. - */ -public class MemberListener { - private static final Log logger = LogFactory.get(); - - private static Map userTagMap = new HashMap<>(); - - /** - * 用于导入多个标签的用户时去重判断 - */ - public static Set tagUserSet; - - public static final String TXT_FILE_DATA_SEPERATOR_REGEX = "\\|"; - - private static List toSearchRowsList; - - /** - * 企业号标签名称->标签ID - */ - private static Map wxCpTagNameToIdMap = Maps.newHashMap(); - - /** - * 企业号标签ID>标签名称 - */ - private static Map wxCpIdToTagNameMap = Maps.newHashMap(); - - /** - * 企业号部门名称->部门ID - */ - private static Map wxCpDeptNameToIdMap = Maps.newHashMap(); - - /** - * 企业号部门ID>部门名称 - */ - private static Map wxCpIdToDeptNameMap = Maps.newHashMap(); - - private static TWxMpUserMapper tWxMpUserMapper = MybatisUtil.getSqlSession().getMapper(TWxMpUserMapper.class); - - public static void addListeners() { - MemberForm memberForm = MemberForm.getInstance(); - JProgressBar progressBar = memberForm.getMemberTabImportProgressBar(); - JTextField filePathField = memberForm.getMemberFilePathField(); - JLabel memberCountLabel = memberForm.getMemberTabCountLabel(); - JPanel memberPanel = memberForm.getMemberPanel(); - JTable memberListTable = memberForm.getMemberListTable(); - - // 按数量导入按钮事件 - memberForm.getImportFromNumButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - if (StringUtils.isBlank(memberForm.getImportNumTextField().getText())) { - JOptionPane.showMessageDialog(memberPanel, "请填写数量!", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - int currentImported = 0; - - try { - int importNum = Integer.parseInt(memberForm.getImportNumTextField().getText()); - progressBar.setVisible(true); - progressBar.setMaximum(importNum); - - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - for (int i = 0; i < importNum; i++) { - String[] array = new String[1]; - array[0] = String.valueOf(i); - PushData.allUser.add(array); - currentImported++; - memberCountLabel.setText(String.valueOf(currentImported)); - } - - renderMemberListTable(); - - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - e1.printStackTrace(); - } finally { - progressBar.setMaximum(100); - progressBar.setValue(100); - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - } - }); - }); - - // 从文件导入按钮事件 - memberForm.getImportFromFileButton().addActionListener(e -> ThreadUtil.execute(MemberListener::importFromFile)); - - // 从sql导入 按钮事件 - memberForm.getImportFromSqlButton().addActionListener(e -> ThreadUtil.execute(MemberListener::importFromSql)); - - // 公众号-导入全员按钮事件 - memberForm.getMemberImportAllButton().addActionListener(e -> ThreadUtil.execute(MemberListener::importWxAll)); - - // 公众号-刷新可选的标签按钮事件 - memberForm.getMemberImportTagFreshButton().addActionListener(e -> { - WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(); - if (wxMpService.getWxMpConfigStorage() == null) { - return; - } - - try { - List wxUserTagList = wxMpService.getUserTagService().tagGet(); - - memberForm.getMemberImportTagComboBox().removeAllItems(); - userTagMap = new HashMap<>(); - - for (WxUserTag wxUserTag : wxUserTagList) { - String item = wxUserTag.getName() + "/" + wxUserTag.getCount() + "用户"; - memberForm.getMemberImportTagComboBox().addItem(item); - userTagMap.put(item, wxUserTag.getId()); - } - - } catch (WxErrorException e1) { - JOptionPane.showMessageDialog(memberPanel, "刷新失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - e1.printStackTrace(); - } - }); - - // 公众号-导入选择的标签分组用户按钮事件(取并集) - memberForm.getMemberImportTagButton().addActionListener(e -> ThreadUtil.execute(() -> { - try { - if (memberForm.getMemberImportTagComboBox().getSelectedItem() != null - && StringUtils.isNotEmpty(memberForm.getMemberImportTagComboBox().getSelectedItem().toString())) { - - long selectedTagId = userTagMap.get(memberForm.getMemberImportTagComboBox().getSelectedItem()); - getMpUserListByTag(selectedTagId, false); - renderMemberListTable(); - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", - JOptionPane.INFORMATION_MESSAGE); - } else { - JOptionPane.showMessageDialog(memberPanel, "请先选择需要导入的标签!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } - } catch (WxErrorException e1) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - e1.printStackTrace(); - } finally { - progressBar.setIndeterminate(false); - progressBar.setValue(progressBar.getMaximum()); - progressBar.setVisible(false); - } - })); - - // 公众号-导入选择的标签分组用户按钮事件(取交集) - memberForm.getMemberImportTagRetainButton().addActionListener(e -> ThreadUtil.execute(() -> { - try { - if (memberForm.getMemberImportTagComboBox().getSelectedItem() != null - && StringUtils.isNotEmpty(memberForm.getMemberImportTagComboBox().getSelectedItem().toString())) { - - long selectedTagId = userTagMap.get(memberForm.getMemberImportTagComboBox().getSelectedItem()); - getMpUserListByTag(selectedTagId, true); - renderMemberListTable(); - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", - JOptionPane.INFORMATION_MESSAGE); - } else { - JOptionPane.showMessageDialog(memberPanel, "请先选择需要导入的标签!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } - } catch (WxErrorException e1) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - e1.printStackTrace(); - } finally { - progressBar.setIndeterminate(false); - progressBar.setValue(progressBar.getMaximum()); - progressBar.setVisible(false); - } - })); - - // 公众号-清空本地缓存按钮事件 - memberForm.getClearDbCacheButton().addActionListener(e -> { - int count = tWxMpUserMapper.deleteAll(); - JOptionPane.showMessageDialog(memberPanel, "清理完毕!\n\n共清理:" + count + "条本地数据", "提示", - JOptionPane.INFORMATION_MESSAGE); - }); - - // 企业号-按标签导入-刷新 - memberForm.getWxCpTagsRefreshButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - if (WxCpMsgForm.getInstance().getAppNameComboBox().getSelectedItem() == null) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请先在编辑消息tab中选择应用!", "提示", - JOptionPane.ERROR_MESSAGE); - MainWindow.getInstance().getTabbedPane().setSelectedIndex(2); - return; - } - memberForm.getWxCpTagsComboBox().removeAllItems(); - - try { - // 获取标签列表 - List wxCpTagList = WxCpMsgSender.getWxCpService().getTagService().listAll(); - for (WxCpTag wxCpTag : wxCpTagList) { - memberForm.getWxCpTagsComboBox().addItem(wxCpTag.getName()); - wxCpTagNameToIdMap.put(wxCpTag.getName(), wxCpTag.getId()); - wxCpIdToTagNameMap.put(wxCpTag.getId(), wxCpTag.getName()); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "刷新失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } - }); - }); - - // 企业号-按标签导入-导入 - memberForm.getWxCpTagsImportButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - if (memberForm.getWxCpTagsComboBox().getSelectedItem() == null) { - return; - } - try { - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - int importedCount = 0; - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - // 获取标签id - String tagId = wxCpTagNameToIdMap.get(memberForm.getWxCpTagsComboBox().getSelectedItem()); - // 获取用户 - List wxCpUsers = WxCpMsgSender.getWxCpService().getTagService().listUsersByTagId(tagId); - for (WxCpUser wxCpUser : wxCpUsers) { - Long[] depIds = wxCpUser.getDepartIds(); - List deptNameList = Lists.newArrayList(); - if (depIds != null) { - for (Long depId : depIds) { - deptNameList.add(wxCpIdToDeptNameMap.get(depId)); - } - } - String[] dataArray = new String[]{wxCpUser.getUserId(), wxCpUser.getName(), String.join("/", deptNameList)}; - PushData.allUser.add(dataArray); - importedCount++; - memberCountLabel.setText(String.valueOf(importedCount)); - } - renderMemberListTable(); - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } finally { - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - } - - }); - }); - - // 企业号-按部门导入-刷新 - memberForm.getWxCpDeptsRefreshButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - if (WxCpMsgForm.getInstance().getAppNameComboBox().getSelectedItem() == null) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请先在编辑消息tab中选择应用!", "提示", - JOptionPane.ERROR_MESSAGE); - MainWindow.getInstance().getTabbedPane().setSelectedIndex(2); - return; - } - memberForm.getWxCpDeptsComboBox().removeAllItems(); - - try { - // 获取部门列表 - List wxCpDepartList = WxCpMsgSender.getWxCpService().getDepartmentService().list(null); - for (WxCpDepart wxCpDepart : wxCpDepartList) { - memberForm.getWxCpDeptsComboBox().addItem(wxCpDepart.getName()); - wxCpDeptNameToIdMap.put(wxCpDepart.getName(), wxCpDepart.getId()); - wxCpIdToDeptNameMap.put(wxCpDepart.getId(), wxCpDepart.getName()); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "刷新失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } - }); - }); - - // 企业号-按部门导入-导入 - memberForm.getWxCpDeptsImportButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - if (memberForm.getWxCpDeptsComboBox().getSelectedItem() == null) { - return; - } - try { - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - int importedCount = 0; - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - // 获取部门id - Long deptId = wxCpDeptNameToIdMap.get(memberForm.getWxCpDeptsComboBox().getSelectedItem()); - // 获取用户 - List wxCpUsers = WxCpMsgSender.getWxCpService().getUserService().listByDepartment(deptId, true, 0); - for (WxCpUser wxCpUser : wxCpUsers) { - String statusStr = ""; - if (wxCpUser.getStatus() == 1) { - statusStr = "已关注"; - } else if (wxCpUser.getStatus() == 2) { - statusStr = "已冻结"; - } else if (wxCpUser.getStatus() == 4) { - statusStr = "未关注"; - } - Long[] depIds = wxCpUser.getDepartIds(); - List deptNameList = Lists.newArrayList(); - if (depIds != null) { - for (Long depId : depIds) { - deptNameList.add(wxCpIdToDeptNameMap.get(depId)); - } - } - String[] dataArray = new String[]{wxCpUser.getUserId(), wxCpUser.getName(), wxCpUser.getGender().getGenderName(), wxCpUser.getEmail(), String.join("/", deptNameList), wxCpUser.getPosition(), statusStr}; - PushData.allUser.add(dataArray); - importedCount++; - memberCountLabel.setText(String.valueOf(importedCount)); - } - renderMemberListTable(); - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } finally { - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - } - - }); - }); - - // 企业号-导入全部 - memberForm.getWxCpImportAllButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - importWxCpAll(); - }); - }); - - // 钉钉-按部门导入-刷新 - memberForm.getDingDeptsRefreshButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - if (DingMsgForm.getInstance().getAppNameComboBox().getSelectedItem() == null) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请先在编辑消息tab中选择应用!", "提示", - JOptionPane.ERROR_MESSAGE); - MainWindow.getInstance().getTabbedPane().setSelectedIndex(2); - return; - } - memberForm.getDingDeptsComboBox().removeAllItems(); - - try { - // 获取部门列表 - DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/list"); - OapiDepartmentListRequest request = new OapiDepartmentListRequest(); - request.setHttpMethod("GET"); - OapiDepartmentListResponse response = client.execute(request, DingMsgSender.getAccessTokenTimedCache().get("accessToken")); - if (response.getErrcode() != 0) { - JOptionPane.showMessageDialog(memberPanel, "刷新失败!\n\n" + response.getErrmsg(), "失败", - JOptionPane.ERROR_MESSAGE); - return; - } - List departmentList = response.getDepartment(); - for (OapiDepartmentListResponse.Department department : departmentList) { - memberForm.getDingDeptsComboBox().addItem(department.getName()); - wxCpDeptNameToIdMap.put(department.getName(), department.getId()); - wxCpIdToDeptNameMap.put(department.getId(), department.getName()); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "刷新失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } - }); - }); - - // 钉钉-按部门导入-导入 - memberForm.getDingDeptsImportButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - if (memberForm.getDingDeptsComboBox().getSelectedItem() == null) { - return; - } - try { - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - int importedCount = 0; - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - // 获取部门id - Long deptId = wxCpDeptNameToIdMap.get(memberForm.getDingDeptsComboBox().getSelectedItem()); - // 获取用户 - DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/simplelist"); - OapiUserSimplelistRequest request = new OapiUserSimplelistRequest(); - request.setDepartmentId(deptId); - request.setOffset(0L); - request.setSize(100L); - request.setHttpMethod("GET"); - - long offset = 0; - OapiUserSimplelistResponse response = new OapiUserSimplelistResponse(); - while (response.getErrcode() == null || response.getUserlist().size() > 0) { - response = client.execute(request, DingMsgSender.getAccessTokenTimedCache().get("accessToken")); - if (response.getErrcode() != 0) { - if (response.getErrcode() == 60011) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + response.getErrmsg() + "\n\n进入开发者后台,在小程序或者微应用详情的「接口权限」模块,点击申请对应的通讯录接口读写权限", "失败", - JOptionPane.ERROR_MESSAGE); - } else { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + response.getErrmsg(), "失败", JOptionPane.ERROR_MESSAGE); - } - - logger.error(response.getErrmsg()); - return; - } - List userlist = response.getUserlist(); - for (OapiUserSimplelistResponse.Userlist dingUser : userlist) { - String[] dataArray = new String[]{dingUser.getUserid(), dingUser.getName()}; - PushData.allUser.add(dataArray); - importedCount++; - memberCountLabel.setText(String.valueOf(importedCount)); - } - offset += 100; - request.setOffset(offset); - } - renderMemberListTable(); - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } finally { - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - } - - }); - }); - - // 钉钉-导入全部 - memberForm.getDingImportAllButton().addActionListener(e -> { - ThreadUtil.execute(() -> { - importDingAll(); - }); - }); - - // 清除按钮事件 - memberForm.getClearImportButton().addActionListener(e -> { - int isClear = JOptionPane.showConfirmDialog(memberPanel, "确认清除?", "确认", - JOptionPane.YES_NO_OPTION); - if (isClear == JOptionPane.YES_OPTION) { - MemberForm.clearMember(); - } - }); - - // 浏览按钮 - memberForm.getMemberImportExploreButton().addActionListener(e -> { - File beforeFile = new File(filePathField.getText()); - JFileChooser fileChooser; - - if (beforeFile.exists()) { - fileChooser = new JFileChooser(beforeFile); - } else { - fileChooser = new JFileChooser(); - } - - FileFilter filter = new FileNameExtensionFilter("*.txt,*.csv,*.xlsx,*.xls", "txt", "csv", "TXT", "CSV", "xlsx", "xls"); - fileChooser.setFileFilter(filter); - - int approve = fileChooser.showOpenDialog(memberPanel); - if (approve == JFileChooser.APPROVE_OPTION) { - filePathField.setText(fileChooser.getSelectedFile().getAbsolutePath()); - } - - }); - - // 列表-全选按钮事件 - memberForm.getSelectAllButton().addActionListener(e -> ThreadUtil.execute(() -> memberListTable.selectAll())); - - // 列表-删除按钮事件 - memberForm.getDeleteButton().addActionListener(e -> ThreadUtil.execute(() -> { - try { - int[] selectedRows = memberListTable.getSelectedRows(); - if (selectedRows.length == 0) { - JOptionPane.showMessageDialog(memberPanel, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } else { - int isDelete = JOptionPane.showConfirmDialog(memberPanel, "确认删除?", "确认", - JOptionPane.YES_NO_OPTION); - if (isDelete == JOptionPane.YES_OPTION) { - DefaultTableModel tableModel = (DefaultTableModel) memberListTable.getModel(); - for (int i = selectedRows.length; i > 0; i--) { - tableModel.removeRow(memberListTable.getSelectedRow()); - } - memberListTable.updateUI(); - } - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(memberPanel, "删除失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - })); - - // 列表-导入按钮事件 - memberForm.getImportSelectedButton().addActionListener(e -> ThreadUtil.execute(() -> { - try { - int[] selectedRows = memberListTable.getSelectedRows(); - if (selectedRows.length <= 0) { - JOptionPane.showMessageDialog(memberPanel, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } else { - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - progressBar.setIndeterminate(true); - progressBar.setVisible(true); - for (int selectedRow : selectedRows) { - String toImportData = (String) memberListTable.getValueAt(selectedRow, 0); - PushData.allUser.add(toImportData.split(TXT_FILE_DATA_SEPERATOR_REGEX)); - memberCountLabel.setText(String.valueOf(PushData.allUser.size())); - progressBar.setMaximum(100); - progressBar.setValue(100); - progressBar.setIndeterminate(false); - } - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", - JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } finally { - progressBar.setMaximum(100); - progressBar.setValue(100); - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - } - })); - - // 列表-导出按钮事件 - memberForm.getExportButton().addActionListener(e -> ThreadUtil.execute(() -> { - int[] selectedRows = memberListTable.getSelectedRows(); - int columnCount = memberListTable.getColumnCount(); - BigExcelWriter writer = null; - try { - if (selectedRows.length > 0) { - ExportDialog.showDialog(); - if (ExportDialog.confirm) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int approve = fileChooser.showOpenDialog(memberPanel); - String exportPath; - if (approve == JFileChooser.APPROVE_OPTION) { - exportPath = fileChooser.getSelectedFile().getAbsolutePath(); - } else { - return; - } - - List rowData; - List> rows = Lists.newArrayList(); - for (int selectedRow : selectedRows) { - rowData = Lists.newArrayList(); - for (int i = 0; i < columnCount; i++) { - String data = (String) memberListTable.getValueAt(selectedRow, i); - rowData.add(data); - } - rows.add(rowData); - } - String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_"); - String fileName = "MemberExport_" + MessageTypeEnum.getName(App.config.getMsgType()) + "_" + nowTime; - String fileFullName = exportPath + File.separator + fileName; - if (ExportDialog.fileType == ExportDialog.EXCEL) { - fileFullName += ".xlsx"; - //通过工具类创建writer - writer = ExcelUtil.getBigWriter(fileFullName); - //合并单元格后的标题行,使用默认标题样式 - writer.merge(rows.get(0).size() - 1, "目标用户列表导出"); - //一次性写出内容,强制输出标题 - writer.write(rows); - writer.flush(); - } else if (ExportDialog.fileType == ExportDialog.CSV) { - fileFullName += ".csv"; - CSVWriter csvWriter = new CSVWriter(new FileWriter(FileUtil.touch(fileFullName))); - for (List row : rows) { - String[] array = row.toArray(new String[row.size()]); - csvWriter.writeNext(array); - } - csvWriter.flush(); - csvWriter.close(); - } else if (ExportDialog.fileType == ExportDialog.TXT) { - fileFullName += ".txt"; - FileWriter fileWriter = new FileWriter(fileFullName); - int size = rows.size(); - for (int i = 0; i < size; i++) { - List row = rows.get(i); - fileWriter.append(String.join("|", row)); - if (i < size - 1) { - fileWriter.append(StrUtil.CRLF); - } - } - fileWriter.flush(); - fileWriter.close(); - } - JOptionPane.showMessageDialog(memberPanel, "导出成功!", "提示", - JOptionPane.INFORMATION_MESSAGE); - try { - Desktop desktop = Desktop.getDesktop(); - desktop.open(FileUtil.file(fileFullName)); - } catch (Exception e2) { - logger.error(e2); - } - } - } else { - JOptionPane.showMessageDialog(memberPanel, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(memberPanel, "导出失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - })); - - // 列表-搜索按钮事件 - memberForm.getSearchButton().addActionListener(e -> searchEvent()); - - // 列表-搜索框键入回车 - memberForm.getSearchTextField().addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - try { - searchEvent(); - } catch (Exception e1) { - logger.error(e1); - } finally { - super.keyPressed(e); - } - } - }); - - } - - private static void searchEvent() { - JTable memberListTable = MemberForm.getInstance().getMemberListTable(); - ThreadUtil.execute(() -> { - int rowCount = memberListTable.getRowCount(); - int columnCount = memberListTable.getColumnCount(); - try { - if (rowCount > 0 || toSearchRowsList != null) { - if (toSearchRowsList == null) { - toSearchRowsList = Lists.newArrayList(); - List rowData; - for (int i = 0; i < rowCount; i++) { - rowData = Lists.newArrayList(); - for (int j = 0; j < columnCount; j++) { - String data = (String) memberListTable.getValueAt(i, j); - rowData.add(data); - } - toSearchRowsList.add(String.join("==", rowData)); - } - } - - String keyWord = MemberForm.getInstance().getSearchTextField().getText(); - List searchResultList = toSearchRowsList.parallelStream().filter(rowStr -> rowStr.contains(keyWord)).collect(Collectors.toList()); - - DefaultTableModel tableModel = (DefaultTableModel) memberListTable.getModel(); - tableModel.setRowCount(0); - for (String rowString : searchResultList) { - tableModel.addRow(rowString.split("==")); - } - } - } catch (Exception e1) { - logger.error(e1); - } - }); - } - - /** - * 拉取公众平台用户列表 - */ - public static void getMpUserList() throws WxErrorException { - JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); - JLabel memberCountLabel = MemberForm.getInstance().getMemberTabCountLabel(); - - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - - WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(); - if (wxMpService.getWxMpConfigStorage() == null) { - return; - } - - WxMpUserList wxMpUserList = wxMpService.getUserService().userList(null); - - ConsoleUtil.consoleWithLog("关注该公众账号的总用户数:" + wxMpUserList.getTotal()); - ConsoleUtil.consoleWithLog("拉取的OPENID个数:" + wxMpUserList.getCount()); - - progressBar.setIndeterminate(false); - progressBar.setMaximum((int) wxMpUserList.getTotal()); - int importedCount = 0; - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - if (wxMpUserList.getCount() == 0) { - memberCountLabel.setText(String.valueOf(importedCount)); - progressBar.setValue(importedCount); - return; - } - - List openIds = wxMpUserList.getOpenids(); - - for (String openId : openIds) { - PushData.allUser.add(new String[]{openId}); - importedCount++; - memberCountLabel.setText(String.valueOf(importedCount)); - progressBar.setValue(importedCount); - } - - while (StringUtils.isNotEmpty(wxMpUserList.getNextOpenid())) { - wxMpUserList = wxMpService.getUserService().userList(wxMpUserList.getNextOpenid()); - - ConsoleUtil.consoleWithLog("拉取的OPENID个数:" + wxMpUserList.getCount()); - - if (wxMpUserList.getCount() == 0) { - break; - } - openIds = wxMpUserList.getOpenids(); - for (String openId : openIds) { - PushData.allUser.add(new String[]{openId}); - importedCount++; - memberCountLabel.setText(String.valueOf(importedCount)); - progressBar.setValue(importedCount); - } - } - - progressBar.setValue((int) wxMpUserList.getTotal()); - } - - /** - * 按标签拉取公众平台用户列表 - * - * @param tagId - * @param retain 是否取交集 - * @throws WxErrorException - */ - public static void getMpUserListByTag(Long tagId, boolean retain) throws WxErrorException { - JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); - JLabel memberCountLabel = MemberForm.getInstance().getMemberTabCountLabel(); - - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - - WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(); - if (wxMpService.getWxMpConfigStorage() == null) { - return; - } - - WxTagListUser wxTagListUser = wxMpService.getUserTagService().tagListUser(tagId, ""); - - ConsoleUtil.consoleWithLog("拉取的OPENID个数:" + wxTagListUser.getCount()); - - if (wxTagListUser.getCount() == 0) { - return; - } - - List openIds = wxTagListUser.getData().getOpenidList(); - - if (tagUserSet == null) { - tagUserSet = Collections.synchronizedSet(new HashSet<>()); - tagUserSet.addAll(openIds); - } - - if (retain) { - // 取交集 - tagUserSet.retainAll(openIds); - } else { - // 无重复并集 - openIds.removeAll(tagUserSet); - tagUserSet.addAll(openIds); - } - - while (StringUtils.isNotEmpty(wxTagListUser.getNextOpenid())) { - wxTagListUser = wxMpService.getUserTagService().tagListUser(tagId, wxTagListUser.getNextOpenid()); - - ConsoleUtil.consoleWithLog("拉取的OPENID个数:" + wxTagListUser.getCount()); - - if (wxTagListUser.getCount() == 0) { - break; - } - openIds = wxTagListUser.getData().getOpenidList(); - - if (retain) { - // 取交集 - tagUserSet.retainAll(openIds); - } else { - // 无重复并集 - openIds.removeAll(tagUserSet); - tagUserSet.addAll(openIds); - } - } - - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - for (String openId : tagUserSet) { - PushData.allUser.add(new String[]{openId}); - } - - memberCountLabel.setText(String.valueOf(PushData.allUser.size())); - progressBar.setIndeterminate(false); - progressBar.setValue(progressBar.getMaximum()); - - } - - /** - * 获取导入数据信息列表 - */ - private static void renderMemberListTable() { - JTable memberListTable = MemberForm.getInstance().getMemberListTable(); - JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); - MemberForm memberForm = MemberForm.getInstance(); - - toSearchRowsList = null; - DefaultTableModel tableModel = (DefaultTableModel) memberListTable.getModel(); - tableModel.setRowCount(0); - progressBar.setVisible(true); - progressBar.setMaximum(PushData.allUser.size()); - - int msgType = App.config.getMsgType(); - - // 是否是微信平台类消息 - boolean isWeixinTypeMsg = false; - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.MA_TEMPLATE_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { - isWeixinTypeMsg = true; - } - // 导入列表 - List headerNameList = Lists.newArrayList(); - headerNameList.add("Data"); - if (isWeixinTypeMsg) { - if (memberForm.getImportOptionAvatarCheckBox().isSelected()) { - headerNameList.add("头像"); - } - if (memberForm.getImportOptionBasicInfoCheckBox().isSelected()) { - headerNameList.add("昵称"); - headerNameList.add("性别"); - headerNameList.add("地区"); - headerNameList.add("关注时间"); - } - headerNameList.add("openId"); - } else { - headerNameList.add("数据"); - } - - String[] headerNames = new String[headerNameList.size()]; - headerNameList.toArray(headerNames); - DefaultTableModel model = new DefaultTableModel(null, headerNames); - memberListTable.setModel(model); - if (isWeixinTypeMsg && memberForm.getImportOptionAvatarCheckBox().isSelected()) { - memberListTable.getColumn("头像").setCellRenderer(new TableInCellImageLabelRenderer()); - } - - DefaultTableCellRenderer hr = (DefaultTableCellRenderer) memberListTable.getTableHeader() - .getDefaultRenderer(); - // 表头列名居左 - hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); - - // 隐藏第0列Data数据列 - JTableUtil.hideColumn(memberListTable, 0); - - // 设置行高 - if (isWeixinTypeMsg && memberForm.getImportOptionAvatarCheckBox().isSelected()) { - memberListTable.setRowHeight(66); - } else { - memberListTable.setRowHeight(36); - } - - List rowDataList; - WxMpService wxMpService = null; - boolean needToGetInfoFromWeiXin = false; - if (isWeixinTypeMsg && (memberForm.getImportOptionBasicInfoCheckBox().isSelected() || - memberForm.getImportOptionAvatarCheckBox().isSelected())) { - needToGetInfoFromWeiXin = true; - } - if (needToGetInfoFromWeiXin) { - wxMpService = WxMpTemplateMsgSender.getWxMpService(); - } - for (int i = 0; i < PushData.allUser.size(); i++) { - String[] importedData = PushData.allUser.get(i); - try { - String openId = importedData[0]; - rowDataList = new ArrayList<>(); - rowDataList.add(String.join("|", importedData)); - if (needToGetInfoFromWeiXin) { - WxMpUser wxMpUser = null; - TWxMpUser tWxMpUser = tWxMpUserMapper.selectByPrimaryKey(openId); - if (tWxMpUser != null) { - wxMpUser = new WxMpUser(); - BeanUtil.copyProperties(tWxMpUser, wxMpUser); - } else { - if (wxMpService != null) { - try { - wxMpUser = wxMpService.getUserService().userInfo(openId); - if (wxMpUser != null) { - tWxMpUser = new TWxMpUser(); - BeanUtil.copyProperties(wxMpUser, tWxMpUser); - tWxMpUserMapper.insertSelective(tWxMpUser); - } - } catch (Exception e) { - logger.error(e); - } - } - } - - if (wxMpUser != null) { - if (memberForm.getImportOptionAvatarCheckBox().isSelected()) { - rowDataList.add(wxMpUser.getHeadImgUrl()); - } - if (memberForm.getImportOptionBasicInfoCheckBox().isSelected()) { - rowDataList.add(wxMpUser.getNickname()); - rowDataList.add(wxMpUser.getSexDesc()); - rowDataList.add(wxMpUser.getCountry() + "-" + wxMpUser.getProvince() + "-" + wxMpUser.getCity()); - rowDataList.add(DateFormatUtils.format(wxMpUser.getSubscribeTime() * 1000, "yyyy-MM-dd HH:mm:ss")); - } - } else { - if (memberForm.getImportOptionAvatarCheckBox().isSelected()) { - rowDataList.add(""); - } - if (memberForm.getImportOptionBasicInfoCheckBox().isSelected()) { - rowDataList.add(""); - rowDataList.add(""); - rowDataList.add(""); - rowDataList.add(""); - } - } - rowDataList.add(openId); - } else { - rowDataList.add(String.join("|", importedData)); - } - - model.addRow(rowDataList.toArray()); - } catch (Exception e) { - logger.error(e); - } - progressBar.setValue(i + 1); - } - } - - /** - * 通过文件导入 - */ - public static void importFromFile() { - MemberForm.getInstance().getImportFromFileButton().setEnabled(false); - JTextField filePathField = MemberForm.getInstance().getMemberFilePathField(); - JPanel memberPanel = MemberForm.getInstance().getMemberPanel(); - JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); - JLabel memberCountLabel = MemberForm.getInstance().getMemberTabCountLabel(); - - if (StringUtils.isBlank(filePathField.getText())) { - JOptionPane.showMessageDialog(memberPanel, "请填写或点击浏览按钮选择要导入的文件的路径!", "提示", - JOptionPane.INFORMATION_MESSAGE); - MemberForm.getInstance().getImportFromFileButton().setEnabled(true); - return; - } - File file = new File(filePathField.getText()); - if (!file.exists()) { - JOptionPane.showMessageDialog(memberPanel, filePathField.getText() + "\n该文件不存在!", "文件不存在", - JOptionPane.ERROR_MESSAGE); - MemberForm.getInstance().getImportFromFileButton().setEnabled(true); - return; - } - CSVReader reader = null; - FileReader fileReader; - - int currentImported = 0; - - try { - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - String fileNameLowerCase = file.getName().toLowerCase(); - - if (fileNameLowerCase.endsWith(".csv")) { - // 可以解决中文乱码问题 - DataInputStream in = new DataInputStream(new FileInputStream(file)); - reader = new CSVReader(new InputStreamReader(in, FileCharSetUtil.getCharSet(file))); - String[] nextLine; - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - while ((nextLine = reader.readNext()) != null) { - PushData.allUser.add(nextLine); - currentImported++; - memberCountLabel.setText(String.valueOf(currentImported)); - } - } else if (fileNameLowerCase.endsWith(".xlsx") || fileNameLowerCase.endsWith(".xls")) { - ExcelReader excelReader = ExcelUtil.getReader(file); - List> readAll = excelReader.read(1, Integer.MAX_VALUE); - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - for (List objects : readAll) { - if (objects != null && objects.size() > 0) { - String[] nextLine = new String[objects.size()]; - for (int i = 0; i < objects.size(); i++) { - nextLine[i] = objects.get(i).toString(); - } - PushData.allUser.add(nextLine); - currentImported++; - memberCountLabel.setText(String.valueOf(currentImported)); - } - } - } else if (fileNameLowerCase.endsWith(".txt")) { - fileReader = new FileReader(file, FileCharSetUtil.getCharSetName(file)); - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - BufferedReader br = fileReader.getReader(); - String line; - while ((line = br.readLine()) != null) { - PushData.allUser.add(line.split(TXT_FILE_DATA_SEPERATOR_REGEX)); - currentImported++; - memberCountLabel.setText(String.valueOf(currentImported)); - } - } else { - JOptionPane.showMessageDialog(memberPanel, "不支持该格式的文件!", "文件格式不支持", - JOptionPane.ERROR_MESSAGE); - MemberForm.getInstance().getImportFromFileButton().setEnabled(true); - return; - } - renderMemberListTable(); - - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - - App.config.setMemberFilePath(filePathField.getText()); - App.config.save(); - } catch (Exception e1) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - e1.printStackTrace(); - } finally { - progressBar.setMaximum(100); - progressBar.setValue(100); - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - MemberForm.getInstance().getImportFromFileButton().setEnabled(true); - if (reader != null) { - try { - reader.close(); - } catch (IOException e1) { - logger.error(e1); - e1.printStackTrace(); - } - } - } - } - - /** - * 通过SQL导入 - */ - public static void importFromSql() { - MemberForm memberForm = MemberForm.getInstance(); - memberForm.getImportFromSqlButton().setEnabled(false); - JPanel memberPanel = memberForm.getMemberPanel(); - JProgressBar progressBar = memberForm.getMemberTabImportProgressBar(); - JLabel memberCountLabel = memberForm.getMemberTabCountLabel(); - - if (StringUtils.isBlank(App.config.getMysqlUrl()) || StringUtils.isBlank(App.config.getMysqlUser())) { - JOptionPane.showMessageDialog(memberPanel, "请先在设置中填写并保存MySQL的配置信息!", "提示", - JOptionPane.INFORMATION_MESSAGE); - memberForm.getImportFromSqlButton().setEnabled(true); - return; - } - String querySql = memberForm.getImportFromSqlTextArea().getText(); - if (StringUtils.isBlank(querySql)) { - JOptionPane.showMessageDialog(memberPanel, "请先填写要执行导入的SQL!", "提示", - JOptionPane.INFORMATION_MESSAGE); - memberForm.getImportFromSqlButton().setEnabled(true); - return; - } - - if (StringUtils.isNotEmpty(querySql)) { - Connection conn = null; - try { - memberForm.getImportFromSqlButton().setEnabled(false); - memberForm.getImportFromSqlButton().updateUI(); - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - - // 表查询 - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - int currentImported = 0; - - conn = HikariUtil.getConnection(); - List entityList = SqlExecutor.query(conn, querySql, new EntityListHandler()); - for (Entity entity : entityList) { - Set fieldNames = entity.getFieldNames(); - String[] msgData = new String[fieldNames.size()]; - int i = 0; - for (String fieldName : fieldNames) { - msgData[i] = entity.getStr(fieldName); - i++; - } - PushData.allUser.add(msgData); - currentImported++; - memberCountLabel.setText(String.valueOf(currentImported)); - } - - renderMemberListTable(); - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - - App.config.setMemberSql(querySql); - App.config.save(); - } catch (Exception e1) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - e1.printStackTrace(); - } finally { - DbUtil.close(conn); - memberForm.getImportFromSqlButton().setEnabled(true); - memberForm.getImportFromSqlButton().updateUI(); - progressBar.setMaximum(100); - progressBar.setValue(100); - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - memberForm.getImportFromSqlButton().setEnabled(true); - } - } - } - - /** - * 导入微信全员 - */ - public static void importWxAll() { - JPanel memberPanel = MemberForm.getInstance().getMemberPanel(); - JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); - MemberForm.getInstance().getMemberImportAllButton().setEnabled(false); - - try { - getMpUserList(); - renderMemberListTable(); - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - } catch (WxErrorException e1) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - e1.printStackTrace(); - } finally { - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - MemberForm.getInstance().getMemberImportAllButton().setEnabled(true); - } - } - - /** - * 导入企业通讯录全员 - */ - public static void importWxCpAll() { - JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); - JLabel memberCountLabel = MemberForm.getInstance().getMemberTabCountLabel(); - JPanel memberPanel = MemberForm.getInstance().getMemberPanel(); - - try { - if (WxCpMsgForm.getInstance().getAppNameComboBox().getSelectedItem() == null) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请先在编辑消息tab中选择应用!", "提示", - JOptionPane.ERROR_MESSAGE); - MainWindow.getInstance().getTabbedPane().setSelectedIndex(2); - return; - } - - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - int importedCount = 0; - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - // 获取最小部门id - List wxCpDepartList = WxCpMsgSender.getWxCpService().getDepartmentService().list(null); - long minDeptId = Long.MAX_VALUE; - for (WxCpDepart wxCpDepart : wxCpDepartList) { - if (wxCpDepart.getId() < minDeptId) { - minDeptId = wxCpDepart.getId(); - } - } - // 获取用户 - List wxCpUsers = WxCpMsgSender.getWxCpService().getUserService().listByDepartment(minDeptId, true, 0); - for (WxCpUser wxCpUser : wxCpUsers) { - String statusStr = ""; - if (wxCpUser.getStatus() == 1) { - statusStr = "已关注"; - } else if (wxCpUser.getStatus() == 2) { - statusStr = "已冻结"; - } else if (wxCpUser.getStatus() == 4) { - statusStr = "未关注"; - } - Long[] depIds = wxCpUser.getDepartIds(); - List deptNameList = Lists.newArrayList(); - if (depIds != null) { - for (Long depId : depIds) { - deptNameList.add(wxCpIdToDeptNameMap.get(depId)); - } - } - String[] dataArray = new String[]{wxCpUser.getUserId(), wxCpUser.getName(), wxCpUser.getGender().getGenderName(), wxCpUser.getEmail(), String.join("/", deptNameList), wxCpUser.getPosition(), statusStr}; - PushData.allUser.add(dataArray); - importedCount++; - memberCountLabel.setText(String.valueOf(importedCount)); - } - renderMemberListTable(); - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } finally { - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - } - } - - /** - * 导入钉钉通讯录全员 - */ - public static void importDingAll() { - JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); - JLabel memberCountLabel = MemberForm.getInstance().getMemberTabCountLabel(); - JPanel memberPanel = MemberForm.getInstance().getMemberPanel(); - - try { - if (DingMsgForm.getInstance().getAppNameComboBox().getSelectedItem() == null) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请先在编辑消息tab中选择应用!", "提示", - JOptionPane.ERROR_MESSAGE); - MainWindow.getInstance().getTabbedPane().setSelectedIndex(2); - return; - } - - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - int importedCount = 0; - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - - // 最小部门id为1 - // 获取用户 - DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/simplelist"); - OapiUserSimplelistRequest request = new OapiUserSimplelistRequest(); - request.setDepartmentId(1L); - request.setOffset(0L); - request.setSize(100L); - request.setHttpMethod("GET"); - - long offset = 0; - OapiUserSimplelistResponse response = new OapiUserSimplelistResponse(); - while (response.getErrcode() == null || response.getUserlist().size() > 0) { - response = client.execute(request, DingMsgSender.getAccessTokenTimedCache().get("accessToken")); - if (response.getErrcode() != 0) { - if (response.getErrcode() == 60011) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + response.getErrmsg() + "\n\n进入开发者后台,在小程序或者微应用详情的「接口权限」模块,点击申请对应的通讯录接口读写权限", "失败", - JOptionPane.ERROR_MESSAGE); - } else { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + response.getErrmsg(), "失败", JOptionPane.ERROR_MESSAGE); - } - - logger.error(response.getErrmsg()); - return; - } - List userlist = response.getUserlist(); - for (OapiUserSimplelistResponse.Userlist dingUser : userlist) { - String[] dataArray = new String[]{dingUser.getUserid(), dingUser.getName()}; - PushData.allUser.add(dataArray); - importedCount++; - memberCountLabel.setText(String.valueOf(importedCount)); - } - offset += 100; - request.setOffset(offset); - } - - renderMemberListTable(); - if (!PushData.fixRateScheduling) { - JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + ex, "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(ex.toString()); - } finally { - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - } - } -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MsgEditListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageEditListener.java similarity index 81% rename from src/main/java/com/fangxuele/tool/push/ui/listener/MsgEditListener.java rename to src/main/java/com/fangxuele/tool/push/ui/listener/MessageEditListener.java index d629aafb3..882dc9a6d 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MsgEditListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageEditListener.java @@ -3,6 +3,8 @@ import cn.hutool.log.Log; import cn.hutool.log.LogFactory; import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TMsgMapper; +import com.fangxuele.tool.push.domain.TMsg; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.logic.PushControl; import com.fangxuele.tool.push.logic.msgsender.HttpSendResult; @@ -15,8 +17,8 @@ import com.fangxuele.tool.push.ui.form.MessageManageForm; import com.fangxuele.tool.push.ui.form.msg.DingMsgForm; import com.fangxuele.tool.push.ui.form.msg.MsgFormFactory; -import com.fangxuele.tool.push.ui.form.msg.WxCpMsgForm; import com.fangxuele.tool.push.ui.frame.HttpResultFrame; +import com.fangxuele.tool.push.util.MybatisUtil; import org.apache.commons.lang3.StringUtils; import javax.swing.*; @@ -33,15 +35,26 @@ * @author RememBerBer * @since 2017/6/18. */ -public class MsgEditListener { +public class MessageEditListener { private static final Log logger = LogFactory.get(); + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + public static void addListeners() { JSplitPane messagePanel = MainWindow.getInstance().getMessagePanel(); MessageEditForm messageEditForm = MessageEditForm.getInstance(); + MessageManageForm messageManageForm = MessageManageForm.getInstance(); // 保存按钮事件 messageEditForm.getMsgSaveButton().addActionListener(e -> { + String selectedAccountName = (String) messageManageForm.getAccountComboBox().getSelectedItem(); + Integer selectedAccountId = MessageManageForm.accountMap.get(selectedAccountName); + if (StringUtils.isBlank(selectedAccountName)) { + JOptionPane.showMessageDialog(messagePanel, "请选择账号!\n\n", "失败", + JOptionPane.ERROR_MESSAGE); + return; + } + String msgName = messageEditForm.getMsgNameField().getText(); if (StringUtils.isBlank(msgName)) { JOptionPane.showMessageDialog(messagePanel, "请填写消息名称!\n\n", "失败", @@ -50,10 +63,7 @@ public static void addListeners() { } try { - MsgFormFactory.getMsgForm().save(msgName); - - App.config.setPreviewUser(messageEditForm.getPreviewUserField().getText()); - App.config.save(); + MsgFormFactory.getMsgForm().save(selectedAccountId, msgName); MessageManageForm.init(); } catch (Exception e1) { JOptionPane.showMessageDialog(messagePanel, "保存失败!\n\n" + e1.getMessage(), "失败", @@ -66,8 +76,19 @@ public static void addListeners() { // 预览按钮事件 messageEditForm.getPreviewMsgButton().addActionListener(e -> { try { - if (App.config.getMsgType() != MessageTypeEnum.HTTP_CODE && "".equals(messageEditForm.getPreviewUserField().getText().trim())) { - if (App.config.getMsgType() == MessageTypeEnum.DING_CODE && DingMsgForm.getInstance().getRobotRadioButton().isSelected()) { + int selectedRow = messageManageForm.getMsgHistable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(messagePanel, "请先保存并选择一条消息!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer selectedMsgId = (Integer) messageManageForm.getMsgHistable().getValueAt(selectedRow, 1); + + TMsg tMsg = msgMapper.selectByPrimaryKey(selectedMsgId); + + if (tMsg.getMsgType() != MessageTypeEnum.HTTP_CODE && "".equals(messageEditForm.getPreviewUserField().getText().trim())) { + if (tMsg.getMsgType() == MessageTypeEnum.DING_CODE && DingMsgForm.getInstance().getRobotRadioButton().isSelected()) { // Do Nothing } else { JOptionPane.showMessageDialog(messagePanel, "预览用户不能为空!", "提示", @@ -75,7 +96,7 @@ public static void addListeners() { return; } } - if (App.config.getMsgType() == MessageTypeEnum.MA_TEMPLATE_CODE + if (tMsg.getMsgType() == MessageTypeEnum.MA_TEMPLATE_CODE && messageEditForm.getPreviewUserField().getText().split(";")[0].length() < 2) { JOptionPane.showMessageDialog(messagePanel, "小程序模板消息预览时,“预览用户openid”输入框里填写openid|formId,\n" + "示例格式:\n" + @@ -84,14 +105,7 @@ public static void addListeners() { return; } - if (App.config.getMsgType() == MessageTypeEnum.WX_CP_CODE - && WxCpMsgForm.getInstance().getAppNameComboBox().getSelectedItem() == null) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "请选择应用!", "失败", - JOptionPane.ERROR_MESSAGE); - return; - } - - List sendResultList = PushControl.preview(); + List sendResultList = PushControl.preview(tMsg.getId()); if (sendResultList != null) { StringBuilder tipsBuilder = new StringBuilder(); @@ -107,7 +121,7 @@ public static void addListeners() { sendResultList.stream().filter(sendResult -> !sendResult.isSuccess()) .forEach(sendResult -> tipsBuilder.append("

").append(sendResult.getInfo()).append("

")); - if (App.config.getMsgType() == MessageTypeEnum.HTTP_CODE && totalCount == successCount) { + if (tMsg.getMsgType() == MessageTypeEnum.HTTP_CODE && totalCount == successCount) { HttpSendResult httpSendResult = (HttpSendResult) sendResultList.get(0); HttpResultForm.getInstance().getBodyTextArea().setText(httpSendResult.getBody()); HttpResultForm.getInstance().getBodyTextArea().setCaretPosition(0); @@ -142,9 +156,7 @@ public void mousePressed(MouseEvent e) { int msgType = App.config.getMsgType(); String fillParaName = ""; String paraDemo = ""; - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE - || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { + if (MessageTypeEnum.isWxMaOrMpType(msgType)) { fillParaName = "预览消息用户的openId"; paraDemo = "ox_kxwS_gGt63adS-zemlETtuvw1;ox_kxwS_gGt63adS-zemlETtuvw2"; } else if (msgType == MessageTypeEnum.MA_TEMPLATE_CODE) { @@ -163,6 +175,7 @@ public void mousePressed(MouseEvent e) { fillParaName = "预览消息用户的UserId(如果是聊天机器人消息,填写需要@ 的用户的手机号,如果@所有人 可不填写)"; paraDemo = "manager9115|manager9116|manager9117"; } else if (msgType == MessageTypeEnum.ALI_YUN_CODE || msgType == MessageTypeEnum.TX_YUN_CODE + || msgType == MessageTypeEnum.TX_YUN_3_CODE || msgType == MessageTypeEnum.HW_YUN_CODE || msgType == MessageTypeEnum.BD_YUN_CODE || msgType == MessageTypeEnum.UP_YUN_CODE || msgType == MessageTypeEnum.YUN_PIAN_CODE || msgType == MessageTypeEnum.QI_NIU_YUN_CODE) { @@ -189,14 +202,14 @@ public void mousePressed(MouseEvent e) { public void mouseEntered(MouseEvent e) { JLabel label = (JLabel) e.getComponent(); label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); + label.setIcon(UiConsts.HELP_FOCUSED_ICON); super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); + label.setIcon(UiConsts.HELP_ICON); super.mouseExited(e); } }); diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageManageListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageManageListener.java new file mode 100644 index 000000000..1c9fbb235 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageManageListener.java @@ -0,0 +1,94 @@ +package com.fangxuele.tool.push.ui.listener; + +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.ui.form.*; +import com.fangxuele.tool.push.util.MybatisUtil; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.event.ItemEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + *
+ * 编辑消息tab相关事件监听
+ * 
+ * + * @author RememBerBer + * @since 2017/6/18. + */ +public class MessageManageListener { + private static final Log logger = LogFactory.get(); + + private static TMsgMapper msgMapper = MybatisUtil.getSqlSession().getMapper(TMsgMapper.class); + + public static void addListeners() { + JTable msgHistable = MessageManageForm.getInstance().getMsgHistable(); + JSplitPane messagePanel = MainWindow.getInstance().getMessagePanel(); + + // 点击左侧表格事件 + msgHistable.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + int selectedRow = msgHistable.getSelectedRow(); + Integer selectedMsgId = (Integer) msgHistable.getValueAt(selectedRow, 1); + + MessageEditForm.init(selectedMsgId); + super.mousePressed(e); + } + }); + + // 历史消息管理-删除 + MessageManageForm.getInstance().getMsgHisTableDeleteButton().addActionListener(e -> ThreadUtil.execute(() -> { + try { + int[] selectedRows = msgHistable.getSelectedRows(); + + if (selectedRows.length == 0) { + JOptionPane.showMessageDialog(messagePanel, "请至少选择一个!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else { + int isDelete = JOptionPane.showConfirmDialog(messagePanel, "确认删除?", "确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + DefaultTableModel tableModel = (DefaultTableModel) msgHistable + .getModel(); + int msgType = App.config.getMsgType(); + + for (int i = selectedRows.length; i > 0; i--) { + int selectedRow = msgHistable.getSelectedRow(); + Integer msgId = (Integer) tableModel.getValueAt(selectedRow, 1); + msgMapper.deleteByPrimaryKey(msgId); + + tableModel.removeRow(selectedRow); + } + } + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(messagePanel, "删除失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + })); + + // 编辑消息-新建 + MessageManageForm.getInstance().getCreateMsgButton().addActionListener(e -> { + MessageTypeForm.init(); + MessageEditForm.getInstance().getMsgNameField().setText(""); + MessageEditForm.getInstance().getMsgNameField().grabFocus(); + }); + + // 切换账号事件 + MessageManageForm.getInstance().getAccountComboBox().addItemListener(e -> { + if (e.getStateChange() == ItemEvent.SELECTED) { + String accountName = e.getItem().toString(); + + MessageManageForm.initMessageList(); + } + }); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java index 72c4e1d66..a00a9afde 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java @@ -4,7 +4,6 @@ import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.ui.UiConsts; import com.fangxuele.tool.push.ui.dialog.CommonTipsDialog; -import com.fangxuele.tool.push.ui.form.MessageEditForm; import com.fangxuele.tool.push.ui.form.MessageTypeForm; import javax.swing.*; @@ -28,6 +27,10 @@ public static void addListeners() { App.config.setMsgType(MessageTypeEnum.MP_TEMPLATE_CODE); saveType(); }); + messageTypeForm.getMpSubscribeRadioButton().addActionListener(e -> { + App.config.setMsgType(MessageTypeEnum.MP_SUBSCRIBE_CODE); + saveType(); + }); messageTypeForm.getMaTemplateRadioButton().addActionListener(e -> { App.config.setMsgType(MessageTypeEnum.MA_TEMPLATE_CODE); saveType(); @@ -56,6 +59,10 @@ public static void addListeners() { App.config.setMsgType(MessageTypeEnum.TX_YUN_CODE); saveType(); }); + messageTypeForm.getTxYun3RadioButton().addActionListener(e -> { + App.config.setMsgType(MessageTypeEnum.TX_YUN_3_CODE); + saveType(); + }); messageTypeForm.getQiniuRadioButton().addActionListener(e -> { App.config.setMsgType(MessageTypeEnum.QI_NIU_YUN_CODE); saveType(); @@ -92,6 +99,10 @@ public static void addListeners() { App.config.setMsgType(MessageTypeEnum.DING_CODE); saveType(); }); + messageTypeForm.getTxYun3RadioButton().addActionListener(e -> { + App.config.setMsgType(MessageTypeEnum.TX_YUN_3_CODE); + saveType(); + }); messageTypeForm.getKefuPriorityTipsLabel().addMouseListener(new MouseAdapter() { @Override @@ -115,14 +126,14 @@ public void mousePressed(MouseEvent e) { public void mouseEntered(MouseEvent e) { JLabel label = (JLabel) e.getComponent(); label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); + label.setIcon(UiConsts.HELP_FOCUSED_ICON); super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); + label.setIcon(UiConsts.HELP_ICON); super.mouseExited(e); } }); @@ -132,10 +143,6 @@ public void mouseExited(MouseEvent e) { * 保存消息类型 */ private static void saveType() { - String msgName = App.config.getMsgName(); - - MessageEditForm.getInstance().getMsgNameField().setText(msgName); - MessageEditForm.getInstance().getPreviewUserField().setText(App.config.getPreviewUser()); App.config.save(); MessageTypeForm.init(); } diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MsgManageListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MsgManageListener.java deleted file mode 100644 index fa98d6bb0..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MsgManageListener.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.fangxuele.tool.push.ui.listener; - -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TMsgDingMapper; -import com.fangxuele.tool.push.dao.TMsgHttpMapper; -import com.fangxuele.tool.push.dao.TMsgKefuMapper; -import com.fangxuele.tool.push.dao.TMsgKefuPriorityMapper; -import com.fangxuele.tool.push.dao.TMsgMaSubscribeMapper; -import com.fangxuele.tool.push.dao.TMsgMaTemplateMapper; -import com.fangxuele.tool.push.dao.TMsgMailMapper; -import com.fangxuele.tool.push.dao.TMsgMpTemplateMapper; -import com.fangxuele.tool.push.dao.TMsgSmsMapper; -import com.fangxuele.tool.push.dao.TMsgWxCpMapper; -import com.fangxuele.tool.push.dao.TMsgWxUniformMapper; -import com.fangxuele.tool.push.logic.MessageTypeEnum; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.MessageManageForm; -import com.fangxuele.tool.push.ui.form.MessageTypeForm; -import com.fangxuele.tool.push.ui.form.PushHisForm; -import com.fangxuele.tool.push.util.MybatisUtil; - -import javax.swing.*; -import javax.swing.table.DefaultTableModel; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** - *
- * 编辑消息tab相关事件监听
- * 
- * - * @author RememBerBer - * @since 2017/6/18. - */ -public class MsgManageListener { - private static final Log logger = LogFactory.get(); - - private static TMsgKefuMapper msgKefuMapper = MybatisUtil.getSqlSession().getMapper(TMsgKefuMapper.class); - private static TMsgKefuPriorityMapper msgKefuPriorityMapper = MybatisUtil.getSqlSession().getMapper(TMsgKefuPriorityMapper.class); - private static TMsgWxUniformMapper wxUniformMapper = MybatisUtil.getSqlSession().getMapper(TMsgWxUniformMapper.class); - private static TMsgMaTemplateMapper msgMaTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaTemplateMapper.class); - private static TMsgMaSubscribeMapper msgMaSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaSubscribeMapper.class); - private static TMsgMpTemplateMapper msgMpTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpTemplateMapper.class); - private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class); - private static TMsgMailMapper msgMailMapper = MybatisUtil.getSqlSession().getMapper(TMsgMailMapper.class); - private static TMsgHttpMapper msgHttpMapper = MybatisUtil.getSqlSession().getMapper(TMsgHttpMapper.class); - private static TMsgWxCpMapper msgWxCpMapper = MybatisUtil.getSqlSession().getMapper(TMsgWxCpMapper.class); - private static TMsgDingMapper msgDingMapper = MybatisUtil.getSqlSession().getMapper(TMsgDingMapper.class); - - public static void addListeners() { - JTable msgHistable = MessageManageForm.getInstance().getMsgHistable(); - JSplitPane messagePanel = MainWindow.getInstance().getMessagePanel(); - - // 点击左侧表格事件 - msgHistable.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - ThreadUtil.execute(() -> { - PushHisForm.getInstance().getPushHisTextArea().setText(""); - - int selectedRow = msgHistable.getSelectedRow(); - String selectedMsgName = msgHistable - .getValueAt(selectedRow, 0).toString(); - - MessageEditForm.init(selectedMsgName); - }); - super.mousePressed(e); - } - }); - - // 历史消息管理-删除 - MessageManageForm.getInstance().getMsgHisTableDeleteButton().addActionListener(e -> ThreadUtil.execute(() -> { - try { - int[] selectedRows = msgHistable.getSelectedRows(); - - if (selectedRows.length == 0) { - JOptionPane.showMessageDialog(messagePanel, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } else { - int isDelete = JOptionPane.showConfirmDialog(messagePanel, "确认删除?", "确认", - JOptionPane.YES_NO_OPTION); - if (isDelete == JOptionPane.YES_OPTION) { - DefaultTableModel tableModel = (DefaultTableModel) msgHistable - .getModel(); - int msgType = App.config.getMsgType(); - - for (int i = selectedRows.length; i > 0; i--) { - int selectedRow = msgHistable.getSelectedRow(); - String msgName = (String) tableModel.getValueAt(selectedRow, 0); - if (msgType == MessageTypeEnum.KEFU_CODE) { - msgKefuMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.KEFU_PRIORITY_CODE) { - msgKefuPriorityMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE) { - wxUniformMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.MA_TEMPLATE_CODE) { - msgMaTemplateMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { - msgMaSubscribeMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE) { - msgMpTemplateMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.EMAIL_CODE) { - msgMailMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.HTTP_CODE) { - msgHttpMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.WX_CP_CODE) { - msgWxCpMapper.deleteByMsgTypeAndName(msgType, msgName); - } else if (msgType == MessageTypeEnum.DING_CODE) { - msgDingMapper.deleteByMsgTypeAndName(msgType, msgName); - } else { - msgSmsMapper.deleteByMsgTypeAndName(msgType, msgName); - } - - tableModel.removeRow(selectedRow); - } - MessageEditForm.init(null); - } - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(messagePanel, "删除失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - })); - - // 编辑消息-新建 - MessageManageForm.getInstance().getCreateMsgButton().addActionListener(e -> { - MessageTypeForm.init(); - MessageEditForm.getInstance().getMsgNameField().setText(""); - MessageEditForm.getInstance().getMsgNameField().grabFocus(); - }); - } -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/PeopleEditListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/PeopleEditListener.java new file mode 100644 index 000000000..596474c1e --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/PeopleEditListener.java @@ -0,0 +1,351 @@ +package com.fangxuele.tool.push.ui.listener; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import cn.hutool.poi.excel.BigExcelWriter; +import cn.hutool.poi.excel.ExcelUtil; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TPeopleDataMapper; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.domain.TPeople; +import com.fangxuele.tool.push.domain.TPeopleData; +import com.fangxuele.tool.push.logic.MessageTypeEnum; +import com.fangxuele.tool.push.logic.PeopleImportWayEnum; +import com.fangxuele.tool.push.ui.dialog.ExportDialog; +import com.fangxuele.tool.push.ui.dialog.importway.*; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.ui.form.PeopleManageForm; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.opencsv.CSVWriter; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.FileWriter; +import java.util.List; + +/** + *
+ * 人群编辑相关事件监听
+ * 
+ * + * @author RememBerBer + * @since 2021/4/27. + */ +public class PeopleEditListener { + private static final Log logger = LogFactory.get(); + + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + private static TPeopleDataMapper peopleDataMapper = MybatisUtil.getSqlSession().getMapper(TPeopleDataMapper.class); + + public static void addListeners() { + PeopleEditForm peopleEditForm = PeopleEditForm.getInstance(); + + JPanel mainPanel = MainWindow.getInstance().getMainPanel(); + + JTable memberListTable = peopleEditForm.getMemberListTable(); + + // 导入按钮 + peopleEditForm.getImportButton().addActionListener(e -> { + + if (PeopleManageListener.selectedPeopleId == null) { + JOptionPane.showMessageDialog(mainPanel, "请先选择一个人群!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + TPeople tPeople = peopleMapper.selectByPrimaryKey(PeopleManageListener.selectedPeopleId); + Integer msgType = tPeople.getMsgType(); + + JPopupMenu popupMenu = new JPopupMenu(); + + JMenuItem menuItem1 = new JMenuItem(); + menuItem1.setText(PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_FILE)); + menuItem1.setIcon(new FlatSVGIcon("icon/file.svg")); + menuItem1.addActionListener(e1 -> { + String actionCommand = e1.getActionCommand(); + showImportDialog(actionCommand); + }); + popupMenu.add(menuItem1); + + JMenuItem menuItem2 = new JMenuItem(); + menuItem2.setText(PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_SQL)); + menuItem2.setIcon(new FlatSVGIcon("icon/data_base.svg")); + menuItem2.addActionListener(e1 -> { + String actionCommand = e1.getActionCommand(); + showImportDialog(actionCommand); + }); + popupMenu.add(menuItem2); + + if (MessageTypeEnum.isWxMaOrMpType(msgType)) { + JMenuItem menuItem3 = new JMenuItem(); + menuItem3.setText(PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_WX_MP)); + menuItem3.setIcon(new FlatSVGIcon("icon/wechat.svg")); + menuItem3.addActionListener(e1 -> { + String actionCommand = e1.getActionCommand(); + showImportDialog(actionCommand); + }); + popupMenu.add(menuItem3); + } + + if (MessageTypeEnum.WX_CP_CODE == msgType) { + JMenuItem menuItem4 = new JMenuItem(); + menuItem4.setText(PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_WX_CP)); + menuItem4.setIcon(new FlatSVGIcon("icon/qiwei.svg")); + menuItem4.addActionListener(e1 -> { + String actionCommand = e1.getActionCommand(); + showImportDialog(actionCommand); + }); + popupMenu.add(menuItem4); + } + + if (MessageTypeEnum.DING_CODE == msgType) { + JMenuItem menuItem5 = new JMenuItem(); + menuItem5.setText(PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_DING)); + menuItem5.setIcon(new FlatSVGIcon("icon/dingding.svg")); + menuItem5.addActionListener(e1 -> { + String actionCommand = e1.getActionCommand(); + showImportDialog(actionCommand); + }); + popupMenu.add(menuItem5); + } + + if (MessageTypeEnum.HTTP_CODE == msgType) { + JMenuItem menuItem6 = new JMenuItem(); + menuItem6.setText(PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_NUM)); + menuItem6.setIcon(new FlatSVGIcon("icon/number.svg")); + menuItem6.addActionListener(e1 -> { + String actionCommand = e1.getActionCommand(); + showImportDialog(actionCommand); + }); + popupMenu.add(menuItem6); + } + + peopleEditForm.getImportButton().setComponentPopupMenu(popupMenu); + + peopleEditForm.getImportButton().getComponentPopupMenu().show(peopleEditForm.getImportButton(), -30, -peopleEditForm.getImportButton().getHeight() * popupMenu.getSubElements().length); + }); + + // 删除按钮 + peopleEditForm.getDeleteButton().addActionListener(e -> { + try { + int[] selectedRows = memberListTable.getSelectedRows(); + if (selectedRows.length == 0) { + JOptionPane.showMessageDialog(mainPanel, "请至少选择一个!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else { + int isDelete = JOptionPane.showConfirmDialog(mainPanel, "确认删除?", "确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + DefaultTableModel tableModel = (DefaultTableModel) memberListTable.getModel(); + + for (int i = 0; i < selectedRows.length; i++) { + int selectedRow = selectedRows[i]; + Integer selectedId = (Integer) tableModel.getValueAt(selectedRow, 2); + peopleDataMapper.deleteByPrimaryKey(selectedId); + } + + PeopleEditForm.initDataTable(PeopleManageListener.selectedPeopleId); + } + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(mainPanel, "删除失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + // 清空按钮 + peopleEditForm.getClearAllButton().addActionListener(e -> { + + try { + if (PeopleManageListener.selectedPeopleId == null) { + JOptionPane.showMessageDialog(mainPanel, "请先选择一个人群!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + int isDelete = JOptionPane.showConfirmDialog(mainPanel, "确认清空?", "确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + peopleDataMapper.deleteByPeopleId(PeopleManageListener.selectedPeopleId); + + PeopleEditForm.initDataTable(PeopleManageListener.selectedPeopleId); + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(mainPanel, "清空失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + // 导出按钮 + peopleEditForm.getExportButton().addActionListener(e -> ThreadUtil.execute(() -> { + BigExcelWriter writer; + try { + if (PeopleManageListener.selectedPeopleId == null) { + JOptionPane.showMessageDialog(mainPanel, "请先选择一个人群!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + List peopleDataList = peopleDataMapper.selectByPeopleId(PeopleManageListener.selectedPeopleId); + if (peopleDataList.size() > 0) { + ExportDialog.showDialog(); + if (ExportDialog.confirm) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int approve = fileChooser.showOpenDialog(mainPanel); + String exportPath; + if (approve == JFileChooser.APPROVE_OPTION) { + exportPath = fileChooser.getSelectedFile().getAbsolutePath(); + } else { + return; + } + + TPeople tPeople = peopleMapper.selectByPrimaryKey(PeopleManageListener.selectedPeopleId); + + String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_"); + String fileName = "MemberExport_" + MessageTypeEnum.getName(App.config.getMsgType()) + "_" + tPeople.getPeopleName() + "_" + nowTime; + String fileFullName = exportPath + File.separator + fileName; + if (ExportDialog.fileType == ExportDialog.EXCEL) { + fileFullName += ".xlsx"; + //通过工具类创建writer + writer = ExcelUtil.getBigWriter(fileFullName); + //合并单元格后的标题行,使用默认标题样式 + writer.merge(JSONUtil.toList(peopleDataList.get(0).getVarData(), String.class).size() - 1, "人群数据列表导出"); + //一次性写出内容,强制输出标题 + for (TPeopleData tPeopleData : peopleDataList) { + String varData = tPeopleData.getVarData(); + writer.writeRow(JSONUtil.toList(varData, String.class)); + } + writer.flush(); + } else if (ExportDialog.fileType == ExportDialog.CSV) { + fileFullName += ".csv"; + CSVWriter csvWriter = new CSVWriter(new FileWriter(FileUtil.touch(fileFullName))); + + for (TPeopleData tPeopleData : peopleDataList) { + String varData = tPeopleData.getVarData(); + JSONArray jsonArray = JSONUtil.parseArray(varData); + String[] nextLine = new String[jsonArray.size()]; + nextLine = jsonArray.toArray(nextLine); + csvWriter.writeNext(nextLine); + } + + csvWriter.flush(); + csvWriter.close(); + } else if (ExportDialog.fileType == ExportDialog.TXT) { + fileFullName += ".txt"; + FileWriter fileWriter = new FileWriter(fileFullName); + + int size = peopleDataList.size(); + for (int i = 0; i < size; i++) { + String varData = peopleDataList.get(i).getVarData(); + List row = JSONUtil.toList(varData, String.class); + fileWriter.append(String.join("|", row)); + if (i < size - 1) { + fileWriter.append(StrUtil.CRLF); + } + } + + fileWriter.flush(); + fileWriter.close(); + } + JOptionPane.showMessageDialog(mainPanel, "导出成功!", "提示", + JOptionPane.INFORMATION_MESSAGE); + try { + Desktop desktop = Desktop.getDesktop(); + desktop.open(FileUtil.file(fileFullName)); + } catch (Exception e2) { + logger.error(e2); + } + } + } else { + JOptionPane.showMessageDialog(mainPanel, "所选人群无数据", "提示", + JOptionPane.INFORMATION_MESSAGE); + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(mainPanel, "导出失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + })); + + // 搜索按钮 + peopleEditForm.getSearchButton().addActionListener(e -> searchEvent()); + + // 搜索框键入回车 + peopleEditForm.getSearchTextField().addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + try { + searchEvent(); + } catch (Exception e1) { + logger.error(e1); + } finally { + super.keyPressed(e); + } + } + }); + + } + + /** + * 弹出导入对话框 + * + * @param actionCommand + */ + private static void showImportDialog(String actionCommand) { + String selectedAccountName = PeopleManageForm.getInstance().getAccountComboBox().getSelectedItem().toString(); + + if (PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_FILE).equals(actionCommand)) { + ImportByFile dialog = new ImportByFile(PeopleManageListener.selectedPeopleId); + dialog.pack(); + dialog.setVisible(true); + } else if (PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_SQL).equals(actionCommand)) { + ImportBySQL dialog = new ImportBySQL(PeopleManageListener.selectedPeopleId); + dialog.pack(); + dialog.setVisible(true); + } else if (PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_WX_MP).equals(actionCommand)) { + ImportByWxMp dialog = new ImportByWxMp(PeopleManageListener.selectedPeopleId); + dialog.pack(); + dialog.setVisible(true); + } else if (PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_WX_CP).equals(actionCommand)) { + ImportByWxCp dialog = new ImportByWxCp(PeopleManageListener.selectedPeopleId); + dialog.pack(); + dialog.setVisible(true); + } else if (PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_DING).equals(actionCommand)) { + ImportByDing dialog = new ImportByDing(PeopleManageListener.selectedPeopleId); + dialog.pack(); + dialog.setVisible(true); + } else if (PeopleImportWayEnum.getName(PeopleImportWayEnum.BY_NUM).equals(actionCommand)) { + ImportByNum dialog = new ImportByNum(PeopleManageListener.selectedPeopleId); + dialog.pack(); + dialog.setVisible(true); + } + } + + /** + * 搜索 + */ + private static void searchEvent() { + try { + String keyWord = PeopleEditForm.getInstance().getSearchTextField().getText(); + List peopleDataList = peopleDataMapper.selectByPeopleIdAndKeyword(PeopleManageListener.selectedPeopleId, "%" + keyWord + "%"); + PeopleEditForm.initPeopleDataTable(peopleDataList); + } catch (Exception e1) { + logger.error(e1); + } + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/PeopleManageListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/PeopleManageListener.java new file mode 100644 index 000000000..8b77e7aa1 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/PeopleManageListener.java @@ -0,0 +1,99 @@ +package com.fangxuele.tool.push.ui.listener; + +import cn.hutool.log.Log; +import cn.hutool.log.LogFactory; +import com.fangxuele.tool.push.dao.TPeopleMapper; +import com.fangxuele.tool.push.ui.dialog.NewPeopleDialog; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.ui.form.PeopleEditForm; +import com.fangxuele.tool.push.ui.form.PeopleManageForm; +import com.fangxuele.tool.push.util.MybatisUtil; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.event.ItemEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + *
+ * 人群管理相关事件监听
+ * 
+ * + * @author RememBerBer + * @since 2021/3/23. + */ +public class PeopleManageListener { + private static final Log logger = LogFactory.get(); + + private static TPeopleMapper peopleMapper = MybatisUtil.getSqlSession().getMapper(TPeopleMapper.class); + + public static Integer selectedPeopleId; + + public static void addListeners() { + PeopleManageForm peopleManageForm = PeopleManageForm.getInstance(); + + JPanel mainPanel = MainWindow.getInstance().getMainPanel(); + + JTable peopleListTable = peopleManageForm.getPeopleListTable(); + + // 新建人群 + peopleManageForm.getCreatePeopleButton().addActionListener(e -> { + NewPeopleDialog dialog = new NewPeopleDialog(); + dialog.pack(); + dialog.setVisible(true); + }); + + // 切换账号事件 + peopleManageForm.getAccountComboBox().addItemListener(e -> { + if (e.getStateChange() == ItemEvent.SELECTED) { + String accountName = e.getItem().toString(); + + PeopleManageForm.initPeopleList(); + } + }); + + // 删除按钮事件 + peopleManageForm.getDeleteButton().addActionListener(e -> { + try { + int[] selectedRows = peopleListTable.getSelectedRows(); + if (selectedRows.length == 0) { + JOptionPane.showMessageDialog(mainPanel, "请至少选择一个!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else { + int isDelete = JOptionPane.showConfirmDialog(mainPanel, "确认删除?", "确认", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + DefaultTableModel tableModel = (DefaultTableModel) peopleListTable.getModel(); + + for (int i = 0; i < selectedRows.length; i++) { + int selectedRow = selectedRows[i]; + Integer selectedId = (Integer) tableModel.getValueAt(selectedRow, 1); + peopleMapper.deleteByPrimaryKey(selectedId); + } + + PeopleManageForm.initPeopleList(); + } + } + } catch (Exception e1) { + JOptionPane.showMessageDialog(mainPanel, "删除失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + } + }); + + // 点击左侧表格事件 + peopleListTable.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + + int selectedRow = peopleListTable.getSelectedRow(); + selectedPeopleId = (int) peopleListTable.getValueAt(selectedRow, 1); + + PeopleEditForm.initDataTable(selectedPeopleId); + + super.mousePressed(e); + } + }); + } +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/PushHisListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/PushHisListener.java deleted file mode 100644 index 5dc5c87db..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/PushHisListener.java +++ /dev/null @@ -1,245 +0,0 @@ -package com.fangxuele.tool.push.ui.listener; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.swing.clipboard.ClipboardUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.dao.TPushHistoryMapper; -import com.fangxuele.tool.push.domain.TPushHistory; -import com.fangxuele.tool.push.logic.PushData; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.MemberForm; -import com.fangxuele.tool.push.ui.form.PushHisForm; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.opencsv.CSVReader; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import javax.swing.table.DefaultTableModel; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collections; - -/** - *
- * 推送历史管理tab相关事件监听
- * 
- * - * @author RememBerBer - * @since 2017/6/16. - */ -public class PushHisListener { - private static final Log logger = LogFactory.get(); - - private static TPushHistoryMapper pushHistoryMapper = MybatisUtil.getSqlSession().getMapper(TPushHistoryMapper.class); - - public static void addListeners() { - JTable pushHisLeftTable = PushHisForm.getInstance().getPushHisLeftTable(); - JPanel pushHisPanel = MainWindow.getInstance().getPushHisPanel(); - PushHisForm pushHisForm = PushHisForm.getInstance(); - MemberForm memberForm = MemberForm.getInstance(); - - // 点击左侧表格事件 - pushHisLeftTable.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - ThreadUtil.execute(() -> { - pushHisForm.getPushHisTextArea().setText(""); - - int selectedRow = pushHisLeftTable.getSelectedRow(); - String selectedId = pushHisLeftTable - .getValueAt(selectedRow, 3).toString(); - TPushHistory tPushHistory = pushHistoryMapper.selectByPrimaryKey(Integer.valueOf(selectedId)); - File pushHisFile = new File(tPushHistory.getCsvFile()); - - try { - BufferedReader br = new BufferedReader(new FileReader(pushHisFile)); - String line = br.readLine(); - long count = 0; - pushHisForm.getProgressBar().setVisible(true); - pushHisForm.getProgressBar().setIndeterminate(true); - pushHisForm.getContentScrollPane().setVisible(false); - pushHisForm.getContentControllPanel().setVisible(false); - while (StringUtils.isNotEmpty(line)) { - pushHisForm.getPushHisTextArea().append(line); - pushHisForm.getPushHisTextArea().append("\n"); - line = br.readLine(); - count++; - } - pushHisForm.getContentScrollPane().setVisible(true); - pushHisForm.getContentControllPanel().setVisible(true); - pushHisForm.getProgressBar().setVisible(false); - - pushHisForm.getPushHisCountLabel().setText("共" + count + "条"); - } catch (IOException e1) { - e1.printStackTrace(); - } - - }); - super.mousePressed(e); - } - }); - - // 推送历史管理-删除 - pushHisForm.getPushHisLeftDeleteButton().addActionListener(e -> ThreadUtil.execute(() -> { - try { - int[] selectedRows = pushHisLeftTable.getSelectedRows(); - if (selectedRows.length == 0) { - JOptionPane.showMessageDialog(pushHisPanel, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } else { - int isDelete = JOptionPane.showConfirmDialog(pushHisPanel, "确认删除?", "确认", - JOptionPane.YES_NO_OPTION); - if (isDelete == JOptionPane.YES_OPTION) { - DefaultTableModel tableModel = (DefaultTableModel) pushHisLeftTable.getModel(); - for (int i = selectedRows.length; i > 0; i--) { - int selectedRow = pushHisLeftTable.getSelectedRow(); - Integer selectedId = (Integer) tableModel.getValueAt(selectedRow, 3); - TPushHistory tPushHistory = pushHistoryMapper.selectByPrimaryKey(selectedId); - - File msgTemplateDataFile = new File(tPushHistory.getCsvFile()); - if (msgTemplateDataFile.exists()) { - msgTemplateDataFile.delete(); - } - pushHistoryMapper.deleteByPrimaryKey(selectedId); - - tableModel.removeRow(selectedRow); - } - pushHisLeftTable.updateUI(); - PushHisForm.init(); - } - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(pushHisPanel, "删除失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - })); - - // 推送历史管理-复制按钮 - pushHisForm.getPushHisCopyButton().addActionListener(e -> ThreadUtil.execute(() -> { - try { - pushHisForm.getPushHisCopyButton().setEnabled(false); - ClipboardUtil.setStr(pushHisForm.getPushHisTextArea().getText()); - JOptionPane.showMessageDialog(pushHisPanel, "内容已经复制到剪贴板!", "复制成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - logger.error(e1); - } finally { - pushHisForm.getPushHisCopyButton().setEnabled(true); - } - - })); - - // 推送历史管理-导出按钮 - pushHisForm.getPushHisExportButton().addActionListener(e -> { - int[] selectedRows = pushHisLeftTable.getSelectedRows(); - - try { - if (selectedRows.length > 0) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int approve = fileChooser.showOpenDialog(pushHisPanel); - String exportPath; - if (approve == JFileChooser.APPROVE_OPTION) { - exportPath = fileChooser.getSelectedFile().getAbsolutePath(); - } else { - return; - } - - for (int row : selectedRows) { - Integer selectedId = (Integer) pushHisLeftTable.getValueAt(row, 3); - TPushHistory tPushHistory = pushHistoryMapper.selectByPrimaryKey(selectedId); - File msgTemplateDataFile = new File(tPushHistory.getCsvFile()); - if (msgTemplateDataFile.exists()) { - FileUtil.copy(msgTemplateDataFile.getAbsolutePath(), exportPath, true); - } - } - JOptionPane.showMessageDialog(pushHisPanel, "导出成功!", "提示", - JOptionPane.INFORMATION_MESSAGE); - try { - Desktop desktop = Desktop.getDesktop(); - desktop.open(new File(exportPath)); - } catch (Exception e2) { - logger.error(e2); - } - } else { - JOptionPane.showMessageDialog(pushHisPanel, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } - - } catch (Exception e1) { - JOptionPane.showMessageDialog(pushHisPanel, "导出失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - - }); - - // 重发 - pushHisForm.getResendFromHisButton().addActionListener(e -> ThreadUtil.execute(() -> { - JProgressBar memberTabImportProgressBar = memberForm.getMemberTabImportProgressBar(); - int[] selectedRows = pushHisLeftTable.getSelectedRows(); - CSVReader reader = null; - try { - if (selectedRows.length > 0) { - MainWindow.getInstance().getTabbedPane().setSelectedIndex(3); - PushData.allUser = Collections.synchronizedList(new ArrayList<>()); - memberTabImportProgressBar.setVisible(true); - memberTabImportProgressBar.setIndeterminate(true); - for (int selectedRow : selectedRows) { - Integer selectedId = (Integer) pushHisLeftTable.getValueAt(selectedRow, 3); - TPushHistory tPushHistory = pushHistoryMapper.selectByPrimaryKey(selectedId); - File msgTemplateDataFile = new File(tPushHistory.getCsvFile()); - if (msgTemplateDataFile.exists()) { - // 可以解决中文乱码问题 - DataInputStream in = new DataInputStream(new FileInputStream(msgTemplateDataFile)); - reader = new CSVReader(new InputStreamReader(in, StandardCharsets.UTF_8)); - String[] nextLine; - while ((nextLine = reader.readNext()) != null) { - PushData.allUser.add(nextLine); - memberForm.getMemberTabCountLabel().setText(String.valueOf(PushData.allUser.size())); - } - } - } - JOptionPane.showMessageDialog(pushHisPanel, "导入完成!", "完成", - JOptionPane.INFORMATION_MESSAGE); - } else { - JOptionPane.showMessageDialog(pushHisPanel, "请至少选择一个!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(pushHisPanel, "导入失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } finally { - memberTabImportProgressBar.setMaximum(100); - memberTabImportProgressBar.setValue(100); - memberTabImportProgressBar.setIndeterminate(false); - memberTabImportProgressBar.setVisible(false); - if (reader != null) { - try { - reader.close(); - } catch (IOException e1) { - logger.error(e1); - e1.printStackTrace(); - } - } - } - - })); - - } - -} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/PushListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/PushListener.java deleted file mode 100644 index 8b009795f..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/PushListener.java +++ /dev/null @@ -1,441 +0,0 @@ -package com.fangxuele.tool.push.ui.listener; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.cron.CronUtil; -import cn.hutool.cron.pattern.CronPattern; -import cn.hutool.cron.pattern.CronPatternUtil; -import cn.hutool.cron.task.Task; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.PushControl; -import com.fangxuele.tool.push.logic.PushData; -import com.fangxuele.tool.push.logic.PushRunThread; -import com.fangxuele.tool.push.ui.UiConsts; -import com.fangxuele.tool.push.ui.dialog.CommonTipsDialog; -import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.PushForm; -import com.fangxuele.tool.push.ui.form.ScheduleForm; -import org.apache.commons.compress.utils.Lists; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.commons.lang3.time.DateUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Date; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -/** - *
- * 推送tab相关事件监听
- * 
- * - * @author RememBerBer - * @since 2017/6/19. - */ -public class PushListener { - private static final Log logger = LogFactory.get(); - - private static ScheduledExecutorService serviceStartAt; - - private static ScheduledExecutorService serviceStartPerDay; - - private static ScheduledExecutorService serviceStartPerWeek; - - public static void addListeners() { - PushForm pushForm = PushForm.getInstance(); - JPanel pushPanel = pushForm.getPushPanel(); - - // 开始按钮事件 - pushForm.getPushStartButton().addActionListener((e) -> ThreadUtil.execute(() -> { - PushData.boostMode = false; - if (PushControl.pushCheck()) { - int isPush = JOptionPane.showConfirmDialog(pushPanel, - "确定开始推送吗?\n\n推送消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - pushForm.getDryRunCheckBox().isSelected() + "\n", "确认推送?", - JOptionPane.YES_NO_OPTION); - if (isPush == JOptionPane.YES_OPTION) { - ThreadUtil.execute(new PushRunThread()); - } - } - })); - - // 停止按钮事件 - pushForm.getPushStopButton().addActionListener((e) -> { - ThreadUtil.execute(() -> { - if (PushData.scheduling) { - pushForm.getScheduleDetailLabel().setText(""); - if (serviceStartAt != null) { - serviceStartAt.shutdownNow(); - } - pushForm.getPushStartButton().setEnabled(true); - pushForm.getScheduleRunButton().setEnabled(true); - pushForm.getPushStopButton().setText("停止"); - pushForm.getPushStopButton().setEnabled(false); - pushForm.getPushStartButton().updateUI(); - pushForm.getScheduleRunButton().updateUI(); - pushForm.getPushStopButton().updateUI(); - pushForm.getScheduleDetailLabel().setVisible(false); - PushData.scheduling = false; - PushData.running = false; - } - - if (PushData.fixRateScheduling) { - pushForm.getScheduleDetailLabel().setText(""); - if (serviceStartPerDay != null) { - serviceStartPerDay.shutdownNow(); - } - if (serviceStartPerWeek != null) { - serviceStartPerWeek.shutdownNow(); - } - try { - CronUtil.stop(); - } catch (Exception e1) { - logger.warn(e1.toString()); - } - pushForm.getPushStartButton().setEnabled(true); - pushForm.getScheduleRunButton().setEnabled(true); - pushForm.getPushStopButton().setText("停止"); - pushForm.getPushStopButton().setEnabled(false); - pushForm.getPushStartButton().updateUI(); - pushForm.getScheduleRunButton().updateUI(); - pushForm.getPushStopButton().updateUI(); - pushForm.getScheduleDetailLabel().setVisible(false); - PushData.fixRateScheduling = false; - PushData.running = false; - } - - if (PushData.running) { - int isStop = JOptionPane.showConfirmDialog(pushPanel, - "确定停止当前的推送吗?", "确认停止?", - JOptionPane.YES_NO_OPTION); - if (isStop == JOptionPane.YES_OPTION) { - PushData.running = false; - pushForm.getPushStartButton().setEnabled(true); - pushForm.getScheduleRunButton().setEnabled(true); - pushForm.getPushStopButton().setText("停止"); - pushForm.getPushStopButton().setEnabled(false); - pushForm.getPushStartButton().updateUI(); - pushForm.getScheduleRunButton().updateUI(); - pushForm.getPushStopButton().updateUI(); - pushForm.getScheduleDetailLabel().setVisible(false); - } - } - }); - }); - - // 按计划执行按钮事件 - pushForm.getScheduleRunButton().addActionListener((e -> ThreadUtil.execute(() -> { - PushData.boostMode = false; - if (PushControl.pushCheck()) { - // 看是否存在设置的计划任务 - boolean existScheduleTask = false; - - // 定时开始 - if (App.config.isRadioStartAt()) { - long startAtMills = DateUtil.parse(App.config.getTextStartAt(), DatePattern.NORM_DATETIME_PATTERN).getTime(); - if (startAtMills < System.currentTimeMillis()) { - JOptionPane.showMessageDialog(pushPanel, "计划开始推送时间不能小于系统当前时间!\n\n请检查计划任务设置!\n\n", "提示", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - int isSchedulePush = JOptionPane.showConfirmDialog(pushPanel, - "将在" + - App.config.getTextStartAt() + - "推送\n\n消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - pushForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.scheduling = true; - // 按钮状态 - pushForm.getScheduleRunButton().setEnabled(false); - pushForm.getPushStartButton().setEnabled(false); - pushForm.getPushStopButton().setText("停止计划任务"); - pushForm.getPushStopButton().setEnabled(true); - - pushForm.getScheduleDetailLabel().setVisible(true); - pushForm.getScheduleDetailLabel().setText("计划任务执行中:将在" + - App.config.getTextStartAt() + - "开始推送"); - - serviceStartAt = Executors.newSingleThreadScheduledExecutor(); - serviceStartAt.schedule(new PushRunThread(), startAtMills - System.currentTimeMillis(), TimeUnit.MILLISECONDS); - } - existScheduleTask = true; - } - - // 每天固定时间开始 - if (App.config.isRadioPerDay()) { - long startPerDayMills = DateUtil.parse(DateUtil.today() + " " + App.config.getTextPerDay(), DatePattern.NORM_DATETIME_PATTERN).getTime(); - - int isSchedulePush = JOptionPane.showConfirmDialog(pushPanel, - "将在每天" + - App.config.getTextPerDay() + - "推送\n\n消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - pushForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.fixRateScheduling = true; - // 按钮状态 - pushForm.getScheduleRunButton().setEnabled(false); - pushForm.getPushStartButton().setEnabled(false); - pushForm.getPushStopButton().setText("停止计划任务"); - pushForm.getPushStopButton().setEnabled(true); - - pushForm.getScheduleDetailLabel().setVisible(true); - pushForm.getScheduleDetailLabel().setText("计划任务执行中:将在每天" + - App.config.getTextPerDay() + - "开始推送"); - - serviceStartPerDay = Executors.newSingleThreadScheduledExecutor(); - long millisBetween = startPerDayMills - System.currentTimeMillis(); - long delay = millisBetween < 0 ? millisBetween + 24 * 60 * 60 * 1000 : millisBetween; - serviceStartPerDay.scheduleAtFixedRate(new PushRunThread(), delay, 24 * 60 * 60 * 1000, TimeUnit.MILLISECONDS); - } - existScheduleTask = true; - } - - // 每周固定时间开始 - if (App.config.isRadioPerWeek()) { - - long todaySetMills = DateUtil.parse(DateUtil.today() + " " + App.config.getTextPerWeekTime(), DatePattern.NORM_DATETIME_PATTERN).getTime(); - int dayBetween = ScheduleForm.getDayOfWeek(App.config.getTextPerWeekWeek()) - DateUtil.thisDayOfWeek(); - long startPerWeekMills = dayBetween < 0 ? (dayBetween + 7) * 24 * 60 * 60 * 1000 : dayBetween * 24 * 60 * 60 * 1000; - - int isSchedulePush = JOptionPane.showConfirmDialog(pushPanel, - "将在每周" + App.config.getTextPerWeekWeek() + - App.config.getTextPerWeekTime() + - "推送\n\n消息:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n\n推送人数:" + PushData.allUser.size() + - "\n\n空跑模式:" + - pushForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.scheduling = true; - PushData.fixRateScheduling = true; - // 按钮状态 - pushForm.getScheduleRunButton().setEnabled(false); - pushForm.getPushStartButton().setEnabled(false); - pushForm.getPushStopButton().setText("停止计划任务"); - pushForm.getPushStopButton().setEnabled(true); - - pushForm.getScheduleDetailLabel().setVisible(true); - pushForm.getScheduleDetailLabel().setText("计划任务执行中:将在每周" + - App.config.getTextPerWeekWeek() + - App.config.getTextPerWeekTime() + - "开始推送"); - - serviceStartPerWeek = Executors.newSingleThreadScheduledExecutor(); - long millisBetween = startPerWeekMills + todaySetMills - System.currentTimeMillis(); - long delay = millisBetween < 0 ? millisBetween + 7 * 24 * 60 * 60 * 1000 : millisBetween; - serviceStartPerWeek.scheduleAtFixedRate(new PushRunThread(), delay, 7 * 24 * 60 * 60 * 1000, TimeUnit.MILLISECONDS); - } - existScheduleTask = true; - } - - // 按Cron表达式触发 - if (App.config.isRadioCron()) { - - List latest5RunTimeList = Lists.newArrayList(); - Date now = new Date(); - for (int i = 0; i < 5; i++) { - Date date = CronPatternUtil.nextDateAfter(new CronPattern(App.config.getTextCron()), DateUtils.addDays(now, i), true); - latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); - } - - int isSchedulePush = JOptionPane.showConfirmDialog(pushPanel, - "将按" + - App.config.getTextCron() + - "表达式触发推送\n\n" + - "最近5次运行时间:\n" + - String.join("\n", latest5RunTimeList) + - "\n\n消息名称:" + - MessageEditForm.getInstance().getMsgNameField().getText() + - "\n推送人数:" + PushData.allUser.size() + - "\n空跑模式:" + - pushForm.getDryRunCheckBox().isSelected(), "确认定时推送?", - JOptionPane.YES_NO_OPTION); - if (isSchedulePush == JOptionPane.YES_OPTION) { - PushData.fixRateScheduling = true; - // 按钮状态 - pushForm.getScheduleRunButton().setEnabled(false); - pushForm.getPushStartButton().setEnabled(false); - pushForm.getPushStopButton().setText("停止计划任务"); - pushForm.getPushStopButton().setEnabled(true); - - pushForm.getScheduleDetailLabel().setVisible(true); - pushForm.getScheduleDetailLabel().setText("计划任务执行中,下一次执行时间:" + latest5RunTimeList.get(0)); - - // 支持秒级别定时任务 - CronUtil.setMatchSecond(true); - CronUtil.schedule(App.config.getTextCron(), (Task) () -> new PushRunThread().start()); - CronUtil.start(); - } - existScheduleTask = true; - } - - if (!existScheduleTask) { - JOptionPane.showMessageDialog(pushPanel, "请先设置计划任务!", "提示", - JOptionPane.INFORMATION_MESSAGE); - } - } - }))); - - // 线程池数失去焦点 - pushForm.getMaxThreadPoolTextField().addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - try { - tEvent(); - } catch (Exception e1) { - logger.error(e1); - } finally { - super.focusLost(e); - } - } - }); - - // 线程池数键入回车 - pushForm.getMaxThreadPoolTextField().addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - try { - tEvent(); - } catch (Exception e1) { - logger.error(e1); - } finally { - super.keyPressed(e); - } - } - }); - - // 线程数滑块 - pushForm.getThreadCountSlider().addChangeListener(e -> { - int slideValue = pushForm.getThreadCountSlider().getValue(); - pushForm.getThreadCountTextField().setText(String.valueOf(slideValue)); - App.config.setThreadCount(slideValue); - refreshPushInfo(); - }); - - pushForm.getThreadTipsLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - CommonTipsDialog dialog = new CommonTipsDialog(); - - StringBuilder tipsBuilder = new StringBuilder(); - tipsBuilder.append("

线程数调整为多少比较合适?

"); - tipsBuilder.append("

建议不要超过100

"); - tipsBuilder.append("

WePush的连接池管理尚未开发完毕

"); - tipsBuilder.append("

目前使用的是各自消息类型官方SDK(微信相关消息除外)内置的连接池

"); - tipsBuilder.append("

如果优先考虑推送的成功率而非速度建议30-50左右

"); - - dialog.setHtmlText(tipsBuilder.toString()); - dialog.pack(); - dialog.setVisible(true); - - super.mousePressed(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); - super.mouseEntered(e); - } - - @Override - public void mouseExited(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); - super.mouseExited(e); - } - }); - - pushForm.getDryRunHelpLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - CommonTipsDialog dialog = new CommonTipsDialog(); - - StringBuilder tipsBuilder = new StringBuilder(); - tipsBuilder.append("

什么是空跑?

"); - tipsBuilder.append("

除了不会真实发送消息,其他与正常推送流程相同

"); - tipsBuilder.append("

空跑模式可以验证消息数据以及流程的准确性

"); - tipsBuilder.append("

建议在执行真正推送之前先进行一遍空跑

"); - - dialog.setHtmlText(tipsBuilder.toString()); - dialog.pack(); - dialog.setVisible(true); - - super.mousePressed(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); - super.mouseEntered(e); - } - - @Override - public void mouseExited(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); - super.mouseExited(e); - } - }); - } - - private static void tEvent() { - PushForm pushForm = PushForm.getInstance(); - - if (Integer.parseInt(pushForm.getMaxThreadPoolTextField().getText()) > 1000) { - JOptionPane.showMessageDialog(pushForm.getPushPanel(), "最大输入1000", "提示", - JOptionPane.INFORMATION_MESSAGE); - pushForm.getMaxThreadPoolTextField().setText("1000"); - } - pushForm.getThreadCountSlider().setMaximum(Integer.parseInt(pushForm.getMaxThreadPoolTextField().getText())); - refreshPushInfo(); - } - - static void refreshPushInfo() { - PushForm pushForm = PushForm.getInstance(); - - // 总记录数 - long totalCount = PushData.allUser.size(); - pushForm.getPushTotalCountLabel().setText("消息总数:" + totalCount); - // 每个线程平均分配 - int threadCount = Integer.parseInt(pushForm.getThreadCountTextField().getText()); - int perThread = (int) (totalCount / threadCount) + 1; - pushForm.getCountPerThread().setText("每个线程平均分配:" + perThread); - // 可用处理器核心 - pushForm.getAvailableProcessorLabel().setText("可用处理器核心:" + Runtime.getRuntime().availableProcessors()); - // JVM内存占用 - pushForm.getJvmMemoryLabel().setText("JVM内存占用:" + FileUtil.readableFileSize(Runtime.getRuntime().totalMemory()) + "/" + FileUtil.readableFileSize(Runtime.getRuntime().maxMemory())); - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/ScheduleListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/ScheduleListener.java deleted file mode 100644 index 5ea0ad78e..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/ScheduleListener.java +++ /dev/null @@ -1,268 +0,0 @@ -package com.fangxuele.tool.push.ui.listener; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.cron.pattern.CronPattern; -import cn.hutool.cron.pattern.CronPatternUtil; -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.ui.UiConsts; -import com.fangxuele.tool.push.ui.dialog.CommonTipsDialog; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.ScheduleForm; -import com.fangxuele.tool.push.ui.form.SettingForm; -import org.apache.commons.compress.utils.Lists; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.commons.lang3.time.DateUtils; -import org.quartz.CronExpression; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Date; -import java.util.List; -import java.util.Objects; - -/** - *
- * 计划任务tab相关事件监听
- * 
- * - * @author RememBerBer - * @since 2017/6/28. - */ -public class ScheduleListener { - private static final Log logger = LogFactory.get(); - - public static void addListeners() { - ScheduleForm scheduleForm = ScheduleForm.getInstance(); - MainWindow mainWindow = MainWindow.getInstance(); - - scheduleForm.getScheduleSaveButton().addActionListener(e -> { - try { - String textStartAt = scheduleForm.getStartAtThisTimeTextField().getText(); - boolean isStartAt = scheduleForm.getRunAtThisTimeRadioButton().isSelected(); - if (StringUtils.isNotEmpty(textStartAt)) { - if (DateUtil.parse(textStartAt).getTime() <= System.currentTimeMillis() && isStartAt) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "保存失败!\n\n开始推送时间不能小于系统当前时间!", "失败", - JOptionPane.ERROR_MESSAGE); - return; - } - App.config.setRadioStartAt(isStartAt); - App.config.setTextStartAt(textStartAt); - } else if (isStartAt) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "保存失败!\n\n开始推送时间不能为空!", "失败", - JOptionPane.ERROR_MESSAGE); - return; - } else { - App.config.setRadioStartAt(isStartAt); - App.config.setTextStartAt(textStartAt); - } - - String textPerDay = scheduleForm.getStartPerDayTextField().getText(); - boolean isPerDay = scheduleForm.getRunPerDayRadioButton().isSelected(); - if (StringUtils.isNotEmpty(textPerDay)) { - DateUtil.parse(textPerDay); - App.config.setRadioPerDay(isPerDay); - App.config.setTextPerDay(textPerDay); - } else if (isPerDay) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "保存失败!\n\n每天固定推送时间不能为空!", "失败", - JOptionPane.ERROR_MESSAGE); - return; - } else { - App.config.setRadioPerDay(isPerDay); - App.config.setTextPerDay(textPerDay); - } - - String textPerWeekTime = scheduleForm.getStartPerWeekTextField().getText(); - boolean isPerWeek = scheduleForm.getRunPerWeekRadioButton().isSelected(); - if (StringUtils.isNotEmpty(textPerWeekTime)) { - DateUtil.parse(textPerWeekTime); - App.config.setRadioPerWeek(isPerWeek); - App.config.setTextPerWeekWeek(Objects.requireNonNull(scheduleForm.getSchedulePerWeekComboBox().getSelectedItem()).toString()); - App.config.setTextPerWeekTime(textPerWeekTime); - } else if (isPerWeek) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "保存失败!\n\n每周固定推送时间不能为空!", "失败", - JOptionPane.ERROR_MESSAGE); - return; - } else { - App.config.setRadioPerWeek(isPerWeek); - App.config.setTextPerWeekWeek(Objects.requireNonNull(scheduleForm.getSchedulePerWeekComboBox().getSelectedItem()).toString()); - App.config.setTextPerWeekTime(textPerWeekTime); - } - - String textCron = scheduleForm.getCronTextField().getText(); - boolean isCron = scheduleForm.getCronRadioButton().isSelected(); - if (StringUtils.isNotEmpty(textCron)) { - try { - CronExpression.validateExpression(textCron); - } catch (Exception e1) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "保存失败!\n\n无效的Cron表达式!\n" + e1.toString(), "失败", - JOptionPane.ERROR_MESSAGE); - return; - } - if (isCron) { - List latest5RunTimeList = Lists.newArrayList(); - Date now = new Date(); - for (int i = 0; i < 5; i++) { - Date date = CronPatternUtil.nextDateAfter(new CronPattern(textCron), DateUtils.addDays(now, i), true); - latest5RunTimeList.add(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); - } - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "最近5次运行时间:\n" + String.join("\n", latest5RunTimeList), "提示", - JOptionPane.INFORMATION_MESSAGE); - } - App.config.setRadioCron(isCron); - App.config.setTextCron(textCron); - } else if (isCron) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "保存失败!\n\nCron表达式不能为空!", "失败", - JOptionPane.ERROR_MESSAGE); - return; - } else { - App.config.setRadioCron(isCron); - App.config.setTextCron(textCron); - } - - if (scheduleForm.getSendPushResultCheckBox().isSelected() && - (StringUtils.isBlank(SettingForm.getInstance().getMailHostTextField().getText()) - || StringUtils.isBlank(SettingForm.getInstance().getMailFromTextField().getText()))) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), - "保存失败!\n\n请先在设置中设置E-Mail服务器!", "失败", - JOptionPane.ERROR_MESSAGE); - return; - } - App.config.setSendPushResult(scheduleForm.getSendPushResultCheckBox().isSelected()); - App.config.setMailResultTos(scheduleForm.getMailResultToTextField().getText()); - - App.config.setNeedReimport(scheduleForm.getReimportCheckBox().isSelected()); - App.config.setReimportWay((String) scheduleForm.getReimportComboBox().getSelectedItem()); - - App.config.save(); - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), "保存成功!\n\n将在下一次按计划执行时生效!\n\n", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(mainWindow.getSchedulePanel(), "保存失败!\n\n时间格式错误:" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - } - }); - - scheduleForm.getRunAtThisTimeRadioButton().addActionListener(e -> { - if (scheduleForm.getRunAtThisTimeRadioButton().isSelected()) { - scheduleForm.getRunPerDayRadioButton().setSelected(false); - scheduleForm.getRunPerWeekRadioButton().setSelected(false); - scheduleForm.getCronRadioButton().setSelected(false); - } - }); - - scheduleForm.getRunPerDayRadioButton().addActionListener(e -> { - if (scheduleForm.getRunPerDayRadioButton().isSelected()) { - scheduleForm.getRunAtThisTimeRadioButton().setSelected(false); - scheduleForm.getRunPerWeekRadioButton().setSelected(false); - scheduleForm.getCronRadioButton().setSelected(false); - } - }); - - scheduleForm.getRunPerWeekRadioButton().addActionListener(e -> { - if (scheduleForm.getRunPerWeekRadioButton().isSelected()) { - scheduleForm.getRunAtThisTimeRadioButton().setSelected(false); - scheduleForm.getRunPerDayRadioButton().setSelected(false); - scheduleForm.getCronRadioButton().setSelected(false); - } - }); - - scheduleForm.getCronRadioButton().addActionListener(e -> { - if (scheduleForm.getCronRadioButton().isSelected()) { - scheduleForm.getRunAtThisTimeRadioButton().setSelected(false); - scheduleForm.getRunPerDayRadioButton().setSelected(false); - scheduleForm.getRunPerWeekRadioButton().setSelected(false); - } - }); - - scheduleForm.getCronHelpLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - CommonTipsDialog dialog = new CommonTipsDialog(); - - StringBuilder tipsBuilder = new StringBuilder(); - tipsBuilder.append("

什么是Cron表达式?

"); - tipsBuilder.append("百度百科"); - tipsBuilder.append("

举几个例子:

\n"); - tipsBuilder.append("

\"0 0 2 1 * ? *\" 表示在每月的1日的凌晨2点调度任务

\n"); - tipsBuilder.append("

\"0 15 10 ? * MON-FRI\" 表示周一到周五每天上午10:15执行作业

\n"); - tipsBuilder.append("

\"0 15 10 ? * 6L 2002-2006\" 表示2002-2006年的每个月的最后一个星期五上午10:15执行作

\n"); - tipsBuilder.append("

\"0 0 10,14,16 * * ?\" 每天上午10点,下午2点,4点

\n"); - tipsBuilder.append("

\"0 0/30 9-17 * * ?\" 朝九晚五工作时间内每半小时

\n"); - tipsBuilder.append("

\"0 0 12 ? * WED\" 表示每个星期三中午12点

\n"); - tipsBuilder.append("

\"0 0 12 * * ?\" 每天中午12点触发

\n"); - tipsBuilder.append("

\"0 15 10 ? * *\" 每天上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 * * ?\" 每天上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 * * ? *\" 每天上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 * * ? 2005\" 2005年的每天上午10:15触发

\n"); - tipsBuilder.append("

\"0 * 14 * * ?\" 在每天下午2点到下午2:59期间的每1分钟触发

\n"); - tipsBuilder.append("

\"0 0/5 14 * * ?\" 在每天下午2点到下午2:55期间的每5分钟触发

\n"); - tipsBuilder.append("

\"0 0/5 14,18 * * ?\" 在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发

\n"); - tipsBuilder.append("

\"0 0-5 14 * * ?\" 在每天下午2点到下午2:05期间的每1分钟触发

\n"); - tipsBuilder.append("

\"0 10,44 14 ? 3 WED\" 每年三月的星期三的下午2:10和2:44触发

\n"); - tipsBuilder.append("

\"0 15 10 ? * MON-FRI\" 周一至周五的上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 15 * ?\" 每月15日上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 L * ?\" 每月最后一日的上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 ? * 6L\" 每月的最后一个星期五上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 ? * 6L 2002-2005\" 2002年至2005年的每月的最后一个星期五上午10:15触发

\n"); - tipsBuilder.append("

\"0 15 10 ? * 6#3\" 每月的第三个星期五上午10:15触发"); - - dialog.setHtmlText(tipsBuilder.toString()); - dialog.getTextPane1().setCaretPosition(0); - dialog.pack(); - dialog.setVisible(true); - - super.mousePressed(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); - super.mouseEntered(e); - } - - @Override - public void mouseExited(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); - super.mouseExited(e); - } - }); - - scheduleForm.getCronOnlineLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - super.mousePressed(e); - Desktop desktop = Desktop.getDesktop(); - try { - desktop.browse(new URI("http://cron.qqe2.com/")); - } catch (IOException | URISyntaxException e1) { - e1.printStackTrace(); - } - } - - @Override - public void mouseEntered(MouseEvent e) { - super.mouseEntered(e); - e.getComponent().setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - - }); - } -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/SettingListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/SettingListener.java deleted file mode 100644 index fa9c9dbdb..000000000 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/SettingListener.java +++ /dev/null @@ -1,671 +0,0 @@ -package com.fangxuele.tool.push.ui.listener; - -import cn.hutool.log.Log; -import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TWxAccountMapper; -import com.fangxuele.tool.push.domain.TWxAccount; -import com.fangxuele.tool.push.logic.msgsender.*; -import com.fangxuele.tool.push.ui.Init; -import com.fangxuele.tool.push.ui.UiConsts; -import com.fangxuele.tool.push.ui.dialog.*; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.SettingForm; -import com.fangxuele.tool.push.ui.form.msg.DingMsgForm; -import com.fangxuele.tool.push.ui.form.msg.WxCpMsgForm; -import com.fangxuele.tool.push.util.HikariUtil; -import com.fangxuele.tool.push.util.MybatisUtil; -import com.fangxuele.tool.push.util.SqliteUtil; -import com.zaxxer.hikari.HikariDataSource; -import org.apache.commons.lang3.StringUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.List; -import java.util.Objects; - -/** - *

- * 设置tab相关事件监听
- * 
- * - * @author RememBerBer - * @since 2017/6/16. - */ -public class SettingListener { - private static final Log logger = LogFactory.get(); - - public static String wxAccountType; - - private static TWxAccountMapper wxAccountMapper = MybatisUtil.getSqlSession().getMapper(TWxAccountMapper.class); - - public static void addListeners() { - SettingForm settingForm = SettingForm.getInstance(); - JPanel settingPanel = settingForm.getSettingPanel(); - - // 设置-常规-启动时自动检查更新 - settingForm.getAutoCheckUpdateCheckBox().addActionListener(e -> { - App.config.setAutoCheckUpdate(settingForm.getAutoCheckUpdateCheckBox().isSelected()); - App.config.save(); - }); - // 设置-常规-显示系统托盘图标 - settingForm.getUseTrayCheckBox().addActionListener(e -> { - App.config.setUseTray(settingForm.getUseTrayCheckBox().isSelected()); - App.config.save(); - if (App.tray == null && App.config.isUseTray()) { - Init.initTray(); - } else if (App.tray != null && !App.config.isUseTray()) { - App.tray.remove(App.trayIcon); - App.trayIcon = null; - App.tray = null; - } - }); - - // 设置-公众号-保存 - settingForm.getSettingMpInfoSaveButton().addActionListener(e -> { - try { - String accountName; - if (settingForm.getMpAccountSwitchComboBox().getSelectedItem() == null || StringUtils.isEmpty(settingForm.getMpAccountSwitchComboBox().getSelectedItem().toString())) { - accountName = "默认账号"; - } else { - accountName = settingForm.getMpAccountSwitchComboBox().getSelectedItem().toString(); - } - App.config.setWechatMpName(accountName); - App.config.setWechatAppId(settingForm.getWechatAppIdTextField().getText()); - App.config.setWechatAppSecret(new String(settingForm.getWechatAppSecretPasswordField().getPassword())); - App.config.setWechatToken(new String(settingForm.getWechatTokenPasswordField().getPassword())); - App.config.setWechatAesKey(new String(settingForm.getWechatAesKeyPasswordField().getPassword())); - - App.config.setMpUseProxy(settingForm.getMpUseProxyCheckBox().isSelected()); - App.config.setMpProxyHost(settingForm.getMpProxyHostTextField().getText()); - App.config.setMpProxyPort(settingForm.getMpProxyPortTextField().getText()); - App.config.setMpProxyUserName(settingForm.getMpProxyUserNameTextField().getText()); - App.config.setMpProxyPassword(settingForm.getMpProxyPasswordTextField().getText()); - - App.config.setMpUseOutSideAt(settingForm.getUseOutSideAccessTokenCheckBox().isSelected()); - App.config.setMpManualAt(settingForm.getManualAtRadioButton().isSelected()); - App.config.setMpApiAt(settingForm.getApiAtRadioButton().isSelected()); - App.config.setMpAt(settingForm.getAccessTokenTextField().getText()); - App.config.setMpAtExpiresIn(settingForm.getAtExpiresInTextField().getText()); - App.config.setMpAtApiUrl(settingForm.getAtApiUrlTextField().getText()); - - App.config.save(); - - boolean update = false; - List tWxAccountList = wxAccountMapper.selectByAccountTypeAndAccountName(SettingForm.WX_ACCOUNT_TYPE_MP, accountName); - if (tWxAccountList.size() > 0) { - update = true; - } - - TWxAccount tWxAccount = new TWxAccount(); - String now = SqliteUtil.nowDateForSqlite(); - tWxAccount.setAccountType(SettingForm.WX_ACCOUNT_TYPE_MP); - tWxAccount.setAccountName(accountName); - tWxAccount.setAppId(App.config.getWechatAppId()); - tWxAccount.setAppSecret(App.config.getWechatAppSecret()); - tWxAccount.setToken(App.config.getWechatToken()); - tWxAccount.setAesKey(App.config.getWechatAesKey()); - tWxAccount.setModifiedTime(now); - if (update) { - tWxAccount.setId(tWxAccountList.get(0).getId()); - wxAccountMapper.updateByPrimaryKeySelective(tWxAccount); - } else { - tWxAccount.setCreateTime(now); - wxAccountMapper.insert(tWxAccount); - } - - SettingForm.initSwitchMultiAccount(); - WxMpTemplateMsgSender.wxMpConfigStorage = null; - WxMpTemplateMsgSender.wxMpService = null; - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-公众号-多账号管理 - settingForm.getMpAccountManageButton().addActionListener(e -> { - SwitchWxAccountDialog dialog = new SwitchWxAccountDialog(); - wxAccountType = SettingForm.WX_ACCOUNT_TYPE_MP; - dialog.renderTable(); - dialog.pack(); - dialog.setVisible(true); - }); - - // 公众号切换账号事件 - settingForm.getMpAccountSwitchComboBox().addItemListener(e -> { - if (e.getStateChange() == ItemEvent.SELECTED) { - String accountName = e.getItem().toString(); - List wxAccountList = wxAccountMapper.selectByAccountTypeAndAccountName(SettingForm.WX_ACCOUNT_TYPE_MP, accountName); - if (wxAccountList.size() > 0) { - TWxAccount tWxAccount = wxAccountList.get(0); - settingForm.getMpAccountSwitchComboBox().setSelectedItem(tWxAccount.getAccountName()); - settingForm.getWechatAppIdTextField().setText(tWxAccount.getAppId()); - settingForm.getWechatAppSecretPasswordField().setText(tWxAccount.getAppSecret()); - settingForm.getWechatTokenPasswordField().setText(tWxAccount.getToken()); - settingForm.getWechatAesKeyPasswordField().setText(tWxAccount.getAesKey()); - } - } - }); - - // 设置-小程序-保存 - settingForm.getSettingMaInfoSaveButton().addActionListener(e -> { - try { - String accountName; - if (settingForm.getMaAccountSwitchComboBox().getSelectedItem() == null || StringUtils.isEmpty(settingForm.getMaAccountSwitchComboBox().getSelectedItem().toString())) { - accountName = "默认账号"; - } else { - accountName = settingForm.getMaAccountSwitchComboBox().getSelectedItem().toString(); - } - App.config.setMiniAppName(accountName); - App.config.setMiniAppAppId(settingForm.getMiniAppAppIdTextField().getText()); - App.config.setMiniAppAppSecret(new String(settingForm.getMiniAppAppSecretPasswordField().getPassword())); - App.config.setMiniAppToken(new String(settingForm.getMiniAppTokenPasswordField().getPassword())); - App.config.setMiniAppAesKey(new String(settingForm.getMiniAppAesKeyPasswordField().getPassword())); - - App.config.setMaUseProxy(settingForm.getMaUseProxyCheckBox().isSelected()); - App.config.setMaProxyHost(settingForm.getMaProxyHostTextField().getText()); - App.config.setMaProxyPort(settingForm.getMaProxyPortTextField().getText()); - App.config.setMaProxyUserName(settingForm.getMaProxyUserNameTextField().getText()); - App.config.setMaProxyPassword(settingForm.getMaProxyPasswordTextField().getText()); - App.config.save(); - - boolean update = false; - List tWxAccountList = wxAccountMapper.selectByAccountTypeAndAccountName(SettingForm.WX_ACCOUNT_TYPE_MA, accountName); - if (tWxAccountList.size() > 0) { - update = true; - } - - TWxAccount tWxAccount = new TWxAccount(); - String now = SqliteUtil.nowDateForSqlite(); - tWxAccount.setAccountType(SettingForm.WX_ACCOUNT_TYPE_MA); - tWxAccount.setAccountName(accountName); - tWxAccount.setAppId(App.config.getMiniAppAppId()); - tWxAccount.setAppSecret(App.config.getMiniAppAppSecret()); - tWxAccount.setToken(App.config.getMiniAppToken()); - tWxAccount.setAesKey(App.config.getMiniAppAesKey()); - tWxAccount.setModifiedTime(now); - if (update) { - tWxAccount.setId(tWxAccountList.get(0).getId()); - wxAccountMapper.updateByPrimaryKeySelective(tWxAccount); - } else { - tWxAccount.setCreateTime(now); - wxAccountMapper.insert(tWxAccount); - } - - SettingForm.initSwitchMultiAccount(); - WxMaTemplateMsgSender.wxMaConfigStorage = null; - WxMaTemplateMsgSender.wxMaService = null; - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-小程序-多账号管理 - settingForm.getMaAccountManageButton().addActionListener(e -> { - SwitchWxAccountDialog dialog = new SwitchWxAccountDialog(); - wxAccountType = SettingForm.WX_ACCOUNT_TYPE_MA; - dialog.renderTable(); - dialog.pack(); - dialog.setVisible(true); - }); - - // 小程序切换账号事件 - settingForm.getMaAccountSwitchComboBox().addItemListener(e -> { - if (e.getStateChange() == ItemEvent.SELECTED) { - String accountName = e.getItem().toString(); - List wxAccountList = wxAccountMapper.selectByAccountTypeAndAccountName(SettingForm.WX_ACCOUNT_TYPE_MA, accountName); - if (wxAccountList.size() > 0) { - TWxAccount tWxAccount = wxAccountList.get(0); - settingForm.getMaAccountSwitchComboBox().setSelectedItem(tWxAccount.getAccountName()); - settingForm.getMiniAppAppIdTextField().setText(tWxAccount.getAppId()); - settingForm.getMiniAppAppSecretPasswordField().setText(tWxAccount.getAppSecret()); - settingForm.getMiniAppTokenPasswordField().setText(tWxAccount.getToken()); - settingForm.getMiniAppAesKeyPasswordField().setText(tWxAccount.getAesKey()); - } - } - }); - - // 企业号-保存 - settingForm.getWxCpSaveButton().addActionListener(e -> { - try { - App.config.setWxCpCorpId(settingForm.getWxCpCorpIdTextField().getText()); - App.config.save(); - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-企业号-应用管理 - settingForm.getWxCpAppManageButton().addActionListener(e -> { - WxCpAppDialog dialog = new WxCpAppDialog(); - dialog.renderTable(); - dialog.pack(); - dialog.setVisible(true); - WxCpMsgForm.initAppNameList(); - }); - - // 设置-钉钉-应用管理 - settingForm.getDingAppManageButton().addActionListener(e -> { - DingAppDialog dialog = new DingAppDialog(); - dialog.renderTable(); - dialog.pack(); - dialog.setVisible(true); - DingMsgForm.initAppNameList(); - }); - - // 设置-阿里云短信-保存 - settingForm.getSettingAliyunSaveButton().addActionListener(e -> { - try { - App.config.setAliyunAccessKeyId(settingForm.getAliyunAccessKeyIdTextField().getText()); - App.config.setAliyunAccessKeySecret(new String(settingForm.getAliyunAccessKeySecretTextField().getPassword())); - App.config.setAliyunSign(settingForm.getAliyunSignTextField().getText()); - App.config.save(); - AliYunMsgSender.iAcsClient = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-腾讯云短信-保存 - settingForm.getSettingTxyunSaveButton().addActionListener(e -> { - try { - App.config.setTxyunAppId(settingForm.getTxyunAppIdTextField().getText()); - App.config.setTxyunAppKey(new String(settingForm.getTxyunAppKeyTextField().getPassword())); - App.config.setTxyunSign(settingForm.getTxyunSignTextField().getText()); - App.config.save(); - - TxYunMsgSender.smsSingleSender = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-华为云短信-保存 - settingForm.getHwSaveButton().addActionListener(e -> { - try { - App.config.setHwAppKey(settingForm.getHwAppKeyTextField().getText()); - App.config.setHwAppSecretPassword(new String(settingForm.getHwAppSecretPasswordField().getPassword())); - App.config.setHwAccessUrl(settingForm.getHwAccessUrlTextField().getText()); - App.config.setHwSenderCode(settingForm.getHwSenderCodeTextField().getText()); - App.config.setHwSignature(settingForm.getHwSignatureTextField().getText()); - App.config.save(); - - HwYunMsgSender.closeableHttpClient = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-百度云短信-保存 - settingForm.getBdSaveButton().addActionListener(e -> { - try { - App.config.setBdAccessKeyId(settingForm.getBdAccessKeyIdTextField().getText()); - App.config.setBdSecretAccessKey(new String(settingForm.getBdSecretAccessKeyPasswordField().getPassword())); - App.config.setBdEndPoint(settingForm.getBdEndPointTextField().getText()); - App.config.setBdInvokeId(settingForm.getBdInvokeIdTextField().getText()); - App.config.save(); - - BdYunMsgSender.smsClient = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-又拍云短信-保存 - settingForm.getUpSaveButton().addActionListener(e -> { - try { - App.config.setUpAuthorizationToken(settingForm.getUpAuthorizationTokenTextField().getText()); - App.config.save(); - - HttpMsgSender.okHttpClient = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-七牛云短信-保存 - settingForm.getQiniuSaveButton().addActionListener(e -> { - try { - App.config.setQiniuAccessKey(settingForm.getQiniuAccessKeyTextField().getText()); - App.config.setQiniuSecretKey(settingForm.getQiniuSecretKeyTextField().getText()); - App.config.save(); - - QiNiuYunMsgSender.smsManager = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 设置-云片网短信-保存 - settingForm.getSettingYunpianSaveButton().addActionListener(e -> { - try { - App.config.setYunpianApiKey(new String(settingForm.getYunpianApiKeyTextField().getPassword())); - App.config.save(); - YunPianMsgSender.yunpianClient = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - settingForm.getHttpSaveButton().addActionListener(e -> { - try { - App.config.setHttpUseProxy(settingForm.getHttpUseProxyCheckBox().isSelected()); - App.config.setHttpProxyHost(settingForm.getHttpProxyHostTextField().getText()); - App.config.setHttpProxyPort(settingForm.getHttpProxyPortTextField().getText()); - App.config.setHttpProxyUserName(settingForm.getHttpProxyUserTextField().getText()); - App.config.setHttpProxyPassword(settingForm.getHttpProxyPasswordTextField().getText()); - App.config.save(); - - HttpMsgSender.proxy = null; - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // E-Mail测试 - settingForm.getTestMailButton().addActionListener(e -> { - App.config.setMailHost(settingForm.getMailHostTextField().getText()); - App.config.setMailPort(settingForm.getMailPortTextField().getText()); - App.config.setMailFrom(settingForm.getMailFromTextField().getText()); - App.config.setMailUser(settingForm.getMailUserTextField().getText()); - App.config.setMailPassword(new String(settingForm.getMailPasswordField().getPassword())); - App.config.setMailUseStartTLS(settingForm.getMailStartTLSCheckBox().isSelected()); - App.config.setMailUseSSL(settingForm.getMailSSLCheckBox().isSelected()); - MailMsgSender.mailAccount = null; - - MailTestDialog mailTestDialog = new MailTestDialog(); - mailTestDialog.pack(); - mailTestDialog.setVisible(true); - }); - - // E-Mail保存 - settingForm.getSaveMailButton().addActionListener(e -> { - try { - App.config.setMailHost(settingForm.getMailHostTextField().getText()); - App.config.setMailPort(settingForm.getMailPortTextField().getText()); - App.config.setMailFrom(settingForm.getMailFromTextField().getText()); - App.config.setMailUser(settingForm.getMailUserTextField().getText()); - App.config.setMailPassword(new String(settingForm.getMailPasswordField().getPassword())); - App.config.setMailUseStartTLS(settingForm.getMailStartTLSCheckBox().isSelected()); - App.config.setMailUseSSL(settingForm.getMailSSLCheckBox().isSelected()); - App.config.save(); - - MailMsgSender.mailAccount = null; - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // mysql数据库-测试链接 - settingForm.getSettingTestDbLinkButton().addActionListener(e -> { - HikariDataSource hikariDataSource = null; - try { - String dbUrl = settingForm.getMysqlUrlTextField().getText(); - String dbUser = settingForm.getMysqlUserTextField().getText(); - String dbPassword = new String(settingForm.getMysqlPasswordField().getPassword()); - if (StringUtils.isBlank(dbUrl)) { - settingForm.getMysqlUrlTextField().grabFocus(); - return; - } - if (StringUtils.isBlank(dbUser)) { - settingForm.getMysqlUserTextField().grabFocus(); - return; - } - if (StringUtils.isBlank(dbPassword)) { - settingForm.getMysqlPasswordField().grabFocus(); - return; - } - hikariDataSource = new HikariDataSource(); - hikariDataSource.setJdbcUrl("jdbc:mysql://" + dbUrl); - hikariDataSource.setUsername(dbUser); - hikariDataSource.setPassword(dbPassword); - if (hikariDataSource.getConnection() == null) { - JOptionPane.showMessageDialog(settingPanel, "连接失败", "失败", - JOptionPane.ERROR_MESSAGE); - } else { - JOptionPane.showMessageDialog(settingPanel, "连接成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "连接失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } finally { - if (hikariDataSource != null) { - try { - hikariDataSource.close(); - } catch (Exception e2) { - logger.error(e2); - } - } - } - }); - - // mysql数据库-保存 - settingForm.getSettingDbInfoSaveButton().addActionListener(e -> { - try { - App.config.setMysqlUrl(settingForm.getMysqlUrlTextField().getText()); - App.config.setMysqlUser(settingForm.getMysqlUserTextField().getText()); - App.config.setMysqlPassword(new String(settingForm.getMysqlPasswordField().getPassword())); - App.config.save(); - - if (HikariUtil.getHikariDataSource() != null) { - HikariUtil.getHikariDataSource().close(); - } - - JOptionPane.showMessageDialog(settingPanel, "保存成功!", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - // 外观-保存 - settingForm.getSettingAppearanceSaveButton().addActionListener(e -> { - try { - App.config.setTheme(Objects.requireNonNull(settingForm.getSettingThemeComboBox().getSelectedItem()).toString()); - App.config.setFont(Objects.requireNonNull(settingForm.getSettingFontNameComboBox().getSelectedItem()).toString()); - App.config.setFontSize(Integer.parseInt(Objects.requireNonNull(settingForm.getSettingFontSizeComboBox().getSelectedItem()).toString())); - App.config.save(); - - Init.initTheme(); - Init.initGlobalFont(); - SwingUtilities.updateComponentTreeUI(App.mainFrame); - SwingUtilities.updateComponentTreeUI(MainWindow.getInstance().getTabbedPane()); - - JOptionPane.showMessageDialog(settingPanel, "保存成功!\n\n部分细节将在下次启动时生效!\n\n", "成功", - JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e1) { - JOptionPane.showMessageDialog(settingPanel, "保存失败!\n\n" + e1.getMessage(), "失败", - JOptionPane.ERROR_MESSAGE); - logger.error(e1); - } - }); - - settingForm.getMpUseProxyCheckBox().addChangeListener(e -> SettingForm.toggleMpProxyPanel()); - settingForm.getMaUseProxyCheckBox().addChangeListener(e -> SettingForm.toggleMaProxyPanel()); - settingForm.getHttpUseProxyCheckBox().addChangeListener(e -> SettingForm.toggleHttpProxyPanel()); - settingForm.getUseOutSideAccessTokenCheckBox().addChangeListener(e -> SettingForm.toggleMpOutSideAccessTokenPanel()); - settingForm.getManualAtRadioButton().addChangeListener(e -> { - boolean isSelected = settingForm.getManualAtRadioButton().isSelected(); - if (isSelected) { - settingForm.getApiAtRadioButton().setSelected(false); - } - }); - settingForm.getApiAtRadioButton().addChangeListener(e -> { - boolean isSelected = settingForm.getApiAtRadioButton().isSelected(); - if (isSelected) { - settingForm.getManualAtRadioButton().setSelected(false); - } - }); - - settingForm.getOutSideAtTipsLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - CommonTipsDialog dialog = new CommonTipsDialog(); - - StringBuilder tipsBuilder = new StringBuilder(); - tipsBuilder.append("

什么场景下需要使用外部AccessToken?

"); - tipsBuilder.append("

调用腾讯公众号接口需要AccessToken,上面配置的AppID、AppSecret等正是为了获得AccessToken;

"); - tipsBuilder.append("

由于有些企业已经开发了微信公众号相关的服务,不必再次通过上面的AppID等配置再次获取;

"); - tipsBuilder.append("

而且每次获取都会使之前的失效,加上每个公众号每天获取的次数有限;

"); - tipsBuilder.append("

建议每天使用WePush频率很高的时候可以使用此功能

"); - tipsBuilder.append("

反之,可不用设置

"); - - dialog.setHtmlText(tipsBuilder.toString()); - dialog.pack(); - dialog.setVisible(true); - - super.mousePressed(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); - super.mouseEntered(e); - } - - @Override - public void mouseExited(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); - super.mouseExited(e); - } - }); - settingForm.getManualAtTipsLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - CommonTipsDialog dialog = new CommonTipsDialog(); - - StringBuilder tipsBuilder = new StringBuilder(); - tipsBuilder.append("

这是什么?

"); - tipsBuilder.append("

手动填写AccessToken和过期时间

"); - tipsBuilder.append("

建议仅在临时使用一次WePush且使用时间不会很长的时候才使用

"); - tipsBuilder.append("

请向您所在企业的开发人员索取,注意保密

"); - - dialog.setHtmlText(tipsBuilder.toString()); - dialog.pack(); - dialog.setVisible(true); - - super.mousePressed(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); - super.mouseEntered(e); - } - - @Override - public void mouseExited(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); - super.mouseExited(e); - } - }); - settingForm.getApiAtTipsLabel().addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - CommonTipsDialog dialog = new CommonTipsDialog(); - - StringBuilder tipsBuilder = new StringBuilder(); - tipsBuilder.append("

这是什么?

"); - tipsBuilder.append("

如果企业已经开发了微信公众号相关的服务,建议使用此项;

"); - tipsBuilder.append("

向您所在企业的开发人员索取该接口;

"); - tipsBuilder.append("

接口使用GET请求,返回格式:

"); - tipsBuilder.append("

{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}

"); - tipsBuilder.append("

请一定注意接口安全性,AccessToken一旦被他人利用,后果不堪设想

"); - tipsBuilder.append("

例如在接口上添加密钥相关的参数:

"); - tipsBuilder.append("

示例:http://mydomain.com/wechat/getAccessToken?secret=jad76^j2#SY

"); - - dialog.setHtmlText(tipsBuilder.toString()); - dialog.pack(); - dialog.setVisible(true); - - super.mousePressed(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setCursor(new Cursor(Cursor.HAND_CURSOR)); - label.setIcon(new ImageIcon(UiConsts.HELP_FOCUSED_ICON)); - super.mouseEntered(e); - } - - @Override - public void mouseExited(MouseEvent e) { - JLabel label = (JLabel) e.getComponent(); - label.setIcon(new ImageIcon(UiConsts.HELP_ICON)); - super.mouseExited(e); - } - }); - } - -} diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/TabListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/TabListener.java index 53cb5372f..552d919d0 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/TabListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/TabListener.java @@ -1,14 +1,8 @@ package com.fangxuele.tool.push.ui.listener; import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.logic.MessageTypeEnum; -import com.fangxuele.tool.push.ui.form.AboutForm; -import com.fangxuele.tool.push.ui.form.BoostForm; import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.PushForm; -import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -36,24 +30,13 @@ public void stateChanged(ChangeEvent e) { int index = MainWindow.getInstance().getTabbedPane().getSelectedIndex(); int msgType = App.config.getMsgType(); switch (index) { - case 0: - AboutForm.init(); - break; case 3: - if (warnFlag && msgType != MessageTypeEnum.EMAIL_CODE && msgType != MessageTypeEnum.HTTP_CODE) { - JOptionPane.showMessageDialog(MainWindow.getInstance().getSettingPanel(), "\n请确认您了解所要发送消息类型的使用频率、使用规范和限制规则,\n" + - "以免账号相关功能被封禁等给您带来麻烦\n", "提示", - JOptionPane.INFORMATION_MESSAGE); - warnFlag = false; - } - break; - case 4: - PushForm.getInstance().getPushMsgName().setText(MessageEditForm.getInstance().getMsgNameField().getText()); - PushListener.refreshPushInfo(); - break; - case 5: - BoostForm.getInstance().getMsgNameLabel().setText(MessageEditForm.getInstance().getMsgNameField().getText()); - BoostListener.refreshPushInfo(); +// if (warnFlag && msgType != MessageTypeEnum.EMAIL_CODE && msgType != MessageTypeEnum.HTTP_CODE) { +// JOptionPane.showMessageDialog(MainWindow.getInstance().getSettingPanel(), "\n请确认您了解所要发送消息类型的使用频率、使用规范和限制规则,\n" + +// "以免账号相关功能被封禁等给您带来麻烦\n", "提示", +// JOptionPane.INFORMATION_MESSAGE); +// warnFlag = false; +// } break; default: break; diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/TaskListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/TaskListener.java new file mode 100644 index 000000000..6cfe15594 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/TaskListener.java @@ -0,0 +1,351 @@ +package com.fangxuele.tool.push.ui.listener; + +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.cron.Scheduler; +import cn.hutool.cron.task.Task; +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TTaskHisMapper; +import com.fangxuele.tool.push.dao.TTaskMapper; +import com.fangxuele.tool.push.domain.TTask; +import com.fangxuele.tool.push.domain.TTaskHis; +import com.fangxuele.tool.push.logic.InfinityTaskRunThread; +import com.fangxuele.tool.push.logic.TaskModeEnum; +import com.fangxuele.tool.push.logic.TaskRunThread; +import com.fangxuele.tool.push.logic.TaskTypeEnum; +import com.fangxuele.tool.push.ui.dialog.InfinityTaskHisDetailDialog; +import com.fangxuele.tool.push.ui.dialog.NewTaskDialog; +import com.fangxuele.tool.push.ui.dialog.TaskHisDetailDialog; +import com.fangxuele.tool.push.ui.form.TaskForm; +import com.fangxuele.tool.push.util.MybatisUtil; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *
+ * 推送任务相关事件监听
+ * 
+ * + * @author RememBerBer + * @since 2021/5/21. + */ +public class TaskListener { + + private static TTaskMapper taskMapper = MybatisUtil.getSqlSession().getMapper(TTaskMapper.class); + private static TTaskHisMapper taskHisMapper = MybatisUtil.getSqlSession().getMapper(TTaskHisMapper.class); + + public static Map scheduledTaskMap = new HashMap<>(16); + + public static void addListeners() { + TaskForm taskForm = TaskForm.getInstance(); + + taskForm.getNewTaskButton().addActionListener(e -> { + NewTaskDialog dialog = new NewTaskDialog(); + dialog.pack(); + dialog.setVisible(true); + }); + + taskForm.getModifyButton().addActionListener(e -> { + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(taskForm.getMainPanel(), "请先选择要修改的任务!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer taskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + TTask tTask = taskMapper.selectByPrimaryKey(taskId); + + NewTaskDialog dialog = new NewTaskDialog(tTask); + dialog.pack(); + dialog.setVisible(true); + }); + + taskForm.getTaskHisDetailButton().addActionListener(e -> { + int selectedRow = taskForm.getTaskHisListTable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(taskForm.getMainPanel(), "请先选择要查看的任务记录!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer taskHisId = (Integer) taskForm.getTaskHisListTable().getValueAt(selectedRow, 0); + TTaskHis tTaskHis = taskHisMapper.selectByPrimaryKey(taskHisId); + if (TaskModeEnum.FIX_THREAD_TASK_CODE == tTaskHis.getTaskMode()) { + TaskRunThread taskRunThread = TaskRunThread.taskRunThreadMap.get(taskHisId); + + TaskHisDetailDialog dialog = new TaskHisDetailDialog(taskRunThread, taskHisId); + dialog.pack(); + dialog.setVisible(true); + } else if (TaskModeEnum.INFINITY_TASK_CODE == tTaskHis.getTaskMode()) { + InfinityTaskRunThread infinityTaskRunThread = InfinityTaskRunThread.infinityTaskRunThreadMap.get(taskHisId); + + InfinityTaskHisDetailDialog dialog = new InfinityTaskHisDetailDialog(infinityTaskRunThread, taskHisId); + dialog.pack(); + dialog.setVisible(true); + } + }); + + taskForm.getStartButton().addActionListener(e -> { + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(taskForm.getMainPanel(), "请先选择要执行的任务!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer taskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + TTask tTask = taskMapper.selectByPrimaryKey(taskId); + + int isPush = JOptionPane.showConfirmDialog(taskForm.getMainPanel(), + "确定开始推送吗?\n\n任务:" + + tTask.getTitle() + "\n", + "确认推送?", + JOptionPane.YES_NO_OPTION); + if (isPush == JOptionPane.YES_OPTION) { + if (TaskModeEnum.FIX_THREAD_TASK_CODE == tTask.getTaskMode()) { + ThreadUtil.execute(new TaskRunThread(taskId, 0)); + } else if (TaskModeEnum.INFINITY_TASK_CODE == tTask.getTaskMode()) { + ThreadUtil.execute(new InfinityTaskRunThread(taskId, 0)); + } + } + }); + + taskForm.getStartDryRunButton().addActionListener(e -> { + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(taskForm.getMainPanel(), "请先选择要执行的任务!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer taskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + TTask tTask = taskMapper.selectByPrimaryKey(taskId); + + int isPush = JOptionPane.showConfirmDialog(taskForm.getMainPanel(), + "确定开始推送吗?\n\n任务:" + + tTask.getTitle() + "\n", + "确认推送?", + JOptionPane.YES_NO_OPTION); + if (isPush == JOptionPane.YES_OPTION) { + if (TaskModeEnum.FIX_THREAD_TASK_CODE == tTask.getTaskMode()) { + ThreadUtil.execute(new TaskRunThread(taskId, 1)); + } else if (TaskModeEnum.INFINITY_TASK_CODE == tTask.getTaskMode()) { + ThreadUtil.execute(new InfinityTaskRunThread(taskId, 1)); + } + } + }); + + // 点击左侧表格事件 + taskForm.getTaskListTable().addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + + TaskForm.initTaskHisListTable(selectedTaskId); + + TTask tTask = taskMapper.selectByPrimaryKey(selectedTaskId); + + TaskForm.fillSchedulePlan(tTask); + super.mousePressed(e); + } + }); + + taskForm.getStopButton().addActionListener(e -> { + int selectedRow = taskForm.getTaskHisListTable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(taskForm.getMainPanel(), "请先选择要停止的任务记录!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer taskHisId = (Integer) taskForm.getTaskHisListTable().getValueAt(selectedRow, 0); + + TTaskHis tTaskHis = taskHisMapper.selectByPrimaryKey(taskHisId); + + if (tTaskHis.getTaskMode() == TaskModeEnum.FIX_THREAD_TASK_CODE) { + TaskRunThread taskRunThread = TaskRunThread.taskRunThreadMap.get(taskHisId); + if (taskRunThread != null && taskRunThread.isRunning()) { + int isStop = JOptionPane.showConfirmDialog(App.mainFrame, + "确定停止当前的推送吗?", "确认停止?", + JOptionPane.YES_NO_OPTION); + if (isStop == JOptionPane.YES_OPTION) { + taskRunThread.running = false; + } + } + } else if (tTaskHis.getTaskMode() == TaskModeEnum.INFINITY_TASK_CODE) { + InfinityTaskRunThread infinityTaskRunThread = InfinityTaskRunThread.infinityTaskRunThreadMap.get(taskHisId); + if (infinityTaskRunThread != null && infinityTaskRunThread.isRunning()) { + int isStop = JOptionPane.showConfirmDialog(App.mainFrame, + "确定停止当前的推送吗?", "确认停止?", + JOptionPane.YES_NO_OPTION); + if (isStop == JOptionPane.YES_OPTION) { + infinityTaskRunThread.running = false; + } + } + } + }); + + taskForm.getHisDeleteButton().addActionListener(e -> { + int selectedRow = taskForm.getTaskHisListTable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(taskForm.getMainPanel(), "请先选择要删除的任务记录!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer taskHisId = (Integer) taskForm.getTaskHisListTable().getValueAt(selectedRow, 0); + + int isDelete = JOptionPane.showConfirmDialog(App.mainFrame, + "确定删除当前的任务记录吗?", "确认删除?", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + + TTaskHis tTaskHis = taskHisMapper.selectByPrimaryKey(taskHisId); + + // 删除文件 + String successFilePath = tTaskHis.getSuccessFilePath(); + if (StringUtils.isNotBlank(successFilePath)) { + File successFile = new File(successFilePath); + if (successFile.exists()) { + successFile.delete(); + } + } + String failFilePath = tTaskHis.getFailFilePath(); + if (StringUtils.isNotBlank(failFilePath)) { + File failFile = new File(failFilePath); + if (failFile.exists()) { + failFile.delete(); + } + } + String noSendFilePath = tTaskHis.getNoSendFilePath(); + if (StringUtils.isNotBlank(noSendFilePath)) { + File noSendFile = new File(noSendFilePath); + if (noSendFile.exists()) { + noSendFile.delete(); + } + } + String logFilePath = tTaskHis.getLogFilePath(); + if (StringUtils.isNotBlank(logFilePath)) { + File logFile = new File(logFilePath); + if (logFile.exists()) { + logFile.delete(); + } + } + + taskHisMapper.deleteByPrimaryKey(taskHisId); + + int selectedTaskRow = taskForm.getTaskListTable().getSelectedRow(); + Integer selectedTaskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedTaskRow, 0); + TaskForm.initTaskHisListTable(selectedTaskId); + } + }); + + taskForm.getDeleteButton().addActionListener(e -> { + int selectedRow = taskForm.getTaskListTable().getSelectedRow(); + if (selectedRow < 0) { + JOptionPane.showMessageDialog(taskForm.getMainPanel(), "请先选择要删除的任务!", "提示", + JOptionPane.INFORMATION_MESSAGE); + return; + } + + Integer taskId = (Integer) taskForm.getTaskListTable().getValueAt(selectedRow, 0); + + int isDelete = JOptionPane.showConfirmDialog(App.mainFrame, + "确定删除当前的任务吗?", "确认删除?", + JOptionPane.YES_NO_OPTION); + if (isDelete == JOptionPane.YES_OPTION) { + // 删除任务历史记录 + taskHisMapper.selectByTaskId(taskId).forEach(tTaskHis -> { + // 删除文件 + String successFilePath = tTaskHis.getSuccessFilePath(); + if (StringUtils.isNotBlank(successFilePath)) { + File successFile = new File(successFilePath); + if (successFile.exists()) { + successFile.delete(); + } + } + String failFilePath = tTaskHis.getFailFilePath(); + if (StringUtils.isNotBlank(failFilePath)) { + File failFile = new File(failFilePath); + if (failFile.exists()) { + failFile.delete(); + } + } + String noSendFilePath = tTaskHis.getNoSendFilePath(); + if (StringUtils.isNotBlank(noSendFilePath)) { + File noSendFile = new File(noSendFilePath); + if (noSendFile.exists()) { + noSendFile.delete(); + } + } + String logFilePath = tTaskHis.getLogFilePath(); + if (StringUtils.isNotBlank(logFilePath)) { + File logFile = new File(logFilePath); + if (logFile.exists()) { + logFile.delete(); + } + } + taskHisMapper.deleteByPrimaryKey(tTaskHis.getId()); + }); + + // 删除定时任务 + Scheduler scheduler = scheduledTaskMap.get(taskId); + if (scheduler != null) { + scheduler.stop(); + scheduledTaskMap.remove(taskId); + } + + TaskRunThread taskRunThread = TaskRunThread.taskRunThreadMap.get(taskId); + if (taskRunThread != null) { + taskRunThread.running = false; + taskRunThread.interrupt(); + } + TaskRunThread.taskRunThreadMap.remove(taskId); + + InfinityTaskRunThread infinityTaskRunThread = InfinityTaskRunThread.infinityTaskRunThreadMap.get(taskId); + if (infinityTaskRunThread != null) { + infinityTaskRunThread.running = false; + infinityTaskRunThread.interrupt(); + } + InfinityTaskRunThread.infinityTaskRunThreadMap.remove(taskId); + + taskMapper.deleteByPrimaryKey(taskId); + TaskForm.initTaskListTable(); + } + }); + } + + /** + * 重启应用时把所有定时任务重新加入到任务队列 + */ + public static void addAllScheduledTask() { + List tTaskList = taskMapper.selectAll(); + for (TTask tTask : tTaskList) { + if (tTask.getTaskPeriod() == TaskTypeEnum.SCHEDULE_TASK_CODE && StringUtils.isNotBlank(tTask.getCron())) { + Scheduler scheduler = new Scheduler(); + scheduler.setMatchSecond(true); + String schedulerId = scheduler.schedule(tTask.getCron(), (Task) () -> { + if (tTask.getTaskMode() == TaskModeEnum.FIX_THREAD_TASK_CODE) { + TaskRunThread taskRunThread = new TaskRunThread(tTask.getId(), 0); + taskRunThread.setFixRateScheduling(true); + taskRunThread.start(); + } else if (tTask.getTaskMode() == TaskModeEnum.INFINITY_TASK_CODE) { + InfinityTaskRunThread infinityTaskRunThread = new InfinityTaskRunThread(tTask.getId(), 0); + infinityTaskRunThread.setFixRateScheduling(true); + infinityTaskRunThread.start(); + } + }); + scheduler.start(); + TaskListener.scheduledTaskMap.put(tTask.getId(), scheduler); + } + } + } +} diff --git a/src/main/java/com/fangxuele/tool/push/util/ComponentUtil.java b/src/main/java/com/fangxuele/tool/push/util/ComponentUtil.java index 7248a6503..1806e4a8d 100644 --- a/src/main/java/com/fangxuele/tool/push/util/ComponentUtil.java +++ b/src/main/java/com/fangxuele/tool/push/util/ComponentUtil.java @@ -21,10 +21,29 @@ public class ComponentUtil { private static int screenHeight = screenSize.height - screenInsets.top - screenInsets.bottom; + /** + * 设置组件位于屏幕中央 + */ + public static void setLocateToCenter(Component component) { + Dimension preferredSize = component.getPreferredSize(); + int preferWidth = (int) preferredSize.getWidth(); + int preferHeight = (int) preferredSize.getHeight(); + component.setBounds((screenWidth - preferWidth) / 2, (screenHeight - preferHeight) / 2, + preferWidth, preferHeight); + } + /** * 设置组件preferSize并定位于屏幕中央 */ - public static void setPreferSizeAndLocateToCenter(Component component, int preferWidth, int preferHeight) { + public static void setPreferSizeAndLocateToCenter(Component component, Integer preferWidth, Integer preferHeight) { + Dimension initPreferredSize = component.getPreferredSize(); + if (preferWidth == null) { + preferWidth = (int) initPreferredSize.getWidth(); + } + if (preferHeight == null) { + preferHeight = (int) initPreferredSize.getHeight(); + } + component.setBounds((screenWidth - preferWidth) / 2, (screenHeight - preferHeight) / 2, preferWidth, preferHeight); Dimension preferSize = new Dimension(preferWidth, preferHeight); @@ -34,9 +53,17 @@ public static void setPreferSizeAndLocateToCenter(Component component, int prefe /** * 设置组件preferSize并定位于屏幕中央(基于屏幕宽高的百分百) */ - public static void setPreferSizeAndLocateToCenter(Component component, double preferWidthPercent, double preferHeightPercent) { - int preferWidth = (int) (screenWidth * preferWidthPercent); - int preferHeight = (int) (screenHeight * preferHeightPercent); + public static void setPreferSizeAndLocateToCenter(Component component, Double preferWidthPercent, Double preferHeightPercent) { + Integer preferWidth = null; + Integer preferHeight = null; + + if (preferWidthPercent != null) { + preferWidth = (int) (screenWidth * preferWidthPercent); + } + if (preferHeightPercent != null) { + preferHeight = (int) (screenHeight * preferHeightPercent); + } + setPreferSizeAndLocateToCenter(component, preferWidth, preferHeight); } } diff --git a/src/main/java/com/fangxuele/tool/push/util/ConfigBaseUtil.java b/src/main/java/com/fangxuele/tool/push/util/ConfigBaseUtil.java index 10fd92b9c..e1b9a9999 100644 --- a/src/main/java/com/fangxuele/tool/push/util/ConfigBaseUtil.java +++ b/src/main/java/com/fangxuele/tool/push/util/ConfigBaseUtil.java @@ -18,7 +18,7 @@ public class ConfigBaseUtil { /** * 设置文件路径 */ - private String settingFilePath = SystemUtil.configHome + "config" + File.separator + "config.setting"; + private String settingFilePath = SystemUtil.CONFIG_HOME + "config" + File.separator + "config.setting"; Setting setting; diff --git a/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java b/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java index 4c4f98fc8..547a38533 100644 --- a/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java +++ b/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java @@ -20,185 +20,6 @@ private ConfigUtil() { super(); } - private int msgType; - - private String msgName; - - private String previewUser; - - private String memberSql; - - private String memberFilePath; - - private int maxThreadPool; - - private int threadCount; - - private boolean dryRun; - - private boolean radioPerDay; - - private String textPerDay; - - private boolean radioPerWeek; - - private String textPerWeekWeek; - - private String textPerWeekTime; - - private boolean radioCron; - - private String textCron; - - private boolean needReimport; - - private String reimportWay; - - private boolean sendPushResult; - - private String mailResultTos; - - private boolean autoCheckUpdate; - - private boolean useTray; - - private long pushTotal; - - private String beforeVersion; - - private String wechatMpName; - - private String wechatAppId; - - private String wechatAppSecret; - - private String wechatToken; - - private String wechatAesKey; - - private boolean mpUseProxy; - - private String mpProxyHost; - - private String mpProxyPort; - - private String mpProxyUserName; - - private String mpProxyPassword; - - private boolean mpUseOutSideAt; - - private boolean mpManualAt; - - private boolean mpApiAt; - - private String mpAt; - - private String mpAtExpiresIn; - - private String mpAtApiUrl; - - private String miniAppName; - - private String miniAppAppId; - - private String miniAppAppSecret; - - private String miniAppToken; - - private String miniAppAesKey; - - private boolean maUseProxy; - - private String maProxyHost; - - private String maProxyPort; - - private String maProxyUserName; - - private String maProxyPassword; - - /** - * 企业号企业id - */ - private String wxCpCorpId; - - private String aliyunAccessKeyId; - - private String aliyunAccessKeySecret; - - private String aliyunSign; - - private String aliServerUrl; - - private String aliAppKey; - - private String aliAppSecret; - - private String aliSign; - - private String txyunAppId; - - private String txyunAppKey; - - private String txyunSign; - - private String hwAppKey; - private String hwAppSecretPassword; - private String hwAccessUrl; - private String hwSignature; - private String hwSenderCode; - - private String bdSecretAccessKey; - private String bdAccessKeyId; - private String bdEndPoint; - private String bdInvokeId; - - private String upAuthorizationToken; - - private String qiniuAccessKey; - private String qiniuSecretKey; - - private String yunpianApiKey; - - private boolean httpUseProxy; - - private String httpProxyHost; - - private String httpProxyPort; - - private String httpProxyUserName; - - private String httpProxyPassword; - - private String mailHost; - - private String mailPort; - - private String mailFrom; - - private String mailUser; - - private String mailPassword; - - private boolean mailUseStartTLS; - - private boolean mailUseSSL; - - private String mysqlUrl; - - private String mysqlDatabase; - - private String mysqlUser; - - private String mysqlPassword; - - private String theme; - - private String font; - - private int fontSize; - public int getMsgType() { return setting.getInt("msgType", "msg", 13); } @@ -215,14 +36,6 @@ public void setMsgName(String msgName) { setting.put("msg", "msgName", msgName); } - public String getPreviewUser() { - return setting.getStr("previewUser", "msg", ""); - } - - public void setPreviewUser(String previewUser) { - setting.put("msg", "previewUser", previewUser); - } - public String getMemberSql() { return setting.getStr("sql", "member", ""); } @@ -231,30 +44,6 @@ public void setMemberSql(String memberSql) { setting.put("member", "sql", memberSql); } - public String getMemberFilePath() { - return setting.getStr("filePath", "member", ""); - } - - public void setMemberFilePath(String memberFilePath) { - setting.put("member", "filePath", memberFilePath); - } - - public int getMaxThreadPool() { - return setting.getInt("maxThreadPool", "push", 100); - } - - public void setMaxThreadPool(int maxThreadPool) { - setting.put("push", "maxThreadPool", String.valueOf(maxThreadPool)); - } - - public int getThreadCount() { - return setting.getInt("threadCount", "push", 60); - } - - public void setThreadCount(int threadCount) { - setting.put("push", "threadCount", String.valueOf(threadCount)); - } - public boolean isDryRun() { return setting.getBool("dryRun", "push", true); } @@ -263,110 +52,6 @@ public void setDryRun(boolean dryRun) { setting.put("push", "dryRun", String.valueOf(dryRun)); } - public boolean isRadioStartAt() { - return setting.getBool("radioStartAt", "schedule", false); - } - - public void setRadioStartAt(boolean radioStartAt) { - setting.put("schedule", "radioStartAt", String.valueOf(radioStartAt)); - } - - public String getTextStartAt() { - return setting.getStr("textStartAt", "schedule", ""); - } - - public void setTextStartAt(String textStartAt) { - setting.put("schedule", "textStartAt", textStartAt); - } - - public boolean isRadioPerDay() { - return setting.getBool("radioPerDay", "schedule", false); - } - - public void setRadioPerDay(boolean radioPerDay) { - setting.put("schedule", "radioPerDay", String.valueOf(radioPerDay)); - } - - public String getTextPerDay() { - return setting.getStr("textPerDay", "schedule", ""); - } - - public void setTextPerDay(String textPerDay) { - setting.put("schedule", "textPerDay", textPerDay); - } - - public boolean isRadioPerWeek() { - return setting.getBool("radioPerWeek", "schedule", false); - } - - public void setRadioPerWeek(boolean radioPerWeek) { - setting.put("schedule", "radioPerWeek", String.valueOf(radioPerWeek)); - } - - public String getTextPerWeekWeek() { - return setting.getStr("textPerWeek.week", "schedule", "一"); - } - - public void setTextPerWeekWeek(String textPerWeekWeek) { - setting.put("schedule", "textPerWeek.week", textPerWeekWeek); - } - - public String getTextPerWeekTime() { - return setting.getStr("textPerWeek.time", "schedule", ""); - } - - public void setTextPerWeekTime(String textPerWeekTime) { - setting.put("schedule", "textPerWeek.time", textPerWeekTime); - } - - public boolean isRadioCron() { - return setting.getBool("radioCron", "schedule", false); - } - - public void setRadioCron(boolean radioCron) { - setting.put("schedule", "radioCron", String.valueOf(radioCron)); - } - - public String getTextCron() { - return setting.getStr("textCron", "schedule", ""); - } - - public void setTextCron(String textCron) { - setting.put("schedule", "textCron", textCron); - } - - public boolean isNeedReimport() { - return setting.getBool("reimportCheckBox", "schedule", false); - } - - public void setNeedReimport(boolean needReimport) { - setting.put("schedule", "reimportCheckBox", String.valueOf(needReimport)); - } - - public String getReimportWay() { - return setting.getStr("reimportComboBox", "schedule", ""); - } - - public void setReimportWay(String reimportWay) { - setting.put("schedule", "reimportComboBox", reimportWay); - } - - public boolean isSendPushResult() { - return setting.getBool("sendPushResult", "schedule", false); - } - - public void setSendPushResult(boolean sendPushResult) { - setting.put("schedule", "sendPushResult", String.valueOf(sendPushResult)); - } - - public String getMailResultTos() { - return setting.getStr("mailResultTos", "schedule", ""); - } - - public void setMailResultTos(String mailResultTos) { - setting.put("schedule", "mailResultTos", mailResultTos); - } - public boolean isAutoCheckUpdate() { return setting.getBool("autoCheckUpdate", "setting.normal", true); } @@ -383,180 +68,52 @@ public void setUseTray(boolean useTray) { setting.put("setting.normal", "useTray", String.valueOf(useTray)); } - public long getPushTotal() { - return setting.getLong("pushTotal", "setting.normal", 0L); - } - - public void setPushTotal(long pushTotal) { - setting.put("setting.normal", "pushTotal", String.valueOf(pushTotal)); - } - - public String getBeforeVersion() { - return setting.getStr("beforeVersion", "setting.normal", "v_3.0.0_190516"); - } - - public void setBeforeVersion(String beforeVersion) { - setting.put("setting.normal", "beforeVersion", beforeVersion); - } - - public String getWechatMpName() { - return setting.getStr("mpName", "setting.wechat", "默认公众号"); - } - - public void setWechatMpName(String wechatMpName) { - setting.put("setting.wechat", "mpName", wechatMpName); - } - - public String getWechatAppId() { - return setting.getStr("appId", "setting.wechat", ""); - } - - public void setWechatAppId(String wechatAppId) { - setting.put("setting.wechat", "appId", wechatAppId); - } - - public String getWechatAppSecret() { - return setting.getStr("AppSecret", "setting.wechat", ""); - } - - public void setWechatAppSecret(String wechatAppSecret) { - setting.put("setting.wechat", "AppSecret", wechatAppSecret); - } - - public String getWechatToken() { - return setting.getStr("token", "setting.wechat", ""); - } - - public void setWechatToken(String wechatToken) { - setting.put("setting.wechat", "token", wechatToken); - } - - public String getWechatAesKey() { - return setting.getStr("aesKey", "setting.wechat", ""); - } - - public void setWechatAesKey(String wechatAesKey) { - setting.put("setting.wechat", "aesKey", wechatAesKey); - } - - public boolean isMpUseProxy() { - return setting.getBool("mpUseProxy", "setting.wechat", false); + public boolean isCloseToTray() { + return setting.getBool("closeToTray", "setting.normal", true); } - public void setMpUseProxy(boolean mpUseProxy) { - setting.put("setting.wechat", "mpUseProxy", String.valueOf(mpUseProxy)); + public void setCloseToTray(boolean closeToTray) { + setting.put("setting.normal", "closeToTray", String.valueOf(closeToTray)); } - public String getMpProxyHost() { - return setting.getStr("mpProxyHost", "setting.wechat", ""); + public boolean isDefaultMaxWindow() { + return setting.getBool("defaultMaxWindow", "setting.normal", true); } - public void setMpProxyHost(String mpProxyHost) { - setting.put("setting.wechat", "mpProxyHost", mpProxyHost); + public void setDefaultMaxWindow(boolean defaultMaxWindow) { + setting.put("setting.normal", "defaultMaxWindow", String.valueOf(defaultMaxWindow)); } - public String getMpProxyPort() { - return setting.getStr("mpProxyPort", "setting.wechat", ""); + public boolean isUnifiedBackground() { + return setting.getBool("unifiedBackground", "setting.normal", true); } - public void setMpProxyPort(String mpProxyPort) { - setting.put("setting.wechat", "mpProxyPort", mpProxyPort); + public void setUnifiedBackground(boolean unifiedBackground) { + setting.put("setting.normal", "unifiedBackground", String.valueOf(unifiedBackground)); } - public String getMpProxyUserName() { - return setting.getStr("mpProxyUserName", "setting.wechat", ""); + public Integer getMaxThreads() { + return setting.getInt("maxThreads", "setting.normal", 100); } - public void setMpProxyUserName(String mpProxyUserName) { - setting.put("setting.wechat", "mpProxyUserName", mpProxyUserName); + public void setMaxThreads(Integer maxThreads) { + setting.put("setting.normal", "maxThreads", String.valueOf(maxThreads)); } - public String getMpProxyPassword() { - return setting.getStr("mpProxyPassword", "setting.wechat", ""); - } - - public void setMpProxyPassword(String mpProxyPassword) { - setting.put("setting.wechat", "mpProxyPassword", mpProxyPassword); - } - - public boolean isMpUseOutSideAt() { - return setting.getBool("mpUseOutSideAt", "setting.wechat", false); - } - - public void setMpUseOutSideAt(boolean mpUseOutSideAt) { - setting.put("setting.wechat", "mpUseOutSideAt", String.valueOf(mpUseOutSideAt)); - } - - public boolean isMpManualAt() { - return setting.getBool("mpManualAt", "setting.wechat", false); - } - - public void setMpManualAt(boolean mpManualAt) { - setting.put("setting.wechat", "mpManualAt", String.valueOf(mpManualAt)); - } - - public boolean isMpApiAt() { - return setting.getBool("mpApiAt", "setting.wechat", false); - } - - public void setMpApiAt(boolean mpApiAt) { - setting.put("setting.wechat", "mpApiAt", String.valueOf(mpApiAt)); - } - - public String getMpAt() { - return setting.getStr("mpAt", "setting.wechat", ""); - } - - public void setMpAt(String mpAt) { - setting.put("setting.wechat", "mpAt", mpAt); - } - - public String getMpAtExpiresIn() { - return setting.getStr("mpAtExpiresIn", "setting.wechat", ""); - } - - public void setMpAtExpiresIn(String mpAtExpiresIn) { - setting.put("setting.wechat", "mpAtExpiresIn", mpAtExpiresIn); - } - - public String getMpAtApiUrl() { - return setting.getStr("mpAtApiUrl", "setting.wechat", ""); - } - - public void setMpAtApiUrl(String mpAtApiUrl) { - setting.put("setting.wechat", "mpAtApiUrl", mpAtApiUrl); - } - - public String getAliServerUrl() { - return setting.getStr("serverUrl", "setting.ali", ""); - } - - public void setAliServerUrl(String aliServerUrl) { - setting.put("setting.ali", "serverUrl", aliServerUrl); - } - - public String getAliAppKey() { - return setting.getStr("appKey", "setting.ali", ""); - } - - public void setAliAppKey(String aliAppKey) { - setting.put("setting.ali", "appKey", aliAppKey); - } - - public String getAliAppSecret() { - return setting.getStr("appSecret", "setting.ali", ""); + public long getPushTotal() { + return setting.getLong("pushTotal", "setting.normal", 0L); } - public void setAliAppSecret(String aliAppSecret) { - setting.put("setting.ali", "appSecret", aliAppSecret); + public void setPushTotal(long pushTotal) { + setting.put("setting.normal", "pushTotal", String.valueOf(pushTotal)); } - public String getAliSign() { - return setting.getStr("sign", "setting.ali", ""); + public String getBeforeVersion() { + return setting.getStr("beforeVersion", "setting.normal", "v_0.0.0"); } - public void setAliSign(String aliSign) { - setting.put("setting.ali", "sign", aliSign); + public void setBeforeVersion(String beforeVersion) { + setting.put("setting.normal", "beforeVersion", beforeVersion); } public String getMailHost() { @@ -623,14 +180,6 @@ public void setMysqlUrl(String mysqlUrl) { setting.put("setting.mysql", "url", mysqlUrl); } - public String getMysqlDatabase() { - return setting.getStr("database", "setting.mysql", ""); - } - - public void setMysqlDatabase(String mysqlDatabase) { - setting.put("setting.mysql", "database", mysqlDatabase); - } - public String getMysqlUser() { return setting.getStr("user", "setting.mysql", ""); } @@ -648,7 +197,7 @@ public void setMysqlPassword(String mysqlPassword) { } public String getTheme() { - return setting.getStr("theme", "setting.appearance", "Darcula(推荐)"); + return setting.getStr("theme", "setting.appearance", "Flat macOS Dark"); } public void setTheme(String theme) { @@ -656,7 +205,13 @@ public void setTheme(String theme) { } public String getFont() { - return setting.getStr("font", "setting.appearance", "微软雅黑"); + if (SystemUtil.isLinuxOs()) { + return setting.getStr("font", "setting.appearance", "Noto Sans CJK HK"); + } else if (SystemUtil.isMacOs()) { + return setting.getStr("font", "setting.appearance", "PingFang SC"); + } else { + return setting.getStr("font", "setting.appearance", "微软雅黑"); + } } public void setFont(String font) { @@ -664,290 +219,11 @@ public void setFont(String font) { } public int getFontSize() { - return setting.getInt("fontSize", "setting.appearance", 13); + return setting.getInt("fontSize", "setting.appearance", 12); } public void setFontSize(int fontSize) { setting.put("setting.appearance", "fontSize", String.valueOf(fontSize)); } - public String getAliyunAccessKeyId() { - return setting.getStr("accessKeyId", "setting.aliyun", ""); - } - - public void setAliyunAccessKeyId(String aliyunAccessKeyId) { - setting.put("setting.aliyun", "accessKeyId", aliyunAccessKeyId); - } - - public String getAliyunAccessKeySecret() { - return setting.getStr("accessKeySecret", "setting.aliyun", ""); - } - - public void setAliyunAccessKeySecret(String aliyunAccessKeySecret) { - setting.put("setting.aliyun", "accessKeySecret", aliyunAccessKeySecret); - } - - public String getAliyunSign() { - return setting.getStr("aliyunSign", "setting.aliyun", ""); - } - - public void setAliyunSign(String aliyunSign) { - setting.put("setting.aliyun", "aliyunSign", aliyunSign); - } - - public String getMiniAppName() { - return setting.getStr("name", "setting.miniApp", "默认小程序"); - } - - public void setMiniAppName(String miniAppName) { - setting.put("setting.miniApp", "name", miniAppName); - } - - public String getMiniAppAppId() { - return setting.getStr("appId", "setting.miniApp", ""); - } - - public void setMiniAppAppId(String miniAppAppId) { - setting.put("setting.miniApp", "appId", miniAppAppId); - } - - public String getMiniAppAppSecret() { - return setting.getStr("AppSecret", "setting.miniApp", ""); - } - - public void setMiniAppAppSecret(String miniAppAppSecret) { - setting.put("setting.miniApp", "AppSecret", miniAppAppSecret); - } - - public String getMiniAppToken() { - return setting.getStr("token", "setting.miniApp", ""); - } - - public void setMiniAppToken(String miniAppToken) { - setting.put("setting.miniApp", "token", miniAppToken); - } - - public String getMiniAppAesKey() { - return setting.getStr("aesKey", "setting.miniApp", ""); - } - - public void setMiniAppAesKey(String miniAppAesKey) { - setting.put("setting.miniApp", "aesKey", miniAppAesKey); - } - - public boolean isMaUseProxy() { - return setting.getBool("maUseProxy", "setting.wechat", false); - } - - public void setMaUseProxy(boolean maUseProxy) { - setting.put("setting.wechat", "maUseProxy", String.valueOf(maUseProxy)); - } - - public String getMaProxyHost() { - return setting.getStr("maProxyHost", "setting.wechat", ""); - } - - public void setMaProxyHost(String maProxyHost) { - setting.put("setting.wechat", "maProxyHost", maProxyHost); - } - - public String getMaProxyPort() { - return setting.getStr("maProxyPort", "setting.wechat", ""); - } - - public void setMaProxyPort(String maProxyPort) { - setting.put("setting.wechat", "maProxyPort", maProxyPort); - } - - public String getMaProxyUserName() { - return setting.getStr("maProxyUserName", "setting.wechat", ""); - } - - public void setMaProxyUserName(String maProxyUserName) { - setting.put("setting.wechat", "maProxyUserName", maProxyUserName); - } - - public String getMaProxyPassword() { - return setting.getStr("maProxyPassword", "setting.wechat", ""); - } - - public void setMaProxyPassword(String maProxyPassword) { - setting.put("setting.wechat", "maProxyPassword", maProxyPassword); - } - - public String getWxCpCorpId() { - return setting.getStr("wxCpCorpId", "setting.wechat", ""); - } - - public void setWxCpCorpId(String wxCpCorpId) { - setting.put("setting.wechat", "wxCpCorpId", wxCpCorpId); - } - - public String getTxyunAppId() { - return setting.getStr("appId", "setting.txyun", ""); - } - - public void setTxyunAppId(String txyunAppId) { - setting.put("setting.txyun", "appId", txyunAppId); - } - - public String getTxyunAppKey() { - return setting.getStr("appKey", "setting.txyun", ""); - } - - public void setTxyunAppKey(String txyunAppKey) { - setting.put("setting.txyun", "appKey", txyunAppKey); - } - - public String getTxyunSign() { - return setting.getStr("txyunSign", "setting.txyun", ""); - } - - public void setTxyunSign(String txyunSign) { - setting.put("setting.txyun", "txyunSign", txyunSign); - } - - public String getHwAppKey() { - return setting.getStr("hwAppKey", "setting.hwyun", ""); - } - - public void setHwAppKey(String hwAppKey) { - setting.put("setting.hwyun", "hwAppKey", hwAppKey); - } - - public String getHwAppSecretPassword() { - return setting.getStr("hwAppSecretPassword", "setting.hwyun", ""); - } - - public void setHwAppSecretPassword(String hwAppSecretPassword) { - setting.put("setting.hwyun", "hwAppSecretPassword", hwAppSecretPassword); - } - - public String getHwAccessUrl() { - return setting.getStr("hwAccessUrl", "setting.hwyun", ""); - } - - public void setHwAccessUrl(String hwAccessUrl) { - setting.put("setting.hwyun", "hwAccessUrl", hwAccessUrl); - } - - public String getHwSignature() { - return setting.getStr("hwSignature", "setting.hwyun", ""); - } - - public void setHwSignature(String hwSignature) { - setting.put("setting.hwyun", "hwSignature", hwSignature); - } - - public String getHwSenderCode() { - return setting.getStr("hwSenderCode", "setting.hwyun", ""); - } - - public void setHwSenderCode(String hwSenderCode) { - setting.put("setting.hwyun", "hwSenderCode", hwSenderCode); - } - - public String getBdSecretAccessKey() { - return setting.getStr("bdSecretAccessKey", "setting.bdyun", ""); - } - - public void setBdSecretAccessKey(String bdSecretAccessKey) { - setting.put("setting.bdyun", "bdSecretAccessKey", bdSecretAccessKey); - } - - public String getBdAccessKeyId() { - return setting.getStr("bdAccessKeyId", "setting.bdyun", ""); - } - - public void setBdAccessKeyId(String bdAccessKeyId) { - setting.put("setting.bdyun", "bdAccessKeyId", bdAccessKeyId); - } - - public String getBdEndPoint() { - return setting.getStr("bdEndPoint", "setting.bdyun", ""); - } - - public void setBdEndPoint(String bdEndPoint) { - setting.put("setting.bdyun", "bdEndPoint", bdEndPoint); - } - - public String getBdInvokeId() { - return setting.getStr("bdInvokeId", "setting.bdyun", ""); - } - - public void setBdInvokeId(String bdInvokeId) { - setting.put("setting.bdyun", "bdInvokeId", bdInvokeId); - } - - public String getUpAuthorizationToken() { - return setting.getStr("upAuthorizationToken", "setting.upyun", ""); - } - - public void setUpAuthorizationToken(String upAuthorizationToken) { - setting.put("setting.upyun", "upAuthorizationToken", upAuthorizationToken); - } - - public String getQiniuAccessKey() { - return setting.getStr("qiniuAccessKey", "setting.qiniu", ""); - } - - public void setQiniuAccessKey(String qiniuAccessKey) { - setting.put("setting.qiniu", "qiniuAccessKey", qiniuAccessKey); - } - - public String getQiniuSecretKey() { - return setting.getStr("qiniuSecretKey", "setting.qiniu", ""); - } - - public void setQiniuSecretKey(String qiniuSecretKey) { - setting.put("setting.qiniu", "qiniuSecretKey", qiniuSecretKey); - } - - public String getYunpianApiKey() { - return setting.getStr("apiKey", "setting.yunpian", ""); - } - - public void setYunpianApiKey(String yunpianApiKey) { - setting.put("setting.yunpian", "apiKey", yunpianApiKey); - } - - public boolean isHttpUseProxy() { - return setting.getBool("httpUseProxy", "setting.http", false); - } - - public void setHttpUseProxy(boolean httpUseProxy) { - setting.put("setting.http", "httpUseProxy", String.valueOf(httpUseProxy)); - } - - public String getHttpProxyHost() { - return setting.getStr("httpProxyHost", "setting.http", ""); - } - - public void setHttpProxyHost(String httpProxyHost) { - setting.put("setting.http", "httpProxyHost", httpProxyHost); - } - - public String getHttpProxyPort() { - return setting.getStr("httpProxyPort", "setting.http", ""); - } - - public void setHttpProxyPort(String httpProxyPort) { - setting.put("setting.http", "httpProxyPort", httpProxyPort); - } - - public String getHttpProxyUserName() { - return setting.getStr("httpProxyUserName", "setting.http", ""); - } - - public void setHttpProxyUserName(String httpProxyUserName) { - setting.put("setting.http", "httpProxyUserName", httpProxyUserName); - } - - public String getHttpProxyPassword() { - return setting.getStr("httpProxyPassword", "setting.http", ""); - } - - public void setHttpProxyPassword(String httpProxyPassword) { - setting.put("setting.http", "httpProxyPassword", httpProxyPassword); - } } diff --git a/src/main/java/com/fangxuele/tool/push/util/ConsoleUtil.java b/src/main/java/com/fangxuele/tool/push/util/ConsoleUtil.java index 5ce09dd46..dc1f4ce94 100644 --- a/src/main/java/com/fangxuele/tool/push/util/ConsoleUtil.java +++ b/src/main/java/com/fangxuele/tool/push/util/ConsoleUtil.java @@ -2,10 +2,10 @@ import cn.hutool.log.Log; import cn.hutool.log.LogFactory; -import com.fangxuele.tool.push.ui.form.BoostForm; -import com.fangxuele.tool.push.ui.form.PushForm; import lombok.extern.slf4j.Slf4j; +import java.io.BufferedWriter; + /** *
  * WePush控制台打印相关
@@ -19,45 +19,13 @@ public class ConsoleUtil {
 
     private static final Log logger = LogFactory.get();
 
-    /**
-     * 输出到控制台和log
-     *
-     * @param log
-     */
-    public static void consoleWithLog(String log) {
-        PushForm.getInstance().getPushConsoleTextArea().append(log + "\n");
-        PushForm.getInstance().getPushConsoleTextArea().setCaretPosition(PushForm.getInstance().getPushConsoleTextArea().getText().length());
-        logger.warn(log);
-    }
-
-    /**
-     * 输出到性能模式控制台和log
-     *
-     * @param log
-     */
-    public static void boostConsoleWithLog(String log) {
-        BoostForm.getInstance().getConsoleTextArea().append(log + "\n");
-        BoostForm.getInstance().getConsoleTextArea().setCaretPosition(BoostForm.getInstance().getConsoleTextArea().getText().length());
-        logger.warn(log);
-    }
-
-    /**
-     * 仅输出到控制台
-     *
-     * @param log
-     */
-    public static void consoleOnly(String log) {
-        PushForm.getInstance().getPushConsoleTextArea().append(log + "\n");
-        PushForm.getInstance().getPushConsoleTextArea().setCaretPosition(PushForm.getInstance().getPushConsoleTextArea().getText().length());
-    }
-
-    /**
-     * 仅输出到性能模式控制台
-     *
-     * @param log
-     */
-    public static void boostConsoleOnly(String log) {
-        BoostForm.getInstance().getConsoleTextArea().append(log + "\n");
-        BoostForm.getInstance().getConsoleTextArea().setCaretPosition(BoostForm.getInstance().getConsoleTextArea().getText().length());
+    public synchronized static void pushLog(BufferedWriter logWriter, String content) {
+        try {
+            logWriter.write(SqliteUtil.nowDateForSqlite() + " " + content);
+            logWriter.newLine();
+            logWriter.flush();
+        } catch (Exception e) {
+            logger.error(e.toString());
+        }
     }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/util/FileCharSetUtil.java b/src/main/java/com/fangxuele/tool/push/util/FileCharSetUtil.java
index 96716e251..cb6de8e2b 100644
--- a/src/main/java/com/fangxuele/tool/push/util/FileCharSetUtil.java
+++ b/src/main/java/com/fangxuele/tool/push/util/FileCharSetUtil.java
@@ -2,7 +2,12 @@
 
 import cn.hutool.log.Log;
 import cn.hutool.log.LogFactory;
-import info.monitorenter.cpdetector.io.*;
+import info.monitorenter.cpdetector.io.ASCIIDetector;
+import info.monitorenter.cpdetector.io.ByteOrderMarkDetector;
+import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
+import info.monitorenter.cpdetector.io.JChardetFacade;
+import info.monitorenter.cpdetector.io.ParsingDetector;
+import info.monitorenter.cpdetector.io.UnicodeDetector;
 
 import java.io.File;
 import java.io.IOException;
diff --git a/src/main/java/com/fangxuele/tool/push/util/JTableUtil.java b/src/main/java/com/fangxuele/tool/push/util/JTableUtil.java
index 842bc1c21..6639f8581 100644
--- a/src/main/java/com/fangxuele/tool/push/util/JTableUtil.java
+++ b/src/main/java/com/fangxuele/tool/push/util/JTableUtil.java
@@ -42,4 +42,15 @@ public static void hideTableHeader(JTable table) {
         renderer.setPreferredSize(new Dimension(0, 0));
         table.getTableHeader().setDefaultRenderer(renderer);
     }
+
+    /**
+     * 表头列名居左
+     */
+    public static void setTableHeaderLeftAlignment(JTable table) {
+        DefaultTableCellRenderer hr = (DefaultTableCellRenderer) table.getTableHeader()
+                .getDefaultRenderer();
+        // 表头列名居左
+        hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT);
+    }
+
 }
diff --git a/src/main/java/com/fangxuele/tool/push/util/MybatisUtil.java b/src/main/java/com/fangxuele/tool/push/util/MybatisUtil.java
index 7745d4ed0..e8776f3b1 100644
--- a/src/main/java/com/fangxuele/tool/push/util/MybatisUtil.java
+++ b/src/main/java/com/fangxuele/tool/push/util/MybatisUtil.java
@@ -34,7 +34,7 @@ public class MybatisUtil {
      */
     private static boolean needInit = false;
 
-    private static File dbFile = new File(SystemUtil.configHome + "WePush.db");
+    private static File dbFile = new File(SystemUtil.CONFIG_HOME + "WePush.db");
 
     static {
         try {
@@ -67,7 +67,7 @@ public static SqlSession getSqlSession() {
      * 初始化数据库文件
      */
     public static void initDbFile() throws SQLException {
-        File configHomeDir = new File(SystemUtil.configHome);
+        File configHomeDir = new File(SystemUtil.CONFIG_HOME);
         if (!configHomeDir.exists()) {
             configHomeDir.mkdirs();
         }
diff --git a/src/main/java/com/fangxuele/tool/push/util/ScrollUtil.java b/src/main/java/com/fangxuele/tool/push/util/ScrollUtil.java
new file mode 100644
index 000000000..fe1bcecde
--- /dev/null
+++ b/src/main/java/com/fangxuele/tool/push/util/ScrollUtil.java
@@ -0,0 +1,19 @@
+package com.fangxuele.tool.push.util;
+
+import javax.swing.*;
+
+/**
+ * some functions about scroll
+ *
+ * @author RememBerBer
+ * @since 2021/11/23.
+ */
+public class ScrollUtil {
+
+    public static void smoothPane(JScrollPane scrollPane) {
+        scrollPane.getVerticalScrollBar().setUnitIncrement(14);
+        scrollPane.getHorizontalScrollBar().setUnitIncrement(14);
+        scrollPane.getVerticalScrollBar().setDoubleBuffered(true);
+        scrollPane.getHorizontalScrollBar().setDoubleBuffered(true);
+    }
+}
diff --git a/src/main/java/com/fangxuele/tool/push/util/SystemUtil.java b/src/main/java/com/fangxuele/tool/push/util/SystemUtil.java
index f010ea06a..03f7080bc 100644
--- a/src/main/java/com/fangxuele/tool/push/util/SystemUtil.java
+++ b/src/main/java/com/fangxuele/tool/push/util/SystemUtil.java
@@ -11,11 +11,32 @@
  * @since 2019/4/20.
  */
 public class SystemUtil {
-    private static String osName = System.getProperty("os.name");
-    public static String configHome = System.getProperty("user.home") + File.separator + ".wepush"
-            + File.separator;
+    private static final String OS_NAME = System.getProperty("os.name");
+    private static final String OS_ARCH = System.getProperty("os.arch");
+    private static final String VM_VENDOR = System.getProperty("java.vm.vendor");
+    private static final String USER_HOME = System.getProperty("user.home");
+    public static final String CONFIG_HOME = USER_HOME + File.separator + ".WePush5" + File.separator;
+    /**
+     * 日志文件路径
+     */
+    public final static String LOG_DIR = USER_HOME + File.separator + ".WePush5" + File.separator + "logs" + File.separator;
 
+    public static boolean isWindowsOs() {
+        return OS_NAME.contains("Windows");
+    }
     public static boolean isMacOs() {
-        return osName.contains("Mac");
+        return OS_NAME.contains("Mac");
+    }
+
+    public static boolean isLinuxOs() {
+        return OS_NAME.contains("Linux");
+    }
+
+    public static boolean isMacM1() {
+        return OS_NAME.contains("Mac") && "aarch64".equals(OS_ARCH);
+    }
+
+    public static boolean isJBR() {
+        return VM_VENDOR.contains("JetBrains");
     }
 }
\ No newline at end of file
diff --git a/src/main/java/com/fangxuele/tool/push/util/TemplateUtil.java b/src/main/java/com/fangxuele/tool/push/util/TemplateUtil.java
index f651e3945..4e41fcf52 100644
--- a/src/main/java/com/fangxuele/tool/push/util/TemplateUtil.java
+++ b/src/main/java/com/fangxuele/tool/push/util/TemplateUtil.java
@@ -1,5 +1,6 @@
 package com.fangxuele.tool.push.util;
 
+import cn.hutool.core.date.DateUtil;
 import com.fangxuele.tool.push.logic.PushControl;
 import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender;
 import me.chanjar.weixin.common.error.WxErrorException;
@@ -8,6 +9,7 @@
 import org.apache.velocity.app.VelocityEngine;
 
 import java.io.StringWriter;
+import java.util.Date;
 
 /**
  * 
@@ -40,6 +42,10 @@ public static String evaluate(String content, VelocityContext velocityContext) {
         }
 
         velocityContext.put("ENTER", "\n");
+        Date now = new Date();
+        velocityContext.put("DATE", DateUtil.today());
+        velocityContext.put("TIME", DateUtil.formatTime(now));
+        velocityContext.put("DATE_TIME", DateUtil.formatDateTime(now));
 
         StringWriter writer = new StringWriter();
         velocityEngine.evaluate(velocityContext, writer, "", content);
diff --git a/src/main/java/com/fangxuele/tool/push/util/UIUtil.java b/src/main/java/com/fangxuele/tool/push/util/UIUtil.java
index 75fac6e74..8991eeca0 100644
--- a/src/main/java/com/fangxuele/tool/push/util/UIUtil.java
+++ b/src/main/java/com/fangxuele/tool/push/util/UIUtil.java
@@ -1,8 +1,14 @@
 package com.fangxuele.tool.push.util;
 
+import com.fangxuele.tool.push.App;
 import lombok.extern.slf4j.Slf4j;
 
+import javax.swing.text.JTextComponent;
+import javax.swing.undo.UndoManager;
 import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.lang.reflect.Field;
 
 /**
  * 
@@ -48,4 +54,32 @@ public static float getScreenScale() {
 
         return scale;
     }
+
+    /**
+     * 是否暗黑主题
+     *
+     * @return
+     */
+    public static boolean isDarkLaf() {
+        return "Darcula".equals(App.config.getTheme())
+                || "Darcula(推荐)".equals(App.config.getTheme())
+                || "Flat Dark".equals(App.config.getTheme())
+                || "Flat Darcula".equals(App.config.getTheme())
+                || "Flat Darcula(推荐)".equals(App.config.getTheme());
+    }
+
+    public static void clearForm(Object object) {
+        Class strClass = object.getClass();
+        Field[] declaredFields = strClass.getDeclaredFields();
+        for (Field field : declaredFields) {
+            if (JTextComponent.class.isAssignableFrom(field.getType())) {
+                try {
+                    field.setAccessible(true);
+                    ((JTextComponent) field.get(object)).setText("");
+                } catch (IllegalAccessException e) {
+                    log.error(e.toString());
+                }
+            }
+        }
+    }
 }
diff --git a/src/main/java/com/fangxuele/tool/push/util/UpgradeUtil.java b/src/main/java/com/fangxuele/tool/push/util/UpgradeUtil.java
index a40fba23e..285b11815 100644
--- a/src/main/java/com/fangxuele/tool/push/util/UpgradeUtil.java
+++ b/src/main/java/com/fangxuele/tool/push/util/UpgradeUtil.java
@@ -6,12 +6,8 @@
 import com.alibaba.fastjson.JSON;
 import com.fangxuele.tool.push.App;
 import com.fangxuele.tool.push.bean.VersionSummary;
-import com.fangxuele.tool.push.dao.TWxAccountMapper;
-import com.fangxuele.tool.push.domain.TWxAccount;
 import com.fangxuele.tool.push.ui.UiConsts;
 import com.fangxuele.tool.push.ui.dialog.UpdateInfoDialog;
-import com.fangxuele.tool.push.ui.form.MainWindow;
-import com.fangxuele.tool.push.ui.form.SettingForm;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 
@@ -39,7 +35,7 @@ public static void checkUpdate(boolean initCheck) {
         // 从github获取最新版本相关信息
         String versionSummaryJsonContent = HttpUtil.get(UiConsts.CHECK_VERSION_URL);
         if (StringUtils.isEmpty(versionSummaryJsonContent) && !initCheck) {
-            JOptionPane.showMessageDialog(MainWindow.getInstance().getSettingPanel(),
+            JOptionPane.showMessageDialog(App.mainFrame,
                     "检查超时,请关注GitHub Release!", "网络错误",
                     JOptionPane.INFORMATION_MESSAGE);
             return;
@@ -76,7 +72,7 @@ public static void checkUpdate(boolean initCheck) {
             updateInfoDialog.setVisible(true);
         } else {
             if (!initCheck) {
-                JOptionPane.showMessageDialog(MainWindow.getInstance().getSettingPanel(),
+                JOptionPane.showMessageDialog(App.mainFrame,
                         "当前已经是最新版本!", "恭喜",
                         JOptionPane.INFORMATION_MESSAGE);
             }
@@ -128,6 +124,7 @@ public static void smoothUpgrade() {
                     String sql = FileUtil.readString(sqlFileUrl, CharsetUtil.UTF_8);
                     try {
                         MybatisUtil.executeSql(sql);
+                        log.info("执行索引为{}的版本对应的sql完毕", i);
                     } catch (SQLException e) {
                         log.error("执行索引为{}的版本对应的sql时异常", i, e);
                         if (!e.getMessage().contains("duplicate column")) {
@@ -154,67 +151,6 @@ public static void smoothUpgrade() {
     private static void upgrade(int versionIndex) {
         log.info("执行升级脚本开始,版本索引:{}", versionIndex);
         switch (versionIndex) {
-            case 21:
-                String accountName = "默认账号";
-                TWxAccountMapper wxAccountMapper = MybatisUtil.getSqlSession().getMapper(TWxAccountMapper.class);
-                if (StringUtils.isNotBlank(App.config.getWechatAppId())) {
-                    boolean update = false;
-                    List tWxAccountList = wxAccountMapper.selectByAccountTypeAndAccountName(SettingForm.WX_ACCOUNT_TYPE_MP, accountName);
-                    if (tWxAccountList.size() > 0) {
-                        update = true;
-                    }
-
-                    TWxAccount tWxAccount = new TWxAccount();
-                    String now = SqliteUtil.nowDateForSqlite();
-                    tWxAccount.setAccountType(SettingForm.WX_ACCOUNT_TYPE_MP);
-                    tWxAccount.setAccountName(accountName);
-                    tWxAccount.setAppId(App.config.getWechatAppId());
-                    tWxAccount.setAppSecret(App.config.getWechatAppSecret());
-                    tWxAccount.setToken(App.config.getWechatToken());
-                    tWxAccount.setAesKey(App.config.getWechatAesKey());
-                    tWxAccount.setModifiedTime(now);
-                    if (update) {
-                        tWxAccount.setId(tWxAccountList.get(0).getId());
-                        wxAccountMapper.updateByPrimaryKeySelective(tWxAccount);
-                    } else {
-                        tWxAccount.setCreateTime(now);
-                        wxAccountMapper.insert(tWxAccount);
-                    }
-
-                    SettingForm.initSwitchMultiAccount();
-                }
-                if (StringUtils.isNotBlank(App.config.getMiniAppAppId())) {
-                    boolean update = false;
-                    List tWxAccountList = wxAccountMapper.selectByAccountTypeAndAccountName(SettingForm.WX_ACCOUNT_TYPE_MA, accountName);
-                    if (tWxAccountList.size() > 0) {
-                        update = true;
-                    }
-
-                    TWxAccount tWxAccount = new TWxAccount();
-                    String now = SqliteUtil.nowDateForSqlite();
-                    tWxAccount.setAccountType(SettingForm.WX_ACCOUNT_TYPE_MA);
-                    tWxAccount.setAccountName(accountName);
-                    tWxAccount.setAppId(App.config.getMiniAppAppId());
-                    tWxAccount.setAppSecret(App.config.getMiniAppAppSecret());
-                    tWxAccount.setToken(App.config.getMiniAppToken());
-                    tWxAccount.setAesKey(App.config.getMiniAppAesKey());
-                    tWxAccount.setModifiedTime(now);
-                    if (update) {
-                        tWxAccount.setId(tWxAccountList.get(0).getId());
-                        wxAccountMapper.updateByPrimaryKeySelective(tWxAccount);
-                    } else {
-                        tWxAccount.setCreateTime(now);
-                        wxAccountMapper.insert(tWxAccount);
-                    }
-                    SettingForm.initSwitchMultiAccount();
-                }
-                break;
-            case 26:
-                if (StringUtils.isNotBlank(App.config.getMysqlDatabase())) {
-                    App.config.setMysqlUrl(App.config.getMysqlUrl() + '/' + App.config.getMysqlDatabase());
-                    App.config.save();
-                }
-                break;
             default:
         }
         log.info("执行升级脚本结束,版本索引:{}", versionIndex);
diff --git a/src/main/java/com/fangxuele/tool/push/util/WeWxMpServiceImpl.java b/src/main/java/com/fangxuele/tool/push/util/WeWxMpServiceImpl.java
index 04c98673f..cfd966a19 100644
--- a/src/main/java/com/fangxuele/tool/push/util/WeWxMpServiceImpl.java
+++ b/src/main/java/com/fangxuele/tool/push/util/WeWxMpServiceImpl.java
@@ -3,9 +3,9 @@
 import cn.hutool.cache.CacheUtil;
 import cn.hutool.cache.impl.TimedCache;
 import cn.hutool.json.JSONUtil;
-import com.fangxuele.tool.push.App;
-import me.chanjar.weixin.common.WxType;
+import com.fangxuele.tool.push.bean.account.WxMpAccountConfig;
 import me.chanjar.weixin.common.bean.WxAccessToken;
+import me.chanjar.weixin.common.enums.WxType;
 import me.chanjar.weixin.common.error.WxError;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
@@ -33,6 +33,12 @@ public class WeWxMpServiceImpl extends WxMpServiceImpl {
 
     private int count;
 
+    private WxMpAccountConfig wxMpAccountConfig;
+
+    public WeWxMpServiceImpl(WxMpAccountConfig wxMpAccountConfig) {
+        this.wxMpAccountConfig = wxMpAccountConfig;
+    }
+
     @Override
     public String getAccessToken(boolean forceRefresh) throws WxErrorException {
         final WxMpConfigStorage config = this.getWxMpConfigStorage();
@@ -47,7 +53,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
             if (!config.isAccessTokenExpired() && !forceRefresh) {
                 return config.getAccessToken();
             }
-            if (timedCache.get("count") != null && Integer.parseInt(timedCache.get("count")) > 10) {
+            if (timedCache.get("count") != null && Integer.parseInt(timedCache.get("count")) > 20) {
                 WxError wxError = WxError.builder().errorCode(98).errorMsg("短时间内大量获取AccessToken失败").errorMsgEn("Fail to get AccessToken in a shot period").json("").build();
                 count = 0;
                 throw new WxErrorException(wxError);
@@ -60,15 +66,15 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
             try {
                 WxAccessToken accessToken;
 
-                if (App.config.isMpUseOutSideAt() && App.config.isMpManualAt()) {
+                if (wxMpAccountConfig.isMpUseOutSideAt() && wxMpAccountConfig.isMpManualAt()) {
                     accessToken = new WxAccessToken();
-                    accessToken.setAccessToken(App.config.getMpAt());
-                    accessToken.setExpiresIn(Integer.parseInt(App.config.getMpAtExpiresIn()));
+                    accessToken.setAccessToken(wxMpAccountConfig.getMpAt());
+                    accessToken.setExpiresIn(Integer.parseInt(wxMpAccountConfig.getMpAtExpiresIn()));
                 } else {
                     String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret());
 
-                    if (App.config.isMpUseOutSideAt() && App.config.isMpApiAt()) {
-                        url = App.config.getMpAtApiUrl();
+                    if (wxMpAccountConfig.isMpUseOutSideAt() && wxMpAccountConfig.isMpApiAt()) {
+                        url = wxMpAccountConfig.getMpAtApiUrl();
                     }
                     HttpGet httpGet = new HttpGet(url);
                     if (this.getRequestHttpProxy() != null) {
@@ -79,7 +85,7 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
                         String resultContent = new BasicResponseHandler().handleResponse(response);
                         WxError error = WxError.fromJson(resultContent, WxType.MP);
                         if (error.getErrorCode() != 0) {
-                            if (App.config.isMpUseOutSideAt() && App.config.isMpApiAt()) {
+                            if (wxMpAccountConfig.isMpUseOutSideAt() && wxMpAccountConfig.isMpApiAt()) {
                                 error = WxError.builder().errorCode(99).errorMsg("通过接口" + url + "获取AccessToken失败").errorMsgEn("Fail to get AccessToken from:" + url).json(resultContent).build();
                                 throw new WxErrorException(error);
                             } else {
diff --git a/src/main/resources/db_init.sql b/src/main/resources/db_init.sql
index 3a391ad7b..19fa22d24 100644
--- a/src/main/resources/db_init.sql
+++ b/src/main/resources/db_init.sql
@@ -1,114 +1,3 @@
-create table if not exists t_msg_kefu
-(
-    id            integer
-        constraint t_msg_kefu_pk
-            primary key autoincrement,
-    msg_type      integer,
-    msg_name      text,
-    kefu_msg_type text,
-    content       text,
-    title         text,
-    img_url       text,
-    describe      text,
-    url           text,
-    create_time   datetime,
-    modified_time datetime
-);
-create unique index if not exists t_msg_kefu_msg_type_msg_name_uindex
-    on t_msg_kefu (msg_type, msg_name);
-create table if not exists t_msg_kefu_priority
-(
-    id            integer
-        constraint t_msg_kefu_priority_pk
-            primary key autoincrement,
-    msg_type      integer,
-    msg_name      text,
-    template_id   text,
-    url           text,
-    ma_appid      text,
-    ma_page_path  text,
-    kefu_msg_type text,
-    content       text,
-    title         text,
-    img_url       text,
-    describe      text,
-    kefu_url      text,
-    create_time   datetime,
-    modified_time datetime
-);
-create unique index if not exists t_msg_kefu_priority_msg_type_msg_name_uindex
-    on t_msg_kefu_priority (msg_type, msg_name);
-create table if not exists t_msg_ma_template
-(
-    id               integer
-        constraint t_msg_ma_template_pk
-            primary key autoincrement,
-    msg_type         integer,
-    msg_name         text,
-    template_id      text,
-    page             text,
-    emphasis_keyword text,
-    create_time      datetime,
-    modified_time    datetime
-);
-create unique index if not exists t_msg_ma_template_msg_type_msg_name_uindex
-    on t_msg_ma_template (msg_type, msg_name);
-create table if not exists t_msg_mp_template
-(
-    id            integer
-        constraint t_msg_mp_template_pk
-            primary key autoincrement,
-    msg_type      integer,
-    msg_name      text,
-    template_id   text,
-    url           text,
-    ma_appid      text,
-    ma_page_path  text,
-    create_time   datetime,
-    modified_time datetime
-);
-create unique index if not exists t_msg_mp_template_msg_type_msg_name_uindex
-    on t_msg_mp_template (msg_type, msg_name);
-create table if not exists t_msg_sms
-(
-    id            integer
-        constraint t_msg_ali_template_pk
-            primary key autoincrement,
-    msg_type      integer,
-    msg_name      text,
-    template_id   text,
-    content       text,
-    create_time   datetime,
-    modified_time datetime
-);
-create unique index if not exists t_msg_sms_msg_type_msg_name_uindex
-    on t_msg_sms (msg_type, msg_name);
-create table if not exists t_push_history
-(
-    id            integer
-        constraint t_push_history_pk
-            primary key autoincrement,
-    msg_id        integer,
-    msg_type      integer,
-    msg_name      text,
-    result        text,
-    csv_file      text,
-    create_time   datetime,
-    modified_time datetime
-);
-create table if not exists t_template_data
-(
-    id            integer
-        constraint t_template_data_ma_pk
-            primary key autoincrement,
-    msg_type      integer,
-    msg_id        integer,
-    name          text,
-    value         text,
-    color         text,
-    create_time   datetime,
-    modified_time datetime
-);
 create table if not exists t_wx_mp_user
 (
     open_id         text
@@ -116,7 +5,7 @@ create table if not exists t_wx_mp_user
             primary key,
     nickname        text,
     sex_desc        text,
-    sex             INTEGER,
+    sex             integer,
     language        text,
     city            text,
     province        text,
@@ -132,163 +21,149 @@ create table if not exists t_wx_mp_user
     create_time     text,
     modified_time   text
 );
-create table if not exists t_wx_account
-(
-    id            INTEGER
-        constraint t_wx_account_pk
-            primary key autoincrement,
-    account_type  text,
-    account_name  text,
-    app_id        text,
-    app_secret    text,
-    token         text,
-    aes_key       text,
-    create_time   datetime,
-    modified_time datetime
-);
 
-create table if not exists t_msg_mail
+create table if not exists t_account
 (
-    id            integer
-        constraint t_msg_mail_pk
+    id             integer
+        constraint t_account_pk
             primary key autoincrement,
-    msg_type      integer,
-    msg_name      text,
-    title         text,
-    Cc            text,
-    files         text,
-    content       text,
-    create_time   datetime,
-    modified_time datetime
+    msg_type       integer,
+    account_name   text,
+    account_config text,
+    remark         text,
+    create_time    datetime,
+    modified_time  datetime
 );
 
-create unique index if not exists t_msg_mail_msg_type_msg_name_uindex
-    on t_msg_mail (msg_type, msg_name);
-
-create table if not exists t_wx_cp_app
-(
-    id            INTEGER
-        constraint t_wx_cp_app_pk
-            primary key autoincrement,
-    corpId        text,
-    app_name      text,
-    agent_id      text,
-    secret        text,
-    token         text,
-    aes_key       text,
-    create_time   datetime,
-    modified_time datetime
-);
+create unique index if not exists t_account_msg_type_account_name_uindex
+    on t_account (msg_type, account_name);
 
-create table if not exists t_msg_wx_cp
+create table if not exists t_people
 (
     id            integer
-        constraint t_msg_wx_cp_pk
+        constraint t_people_pk
             primary key autoincrement,
     msg_type      integer,
-    msg_name      text,
-    cp_msg_type   text,
-    agent_id      text,
-    content       text,
-    title         text,
-    img_url       text,
-    describe      text,
-    url           text,
-    btn_txt       text,
+    account_id    integer,
+    people_name   text,
+    app_version   text,
+    remark        text,
     create_time   datetime,
     modified_time datetime
 );
 
-create unique index if not exists t_msg_wx_cp_msg_type_msg_name_uindex
-    on t_msg_wx_cp (msg_type, msg_name);
+create unique index if not exists t_people_msg_type_account_id_people_name_uindex
+    on t_people (msg_type, account_id, people_name);
+
 
-create table if not exists t_msg_http
+create table if not exists t_people_data
 (
     id            integer
-        constraint t_msg_http_pk
-            primary key autoincrement,
-    msg_type      integer,
-    msg_name      text,
-    method        text,
-    url           text,
-    params        text,
-    headers       text,
-    cookies       text,
-    body          text,
-    body_type     text,
+        constraint t_people_data_pk
+            primary key autoincrement,
+    people_id     integer,
+    pin           text,
+    var_data      text,
+    app_version   text,
+    data_version  text,
+    remark        text,
     create_time   datetime,
     modified_time datetime
 );
 
-create unique index if not exists t_msg_http_msg_type_msg_name_uindex
-    on t_msg_http (msg_type, msg_name);
+create index if not exists t_people_data_people_id_index
+    on t_people_data (people_id);
 
-create table if not exists t_msg_ding
-(
-    id            integer
-        constraint t_msg_ding_pk
-            primary key autoincrement,
-    msg_type      integer,
-    msg_name      text,
-    radio_type    text,
-    ding_msg_type text,
-    agent_id      text,
-    web_hook      text,
-    content       text,
-    create_time   datetime,
-    modified_time datetime
+create table if not exists t_people_import_config
+(
+    id                integer
+        constraint t_people_import_config_pk
+            primary key autoincrement,
+    people_id         integer,
+    last_way          text,
+    last_file_path    text,
+    last_sql          text,
+    app_version       text,
+    last_way_config   text,
+    last_data_version text,
+    remark            text,
+    create_time       datetime,
+    modified_time     datetime
 );
 
-create unique index if not exists t_msg_ding_msg_type_msg_name_uindex
-    on t_msg_ding (msg_type, msg_name);
+create unique index if not exists t_people_import_config_people_id_uindex
+    on t_people_import_config (people_id);
 
-create table if not exists t_ding_app
-(
-    id            INTEGER
-        constraint t_ding_app_pk
-            primary key autoincrement,
-    app_name      text,
-    agent_id      text,
-    app_key       text,
-    app_secret    text,
-    create_time   datetime,
-    modified_time datetime
+create table if not exists t_task
+(
+    id              integer
+        constraint t_task_pk
+            primary key autoincrement,
+    title           text,
+    msg_type        integer,
+    account_id      integer,
+    message_id      integer,
+    people_id       integer,
+    task_mode       integer,
+    task_period     integer,
+    period_type     integer,
+    period_time     text,
+    cron            text,
+    thread_cnt      integer,
+    max_thread_cnt  integer,
+    reimport_people integer,
+    result_alert    integer,
+    alert_emails    text,
+    save_result     integer,
+    remark          text,
+    create_time     datetime,
+    modified_time   datetime
 );
 
-create table if not exists t_msg_wx_uniform
-(
-    id               integer
-        constraint t_msg_wx_uniform_pk
-            primary key autoincrement,
-    msg_type         integer,
-    msg_name         text,
-    mp_template_id   text,
-    ma_template_id   text,
-    mp_url           text,
-    ma_appid         text,
-    ma_page_path     text,
-    page             text,
-    emphasis_keyword text,
-    create_time      datetime,
-    modified_time    datetime
+create unique index if not exists t_task_title_uindex
+    on t_task (title);
+
+create table if not exists t_task_his
+(
+    id                integer
+        constraint t_task_his_pk
+            primary key autoincrement,
+    task_id           integer,
+    start_time        datetime,
+    end_time          datetime,
+    total_cnt         integer,
+    success_cnt       integer,
+    fail_cnt          integer,
+    status            integer,
+    dry_run           integer,
+    success_file_path text,
+    fail_file_path    text,
+    no_send_file_path text,
+    log_file_path     text,
+    task_mode         integer,
+    remark            text,
+    create_time       datetime,
+    modified_time     datetime
 );
 
-create unique index if not exists t_msg_wx_uniform_msg_type_msg_name_uindex
-    on t_msg_wx_uniform (msg_type, msg_name);
+create index if not exists t_task_his_task_id_index
+    on t_task_his (task_id);
 
-create table if not exists t_msg_ma_subscribe
+create table if not exists t_msg
 (
     id            integer
-        constraint t_msg_ma_subscribe_pk
+        constraint t_msg_pk
             primary key autoincrement,
-    msg_type      integer,
+    msg_type      intteger,
+    account_id    integer,
     msg_name      text,
-    template_id   text,
-    page          text,
+    content       text,
+    preview_user  text,
+    remark        text,
     create_time   datetime,
     modified_time datetime
 );
 
-create unique index if not exists t_msg_ma_subscribe_msg_type_msg_name_uindex
-    on t_msg_ma_subscribe (msg_type, msg_name);
+create unique index if not exists t_msg_msg_type_account_id_msg_name_uindex
+    on t_msg (msg_type, account_id, msg_name);
 
diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml
index 31178e72b..68d8f8a8e 100644
--- a/src/main/resources/generatorConfig.xml
+++ b/src/main/resources/generatorConfig.xml
@@ -4,12 +4,9 @@
         "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
 
 
-    
+    
 
     
-        
-        
-        
         
         
             
@@ -17,7 +14,7 @@
         
 
         
+                        connectionURL="jdbc:sqlite:/Users/zhoubo/.WePush5/WePush.db">
         
 
         
@@ -26,26 +23,26 @@
 
         
         
+                            targetProject="/Users/zhoubo/IdeaProjects/WePush/src/main/java">
             
             
         
 
         
         
+                         targetProject="/Users/zhoubo/IdeaProjects/WePush/src/main/resources">
             
         
 
         
         
+                             targetProject="/Users/zhoubo/IdeaProjects/WePush/src/main/java">
             
         
 
         
+               tableName="t_msg" domainObjectName="TMsg">
             
             
         
diff --git a/src/main/resources/icon/add.svg b/src/main/resources/icon/add.svg new file mode 100644 index 000000000..408fb03a6 --- /dev/null +++ b/src/main/resources/icon/add.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/clear.svg b/src/main/resources/icon/clear.svg new file mode 100644 index 000000000..aed21e233 --- /dev/null +++ b/src/main/resources/icon/clear.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/data_base.svg b/src/main/resources/icon/data_base.svg new file mode 100644 index 000000000..4c1bdbd17 --- /dev/null +++ b/src/main/resources/icon/data_base.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/debug.svg b/src/main/resources/icon/debug.svg new file mode 100644 index 000000000..09b6a8f14 --- /dev/null +++ b/src/main/resources/icon/debug.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/detail.svg b/src/main/resources/icon/detail.svg new file mode 100644 index 000000000..b6525b8a3 --- /dev/null +++ b/src/main/resources/icon/detail.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/dingding.svg b/src/main/resources/icon/dingding.svg new file mode 100644 index 000000000..b974d5fb9 --- /dev/null +++ b/src/main/resources/icon/dingding.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/export.svg b/src/main/resources/icon/export.svg new file mode 100644 index 000000000..493858874 --- /dev/null +++ b/src/main/resources/icon/export.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/file-open.svg b/src/main/resources/icon/file-open.svg new file mode 100644 index 000000000..f9bee8e32 --- /dev/null +++ b/src/main/resources/icon/file-open.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/file.svg b/src/main/resources/icon/file.svg new file mode 100644 index 000000000..e47c6072a --- /dev/null +++ b/src/main/resources/icon/file.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/find.svg b/src/main/resources/icon/find.svg new file mode 100644 index 000000000..73c5e2298 --- /dev/null +++ b/src/main/resources/icon/find.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/help-filling.svg b/src/main/resources/icon/help-filling.svg new file mode 100644 index 000000000..1cc3e4536 --- /dev/null +++ b/src/main/resources/icon/help-filling.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/help.svg b/src/main/resources/icon/help.svg new file mode 100644 index 000000000..b3fdfef34 --- /dev/null +++ b/src/main/resources/icon/help.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/icon_push.svg b/src/main/resources/icon/icon_push.svg new file mode 100644 index 000000000..23dcb5e22 --- /dev/null +++ b/src/main/resources/icon/icon_push.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/import.svg b/src/main/resources/icon/import.svg new file mode 100644 index 000000000..9d5cf6632 --- /dev/null +++ b/src/main/resources/icon/import.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/modify.svg b/src/main/resources/icon/modify.svg new file mode 100644 index 000000000..7a6e42a13 --- /dev/null +++ b/src/main/resources/icon/modify.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/number.svg b/src/main/resources/icon/number.svg new file mode 100644 index 000000000..af0dba57c --- /dev/null +++ b/src/main/resources/icon/number.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/people.svg b/src/main/resources/icon/people.svg new file mode 100644 index 000000000..a595daac9 --- /dev/null +++ b/src/main/resources/icon/people.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/qiwei.svg b/src/main/resources/icon/qiwei.svg new file mode 100644 index 000000000..7e74d13e6 --- /dev/null +++ b/src/main/resources/icon/qiwei.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/refresh.svg b/src/main/resources/icon/refresh.svg new file mode 100644 index 000000000..5f2c4ef96 --- /dev/null +++ b/src/main/resources/icon/refresh.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/remove.svg b/src/main/resources/icon/remove.svg new file mode 100644 index 000000000..1e9b6896a --- /dev/null +++ b/src/main/resources/icon/remove.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/save.svg b/src/main/resources/icon/save.svg new file mode 100644 index 000000000..a8819925b --- /dev/null +++ b/src/main/resources/icon/save.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/schedule.svg b/src/main/resources/icon/schedule.svg new file mode 100644 index 000000000..4af799896 --- /dev/null +++ b/src/main/resources/icon/schedule.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/send.svg b/src/main/resources/icon/send.svg new file mode 100644 index 000000000..8424bbdc1 --- /dev/null +++ b/src/main/resources/icon/send.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/stop.svg b/src/main/resources/icon/stop.svg new file mode 100644 index 000000000..9d953a921 --- /dev/null +++ b/src/main/resources/icon/stop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/test.svg b/src/main/resources/icon/test.svg new file mode 100644 index 000000000..af3fece06 --- /dev/null +++ b/src/main/resources/icon/test.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/wechat.svg b/src/main/resources/icon/wechat.svg new file mode 100644 index 000000000..c33771c10 --- /dev/null +++ b/src/main/resources/icon/wechat.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/resources/icon/wx-zanshang.jpg b/src/main/resources/icon/wx-zanshang.jpg new file mode 100644 index 000000000..9d663627d Binary files /dev/null and b/src/main/resources/icon/wx-zanshang.jpg differ diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 3055c8281..0ed6184ee 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -8,7 +8,7 @@ - ./logs/wechat-push.%d{yyyy-MM-dd}.log + ${user.home}/.WePush5/logs/wechat-push.%d{yyyy-MM-dd}.log %date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} :%line - %msg%n diff --git a/src/main/resources/mapper/InitMapper.xml b/src/main/resources/mapper/InitMapper.xml deleted file mode 100644 index b1fbd4f8a..000000000 --- a/src/main/resources/mapper/InitMapper.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - create table t_msg_kefu - ( - id integer - constraint t_msg_kefu_pk - primary key autoincrement, - msg_type integer, - msg_name text, - kefu_msg_type text, - content text, - title text, - img_url text, - describe text, - url text, - create_time datetime, - modified_time datetime - ); - create unique index t_msg_kefu_msg_type_msg_name_uindex - on t_msg_kefu (msg_type, msg_name); - create table t_msg_kefu_priority - ( - id integer - constraint t_msg_kefu_priority_pk - primary key autoincrement, - msg_type integer, - msg_name text, - template_id text, - url text, - ma_appid text, - ma_page_path text, - kefu_msg_type text, - content text, - title text, - img_url text, - describe text, - kefu_url text, - create_time datetime, - modified_time datetime - ); - create unique index t_msg_kefu_priority_msg_type_msg_name_uindex - on t_msg_kefu_priority (msg_type, msg_name); - create table t_msg_ma_template - ( - id integer - constraint t_msg_ma_template_pk - primary key autoincrement, - msg_type integer, - msg_name text, - template_id text, - page text, - emphasis_keyword text, - create_time datetime, - modified_time datetime - ); - create unique index t_msg_ma_template_msg_type_msg_name_uindex - on t_msg_ma_template (msg_type, msg_name); - create table t_msg_mp_template - ( - id integer - constraint t_msg_mp_template_pk - primary key autoincrement, - msg_type integer, - msg_name text, - template_id text, - url text, - ma_appid text, - ma_page_path text, - create_time datetime, - modified_time datetime - ); - create unique index t_msg_mp_template_msg_type_msg_name_uindex - on t_msg_mp_template (msg_type, msg_name); - create table t_msg_sms - ( - id integer - constraint t_msg_ali_template_pk - primary key autoincrement, - msg_type integer, - msg_name text, - template_id text, - content text, - create_time datetime, - modified_time datetime - ); - create unique index t_msg_sms_msg_type_msg_name_uindex - on t_msg_sms (msg_type, msg_name); - create table t_push_history - ( - id integer - constraint t_push_history_pk - primary key autoincrement, - msg_id integer, - msg_type integer, - msg_name text, - result text, - csv_file text, - create_time datetime, - modified_time datetime - ); - create table t_template_data - ( - id integer - constraint t_template_data_ma_pk - primary key autoincrement, - msg_id integer, - name text, - value text, - color text, - create_time datetime, - modified_time datetime - ); - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgSmsMapper.xml b/src/main/resources/mapper/TAccountMapper.xml similarity index 52% rename from src/main/resources/mapper/TMsgSmsMapper.xml rename to src/main/resources/mapper/TAccountMapper.xml index 8092f09fb..494e610d6 100644 --- a/src/main/resources/mapper/TMsgSmsMapper.xml +++ b/src/main/resources/mapper/TAccountMapper.xml @@ -1,40 +1,39 @@ - - + + - - - + + + - id, msg_type, msg_name, template_id, content, create_time, modified_time + id, msg_type, account_name, account_config, remark, create_time, modified_time delete - from t_msg_sms + from t_account where id = #{id,jdbcType=INTEGER} - - insert into t_msg_sms (id, msg_type, msg_name, - template_id, content, create_time, - modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{templateId,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, - #{modifiedTime,jdbcType=VARCHAR}) + + insert into t_account (id, msg_type, account_name, + account_config, remark, create_time, + modified_time) + values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{accountName,jdbcType=VARCHAR}, + #{accountConfig,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, + #{modifiedTime,jdbcType=VARCHAR}) - - insert into t_msg_sms + + insert into t_account id, @@ -42,14 +41,14 @@ msg_type, - - msg_name, + + account_name, - - template_id, + + account_config, - - content, + + remark, create_time, @@ -65,14 +64,14 @@ #{msgType,jdbcType=INTEGER}, - - #{msgName,jdbcType=VARCHAR}, + + #{accountName,jdbcType=VARCHAR}, - - #{templateId,jdbcType=VARCHAR}, + + #{accountConfig,jdbcType=VARCHAR}, - - #{content,jdbcType=VARCHAR}, + + #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, @@ -82,20 +81,20 @@ - - update t_msg_sms + + update t_account msg_type = #{msgType,jdbcType=INTEGER}, - - msg_name = #{msgName,jdbcType=VARCHAR}, + + account_name = #{accountName,jdbcType=VARCHAR}, - - template_id = #{templateId,jdbcType=VARCHAR}, + + account_config = #{accountConfig,jdbcType=VARCHAR}, - - content = #{content,jdbcType=VARCHAR}, + + remark = #{remark,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=VARCHAR}, @@ -106,41 +105,47 @@ where id = #{id,jdbcType=INTEGER} - - update t_msg_sms - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - template_id = #{templateId,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} + + update t_account + set msg_type = #{msgType,jdbcType=INTEGER}, + account_name = #{accountName,jdbcType=VARCHAR}, + account_config = #{accountConfig,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} - select - from t_msg_sms + from t_account where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} + order by create_time desc - - update t_msg_sms - set template_id = #{templateId,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} + + + delete + from t_account where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - select - from t_msg_sms + from t_account where msg_type = #{msgType,jdbcType=INTEGER} - order by create_time desc + and account_name = #{accountName,jdbcType=VARCHAR} - - delete - from t_msg_sms + + update t_account + set msg_type = #{msgType,jdbcType=INTEGER}, + account_name = #{accountName,jdbcType=VARCHAR}, + account_config = #{accountConfig,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - + and account_name = #{accountName,jdbcType=VARCHAR} + \ No newline at end of file diff --git a/src/main/resources/mapper/TDingAppMapper.xml b/src/main/resources/mapper/TDingAppMapper.xml deleted file mode 100644 index 8a90018f9..000000000 --- a/src/main/resources/mapper/TDingAppMapper.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - id, app_name, agent_id, app_key, app_secret, create_time, modified_time - - - - delete - from t_ding_app - where id = #{id,jdbcType=INTEGER} - - - insert into t_ding_app (id, app_name, agent_id, - app_key, app_secret, create_time, - modified_time) - values (#{id,jdbcType=INTEGER}, #{appName,jdbcType=VARCHAR}, #{agentId,jdbcType=VARCHAR}, - #{appKey,jdbcType=VARCHAR}, #{appSecret,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, - #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_ding_app - - - id, - - - app_name, - - - agent_id, - - - app_key, - - - app_secret, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{appName,jdbcType=VARCHAR}, - - - #{agentId,jdbcType=VARCHAR}, - - - #{appKey,jdbcType=VARCHAR}, - - - #{appSecret,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_ding_app - - - app_name = #{appName,jdbcType=VARCHAR}, - - - agent_id = #{agentId,jdbcType=VARCHAR}, - - - app_key = #{appKey,jdbcType=VARCHAR}, - - - app_secret = #{appSecret,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_ding_app - set app_name = #{appName,jdbcType=VARCHAR}, - agent_id = #{agentId,jdbcType=VARCHAR}, - app_key = #{appKey,jdbcType=VARCHAR}, - app_secret = #{appSecret,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgDingMapper.xml b/src/main/resources/mapper/TMsgDingMapper.xml deleted file mode 100644 index 65fd91c9b..000000000 --- a/src/main/resources/mapper/TMsgDingMapper.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - - id, msg_type, msg_name, ding_msg_type, agent_id, web_hook, content, create_time, - modified_time, radio_type - - - - delete - from t_msg_ding - where id = #{id,jdbcType=INTEGER} - - - delete - from t_msg_ding - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - insert into t_msg_ding (id, msg_type, msg_name, - ding_msg_type, agent_id, web_hook, - content, create_time, modified_time, - radio_type) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{dingMsgType,jdbcType=VARCHAR}, #{agentId,jdbcType=VARCHAR}, #{webHook,jdbcType=VARCHAR}, - #{content,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}, - #{radioType,jdbcType=VARCHAR}) - - - insert into t_msg_ding - - - id, - - - msg_type, - - - msg_name, - - - ding_msg_type, - - - agent_id, - - - web_hook, - - - content, - - - create_time, - - - modified_time, - - - radio_type, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{dingMsgType,jdbcType=VARCHAR}, - - - #{agentId,jdbcType=VARCHAR}, - - - #{webHook,jdbcType=VARCHAR}, - - - #{content,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - #{radioType,jdbcType=VARCHAR}, - - - - - update t_msg_ding - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - ding_msg_type = #{dingMsgType,jdbcType=VARCHAR}, - - - agent_id = #{agentId,jdbcType=VARCHAR}, - - - web_hook = #{webHook,jdbcType=VARCHAR}, - - - content = #{content,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - radio_type = #{radioType,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_ding - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - ding_msg_type = #{dingMsgType,jdbcType=VARCHAR}, - agent_id = #{agentId,jdbcType=VARCHAR}, - web_hook = #{webHook,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - radio_type = #{radioType,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_ding - set ding_msg_type = #{dingMsgType,jdbcType=VARCHAR}, - agent_id = #{agentId,jdbcType=VARCHAR}, - web_hook = #{webHook,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - radio_type = #{radioType,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgHttpMapper.xml b/src/main/resources/mapper/TMsgHttpMapper.xml deleted file mode 100644 index 4d04aa761..000000000 --- a/src/main/resources/mapper/TMsgHttpMapper.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - id, msg_type, msg_name, method, url, params, headers, cookies, body, create_time, - modified_time, body_type - - - - delete - from t_msg_http - where id = #{id,jdbcType=INTEGER} - - - delete - from t_msg_http - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - insert into t_msg_http (id, msg_type, msg_name, - method, url, params, - headers, cookies, body, - create_time, modified_time, body_type) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{method,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{params,jdbcType=VARCHAR}, - #{headers,jdbcType=VARCHAR}, #{cookies,jdbcType=VARCHAR}, #{body,jdbcType=VARCHAR}, - #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}, #{bodyType,jdbcType=VARCHAR}) - - - insert into t_msg_http - - - id, - - - msg_type, - - - msg_name, - - - method, - - - url, - - - params, - - - headers, - - - cookies, - - - body, - - - create_time, - - - modified_time, - - - body_type, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{method,jdbcType=VARCHAR}, - - - #{url,jdbcType=VARCHAR}, - - - #{params,jdbcType=VARCHAR}, - - - #{headers,jdbcType=VARCHAR}, - - - #{cookies,jdbcType=VARCHAR}, - - - #{body,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - #{bodyType,jdbcType=VARCHAR}, - - - - - update t_msg_http - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - method = #{method,jdbcType=VARCHAR}, - - - url = #{url,jdbcType=VARCHAR}, - - - params = #{params,jdbcType=VARCHAR}, - - - headers = #{headers,jdbcType=VARCHAR}, - - - cookies = #{cookies,jdbcType=VARCHAR}, - - - body = #{body,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - body_type = #{bodyType,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_http - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - method = #{method,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - params = #{params,jdbcType=VARCHAR}, - headers = #{headers,jdbcType=VARCHAR}, - cookies = #{cookies,jdbcType=VARCHAR}, - body = #{body,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - body_type = #{bodyType,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_http - set method = #{method,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - params = #{params,jdbcType=VARCHAR}, - headers = #{headers,jdbcType=VARCHAR}, - cookies = #{cookies,jdbcType=VARCHAR}, - body = #{body,jdbcType=VARCHAR}, - body_type = #{bodyType,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgKefuMapper.xml b/src/main/resources/mapper/TMsgKefuMapper.xml deleted file mode 100644 index 6d4be5840..000000000 --- a/src/main/resources/mapper/TMsgKefuMapper.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - id, msg_type, msg_name, kefu_msg_type, content, title, img_url, describe, url, create_time, - modified_time - - - - delete - from t_msg_kefu - where id = #{id,jdbcType=INTEGER} - - - insert into t_msg_kefu (id, msg_type, msg_name, - kefu_msg_type, content, title, - img_url, describe, url, - create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{kefuMsgType,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, - #{imgUrl,jdbcType=VARCHAR}, #{describe,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, - #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_msg_kefu - - - id, - - - msg_type, - - - msg_name, - - - kefu_msg_type, - - - content, - - - title, - - - img_url, - - - describe, - - - url, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{kefuMsgType,jdbcType=VARCHAR}, - - - #{content,jdbcType=VARCHAR}, - - - #{title,jdbcType=VARCHAR}, - - - #{imgUrl,jdbcType=VARCHAR}, - - - #{describe,jdbcType=VARCHAR}, - - - #{url,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_msg_kefu - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - kefu_msg_type = #{kefuMsgType,jdbcType=VARCHAR}, - - - content = #{content,jdbcType=VARCHAR}, - - - title = #{title,jdbcType=VARCHAR}, - - - img_url = #{imgUrl,jdbcType=VARCHAR}, - - - describe = #{describe,jdbcType=VARCHAR}, - - - url = #{url,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_kefu - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - kefu_msg_type = #{kefuMsgType,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - title = #{title,jdbcType=VARCHAR}, - img_url = #{imgUrl,jdbcType=VARCHAR}, - describe = #{describe,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_kefu - set kefu_msg_type = #{kefuMsgType,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - title = #{title,jdbcType=VARCHAR}, - img_url = #{imgUrl,jdbcType=VARCHAR}, - describe = #{describe,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - - delete - from t_msg_kefu - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgKefuPriorityMapper.xml b/src/main/resources/mapper/TMsgKefuPriorityMapper.xml deleted file mode 100644 index a5fbd5f35..000000000 --- a/src/main/resources/mapper/TMsgKefuPriorityMapper.xml +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - id, msg_type, msg_name, template_id, url, ma_appid, ma_page_path, kefu_msg_type, - content, title, img_url, describe, kefu_url, create_time, modified_time - - - - delete - from t_msg_kefu_priority - where id = #{id,jdbcType=INTEGER} - - - insert into t_msg_kefu_priority (id, msg_type, msg_name, - template_id, url, ma_appid, - ma_page_path, kefu_msg_type, content, - title, img_url, describe, - kefu_url, create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{templateId,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{maAppid,jdbcType=VARCHAR}, - #{maPagePath,jdbcType=VARCHAR}, #{kefuMsgType,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, - #{title,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR}, #{describe,jdbcType=VARCHAR}, - #{kefuUrl,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_msg_kefu_priority - - - id, - - - msg_type, - - - msg_name, - - - template_id, - - - url, - - - ma_appid, - - - ma_page_path, - - - kefu_msg_type, - - - content, - - - title, - - - img_url, - - - describe, - - - kefu_url, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{templateId,jdbcType=VARCHAR}, - - - #{url,jdbcType=VARCHAR}, - - - #{maAppid,jdbcType=VARCHAR}, - - - #{maPagePath,jdbcType=VARCHAR}, - - - #{kefuMsgType,jdbcType=VARCHAR}, - - - #{content,jdbcType=VARCHAR}, - - - #{title,jdbcType=VARCHAR}, - - - #{imgUrl,jdbcType=VARCHAR}, - - - #{describe,jdbcType=VARCHAR}, - - - #{kefuUrl,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_msg_kefu_priority - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - template_id = #{templateId,jdbcType=VARCHAR}, - - - url = #{url,jdbcType=VARCHAR}, - - - ma_appid = #{maAppid,jdbcType=VARCHAR}, - - - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - - - kefu_msg_type = #{kefuMsgType,jdbcType=VARCHAR}, - - - content = #{content,jdbcType=VARCHAR}, - - - title = #{title,jdbcType=VARCHAR}, - - - img_url = #{imgUrl,jdbcType=VARCHAR}, - - - describe = #{describe,jdbcType=VARCHAR}, - - - kefu_url = #{kefuUrl,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_kefu_priority - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - template_id = #{templateId,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - ma_appid = #{maAppid,jdbcType=VARCHAR}, - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - kefu_msg_type = #{kefuMsgType,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - title = #{title,jdbcType=VARCHAR}, - img_url = #{imgUrl,jdbcType=VARCHAR}, - describe = #{describe,jdbcType=VARCHAR}, - kefu_url = #{kefuUrl,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_kefu_priority - set template_id = #{templateId,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - ma_appid = #{maAppid,jdbcType=VARCHAR}, - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - kefu_msg_type = #{kefuMsgType,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - title = #{title,jdbcType=VARCHAR}, - img_url = #{imgUrl,jdbcType=VARCHAR}, - describe = #{describe,jdbcType=VARCHAR}, - kefu_url = #{kefuUrl,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - - delete - from t_msg_kefu_priority - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgMaTemplateMapper.xml b/src/main/resources/mapper/TMsgMaTemplateMapper.xml deleted file mode 100644 index 1bda7aec5..000000000 --- a/src/main/resources/mapper/TMsgMaTemplateMapper.xml +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - - id, msg_type, msg_name, template_id, page, emphasis_keyword, create_time, modified_time - - - - delete - from t_msg_ma_template - where id = #{id,jdbcType=INTEGER} - - - insert into t_msg_ma_template (id, msg_type, msg_name, - template_id, page, emphasis_keyword, - create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{templateId,jdbcType=VARCHAR}, #{page,jdbcType=VARCHAR}, #{emphasisKeyword,jdbcType=VARCHAR}, - #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_msg_ma_template - - - id, - - - msg_type, - - - msg_name, - - - template_id, - - - page, - - - emphasis_keyword, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{templateId,jdbcType=VARCHAR}, - - - #{page,jdbcType=VARCHAR}, - - - #{emphasisKeyword,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_msg_ma_template - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - template_id = #{templateId,jdbcType=VARCHAR}, - - - page = #{page,jdbcType=VARCHAR}, - - - emphasis_keyword = #{emphasisKeyword,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_ma_template - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - template_id = #{templateId,jdbcType=VARCHAR}, - page = #{page,jdbcType=VARCHAR}, - emphasis_keyword = #{emphasisKeyword,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_ma_template - set template_id = #{templateId,jdbcType=VARCHAR}, - page = #{page,jdbcType=VARCHAR}, - emphasis_keyword = #{emphasisKeyword,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - - delete - from t_msg_ma_template - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgMailMapper.xml b/src/main/resources/mapper/TMsgMailMapper.xml deleted file mode 100644 index 1751636b8..000000000 --- a/src/main/resources/mapper/TMsgMailMapper.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - id, msg_type, msg_name, title, files, content, create_time, modified_time, Cc - - - - delete - from t_msg_mail - where id = #{id,jdbcType=INTEGER} - - - insert into t_msg_mail (id, msg_type, msg_name, - title, files, content, - create_time, modified_time, Cc) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{title,jdbcType=VARCHAR}, #{files,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, - #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}, #{cc,jdbcType=VARCHAR}) - - - insert into t_msg_mail - - - id, - - - msg_type, - - - msg_name, - - - title, - - - files, - - - content, - - - create_time, - - - modified_time, - - - Cc, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{title,jdbcType=VARCHAR}, - - - #{files,jdbcType=VARCHAR}, - - - #{content,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - #{cc,jdbcType=VARCHAR}, - - - - - update t_msg_mail - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - title = #{title,jdbcType=VARCHAR}, - - - files = #{files,jdbcType=VARCHAR}, - - - content = #{content,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - Cc = #{cc,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_mail - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - title = #{title,jdbcType=VARCHAR}, - files = #{files,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - Cc = #{cc,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_mail - set title = #{title,jdbcType=VARCHAR}, - Cc = #{cc,jdbcType=VARCHAR}, - files = #{files,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - - delete - from t_msg_mail - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgMapper.xml b/src/main/resources/mapper/TMsgMapper.xml new file mode 100644 index 000000000..ae9d1e157 --- /dev/null +++ b/src/main/resources/mapper/TMsgMapper.xml @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + id, msg_type, account_id, msg_name, content, preview_user, remark, create_time, modified_time + + + + + + delete from t_msg + where id = #{id,jdbcType=INTEGER} + + + insert into t_msg (id, msg_type, account_id, + msg_name, content, preview_user, + remark, create_time, modified_time + ) + values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=VARCHAR}, #{accountId,jdbcType=INTEGER}, + #{msgName,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{previewUser,jdbcType=VARCHAR}, + #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR} + ) + + + insert into t_msg + + + id, + + + msg_type, + + + account_id, + + + msg_name, + + + content, + + + preview_user, + + + remark, + + + create_time, + + + modified_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{msgType,jdbcType=VARCHAR}, + + + #{accountId,jdbcType=INTEGER}, + + + #{msgName,jdbcType=VARCHAR}, + + + #{content,jdbcType=VARCHAR}, + + + #{previewUser,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=VARCHAR}, + + + #{modifiedTime,jdbcType=VARCHAR}, + + + + + update t_msg + + + msg_type = #{msgType,jdbcType=VARCHAR}, + + + account_id = #{accountId,jdbcType=INTEGER}, + + + msg_name = #{msgName,jdbcType=VARCHAR}, + + + content = #{content,jdbcType=VARCHAR}, + + + preview_user = #{previewUser,jdbcType=VARCHAR}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=VARCHAR}, + + + modified_time = #{modifiedTime,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update t_msg + set msg_type = #{msgType,jdbcType=VARCHAR}, + account_id = #{accountId,jdbcType=INTEGER}, + msg_name = #{msgName,jdbcType=VARCHAR}, + content = #{content,jdbcType=VARCHAR}, + preview_user = #{previewUser,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgMpTemplateMapper.xml b/src/main/resources/mapper/TMsgMpTemplateMapper.xml deleted file mode 100644 index 6531b81be..000000000 --- a/src/main/resources/mapper/TMsgMpTemplateMapper.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - id, msg_type, msg_name, template_id, url, ma_appid, ma_page_path, create_time, modified_time - - - - delete - from t_msg_mp_template - where id = #{id,jdbcType=INTEGER} - - - insert into t_msg_mp_template (id, msg_type, msg_name, - template_id, url, ma_appid, - ma_page_path, create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{templateId,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{maAppid,jdbcType=VARCHAR}, - #{maPagePath,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_msg_mp_template - - - id, - - - msg_type, - - - msg_name, - - - template_id, - - - url, - - - ma_appid, - - - ma_page_path, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{templateId,jdbcType=VARCHAR}, - - - #{url,jdbcType=VARCHAR}, - - - #{maAppid,jdbcType=VARCHAR}, - - - #{maPagePath,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_msg_mp_template - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - template_id = #{templateId,jdbcType=VARCHAR}, - - - url = #{url,jdbcType=VARCHAR}, - - - ma_appid = #{maAppid,jdbcType=VARCHAR}, - - - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_mp_template - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - template_id = #{templateId,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - ma_appid = #{maAppid,jdbcType=VARCHAR}, - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_mp_template - set template_id = #{templateId,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - ma_appid = #{maAppid,jdbcType=VARCHAR}, - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - - delete - from t_msg_mp_template - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgWxCpMapper.xml b/src/main/resources/mapper/TMsgWxCpMapper.xml deleted file mode 100644 index 247f69a51..000000000 --- a/src/main/resources/mapper/TMsgWxCpMapper.xml +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - - - - - - - - - - - - - - - id, msg_type, msg_name, cp_msg_type, agent_id, content, title, img_url, describe, - url, create_time, modified_time, btn_txt - - - - delete - from t_msg_wx_cp - where id = #{id,jdbcType=INTEGER} - - - insert into t_msg_wx_cp (id, msg_type, msg_name, - cp_msg_type, agent_id, content, - title, img_url, describe, - url, create_time, modified_time, - btn_txt) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{cpMsgType,jdbcType=VARCHAR}, #{agentId,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, - #{title,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR}, #{describe,jdbcType=VARCHAR}, - #{url,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}, - #{btnTxt,jdbcType=VARCHAR}) - - - insert into t_msg_wx_cp - - - id, - - - msg_type, - - - msg_name, - - - cp_msg_type, - - - agent_id, - - - content, - - - title, - - - img_url, - - - describe, - - - url, - - - create_time, - - - modified_time, - - - btn_txt, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{cpMsgType,jdbcType=VARCHAR}, - - - #{agentId,jdbcType=VARCHAR}, - - - #{content,jdbcType=VARCHAR}, - - - #{title,jdbcType=VARCHAR}, - - - #{imgUrl,jdbcType=VARCHAR}, - - - #{describe,jdbcType=VARCHAR}, - - - #{url,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - #{btnTxt,jdbcType=VARCHAR}, - - - - - update t_msg_wx_cp - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - cp_msg_type = #{cpMsgType,jdbcType=VARCHAR}, - - - agent_id = #{agentId,jdbcType=VARCHAR}, - - - content = #{content,jdbcType=VARCHAR}, - - - title = #{title,jdbcType=VARCHAR}, - - - img_url = #{imgUrl,jdbcType=VARCHAR}, - - - describe = #{describe,jdbcType=VARCHAR}, - - - url = #{url,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - btn_txt = #{btnTxt,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_wx_cp - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - cp_msg_type = #{cpMsgType,jdbcType=VARCHAR}, - agent_id = #{agentId,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - title = #{title,jdbcType=VARCHAR}, - img_url = #{imgUrl,jdbcType=VARCHAR}, - describe = #{describe,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - btn_txt = #{btnTxt,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - update t_msg_wx_cp - set cp_msg_type = #{cpMsgType,jdbcType=VARCHAR}, - agent_id = #{agentId,jdbcType=VARCHAR}, - content = #{content,jdbcType=VARCHAR}, - title = #{title,jdbcType=VARCHAR}, - img_url = #{imgUrl,jdbcType=VARCHAR}, - describe = #{describe,jdbcType=VARCHAR}, - url = #{url,jdbcType=VARCHAR}, - btn_txt = #{btnTxt,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - - delete - from t_msg_wx_cp - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgWxUniformMapper.xml b/src/main/resources/mapper/TMsgWxUniformMapper.xml deleted file mode 100644 index 3d2d157f7..000000000 --- a/src/main/resources/mapper/TMsgWxUniformMapper.xml +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - id, msg_type, msg_name, mp_template_id, ma_template_id, mp_url, ma_appid, ma_page_path, - page, emphasis_keyword, create_time, modified_time - - - - - - delete - from t_msg_wx_uniform - where msg_type = #{msgType,jdbcType=INTEGER} - - - delete - from t_msg_wx_uniform - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - insert into t_msg_wx_uniform (id, msg_type, msg_name, - mp_template_id, ma_template_id, mp_url, - ma_appid, ma_page_path, page, - emphasis_keyword, create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{mpTemplateId,jdbcType=VARCHAR}, #{maTemplateId,jdbcType=VARCHAR}, #{mpUrl,jdbcType=VARCHAR}, - #{maAppid,jdbcType=VARCHAR}, #{maPagePath,jdbcType=VARCHAR}, #{page,jdbcType=VARCHAR}, - #{emphasisKeyword,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_msg_wx_uniform - - - id, - - - msg_type, - - - msg_name, - - - mp_template_id, - - - ma_template_id, - - - mp_url, - - - ma_appid, - - - ma_page_path, - - - page, - - - emphasis_keyword, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{mpTemplateId,jdbcType=VARCHAR}, - - - #{maTemplateId,jdbcType=VARCHAR}, - - - #{mpUrl,jdbcType=VARCHAR}, - - - #{maAppid,jdbcType=VARCHAR}, - - - #{maPagePath,jdbcType=VARCHAR}, - - - #{page,jdbcType=VARCHAR}, - - - #{emphasisKeyword,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_msg_wx_uniform - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - mp_template_id = #{mpTemplateId,jdbcType=VARCHAR}, - - - ma_template_id = #{maTemplateId,jdbcType=VARCHAR}, - - - mp_url = #{mpUrl,jdbcType=VARCHAR}, - - - ma_appid = #{maAppid,jdbcType=VARCHAR}, - - - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - - - page = #{page,jdbcType=VARCHAR}, - - - emphasis_keyword = #{emphasisKeyword,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_msg_wx_uniform - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - mp_template_id = #{mpTemplateId,jdbcType=VARCHAR}, - ma_template_id = #{maTemplateId,jdbcType=VARCHAR}, - mp_url = #{mpUrl,jdbcType=VARCHAR}, - ma_appid = #{maAppid,jdbcType=VARCHAR}, - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - page = #{page,jdbcType=VARCHAR}, - emphasis_keyword = #{emphasisKeyword,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - update t_msg_wx_uniform - set mp_template_id = #{mpTemplateId,jdbcType=VARCHAR}, - ma_template_id = #{maTemplateId,jdbcType=VARCHAR}, - mp_url = #{mpUrl,jdbcType=VARCHAR}, - ma_appid = #{maAppid,jdbcType=VARCHAR}, - ma_page_path = #{maPagePath,jdbcType=VARCHAR}, - page = #{page,jdbcType=VARCHAR}, - emphasis_keyword = #{emphasisKeyword,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TPeopleDataMapper.xml b/src/main/resources/mapper/TPeopleDataMapper.xml new file mode 100644 index 000000000..2c74ae0b6 --- /dev/null +++ b/src/main/resources/mapper/TPeopleDataMapper.xml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + id, people_id, pin, var_data, app_version, data_version, remark, create_time, modified_time + + + + delete from t_people_data + where id = #{id,jdbcType=INTEGER} + + + insert into t_people_data (id, people_id, pin, + var_data, app_version, data_version, remark, + create_time, modified_time) + values (#{id,jdbcType=INTEGER}, #{peopleId,jdbcType=INTEGER}, #{pin,jdbcType=VARCHAR}, + #{varData,jdbcType=VARCHAR}, #{appVersion,jdbcType=VARCHAR}, #{dataVersion,jdbcType=VARCHAR}, + #{remark,jdbcType=VARCHAR}, + #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) + + + insert into t_people_data + + + id, + + + people_id, + + + pin, + + + var_data, + + + app_version, + + + data_version, + + + remark, + + + create_time, + + + modified_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{peopleId,jdbcType=INTEGER}, + + + #{pin,jdbcType=VARCHAR}, + + + #{varData,jdbcType=VARCHAR}, + + + #{appVersion,jdbcType=VARCHAR}, + + + #{dataVersion,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=VARCHAR}, + + + #{modifiedTime,jdbcType=VARCHAR}, + + + + + update t_people_data + + + people_id = #{peopleId,jdbcType=INTEGER}, + + + pin = #{pin,jdbcType=VARCHAR}, + + + var_data = #{varData,jdbcType=VARCHAR}, + + + app_version = #{appVersion,jdbcType=VARCHAR}, + + + data_version = #{dataVersion,jdbcType=VARCHAR}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=VARCHAR}, + + + modified_time = #{modifiedTime,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update t_people_data + set people_id = #{peopleId,jdbcType=INTEGER}, + pin = #{pin,jdbcType=VARCHAR}, + var_data = #{varData,jdbcType=VARCHAR}, + app_version = #{appVersion,jdbcType=VARCHAR}, + data_version = #{dataVersion,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + + + + + delete from t_people_data + where people_id = #{peopleId,jdbcType=INTEGER} + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TPeopleImportConfigMapper.xml b/src/main/resources/mapper/TPeopleImportConfigMapper.xml new file mode 100644 index 000000000..5f62ce194 --- /dev/null +++ b/src/main/resources/mapper/TPeopleImportConfigMapper.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + id + , people_id, last_way, last_file_path, last_sql, app_version,last_way_config,last_data_version, remark, create_time, + modified_time + + + + + delete + from t_people_import_config + where id = #{id,jdbcType=INTEGER} + + + insert into t_people_import_config (id, people_id, last_way, + last_file_path, last_sql, app_version, + last_way_config, + last_data_version, remark, create_time, modified_time) + values (#{id,jdbcType=INTEGER}, #{peopleId,jdbcType=INTEGER}, #{lastWay,jdbcType=VARCHAR}, + #{lastFilePath,jdbcType=VARCHAR}, #{lastSql,jdbcType=VARCHAR}, #{appVersion,jdbcType=VARCHAR}, + #{lastWayConfig,jdbcType=VARCHAR}, #{lastDataVersion,jdbcType=VARCHAR}, + #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) + + + insert into t_people_import_config + + + id, + + + people_id, + + + last_way, + + + last_file_path, + + + last_sql, + + + app_version, + + + last_way_config, + + + last_data_version, + + + remark, + + + create_time, + + + modified_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{peopleId,jdbcType=INTEGER}, + + + #{lastWay,jdbcType=VARCHAR}, + + + #{lastFilePath,jdbcType=VARCHAR}, + + + #{lastSql,jdbcType=VARCHAR}, + + + #{appVersion,jdbcType=VARCHAR}, + + + #{lastWayConfig,jdbcType=VARCHAR}, + + + #{lastDataVersion,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=VARCHAR}, + + + #{modifiedTime,jdbcType=VARCHAR}, + + + + + update t_people_import_config + + + people_id = #{peopleId,jdbcType=INTEGER}, + + + last_way = #{lastWay,jdbcType=VARCHAR}, + + + last_file_path = #{lastFilePath,jdbcType=VARCHAR}, + + + last_sql = #{lastSql,jdbcType=VARCHAR}, + + + app_version = #{appVersion,jdbcType=VARCHAR}, + + + last_way_config = #{lastWayConfig,jdbcType=VARCHAR}, + + + last_data_version = #{lastDataVersion,jdbcType=VARCHAR}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=VARCHAR}, + + + modified_time = #{modifiedTime,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update t_people_import_config + set people_id = #{peopleId,jdbcType=INTEGER}, + last_way = #{lastWay,jdbcType=VARCHAR}, + last_file_path = #{lastFilePath,jdbcType=VARCHAR}, + last_sql = #{lastSql,jdbcType=VARCHAR}, + app_version = #{appVersion,jdbcType=VARCHAR}, + last_way_config = #{lastWayConfig,jdbcType=VARCHAR}, + last_data_version = #{lastDataVersion,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mapper/TMsgMaSubscribeMapper.xml b/src/main/resources/mapper/TPeopleMapper.xml similarity index 52% rename from src/main/resources/mapper/TMsgMaSubscribeMapper.xml rename to src/main/resources/mapper/TPeopleMapper.xml index a4d8fdcab..ca9044851 100644 --- a/src/main/resources/mapper/TMsgMaSubscribeMapper.xml +++ b/src/main/resources/mapper/TPeopleMapper.xml @@ -1,59 +1,41 @@ - - + + - - - + + + + - id, msg_type, msg_name, template_id, page, create_time, modified_time + id + , msg_type, account_id, people_name, app_version, remark, create_time, modified_time - - delete - from t_msg_ma_subscribe + from t_people where id = #{id,jdbcType=INTEGER} - - delete - from t_msg_ma_subscribe - where msg_type = #{msgType,jdbcType=INTEGER} - and msg_name = #{msgName,jdbcType=VARCHAR} - - - insert into t_msg_ma_subscribe (id, msg_type, msg_name, - template_id, page, create_time, - modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, - #{templateId,jdbcType=VARCHAR}, #{page,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, - #{modifiedTime,jdbcType=VARCHAR}) + + insert into t_people (id, msg_type, account_id, + people_name, app_version, remark, + create_time, modified_time) + values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{accountId,jdbcType=INTEGER}, + #{peopleName,jdbcType=VARCHAR}, #{appVersion,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, + #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - insert into t_msg_ma_subscribe + + insert into t_people id, @@ -61,14 +43,17 @@ msg_type, - - msg_name, + + account_id, + + + people_name, - - template_id, + + app_version, - - page, + + remark, create_time, @@ -84,14 +69,17 @@ #{msgType,jdbcType=INTEGER}, - - #{msgName,jdbcType=VARCHAR}, + + #{accountId,jdbcType=INTEGER}, - - #{templateId,jdbcType=VARCHAR}, + + #{peopleName,jdbcType=VARCHAR}, - - #{page,jdbcType=VARCHAR}, + + #{appVersion,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, @@ -101,20 +89,23 @@ - - update t_msg_ma_subscribe + + update t_people msg_type = #{msgType,jdbcType=INTEGER}, - - msg_name = #{msgName,jdbcType=VARCHAR}, + + account_id = #{accountId,jdbcType=INTEGER}, + + + people_name = #{peopleName,jdbcType=VARCHAR}, - - template_id = #{templateId,jdbcType=VARCHAR}, + + app_version = #{appVersion,jdbcType=VARCHAR}, - - page = #{page,jdbcType=VARCHAR}, + + remark = #{remark,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=VARCHAR}, @@ -125,23 +116,34 @@ where id = #{id,jdbcType=INTEGER} - - update t_msg_ma_subscribe + + update t_people set msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - template_id = #{templateId,jdbcType=VARCHAR}, - page = #{page,jdbcType=VARCHAR}, + account_id = #{accountId,jdbcType=INTEGER}, + people_name = #{peopleName,jdbcType=VARCHAR}, + app_version = #{appVersion,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=VARCHAR}, modified_time = #{modifiedTime,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} - - update t_msg_ma_subscribe - set template_id = #{templateId,jdbcType=VARCHAR}, - page = #{page,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TPushHistoryMapper.xml b/src/main/resources/mapper/TPushHistoryMapper.xml deleted file mode 100644 index 117e68c9a..000000000 --- a/src/main/resources/mapper/TPushHistoryMapper.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - id, msg_id, msg_type, msg_name, result, csv_file, create_time, modified_time - - - - delete - from t_push_history - where id = #{id,jdbcType=INTEGER} - - - insert into t_push_history (id, msg_id, msg_type, - msg_name, result, csv_file, - create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{msgId,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, - #{msgName,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR}, #{csvFile,jdbcType=VARCHAR}, - #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_push_history - - - id, - - - msg_id, - - - msg_type, - - - msg_name, - - - result, - - - csv_file, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgId,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgName,jdbcType=VARCHAR}, - - - #{result,jdbcType=VARCHAR}, - - - #{csvFile,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_push_history - - - msg_id = #{msgId,jdbcType=INTEGER}, - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_name = #{msgName,jdbcType=VARCHAR}, - - - result = #{result,jdbcType=VARCHAR}, - - - csv_file = #{csvFile,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_push_history - set msg_id = #{msgId,jdbcType=INTEGER}, - msg_type = #{msgType,jdbcType=INTEGER}, - msg_name = #{msgName,jdbcType=VARCHAR}, - result = #{result,jdbcType=VARCHAR}, - csv_file = #{csvFile,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - \ No newline at end of file diff --git a/src/main/resources/mapper/TTaskExtMapper.xml b/src/main/resources/mapper/TTaskExtMapper.xml new file mode 100644 index 000000000..de807041e --- /dev/null +++ b/src/main/resources/mapper/TTaskExtMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + id, title, msg_type, account_id, message_id, people_id, task_mode, task_period, period_type, + period_time, cron, thread_cnt, max_thread_cnt, reimport_people, result_alert, alert_emails, save_result, + remark, create_time, modified_time + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TTaskHisMapper.xml b/src/main/resources/mapper/TTaskHisMapper.xml new file mode 100644 index 000000000..122510937 --- /dev/null +++ b/src/main/resources/mapper/TTaskHisMapper.xml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, task_id, start_time, end_time, total_cnt, success_cnt, fail_cnt, status, dry_run, + success_file_path, fail_file_path, no_send_file_path, log_file_path, task_mode, remark, create_time, + modified_time + + + + + delete from t_task_his + where id = #{id,jdbcType=INTEGER} + + + insert into t_task_his (id, task_id, start_time, + end_time, total_cnt, success_cnt, + fail_cnt, status, dry_run, + success_file_path, fail_file_path, no_send_file_path, + log_file_path, task_mode, remark, create_time, + modified_time) + values (#{id,jdbcType=INTEGER}, #{taskId,jdbcType=INTEGER}, #{startTime,jdbcType=VARCHAR}, + #{endTime,jdbcType=VARCHAR}, #{totalCnt,jdbcType=INTEGER}, #{successCnt,jdbcType=INTEGER}, + #{failCnt,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{dryRun,jdbcType=INTEGER}, + #{successFilePath,jdbcType=VARCHAR}, #{failFilePath,jdbcType=VARCHAR}, + #{noSendFilePath,jdbcType=VARCHAR}, + #{logFilePath,jdbcType=VARCHAR}, #{taskMode,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, + #{createTime,jdbcType=VARCHAR}, + #{modifiedTime,jdbcType=VARCHAR}) + + + insert into t_task_his + + + id, + + + task_id, + + + start_time, + + + end_time, + + + total_cnt, + + + success_cnt, + + + fail_cnt, + + + status, + + + dry_run, + + + success_file_path, + + + fail_file_path, + + + no_send_file_path, + + + log_file_path, + + + task_mode, + + + remark, + + + create_time, + + + modified_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{taskId,jdbcType=INTEGER}, + + + #{startTime,jdbcType=VARCHAR}, + + + #{endTime,jdbcType=VARCHAR}, + + + #{totalCnt,jdbcType=INTEGER}, + + + #{successCnt,jdbcType=INTEGER}, + + + #{failCnt,jdbcType=INTEGER}, + + + #{status,jdbcType=INTEGER}, + + + #{dryRun,jdbcType=INTEGER}, + + + #{successFilePath,jdbcType=VARCHAR}, + + + #{failFilePath,jdbcType=VARCHAR}, + + + #{noSendFilePath,jdbcType=VARCHAR}, + + + #{logFilePath,jdbcType=VARCHAR}, + + + #{taskMode,jdbcType=INTEGER}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=VARCHAR}, + + + #{modifiedTime,jdbcType=VARCHAR}, + + + + + update t_task_his + + + task_id = #{taskId,jdbcType=INTEGER}, + + + start_time = #{startTime,jdbcType=VARCHAR}, + + + end_time = #{endTime,jdbcType=VARCHAR}, + + + total_cnt = #{totalCnt,jdbcType=INTEGER}, + + + success_cnt = #{successCnt,jdbcType=INTEGER}, + + + fail_cnt = #{failCnt,jdbcType=INTEGER}, + + + status = #{status,jdbcType=INTEGER}, + + + dry_run = #{dryRun,jdbcType=INTEGER}, + + + success_file_path = #{successFilePath,jdbcType=VARCHAR}, + + + fail_file_path = #{failFilePath,jdbcType=VARCHAR}, + + + no_send_file_path = #{noSendFilePath,jdbcType=VARCHAR}, + + + log_file_path = #{logFilePath,jdbcType=VARCHAR}, + + + task_mode = #{taskMode,jdbcType=INTEGER}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=VARCHAR}, + + + modified_time = #{modifiedTime,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update t_task_his + set task_id = #{taskId,jdbcType=INTEGER}, + start_time = #{startTime,jdbcType=VARCHAR}, + end_time = #{endTime,jdbcType=VARCHAR}, + total_cnt = #{totalCnt,jdbcType=INTEGER}, + success_cnt = #{successCnt,jdbcType=INTEGER}, + fail_cnt = #{failCnt,jdbcType=INTEGER}, + status = #{status,jdbcType=INTEGER}, + dry_run = #{dryRun,jdbcType=INTEGER}, + success_file_path = #{successFilePath,jdbcType=VARCHAR}, + fail_file_path = #{failFilePath,jdbcType=VARCHAR}, + no_send_file_path = #{noSendFilePath,jdbcType=VARCHAR}, + log_file_path = #{logFilePath,jdbcType=VARCHAR}, + task_mode = #{taskMode,jdbcType=INTEGER}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mapper/TTaskMapper.xml b/src/main/resources/mapper/TTaskMapper.xml new file mode 100644 index 000000000..f2bdacfeb --- /dev/null +++ b/src/main/resources/mapper/TTaskMapper.xml @@ -0,0 +1,302 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, title, msg_type, account_id, message_id, people_id, task_mode, task_period, period_type, + period_time, cron, thread_cnt, max_thread_cnt, reimport_people, result_alert, alert_emails, save_result, + interval_push, interval_time, + remark, create_time, modified_time + + + + + delete from t_task + where id = #{id,jdbcType=INTEGER} + + + insert into t_task (id, title, msg_type, + account_id, message_id, people_id, + task_mode, task_period, period_type, + period_time, cron, thread_cnt, max_thread_cnt, + reimport_people, result_alert, alert_emails, + save_result, interval_push, interval_time, + remark, create_time, + modified_time) + values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{msgType,jdbcType=INTEGER}, + #{accountId,jdbcType=INTEGER}, #{messageId,jdbcType=INTEGER}, #{peopleId,jdbcType=INTEGER}, + #{taskMode,jdbcType=INTEGER}, #{taskPeriod,jdbcType=INTEGER}, #{periodType,jdbcType=INTEGER}, + #{periodTime,jdbcType=VARCHAR}, #{cron,jdbcType=VARCHAR}, #{threadCnt,jdbcType=INTEGER}, + #{maxThreadCnt,jdbcType=INTEGER}, + #{reimportPeople,jdbcType=INTEGER}, #{resultAlert,jdbcType=INTEGER}, #{alertEmails,jdbcType=VARCHAR}, + #{saveResult,jdbcType=INTEGER}, + #{intervalPush,jdbcType=INTEGER}, #{intervalTime,jdbcType=INTEGER}, + #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, + #{modifiedTime,jdbcType=VARCHAR}) + + + insert into t_task + + + id, + + + title, + + + msg_type, + + + account_id, + + + message_id, + + + people_id, + + + task_mode, + + + task_period, + + + period_type, + + + period_time, + + + cron, + + + thread_cnt, + + + max_thread_cnt, + + + reimport_people, + + + result_alert, + + + alert_emails, + + + save_result, + + + interval_push, + + + interval_time, + + + remark, + + + create_time, + + + modified_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{title,jdbcType=VARCHAR}, + + + #{msgType,jdbcType=INTEGER}, + + + #{accountId,jdbcType=INTEGER}, + + + #{messageId,jdbcType=INTEGER}, + + + #{peopleId,jdbcType=INTEGER}, + + + #{taskMode,jdbcType=INTEGER}, + + + #{taskPeriod,jdbcType=INTEGER}, + + + #{periodType,jdbcType=INTEGER}, + + + #{periodTime,jdbcType=VARCHAR}, + + + #{cron,jdbcType=VARCHAR}, + + + #{threadCnt,jdbcType=INTEGER}, + + + #{maxThreadCnt,jdbcType=INTEGER}, + + + #{reimportPeople,jdbcType=INTEGER}, + + + #{resultAlert,jdbcType=INTEGER}, + + + #{alertEmails,jdbcType=VARCHAR}, + + + #{saveResult,jdbcType=INTEGER}, + + + #{intervalPush,jdbcType=INTEGER}, + + + #{intervalTime,jdbcType=INTEGER}, + + + #{remark,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=VARCHAR}, + + + #{modifiedTime,jdbcType=VARCHAR}, + + + + + update t_task + + + title = #{title,jdbcType=VARCHAR}, + + + msg_type = #{msgType,jdbcType=INTEGER}, + + + account_id = #{accountId,jdbcType=INTEGER}, + + + message_id = #{messageId,jdbcType=INTEGER}, + + + people_id = #{peopleId,jdbcType=INTEGER}, + + + task_mode = #{taskMode,jdbcType=INTEGER}, + + + task_period = #{taskPeriod,jdbcType=INTEGER}, + + + period_type = #{periodType,jdbcType=INTEGER}, + + + period_time = #{periodTime,jdbcType=VARCHAR}, + + + cron = #{cron,jdbcType=VARCHAR}, + + + thread_cnt = #{threadCnt,jdbcType=INTEGER}, + + + max_thread_cnt = #{maxThreadCnt,jdbcType=INTEGER}, + + + reimport_people = #{reimportPeople,jdbcType=INTEGER}, + + + result_alert = #{resultAlert,jdbcType=INTEGER}, + + + alert_emails = #{alertEmails,jdbcType=VARCHAR}, + + + save_result = #{saveResult,jdbcType=INTEGER}, + + + interval_push = #{intervalPush,jdbcType=INTEGER}, + + + interval_time = #{intervalTime,jdbcType=INTEGER}, + + + remark = #{remark,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=VARCHAR}, + + + modified_time = #{modifiedTime,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update t_task + set title = #{title,jdbcType=VARCHAR}, + msg_type = #{msgType,jdbcType=INTEGER}, + account_id = #{accountId,jdbcType=INTEGER}, + message_id = #{messageId,jdbcType=INTEGER}, + people_id = #{peopleId,jdbcType=INTEGER}, + task_mode = #{taskMode,jdbcType=INTEGER}, + task_period = #{taskPeriod,jdbcType=INTEGER}, + period_type = #{periodType,jdbcType=INTEGER}, + period_time = #{periodTime,jdbcType=VARCHAR}, + cron = #{cron,jdbcType=VARCHAR}, + thread_cnt = #{threadCnt,jdbcType=INTEGER}, + max_thread_cnt = #{maxThreadCnt,jdbcType=INTEGER}, + reimport_people = #{reimportPeople,jdbcType=INTEGER}, + result_alert = #{resultAlert,jdbcType=INTEGER}, + alert_emails = #{alertEmails,jdbcType=VARCHAR}, + save_result = #{saveResult,jdbcType=INTEGER}, + interval_push = #{intervalPush,jdbcType=INTEGER}, + interval_time = #{intervalTime,jdbcType=INTEGER}, + remark = #{remark,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mapper/TTemplateDataMapper.xml b/src/main/resources/mapper/TTemplateDataMapper.xml deleted file mode 100644 index 9a108b508..000000000 --- a/src/main/resources/mapper/TTemplateDataMapper.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - id, msg_type, msg_id, name, value, color, create_time, modified_time - - - - delete - from t_template_data - where id = #{id,jdbcType=INTEGER} - - - insert into t_template_data (id, msg_type, msg_id, - name, value, color, - create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgId,jdbcType=INTEGER}, - #{name,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, #{color,jdbcType=VARCHAR}, - #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_template_data - - - id, - - - msg_type, - - - msg_id, - - - name, - - - value, - - - color, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{msgType,jdbcType=INTEGER}, - - - #{msgId,jdbcType=INTEGER}, - - - #{name,jdbcType=VARCHAR}, - - - #{value,jdbcType=VARCHAR}, - - - #{color,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_template_data - - - msg_type = #{msgType,jdbcType=INTEGER}, - - - msg_id = #{msgId,jdbcType=INTEGER}, - - - name = #{name,jdbcType=VARCHAR}, - - - value = #{value,jdbcType=VARCHAR}, - - - color = #{color,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_template_data - set msg_type = #{msgType,jdbcType=INTEGER}, - msg_id = #{msgId,jdbcType=INTEGER}, - name = #{name,jdbcType=VARCHAR}, - value = #{value,jdbcType=VARCHAR}, - color = #{color,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - delete - from t_template_data - where msg_id = #{msgId,jdbcType=INTEGER} - and msg_type = #{msgType,jdbcType=INTEGER} - - \ No newline at end of file diff --git a/src/main/resources/mapper/TWxAccountMapper.xml b/src/main/resources/mapper/TWxAccountMapper.xml deleted file mode 100644 index 93fd8afcc..000000000 --- a/src/main/resources/mapper/TWxAccountMapper.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - id, account_type, account_name, app_id, app_secret, token, aes_key, create_time, - modified_time - - - - delete - from t_wx_account - where id = #{id,jdbcType=INTEGER} - - - insert into t_wx_account (id, account_type, account_name, - app_id, app_secret, token, - aes_key, create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{accountType,jdbcType=VARCHAR}, #{accountName,jdbcType=VARCHAR}, - #{appId,jdbcType=VARCHAR}, #{appSecret,jdbcType=VARCHAR}, #{token,jdbcType=VARCHAR}, - #{aesKey,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_wx_account - - - id, - - - account_type, - - - account_name, - - - app_id, - - - app_secret, - - - token, - - - aes_key, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{accountType,jdbcType=VARCHAR}, - - - #{accountName,jdbcType=VARCHAR}, - - - #{appId,jdbcType=VARCHAR}, - - - #{appSecret,jdbcType=VARCHAR}, - - - #{token,jdbcType=VARCHAR}, - - - #{aesKey,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_wx_account - - - account_type = #{accountType,jdbcType=VARCHAR}, - - - account_name = #{accountName,jdbcType=VARCHAR}, - - - app_id = #{appId,jdbcType=VARCHAR}, - - - app_secret = #{appSecret,jdbcType=VARCHAR}, - - - token = #{token,jdbcType=VARCHAR}, - - - aes_key = #{aesKey,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_wx_account - set account_type = #{accountType,jdbcType=VARCHAR}, - account_name = #{accountName,jdbcType=VARCHAR}, - app_id = #{appId,jdbcType=VARCHAR}, - app_secret = #{appSecret,jdbcType=VARCHAR}, - token = #{token,jdbcType=VARCHAR}, - aes_key = #{aesKey,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - \ No newline at end of file diff --git a/src/main/resources/mapper/TWxCpAppMapper.xml b/src/main/resources/mapper/TWxCpAppMapper.xml deleted file mode 100644 index 6a6510e66..000000000 --- a/src/main/resources/mapper/TWxCpAppMapper.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - - - - - - - - id, corpId, app_name, agent_id, secret, token, aes_key, create_time, modified_time - - - - delete - from t_wx_cp_app - where id = #{id,jdbcType=INTEGER} - - - insert into t_wx_cp_app (id, corpId, app_name, - agent_id, secret, token, - aes_key, create_time, modified_time) - values (#{id,jdbcType=INTEGER}, #{corpid,jdbcType=VARCHAR}, #{appName,jdbcType=VARCHAR}, - #{agentId,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR}, #{token,jdbcType=VARCHAR}, - #{aesKey,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) - - - insert into t_wx_cp_app - - - id, - - - corpId, - - - app_name, - - - agent_id, - - - secret, - - - token, - - - aes_key, - - - create_time, - - - modified_time, - - - - - #{id,jdbcType=INTEGER}, - - - #{corpid,jdbcType=VARCHAR}, - - - #{appName,jdbcType=VARCHAR}, - - - #{agentId,jdbcType=VARCHAR}, - - - #{secret,jdbcType=VARCHAR}, - - - #{token,jdbcType=VARCHAR}, - - - #{aesKey,jdbcType=VARCHAR}, - - - #{createTime,jdbcType=VARCHAR}, - - - #{modifiedTime,jdbcType=VARCHAR}, - - - - - update t_wx_cp_app - - - corpId = #{corpid,jdbcType=VARCHAR}, - - - app_name = #{appName,jdbcType=VARCHAR}, - - - agent_id = #{agentId,jdbcType=VARCHAR}, - - - secret = #{secret,jdbcType=VARCHAR}, - - - token = #{token,jdbcType=VARCHAR}, - - - aes_key = #{aesKey,jdbcType=VARCHAR}, - - - create_time = #{createTime,jdbcType=VARCHAR}, - - - modified_time = #{modifiedTime,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - update t_wx_cp_app - set corpId = #{corpid,jdbcType=VARCHAR}, - app_name = #{appName,jdbcType=VARCHAR}, - agent_id = #{agentId,jdbcType=VARCHAR}, - secret = #{secret,jdbcType=VARCHAR}, - token = #{token,jdbcType=VARCHAR}, - aes_key = #{aesKey,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=VARCHAR}, - modified_time = #{modifiedTime,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - - - - - \ No newline at end of file diff --git a/src/main/resources/mybatis-config.xml b/src/main/resources/mybatis-config.xml index 920ef3791..4874a8d15 100644 --- a/src/main/resources/mybatis-config.xml +++ b/src/main/resources/mybatis-config.xml @@ -13,23 +13,14 @@ - - - - - - - - - - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/theme/Cyan.theme.json b/src/main/resources/theme/Cyan.theme.json new file mode 100644 index 000000000..021630a81 --- /dev/null +++ b/src/main/resources/theme/Cyan.theme.json @@ -0,0 +1,293 @@ +{ + "name": "Cyan light", + "dark": false, + "author": "Olga Berdnikova", + + "editorScheme": "/themes/cyanScheme.xml", + + "ui": { + "*": { + "background": "#e4e6eb", + "foreground": "#1d1d1d", + + "selectionBackground": "#3eb2c2", + "selectionBackgroundInactive": "#d0d5db", + "selectionInactiveBackground": "#d0d5db", + "lightSelectionBackground": "#d3e4eb", + + "disabledForeground": "#b1b1b1", + "disabledText": "#b1b1b1", + "inactiveForeground": "#b1b1b1", + + "infoForeground": "#787878", + "modifiedItemForeground": "#00a9bf", + + "separatorColor": "#bec5cd", + "borderColor": "#bec5cd", + + "underlineColor": "#0ab0d1" + }, + + "ActionButton": { + "hoverBackground": "#d0d3d9", + "hoverBorderColor": "#d0d3d9", + "pressedBackground": "#c3c7cf", + "pressedBorderColor": "#c3c7cf" + }, + + "Borders": { + "color": "#bec5cd", + "ContrastBorderColor": "#bec5cd" + }, + + "Button": { + "startBorderColor": "#b0b9c3", + "endBorderColor": "#b0b9c3", + "default": { + "foreground": "#FFFFFF", + "startBackground": "#28a4c3", + "endBackground": "#28a4c3", + "startBorderColor": "#258aa4", + "endBorderColor": "#258aa4", + "focusedBorderColor": "#82d3dd" + } + }, + + "ComboBox": { + "background": "#eef0f4", + "nonEditableBackground": "#FFFFFF", + "ArrowButton.background": "#FFFFFF" + }, + "ComboBoxButton.background": "#FFFFFF", + "ComboPopup.border": "1,1,1,1,b0b9c3", + + "CompletionPopup": { + "foreground": "#404040", + "infoForeground": "#8c8c8c", + "selectionBackground": "#bce2e6", + "selectionInactiveBackground": "#d7dbe0", + "matchForeground": "#00a0d1", + "selectionForeground": "#404040", + "selectionInfoForeground": "#8c8c8c", + "matchSelectionForeground": "#00a0d1" + }, + + "Component": { + "borderColor": "#b0b9c3", + "focusedBorderColor": "#31b1d0", + "focusColor": "#5fc5de" + }, + + "Counter": { + "background": "#9AA7B0", + "foreground": "#FFFFFF" + }, + + "DefaultTabs": { + "inactiveUnderlineColor": "#8699a6", + "hoverBackground": "#ced2d9" + }, + + "DragAndDrop": { + "areaBackground": "#4cb2c733" + }, + + "Editor": { + "background": "#d0d3d9", + "foreground": "#808080", + "shortcutForeground": "#1b9bb6" + }, + + "EditorPane.inactiveBackground": "#e4e6eb", + + "EditorTabs": { + "selectedBackground": "#f3f3f3", + "inactiveMaskColor": "#4752661A", + + "underlineColor": "#29abcb", + + "underlinedTabBackground": "#f2f4f5", + "inactiveColoredFileBackground": "#a6a9b350", + "hoverBackground": "#b9bdc999" + }, + + "DebuggerTabs.selectedBackground": "#e4e6eb", + + "FileColor.Yellow": "#f2efda", + "FileColor.Green": "#d8f0e2", + "FileColor.Blue": "#d3f0f4", + + "Label.errorForeground": "#C7222D", + + "Link": { + "activeForeground": "#009eb3", + "hoverForeground": "#009eb3", + "pressedForeground": "#009eb3", + "visitedForeground": "#009eb3", + "secondaryForeground": "#7ac2cc" + }, + + "List.background": "#eef0f4", + + "Notification": { + "MoreButton.innerBorderColor": "#bec5cd", + "errorBackground": "#f5e1e4", + "errorBorderColor": "#e695a3", + "ToolWindow": { + "informativeBackground": "#ccedcf", + "informativeBorderColor": "#8ebd91", + "warningBackground": "#f0e4c0", + "warningBorderColor": "#d9b857", + "errorBackground": "#fad7dd", + "errorBorderColor": "#e68a99" + } + }, + + "PasswordField.background": "#FFFFFF", + + "Plugins": { + "background": "#f5f7fa", + "SearchField.background": "#FFFFFF", + "SectionHeader.foreground": "#808080", + "SectionHeader.background": "#edeef2", + "Tab.selectedBackground": "#cacccf", + "Tab.hoverBackground": "#cacccf" + }, + + "Popup": { + "Header": { + "activeBackground": "#d6dae5", + "inactiveBackground": "#d6dae5" + }, + + "separatorColor": "#bec5cd", + "separatorForeground": "#919699", + + "Advertiser": { + "foreground": "#787878", + "background": "#e4e6eb", + "borderColor": "#e4e6eb" + } + }, + + "ProgressBar": { + "trackColor": "#c4c9d5", + "progressColor": "#2b9cb8", + "indeterminateStartColor": "#b8dde6", + "indeterminateEndColor": "#2b9cb8", + "passedEndColor": "#bcebd5", + "passedColor": "#1eb070", + "failedEndColor": "#e6b8bf", + "failedColor": "#dc445d" + }, + + "SearchEverywhere": { + "SearchField.background": "#FFFFFF", + "Tab.selectedBackground": "#d1d4d4", + "Advertiser.foreground": "#787878" + }, + + "SearchMatch": { + "startBackground": "#ffc466", + "endBackground": "#FFC466" + }, + + "SidePanel.background": "#e4e6eb", + + "SpeedSearch": { + "background": "#FFFFFF", + "errorForeground": "#C7222D" + }, + + "TabbedPane": { + "hoverColor": "#ced2d9", + "focusColor": "#dbebed", + "contentAreaColor": "#bec5cd" + }, + + "Table": { + "background": "#eef0f4", + "hoverBackground": "#C3D2E366" + }, + + "TableHeader": { + "cellBorder": "3,0,3,0", + "background": "#e9ecf0", + "bottomSeparatorColor": "#dfe2e6" + }, + + "TextArea.background": "#FFFFFF", + + "TextField.background": "#FFFFFF", + + "ToggleButton": { + "onBackground": "#28a4c3", + "offForeground": "#787878", + "buttonColor": "#b0b9c3", + "borderColor": "#b0b9c3" + }, + + "ToolTip": { + "background": "#f3f6fb", + "Actions.background": "#e4e6eb" + }, + + "ToolWindow": { + "Header": { + "background": "#d8dee8", + "inactiveBackground": "#e4e6eb" + }, + "HeaderTab": { + "selectedBackground": "#b9bec7", + "hoverBackground": "#b9bdc999", + "selectedInactiveBackground": "#CED1D6", + "hoverInactiveBackground": "#b9bdc999" + }, + "Button": { + "selectedBackground": "#C3C6C9", + "hoverBackground": "#C3C6C9" + } + }, + + "Tree.background": "#eef0f4", + + "WelcomeScreen": { + "Details.background": "#eef0f4", + "Projects.actions.background": "#E1E4EB" + } + }, + + "icons": { + "ColorPalette": { + "Actions.Grey": "#696d78", + "Actions.Red": "#e0516b", + "Actions.Blue": "#348def", + "Actions.Green": "#29a66c", + "Actions.Yellow": "#e3b610", + + "Objects.Grey": "#858994", + "Objects.RedStatus": "#dc445d", + "Objects.Red": "#de4765", + "Objects.Pink": "#f070a5", + "Objects.Yellow": "#e6ba29", + "Objects.Green": "#1eb070", + "Objects.Blue": "#499df2", + "Objects.Purple": "#bc8af2", + "Objects.YellowDark": "#b79108", + "Objects.BlackText": "#26282b", + + "Checkbox.Background.Default": "#f3f3f3", + "Checkbox.Border.Default": "#8a9199", + "Checkbox.Background.Selected": "#28a4c3", + "Checkbox.Border.Selected": "#2896b2", + "Checkbox.Foreground.Selected": "#FFFFFF", + "Checkbox.Focus.Wide": "#5fc5de", + "Checkbox.Focus.Thin.Default": "#98a0aa4c", + "Checkbox.Focus.Thin.Selected": "#82d3dd", + "Checkbox.Background.Disabled": "#e4e6eb", + "Checkbox.Border.Disabled": "#babfc4", + "Checkbox.Foreground.Disabled": "#babfc4" + } + } + +} \ No newline at end of file diff --git a/src/main/resources/theme/DarkPurple.theme.json b/src/main/resources/theme/DarkPurple.theme.json new file mode 100644 index 000000000..2cfc2babb --- /dev/null +++ b/src/main/resources/theme/DarkPurple.theme.json @@ -0,0 +1,421 @@ +{ + "name": "Dark purple", + "dark": true, + "author": "JetBrains", + + "editorScheme": "/themes/darkPurpleScheme.xml", + + "ui": { + "*": { + "background": "#2C2C3B", + "foreground": "#D0D0D9", + + "infoForeground": "#6d6a80", + + "selectionBackground": "#713a91", + "selectionForeground": "#D0D0D9", + "selectionInactiveBackground": "#3d3952", + "selectionBackgroundInactive": "#3d3952", + + "lightSelectionBackground": "#3a324a", + "lightSelectionForeground": "#D0D0D9", + "lightSelectionInactiveBackground": "#3d3952", + "lightSelectionInactiveForeground":"#D0D0D9", + + "disabledBackground": "#2C2C3B", + "inactiveBackground": "#2C2C3B", + + "disabledForeground": "#646078", + "disabledText": "#646078", + "inactiveForeground": "#646078", + + "acceleratorForeground": "#D0D0D9", + "acceleratorSelectionForeground": "#D0D0D9", + + "errorForeground": "#dd3962", + + "borderColor": "#4E4C63", + "disabledBorderColor": "#45405C", + + "focusColor": "#693687", + "focusedBorderColor": "#814F9E", + + "separatorForeground": "#6d6a80", + "separatorColor": "#4e4b61", + "lineSeparatorColor": "#55506b", + + "modifiedItemForeground": "#b279f2" + }, + + "ActionButton": { + "hoverBackground": "#453e57", + "hoverBorderColor": "#453E57", + "pressedBackground": "#49415c", + "pressedBorderColor": "#49415C", + "focusedBorderColor": "#476fcc" + }, + + "Button": { + "startBackground": "#45405C", + "endBackground": "#45405C", + "startBorderColor": "#544F70", + "endBorderColor": "#544F70", + "shadowColor": "#27282B", + + "default": { + "foreground": "#D0D0D9", + "startBackground": "#6B388F", + "endBackground": "#6B388F", + "startBorderColor": "#7C519C", + "endBorderColor": "#7C519C", + "focusedBorderColor": "#8465a6", + "focusColor": "#784299", + "shadowColor": "#27282B" + } + }, + + "Borders": { + "color": "#1a1721", + "ContrastBorderColor": "#1a1721" + }, + + "ComboBox": { + "nonEditableBackground": "#3A384D", + "background": "#343445", + "ArrowButton": { + "iconColor": "#9A97A8", + "disabledIconColor": "#454554", + "nonEditableBackground": "#3A384D" + } + }, + + "ComboPopup.border": "1,1,1,1,64647A", + + "CompletionPopup": { + "matchForeground": "#ED94FF", + "matchSelectionForeground": "#ED94FF", + "selectionInactiveBackground": "#44405c", + "nonFocusedMask": "#00000033", + "selectionBackground": "#623380" + }, + + "Component": { + "errorFocusColor": "#993750", + "inactiveErrorFocusColor": "#522530", + "warningFocusColor": "#8c812b", + "inactiveWarningFocusColor": "#47441f", + "iconColor": "#77728fCC", + "hoverIconColor": "#8b85a6" + }, + + "Counter": { + "background": "#FFFFFF80", + "foreground": "#000000" + }, + + "DebuggerPopup.borderColor": "#524e66", + + "DebuggerTabs.selectedBackground": "#332C40", + + "DefaultTabs": { + "underlineColor": "#9649cc", + "inactiveUnderlineColor": "#877399", + "hoverBackground": "#dfb3ff1a" + }, + + "DragAndDrop": { + "areaForeground": "#D0D0D9", + "areaBackground": "#5d476680", + "areaBorderColor": "#343142" + }, + + "Editor": { + "background": "#1D1D26", + "foreground": "#6d6a80", + "shortcutForeground": "#6E86FF" + }, + + "EditorPane.inactiveBackground": "#2C2C3B", + + "EditorTabs": { + "selectedForeground": "#D0D0D9", + "selectedBackground": "#343445", + "inactiveMaskColor": "#0d0d0d33", + + "underlineColor": "#904ac2", + + "underlinedTabBackground": "#363647", + "inactiveColoredFileBackground": "#2C2C3B80", + + "borderColor": "#1a1721" + }, + + "FileColor": { + "Yellow": "#45243b", + "Green": "#213d37", + "Blue": "#1f3557", + "Violet": "#2a2754", + "Orange": "#402e23", + "Rose": "#4a2d59" + }, + + "InplaceRefactoringPopup.borderColor": "#474359", + + "Link": { + "activeForeground": "#7094ff", + "hoverForeground": "#7094FF", + "pressedForeground": "#7094FF", + "visitedForeground": "#7094FF" + }, + + "MenuBar.borderColor": "#1a1721", + + "NavBar.borderColor": "#1a1721", + + "Notification": { + "background": "#3d394d", + "borderColor": "#57506e", + + "errorForeground": "#D0D0D9", + "errorBackground": "#4d232e", + "errorBorderColor": "#802e44", + + "MoreButton.innerBorderColor": "#1a1721", + + "ToolWindow": { + "informativeForeground": "#D0D0D9", + "informativeBackground": "#2e4280", + "informativeBorderColor": "#17254d", + + "warningForeground": "#D0D0D9", + "warningBackground": "#735822", + "warningBorderColor": "#403013", + + "errorForeground": "#D0D0D9", + "errorBackground": "#802d43", + "errorBorderColor": "#4d1c2b" + } + }, + + "MemoryIndicator": { + "allocatedBackground": "#352140", + "usedBackground": "#533473" + }, + + "ParameterInfo": { + "background": "#463f57", + "foreground": "#ababb3", + "infoForeground": "ababb3", + "currentOverloadBackground": "#6A6173", + "currentParameterForeground": "#D0D0D9" + }, + + "Plugins": { + "Tab": { + "selectedForeground": "#D0D0D9", + "selectedBackground": "#593f73", + "hoverBackground": "#593F73" + }, + + "SearchField.borderColor": "#1a1721", + "SearchField.background": "#252533", + "SectionHeader.background": "#3d3952", + "tagBackground": "#4c4766", + "tagForeground": "#D0D0D9", + + "Button": { + "installForeground": "#8862b3", + "installBorderColor":"#8862b3", + "installFillForeground": "#D0D0D9", + "installFillBackground": "#713a91", + "updateForeground":"#D0D0D9", + "updateBackground": "#713a91", + "updateBorderColor": "#713a91" + } + }, + + "Popup": { + "paintBorder": true, + "borderColor": "#4e4b61", + "inactiveBorderColor": "#343142", + "Toolbar.borderColor": "#1a1721", + "Header.activeBackground": "#453A5C", + "Header.inactiveBackground": "#453A5C", + "Advertiser": { + "foreground": "#8785a6", + "borderColor": "#4e4b61", + "borderInsets": "4,8,3,0" + } + }, + + "PopupMenu": { + "borderWidth": 1, + "borderInsets": "4,1,4,1" + }, + + "ProgressBar": { + "trackColor": "#1D1D26", + "progressColor": "#a85ed6", + "indeterminateStartColor": "#a85ed6", + "indeterminateEndColor": "#402e4d", + "failedColor": "#bd3c5f", + "failedEndColor": "#472c33", + "passedColor": "#239E62", + "passedEndColor": "#2b4242" + }, + + "SearchEverywhere": { + "Header.background": "#3a394d", + "Tab": { + "selectedForeground": "#D0D0D9", + "selectedBackground": "#5c3d7a" + }, + "SearchField":{ + "background": "#252533", + "borderColor": "#1a1721" + }, + "Advertiser.foreground": "#8785a6" + }, + + "SearchMatch": { + "startBackground": "#cca929", + "endBackground": "#cca929" + }, + + "SearchOption.selectedBackground": "#424885", + + "SpeedSearch": { + "foreground": "#D0D0D9", + "borderColor": "#69418c", + "background": "#5c3a7a", + "errorForeground": "#ff80a1" + }, + + "StatusBar.borderColor": "#1a1721", + + "TabbedPane": { + "underlineColor": "#9649cc", + "disabledUnderlineColor": "#5e5b6b", + "contentAreaColor": "#1a1721", + "hoverColor": "#dfb3ff1a", + "focusColor": "#523366" + }, + + "TableHeader": { + "cellBorder": "3,0,3,0", + "background": "#363445", + "separatorColor": "#1a1721", + "bottomSeparatorColor": "#282430" + }, + + "Table": { + "stripeColor": "#323242", + "hoverBackground": "#00000028" + }, + + "TextArea": { + "background": "#3A384D", + "selectionBackground": "#69418c" + }, + + "TextField": { + "background": "#3A384D", + "selectionBackground": "#69418c" + }, + + "ToggleButton": { + "onForeground": "#D0D0D9", + "onBackground": "#543073", + "offForeground": "#9f9fa6", + "offBackground": "#2C2C3B", + "buttonColor": "#666380", + "borderColor": "#666380" + }, + + "ToolTip": { + "background": "#463f57", + "Actions.background": "#323245", + "infoForeground": "#8985a1", + "shortcutForeground": "#8985A1" + }, + + "ToolWindow": { + "Header": { + "background": "#453A5C", + "inactiveBackground": "#2C2C3B", + "borderColor": "#1a1721" + }, + + "HeaderTab": { + "selectedBackground": "#0a0a0a66", + "selectedInactiveBackground": "#0a0a0a4D", + "hoverBackground": "#dfb3ff1a", + "hoverInactiveBackground": "#dfb3ff1a" + }, + + "Button": { + "hoverBackground": "#1e1e24", + "selectedBackground": "#1e1e24", + "selectedForeground": "#D0D0D9" + } + }, + + "Tree.rowHeight": 20, + + "ValidationTooltip": { + "errorBackground": "#802d43", + "errorBorderColor": "#4d1c2b", + "warningBackground": "#735822", + "warningBorderColor": "#403013" + }, + + "VersionControl": { + "Log.Commit": { + "currentBranchBackground": "#202340", + "unmatchedForeground": "#6d6a80", + "hoveredBackground": "#000000B9" + }, + "FileHistory.Commit.selectedBranchBackground": "#202340" + }, + + "WelcomeScreen": { + "Projects.selectionInactiveBackground": "#713a91", + "separatorColor": "#1a1721", + "Details.background": "#26262E", + "Projects.actions.background": "#343445" + } + }, + + "icons": { + "ColorPalette": { + "Actions.Grey": "#a4a1b3", + "Actions.Red": "#c63a5d", + "Actions.Yellow": "#caba2d", + "Actions.Green": "#25ad6b", + "Actions.Blue": "#4d85ff", + "Actions.GreyInline.Dark": "#9f99bfb3", + + "Objects.Grey": "#9790ad", + "Objects.RedStatus": "#dd3962", + "Objects.Red": "#c63a5d", + "Objects.Pink": "#f98b9e", + "Objects.Yellow": "#caba2d", + "Objects.Green": "#239e62", + "Objects.Blue": "#598bff", + "Objects.Purple": "#af71e0", + "Objects.BlackText": "#000000ff", + "Objects.YellowDark": "#988c26", + "Objects.GreenAndroid": "#78c257", + + "Checkbox.Background.Default.Dark": "#343445", + "Checkbox.Border.Default.Dark": "#756b8c", + "Checkbox.Foreground.Selected.Dark": "#a4a1b3", + "Checkbox.Focus.Wide.Dark": "#723b94", + "Checkbox.Focus.Thin.Default.Dark": "#8a64b3", + "Checkbox.Focus.Thin.Selected.Dark": "#8a64b3", + "Checkbox.Background.Disabled.Dark": "#2C2C3B", + "Checkbox.Border.Disabled.Dark": "#4c4766", + "Checkbox.Foreground.Disabled.Dark": "#565073" + } + } +} diff --git a/src/main/resources/theme/Light.theme.json b/src/main/resources/theme/Light.theme.json new file mode 100644 index 000000000..531ad9652 --- /dev/null +++ b/src/main/resources/theme/Light.theme.json @@ -0,0 +1,145 @@ +{ + "name": "IntelliJ Light", + "dark": false, + "author": "JetBrains", + "editorScheme": "/themes/Light.xml", + + "colors": { + "foreground": "#000000", + "infoPanelForeground": "#808080", + "infoInputForeground": "#999999", + "disabledForeground": "#8C8C8C", + "selectionForeground": "#FFFFFF", + "linkForeground": "#2470B3", + + "border": "#D1D1D1", + "componentBorder": "#C4C4C4", + "lightBorder": "#d9d9d9", + "windowsPopupBorder": "#adadad", + + "panel": "#F2F2F2" + }, + + "ui": { + "*": { + "foreground": "foreground", + "acceleratorForeground": "foreground", + "caretForeground": "foreground", + "selectedForeground": "foreground", + "selectionInactiveForeground": "foreground", + + "selectionBackground": "#2675BF", + "selectionBackgroundInactive": "#D5D5D5", + "selectionInactiveBackground": "#D5D5D5", + + "disabledForeground": "disabledForeground", + "disabledText": "disabledForeground", + "inactiveForeground": "disabledForeground", + + "modifiedItemForeground": "#005ad9", + + "acceleratorSelectionForeground": "selectionForeground", + + "separatorColor": "border", + "separatorForeground": "infoInputForeground" + }, + + "Borders": { + "color": "border", + "ContrastBorderColor": "border" + }, + + "Button": { + "shadowColor": "#A6A6A600", + "startBorderColor": "componentBorder", + "endBorderColor": "componentBorder", + "default": { + "foreground": "selectionForeground", + "startBackground": "#528CC7", + "endBackground": "#4989CC", + "startBorderColor": "#487EB8", + "endBorderColor": "#346DAD", + "shadowColor": "#A6A6A600", + "focusedBorderColor": "#A9C9F5" + } + }, + + "ComboBox": { + "background": "#FFFFFF", + "nonEditableBackground": "#FFFFFF", + "ArrowButton.background": "#fafafa" + }, + + "ComboBoxButton.background": "#FFFFFF", + + "CompletionPopup": { + "selectionBackground": "#c5dffc", + "selectionInactiveBackground": "#e0e0e0" + }, + + "Component": { + "borderColor": "componentBorder", + "infoForeground": "infoInputForeground" + }, + + "DefaultTabs.background": "panel", + + "EditorTabs.underlinedTabBackground": "#ffffff", + + "Editor": { + "background": "#cccccc", + "foreground": "#737373", + "shortcutForeground": "#4274A6" + }, + + "Label": { + "errorForeground": "#C7222D", + "infoForeground": "infoPanelForeground" + }, + + "Link": { + "activeForeground": "linkForeground", + "hoverForeground": "linkForeground", + "pressedForeground": "linkForeground", + "visitedForeground": "linkForeground", + "secondaryForeground": "#77a8d9" + }, + + "Notification": { + "borderColor": "border" + }, + + "Menu.borderColor": "lightBorder", + + "Panel.background": "panel", + + "PasswordField.background": "#FFFFFF", + + "Popup": { + "separatorColor": "lightBorder", + "Advertiser.borderColor": "border", + "borderColor": "windowsPopupBorder" + }, + + "ProgressBar": { + "trackColor": "#D1D1D1", + "progressColor": "#1E82E6", + "indeterminateStartColor": "#91C5F2", + "indeterminateEndColor": "#1E82E6" + }, + + "StatusBar.borderColor": "border", + + "ToolWindow.Header.inactiveBackground": "panel", + + "Tree.rowHeight": 20 + }, + + "icons": { + "ColorPalette": { + "Checkbox.Border.Default": "#b0b0b0", + "Checkbox.Background.Selected": "#4F9EE3", + "Checkbox.Border.Selected": "#4B97D9" + } + } +} \ No newline at end of file diff --git a/src/main/resources/upgrade/28.sql b/src/main/resources/upgrade/28.sql deleted file mode 100644 index 818d9b413..000000000 --- a/src/main/resources/upgrade/28.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table t_msg_wx_cp - add btn_txt text; -alter table t_msg_mail - add Cc text; \ No newline at end of file diff --git a/src/main/resources/upgrade/30.sql b/src/main/resources/upgrade/30.sql deleted file mode 100644 index 1bfc3a57b..000000000 --- a/src/main/resources/upgrade/30.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table t_msg_http - add body_type text; \ No newline at end of file diff --git a/src/main/resources/upgrade/4.sql b/src/main/resources/upgrade/4.sql new file mode 100644 index 000000000..495e3aa40 --- /dev/null +++ b/src/main/resources/upgrade/4.sql @@ -0,0 +1,4 @@ +alter table t_task + add interval_push integer; +alter table t_task + add interval_time integer; \ No newline at end of file diff --git a/src/main/resources/version_summary.json b/src/main/resources/version_summary.json index f9054dcc7..6d0049afe 100644 --- a/src/main/resources/version_summary.json +++ b/src/main/resources/version_summary.json @@ -1,253 +1,49 @@ { - "currentVersion": "v_4.2.1_200308", + "currentVersion": "v_5.0.5", "versionIndex": { - "v_1.1.0_170701": "0", - "v_1.2.0_170831": "1", - "v_1.3.0_180207": "2", - "v_1.4.0_180209": "3", - "v_1.5.0_180209": "4", - "v_1.6.0_180222": "5", - "v_1.7.0_180226": "6", - "v_1.8.0_180226": "7", - "v_1.9.0_180228": "8", - "v_1.10.0_180316": "9", - "v_2.0.0_180319": "10", - "v_2.0.1_180401": "11", - "v_2.0.2_180401": "12", - "v_2.1.0_180509": "13", - "v_2.2.0_180516": "14", - "v_2.2.1_180625": "15", - "v_2.3.0_180714": "16", - "v_2.3.1_180721": "17", - "v_2.3.2_181227": "18", - "v_2.3.3_190107": "19", - "v_3.0.0_190516": "20", - "v_3.1.0_190524": "21", - "v_3.2.0_190601": "22", - "v_3.2.1_190603": "23", - "v_3.3.0_190608": "24", - "v_3.4.0_190619": "25", - "v_3.4.1_190624": "26", - "v_3.4.2_190630": "27", - "v_3.5.0_190713": "28", - "v_3.6.0_190721": "29", - "v_3.6.1_190728": "30", - "v_3.6.2_190811": "31", - "v_3.6.3_190825": "32", - "v_3.7.0_190904": "33", - "v_3.8.0_190909": "34", - "v_3.9.0_190915": "35", - "v_4.0.0_190928": "36", - "v_4.1.0_190930": "37", - "v_4.1.1_191027": "38", - "v_4.2.0_191129": "39", - "v_4.2.1_200308": "40" + "v_0.0.0": "0", + "v_5.0.0": "1", + "v_5.0.1": "2", + "v_5.0.2": "3", + "v_5.0.3": "4", + "v_5.0.4": "5", + "v_5.0.5": "6" }, "versionDetailList": [ { - "version": "v_1.1.0_170701", - "title": "计划任务功能实现", - "log": "1.支持在某一计划时间开始推送\n2.支持每天固定时间开始推送\n3.支持每周固定时间开始推送\n" + "version": "v_0.0.0", + "title": "UI细节调整,优化依赖和资源链接", + "log": "● UI细节调整\n● 优化了maven依赖\n● 调整了资源链接\n" }, { - "version": "v_1.2.0_170831", - "title": "小优化,不重要更新", - "log": "1.部分代码lambda表达式化\n2.导入用户时trim掉空格\n3.新增weblnf主题\n" + "version": "v_5.0.0", + "title": "5.0全新改版升级", + "log": "● 新增任务机制\n● 多账号模式\n● 简化交互流程\n● UI调整,沉浸式窗口,优化macOS下体验\n● 更多细节等你发现\n● 该版本重构改动较大,未经充分测试,有问题可退回使用4.x版本,之前的数据还在\n" }, { - "version": "v_1.3.0_180207", - "title": "新增变量消息,可实现每条消息内容不同", - "log": "1.新增支持变量消息,可实现每个用户/每条消息内容不同\n2.微信模板消息和客服消息支持昵称变量,可在消息内容中增加用户昵称\n3.换行符规则变更:由#ENTER#变更为$ENTER$\n4.导入数据进度条优化\n" + "version": "v_5.0.1", + "title": "针对5.0新版多处修复和优化", + "log": "● 任务:修复任务执行状态更新不及时的问题\n● 窗口:优化esc键最小化后窗口再次恢复的表现\n● 修复excel导入提示缺少依赖的问题\n● 任务:修复任务详情成功失败文件路径不实时显示的问题\n● 增加执行前重新导入目标用户功能\n● 任务详情增加模式和线程数等更多细节展示\n" }, { - "version": "v_1.4.0_180209", - "title": "微信模板消息增加支持跳转小程序", - "log": "微信模板消息相关类型,新增支持跳转小程序\n" + "version": "v_5.0.2", + "title": "增加支持腾讯云短信3.0", + "log": "● 增加支持腾讯云短信3.0,由于没有条件,无法充分验证\n● 企业微信消息:支持私有化部署时BaseApiUrl配置\n● 全局:优化窗口关闭时的行为,避免再次点击任务栏图标无法唤出窗口\n" }, { - "version": "v_1.5.0_180209", - "title": "增加使用帮助+细节打磨", - "log": "1.增加了使用帮助\n2.界面多处细节打磨\n3.微信客服消息和模板消息空跑模式优化\n" + "version": "v_5.0.3", + "title": "使用Java21虚拟线程", + "log": "● 全局:升级Java版本至Java21\n● 推送:固定线程模式下使用虚拟线程,线程数可以放心随意增大\n● 推送:支持设置推送间隔,避免超过频率限制\n● 消息:邮件,修复消息编辑tab邮件正文回显不正确的问题\n● 消息:企业微信,修复消息编辑tab内容回显不正确的问题\n● 消息:企业微信,修复初始打开时 “图文消息编辑框不一致” 问题\n● 任务:去掉保存成功时的弹框提示\n● 账号:企业微信,修复初始打开时 “私有BaseApiUrl” 可见性问题\n" }, { - "version": "v_1.6.0_180222", - "title": "优化检查更新策略", - "log": "1.优化检查更新策略,联网检查新版本\n2.软件启动后自动检查更新(可在设置中选择性开启)\n3.优化:未在设置中配置阿里大于信息时,执行导入操作的报错\n4.优化:未在设置中配置数据库信息时,执行导入操作的报错\n5.优化:未在设置中配置公众号信息时,执行各种相关操作的报错\n6.修复:切换消息类型时阿里短信带小程序相关输入框的bug\n" + "version": "v_5.0.4", + "title": "修复微信企业号/企业微信导入用户时因性别参数不支持而报错的问题", + "log": "● 修复微信企业号/企业微信导入用户时因性别参数不支持而报错的问题\n● 升级部分依赖\n" }, { - "version": "v_1.7.0_180226", - "title": "新增推送历史管理+新增支持按微信公众平台标签导入", - "log": "1.新增推送历史管理\n2.准备目标用户:新增支持按微信公众平台标签导入\n3.优化在Mac系统系下的显示,为Mac版发布做准备\n4.优雅的Mac版的安装App就快到来,敬请期待\n5.其他多处优化和修复\n" - }, - { - "version": "v_1.8.0_180226", - "title": "新增Mac版", - "log": "1.Mac版来啦~\n2.推送历史支持导出功能\n3.通过文件导入时支持浏览本地文件\n4.其他多处优化和修复\n" - }, - { - "version": "v_1.9.0_180228", - "title": "新版消息管理/消息编辑", - "log": "1.消息管理和消息编辑整合到同一个tab~\n2.优化消息编辑tab布局\n3.优化推送历史管理和消息管理空删除时的错误提示\n4.动态刷新推送线程数等相关信息\n5.剥离安装包到云存储,精简项目体积,修复若干bug\n" - }, - { - "version": "v_1.10.0_180316", - "title": "新增对阿里云短信的支持", - "log": "1.新增对阿里云短信的支持~\n2.其他细节优化\n" - }, - { - "version": "v_2.0.0_180319", - "title": "新增支持通过excel导入目标用户和数据", - "log": "1.新增支持通过excel导入目标用户和数据~\n2.其他细节优化\n" - }, - { - "version": "v_2.0.1_180401", - "title": "按公众号标签导入用户时,支持导入多个标签内的用户并去重", - "log": "1.新增按公众号标签导入用户时,支持导入多个标签内的用户并去重\n" - }, - { - "version": "v_2.0.2_180401", - "title": "公众号通过标签导入用户时,支持多个标签取交并集", - "log": "1.公众号通过标签导入用户时,支持多个标签取交并集~\n2.多处界面调整\n" - }, - { - "version": "v_2.1.0_180509", - "title": "新增支持小程序模板消息和腾讯云短信", - "log": "1.新增支持小程序模板消息\n2.新增支持腾讯云短信\n" - }, - { - "version": "v_2.2.0_180516", - "title": "调整小程序模板消息FormId策略", - "log": "1.小程序模板消息FormId在'准备目标用户'时,第一列openId,第二列formId即可\n" - }, - { - "version": "v_2.2.1_180625", - "title": "修复模板消息跳转小程序路径问题", - "log": "1.升级weixin-java-tools版本,修复模板消息跳转小程序路径问题\n" - }, - { - "version": "v_2.3.0_180714", - "title": "新增支持云片网短信", - "log": "1.新增支持云片网短信\n2.多处界面优化\n3.bug修复,优化性能\n" - }, - { - "version": "v_2.3.1_180721", - "title": "编辑消息Tab bug修复", - "log": "1.修复编辑消息界面切换消息类型无反应的bug\n" - }, - { - "version": "v_2.3.2_181227", - "title": "性能优化+体验优化+减小项目体积", - "log": "1.通过文件导入时,自动判断文件字符集,防止乱码\n2.微信公众号配置必填项校验优化\n3.使用线程池,且限制最大线程数\n4.优化1366分辨率下默认字体大小\n5.优化依赖,减小安装包体积\n6.修复安全漏洞,解决代码中的Warning\n7.移除git中的大文件,大大大幅减少clone时的体积\n" - }, - { - "version": "v_2.3.3_190107", - "title": "使用模板引擎处理变量消息", - "log": "1.使用Velocity模板引擎处理变量消息\n2.微信相关消息全局支持昵称变量:“${NICK_NAME}”\n3.所有消息全局支持换行变量:“${ENTER}”\n" - }, - { - "version": "v_3.0.0_190516", - "title": "3.0.0多项改进新鲜出炉!", - "log": "1.调整启动时UI加载策略,Windows平台增加启动器,提高启动速度\n2.全局设置文件由property改为setting(感谢HuTool)\n3.数据存储由文件调整为sqlite数据库\n4.新增支持直接滑动设置线程数\n5.消息类型解耦,为以后支持更多类型以及类型插件化做准备\n6.版本更新时支持直接下载立即安装\n7.大规模代码重构,bug修复\n8.大规模UI打磨优化\n9.微信用户数据导入优化\n10.由于底层数据存储方式变更较大,3.0.0版本及以后不再兼容老版本的数据\n……\n" - }, - { - "version": "v_3.1.0_190524", - "title": "新增支持微信公众号和小程序多账号切换", - "log": "1.新增支持微信公众号和小程序多账号管理和切换\n2.在UI打磨优化的路上执迷不悟\n3.新增平滑升级策略,无论什么版本升到最新版本理论上都不会影响用户本地旧的数据\n4.bug fix\n" - }, - { - "version": "v_3.2.0_190601", - "title": "集中bug修复版本", - "log": "1.修复1366x768等低分辨率情况下显示不全的问题\n2.优化表格行点击事件,反应更灵敏\n3.feature:多账号管理对话框增加ESC按钮事件 rememberber 2019/5/27 20:38\n4.修复微信相关账号修改需要重启应用的问题\n5.优化微信小程序模板消息预览需要formId的提示\n6.移除不合适的皮肤,修复某些情况下切换皮肤后无法正常启动的问题\n" - }, - { - "version": "v_3.2.1_190603", - "title": "修复阿里云短信发送失败的问题", - "log": "1.修复阿里云短信发送失败的问题\n2.优化其他类型短信客户端\n" - }, - { - "version": "v_3.3.0_190608", - "title": "微信相关消息支持使用http代理+优化连接池+全局帮助", - "log": "● 增加全局帮助对话框\n● 版本更新对话框优化,避免更新日志过多显示不下\n● 根据屏幕DPI自动初始化字号\n● 短信编辑form调整\n● 优化微信相关消息发送时连接获取超时的问题\n● 微信相关消息类型增加Http代理设置\n● 第一次安装时增加字号大小设置引导\n● 消息编辑深度梳理大规模重构\n" - }, - { - "version": "v_3.4.0_190619", - "title": "自动获取微信公众号可选模板+模板参数自动填充", - "log": "● 自动获取微信公众号可选模板\n● 模板参数自动填充\n● 客服消息文本类型输入区域优化\n● UI调整,消息编辑可见范围不受屏幕分辨率限制\n● 增加空跑帮助提示\n● 消息发送器解耦,新增消息加工器策略,大幅提高消息加工性能\n● push相关流程深度梳理和大规模重构\n● UI细节调整,增加累计推送量展示\n" - }, - { - "version": "v_3.4.1_190624", - "title": "新增支持E-Mail类型消息", - "log": "● 新增支持发送E-Mail类型消息(beta)\n● 计划任务增加推送结果邮件通知\n● 优化SQL连接测试\n● 计划任务支持执行时重新导入目标用户\n● 统一全局强调色为黄色\n● SQL导入支持导入变量信息\n● 使用Hikari连接池\n" - }, - { - "version": "v_3.4.2_190630", - "title": "新增支持微信企业号/企业微信类型消息", - "log": "● feature:新增支持发送微信企业号/企业微信类型消息\n● feature:支持按标签按部门导入企业通讯录员工\n● optimization:低分辨率下自动最大化窗口\n● feature:企业号支持应用管理\n● optimization:外观设置中支持从系统可用字体列表中选择字体+默认字体调整为:微软雅黑\n● fix:修复NICK_NAME变量失效的bug\n" - }, - { - "version": "v_3.5.0_190713", - "title": "新增性能模式", - "log": "● feature:新增性能模式(目前仅支持微信模板消息)\n● feature:计划任务增加可以按Cron表达式触发\n● feature:e-mail消息支持抄送\n● feature:企业微信消息新增对文本卡片类型的支持\n● feature:企业微信消息新增对markdown类型的支持\n● optimization:优化平滑升级时sql执行的幂等\n● bug fix:修复普通计划任务保存时误提示最近5次运行时间的问题\n● fix:修复推送总进度条状态异常问题\n● 其他细节调整\n" - }, - { - "version": "v_3.6.0_190721", - "title": "消息类型新增支持HTTP请求", - "log": "● feature:消息类型新增支持HTTP请求\n● feature:成员导出支持选择文件类型\n● feature:支持外部AccessToken\n● feature:推送页签增加tps展示\n● optimization:消息编辑form重构\n● 其他细节调整\n" - }, - { - "version": "v_3.6.1_190728", - "title": "HTTP请求类型消息使用OkHttp", - "log": "● feature:HTTP请求类型消息使用OkHttp引擎\n● optimization:HTTP请求支持选择body类型\n" - }, - { - "version": "v_3.6.2_190811", - "title": "全局支持撤销", - "log": "● feature:全局输入框支持撤销/重做\n● bugfix:修复http请求消息非get请求不支持空参的问题\n● optimization:MacOS环境时的菜单禁用\n● optimization:优化启动时UI渲染速度\n" - }, - { - "version": "v_3.6.3_190825", - "title": "小的优化和修复", - "log": "● feature:微信相关消息类型url支持变量\n● 代码大规模重构,优化加载速度\n● optimization:一些界面相关的bug修复和细节调整\n● optimization:更新高清logo\n" - }, - { - "version": "v_3.7.0_190904", - "title": "严重bug修复", - "log": "● bug fix:修复客服消息文本类型发送失败的问题\n● bug fix:修复微信公众号相关消息accessToken缓存机制问题\n● optimization:导入用户tab相关按钮防止重复点击\n● optimization:移除对阿里大于短信的支持\n" - }, - { - "version": "v_3.8.0_190909", - "title": "新增支持钉钉消息", - "log": "● feature:新增支持钉钉消息类型(工作通知消息和群机器人消息)\n● bug fix:修复微信公众号相关消息使用外部accessToken缓存异常的问题\n● optimization:优化http请求失败提示更详细准确\n● bug fix:修复消息类型不存在时启动异常,预览消息失败时提示框标题等问题\n" - }, - { - "version": "v_3.9.0_190915", - "title": "新增支持华为云短信和百度云短信", - "log": "● feature:新增支持又拍云短信消息类型\n● feature:新增支持七牛云短信消息类型\n● bug fix:修复导入成员异常时按钮状态不正确的问题\n" - }, - { - "version": "v_4.0.0_190928", - "title": "新增支持又拍云短信和七牛云短信", - "log": "● feature:新增支持华为云短信消息类型\n● feature:新增支持百度云短信消息类型\n● optimization:微信公众号消息前置校验优化\n● feature:增加系统托盘(不喜欢可在设置中关闭)\n" - }, - { - "version": "v_4.1.0_190930", - "title": "新增支持小程序统一服务消息", - "log": "● feature:新增支持小程序统一服务消息类型\n● bug fix:修复阿里云短信发送失败的问题(感谢@LEE.MW反馈)\n" - }, - { - "version": "v_4.1.1_191027", - "title": "一波细节优化", - "log": "● optimization:优化推送历史复制按钮功能\n● optimization:窗口关闭更优雅一些\n● optimization:窗口增加esc按钮事件\n● optimization:UI细节优化\n" - }, - { - "version": "v_4.2.0_191129", - "title": "新增支持小程序订阅消息", - "log": "● feature:新增支持小程序订阅消息类型\n● optimization:优化消息发送器日志打印\n● optimization:提高启动时界面渲染速度\n● fix:修复http请求消息和钉钉消息无法删除的问题\n" - }, - { - "version": "v_4.2.1_200308", - "title": "修复bug", - "log": "● fix:修复小程序订阅消息无法发送问题\n● optimization:由于小程序模板消息接口将于2020年1月10日下线,禁用小程序模板消息入口\n● fix:公众号模板消息支持小程序路径修复\n● fix:代码优化,界面细节优化\n" + "version": "v_5.0.5", + "title": "修复macOS15下无法启动的问题", + "log": "● 修复macOS15下无法启动的问题\n● 调整macOS下的图标\n● 升级部分依赖\n" } ] } \ No newline at end of file