ソースを参照

Merge remote-tracking branch 'origin/master'

lizeyu 4 ヶ月 前
コミット
81fc2ff973

+ 4 - 4
parth5/parth5/src/app/api/wechat/index.ts

@@ -7,15 +7,15 @@ export class WechatApi {
   constructor(private configService: ConfigService) {
   constructor(private configService: ConfigService) {
   }
   }
 
 
-  getOAuthUrl(redirectUrl:string):Observable<RequsetData> {
+  getOAuthUrl(redirectUrl: string): Observable<RequsetData> {
     return this.configService.HttpGetRomote('/wxapi/cp/getOAuthUrl', {
     return this.configService.HttpGetRomote('/wxapi/cp/getOAuthUrl', {
-      redirectUrl
+      redirectUrl: redirectUrl
     });
     });
   }
   }
 
 
-  getWxCpUserId(code:string):Observable<RequsetData> {
+  getWxCpUserId(code: string): Observable<RequsetData> {
     return this.configService.HttpGetRomote('/wxapi/cp/getWxCpUserId', {
     return this.configService.HttpGetRomote('/wxapi/cp/getWxCpUserId', {
-      code
+      code: code
     });
     });
   }
   }
 
 

+ 37 - 27
parth5/parth5/src/app/service/account.service.ts

@@ -1,14 +1,11 @@
 import {Injectable, Inject} from '@angular/core';
 import {Injectable, Inject} from '@angular/core';
-import {DOCUMENT} from '@angular/common';
 import {ConfigService, RequsetData} from "./config.service";
 import {ConfigService, RequsetData} from "./config.service";
-import {from, Observable} from "rxjs";
-import * as moment from "./work.service";
 import {Router} from "@angular/router";
 import {Router} from "@angular/router";
-import {AlertController} from "@ionic/angular";
 import {AccountApi} from "../api/account";
 import {AccountApi} from "../api/account";
 import {UsemodularService} from "./usemodular.service";
 import {UsemodularService} from "./usemodular.service";
 import {AlertModal} from "../comm/modal/alert";
 import {AlertModal} from "../comm/modal/alert";
 import {UserService} from "./user.service";
 import {UserService} from "./user.service";
+import {splitRouterUrl} from "../utils/urlUtils";
 
 
 
 
 @Injectable({providedIn: 'root'})
 @Injectable({providedIn: 'root'})
@@ -25,33 +22,46 @@ export class AccountService {
    * @param wxUserId 企业微信用户id
    * @param wxUserId 企业微信用户id
    * @param currentUrl 登录成功后跳转路由,可未空,默认首页路由
    * @param currentUrl 登录成功后跳转路由,可未空,默认首页路由
    */
    */
-  async loginByWxUserId(wxUserId: string, currentUrl: string) {
-    if (!wxUserId)
-      return false;
-
-    const loading = await this.alertModal.loading('验证微信用户中,请稍等...');
-    await loading.present();
-
-    this.accountApi.loginByWxUserId(wxUserId).subscribe(req => {
-      loading.dismiss();
-      if (req.success) {
-        req.item.curRoleId = req.extdata.userRoles[0].roleid;
-        this.userService.SetUser(req.item);
-        this.userService.SetExt(req.extdata);
-        this.userService.setToken(req.item.logintoken);
-        this.userService.ReadUserDataScope(req.item.curRoleId, this.configService);
-        this.usemodularService.getButtonList();
-        this.router.navigate([currentUrl || '/tapp/tabs/tabMain']);
-      } else {
+  loginByWxUserId(wxUserId: string, currentUrl: string) {
+    if (!wxUserId) {
+      this.alertModal.alert('微信用户ID为空,不能使用微信用户登录,请输入账号密码登录');
+      this.router.navigate(['/login']);
+    }
+
+    this.alertModal.loading('验证微信用户中,请稍等...').then(loading => {
+      this.accountApi.loginByWxUserId(wxUserId).subscribe(res => {
+        if (res.success) {
+          try {
+            this.loginSuccessBack(res);
+          } catch (ex) {
+          } finally {
+            loading.dismiss();
+          }
+
+          const routerUrl = splitRouterUrl(currentUrl);
+          this.router.navigate([routerUrl.routerUrl || '/tapp/tabs/tabMain'], {
+            queryParams: {random: Math.random(), ...routerUrl.params}
+          });
+        } else {
+          loading.dismiss();
+          this.alertModal.alert('微信用户未绑定或验证失败,请输入账号密码登录');
+          this.router.navigate(['/login']);
+        }
+      }, () => {
+        loading.dismiss();
         this.alertModal.alert('微信用户未绑定或验证失败,请输入账号密码登录');
         this.alertModal.alert('微信用户未绑定或验证失败,请输入账号密码登录');
         this.router.navigate(['/login']);
         this.router.navigate(['/login']);
-      }
-    }, () => {
-      loading.dismiss();
-      this.alertModal.alert('微信用户未绑定或验证失败,请输入账号密码登录');
-      this.router.navigate(['/login']);
+      });
     });
     });
   };
   };
 
 
+  loginSuccessBack(data: any) {
+    data.item.curRoleId = data.extdata.userRoles[0].roleid;
+    this.userService.SetUser(data.item);
+    this.userService.SetExt(data.extdata);
+    this.userService.setToken(data.item.logintoken);
+    this.userService.ReadUserDataScope(data.item.curRoleId, this.configService);
+    this.usemodularService.getButtonList();
+  }
 
 
 }
 }

+ 1 - 1
parth5/parth5/src/app/service/user.service.ts

@@ -99,7 +99,7 @@ export class UserService {
     let url = location.href.split("#");
     let url = location.href.split("#");
     if (!token && url.length == 2) {
     if (!token && url.length == 2) {
       let pageUrl = url[1].split("?");
       let pageUrl = url[1].split("?");
-      if (pageUrl[0] != '/' && pageUrl[0] != '/login') {
+      if (pageUrl[0] != '/' && pageUrl[0] != '/login' && pageUrl[0] != '/index') {
         this.presentAlert("登录过期,请重新登录!");
         this.presentAlert("登录过期,请重新登录!");
         this.router.navigate(['/login']);
         this.router.navigate(['/login']);
       }
       }

+ 53 - 42
parth5/parth5/src/app/service/wxcp.service.ts

@@ -1,14 +1,12 @@
 import {Inject, Injectable} from '@angular/core';
 import {Inject, Injectable} from '@angular/core';
-import {ConfigService, RequsetData} from "./config.service";
+import {ConfigService} from "./config.service";
 import {UserService} from "./user.service";
 import {UserService} from "./user.service";
-import {from, interval, Observable, of, Subject} from "rxjs";
-import * as moment from 'moment';
 import {DOCUMENT} from "@angular/common";
 import {DOCUMENT} from "@angular/common";
-import {AlertController, LoadingController} from "@ionic/angular";
 import {ActivatedRoute, Router} from "@angular/router";
 import {ActivatedRoute, Router} from "@angular/router";
 import {AlertModal} from "../comm/modal/alert";
 import {AlertModal} from "../comm/modal/alert";
 import {WechatApi} from "../api/wechat";
 import {WechatApi} from "../api/wechat";
 import {getUrlParams} from "../utils/urlUtils";
 import {getUrlParams} from "../utils/urlUtils";
+import {AccountService} from "./account.service";
 
 
 @Injectable({
 @Injectable({
   providedIn: 'root'
   providedIn: 'root'
@@ -18,7 +16,7 @@ export class WxcpService {
   private siteUrl: string = '';
   private siteUrl: string = '';
 
 
   constructor(@Inject(DOCUMENT) private document: any, private router: Router, private configService: ConfigService, private userService: UserService
   constructor(@Inject(DOCUMENT) private document: any, private router: Router, private configService: ConfigService, private userService: UserService
-    , private alertModal: AlertModal, private wechatApi: WechatApi, private routeInfo: ActivatedRoute) {
+    , private alertModal: AlertModal, private wechatApi: WechatApi, private routeInfo: ActivatedRoute, private accountService: AccountService) {
     this.configService.GetConfig().subscribe((config) => {
     this.configService.GetConfig().subscribe((config) => {
       this.siteUrl = config.siteUrl;
       this.siteUrl = config.siteUrl;
     });
     });
@@ -28,48 +26,61 @@ export class WxcpService {
     return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
     return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
   }
   }
 
 
-  wxAuth = async <Object>(routePath: string): Promise<string> => {
-    try {
-      const urlParams = getUrlParams() as any;
-      const openId = urlParams["wxUserId"] || this.userService.getWxUserID();
-      const code = urlParams["code"];
+  wxAuth = async <Object>(routePath: string): Promise<boolean> => {
+    return new Promise(async (resolve, reject) => {
+      try {
+        const urlParams = getUrlParams() as any;
+        let wxUserId = urlParams["wxUserId"] || this.userService.getWxUserID();
+        const code = urlParams["code"];
 
 
-      if (this.isWechat()) {
-        if (openId) {
-          this.userService.setWxUserID(openId);
-        } else {
-          if (!code) {
-            const loading = await this.alertModal.loading('微信授权中,请稍等...');
-            await loading.present();
-
-            let oAuthUrl_redirectUrl = this.siteUrl + "?routePath=" + encodeURIComponent(routePath); //www.aa.com/mobile?routePath=xxxxx
-            this.wechatApi.getOAuthUrl(encodeURIComponent(oAuthUrl_redirectUrl)).subscribe((res: any) => {
-              if (res) {
-                window.location.replace(res);
-              } else {
-                this.alertModal.alert("微信授权失败!");
-              }
-            });
+        if (this.isWechat()) {
+          if (wxUserId) {
+            this.userService.setWxUserID(wxUserId);
+            this.accountService.loginByWxUserId(wxUserId, routePath);
           } else {
           } else {
-            const loading = await this.alertModal.loading('微信授权成功,请稍等...');
-            await loading.present();
-            await this.wechatApi.getWxCpUserId(code).subscribe((res: any) => {
-              this.userService.setWxUserID(res);
-
-              const currentUrl = routePath + (routePath.indexOf("?") >= 0 ? "&" : "?") + "wxUserId=" + res;
-
-              this.router.navigate([currentUrl], {
-                relativeTo: this.routeInfo,
-                queryParams: {random: Math.random(), op: 0}
+            if (!code) {
+              await this.alertModal.loading('正在获取企业微信授权链接,请稍等...').then(async loading => {
+                let oAuthUrl_redirectUrl = this.siteUrl + "?routePath=" + encodeURIComponent(routePath); //www.aa.com/mobile?routePath=xxxxx
+                await this.wechatApi.getOAuthUrl(encodeURIComponent(oAuthUrl_redirectUrl)).toPromise().then((res: any) => {
+                  loading.dismiss();
+                  if (res != null && res.success) {
+                    window.location.replace(res.item);
+                  } else {
+                    this.alertModal.alert("企业微信授权链接获取失败!");
+                    resolve(false);
+                  }
+                }, () => {
+                  loading.dismiss();
+                  this.alertModal.alert("企业微信授权链接获取失败!");
+                  resolve(false);
+                });
               });
               });
-            });
+            } else {
+              await this.alertModal.loading('企业微信授权成功,正在获取企业微信用户信息,请稍等...').then(async loading => {
+                await this.wechatApi.getWxCpUserId(code).toPromise().then((res: any) => {
+                  loading.dismiss();
+                  if (res != null && res.success && res.item) {
+                    wxUserId = res.item;
+                    this.userService.setWxUserID(wxUserId);
+                    const currentUrl = routePath + (routePath.indexOf("?") >= 0 ? "&" : "?") + "wxUserId=" + wxUserId;
+                    this.accountService.loginByWxUserId(wxUserId, currentUrl);
+                  } else {
+                    this.alertModal.alert("获取企业微信用户信息失败!");
+                    resolve(false);
+                  }
+                }, () => {
+                  loading.dismiss();
+                  this.alertModal.alert("获取企业微信用户信息失败!");
+                  resolve(false);
+                });
+              });
+            }
           }
           }
         }
         }
+      } catch (e) {
+        this.alertModal.alert("调用微信接口异常!" + e);
+        resolve(false);
       }
       }
-
-      return "";
-    } catch (e) {
-      return Promise.reject(null);
-    }
+    });
   }
   }
 }
 }

+ 32 - 0
parth5/parth5/src/app/utils/urlUtils.ts

@@ -71,3 +71,35 @@ export function getUrlParams() {
 
 
   return theRequest;
   return theRequest;
 }
 }
+
+export function splitRouterUrl(url: string) {
+  if (!url)
+    return {
+      routerUrl: '',
+      params: {}
+    };
+
+  const routerUrlSplit = url.split('?');
+  if (routerUrlSplit.length === 1)
+    return {
+      routerUrl: url,
+      params: {}
+    };
+
+  const params = {};
+  const strs = routerUrlSplit[1].split("&");
+  for (let i = 0; i < strs.length; i++) {
+    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+    // @ts-ignore
+    const paramsIndex = strs[i].indexOf("=");
+    const paramsSplits = [strs[i].slice(0, paramsIndex), strs[i].slice(paramsIndex + 1)];
+
+    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+    // @ts-ignore
+    params[paramsSplits[0]] = paramsSplits[1];
+  }
+  return {
+    routerUrl: routerUrlSplit[0],
+    params: params
+  }
+}

+ 15 - 14
parth5/parth5/src/app/views/index/index.page.ts

@@ -3,10 +3,6 @@ import {getUrlParams} from "../../utils/urlUtils";
 import {WxcpService} from "../../service/wxcp.service";
 import {WxcpService} from "../../service/wxcp.service";
 import {ActivatedRoute, Router} from "@angular/router";
 import {ActivatedRoute, Router} from "@angular/router";
 import {UserService} from "../../service/user.service";
 import {UserService} from "../../service/user.service";
-import {ConfigService} from "../../service/config.service";
-import {AccountApi} from "../../api/account";
-import {UsemodularService} from "../../service/usemodular.service";
-import {AlertModal} from "../../comm/modal/alert";
 import {AccountService} from "../../service/account.service";
 import {AccountService} from "../../service/account.service";
 
 
 @Component({
 @Component({
@@ -15,11 +11,9 @@ import {AccountService} from "../../service/account.service";
   styleUrls: ['./index.page.scss'],
   styleUrls: ['./index.page.scss'],
 })
 })
 export class IndexPage implements OnInit {
 export class IndexPage implements OnInit {
-  private routePath = '';
-
 
 
   constructor(private router: Router, private route: ActivatedRoute, private wxcpService: WxcpService, private userService: UserService,
   constructor(private router: Router, private route: ActivatedRoute, private wxcpService: WxcpService, private userService: UserService,
-              private accountService: AccountService) {
+              private accountService: AccountService, private routeInfo: ActivatedRoute) {
   }
   }
 
 
   ngOnInit() {
   ngOnInit() {
@@ -27,21 +21,28 @@ export class IndexPage implements OnInit {
 
 
   ionViewWillEnter() {
   ionViewWillEnter() {
     const urlParams = getUrlParams() as any;
     const urlParams = getUrlParams() as any;
-    this.routePath = urlParams["routePath"] || '/login';
-    this.routePath = decodeURIComponent(this.routePath);
+    if (this.wxcpService.isWechat()) {
+      let routePath = urlParams["routePath"] || '/tapp/tabs/tabMain'; //登录成功后跳转地址
+      routePath = decodeURIComponent(routePath);
 
 
-    if (this.wxcpService.isWechat() && this.routePath.indexOf("wxMessage") < 0) {
       const wxUserId = urlParams["wxUserId"] || this.userService.getWxUserID();
       const wxUserId = urlParams["wxUserId"] || this.userService.getWxUserID();
       if (wxUserId) {
       if (wxUserId) {
         //根据微信用户id登录系统
         //根据微信用户id登录系统
-        this.accountService.loginByWxUserId(wxUserId, null).then(e => {
-        });
+        this.accountService.loginByWxUserId(wxUserId, routePath);
       } else {
       } else {
-        this.wxcpService.wxAuth(this.routePath);
+        this.wxcpService.wxAuth(routePath).then(res => {
+          if (res === false) {
+            this.router.navigate(['/login'], {
+              relativeTo: this.routeInfo,
+              queryParams: {random: Math.random()}
+            });
+          }
+        });
       }
       }
     } else {
     } else {
-      this.router.navigate([this.routePath], {queryParams: {random: Math.random()}});
+      this.router.navigate(['/login'], {queryParams: {random: Math.random()}});
     }
     }
   }
   }
 
 
+
 }
 }

+ 1 - 1
parth5/parth5/src/app/views/login/login.page.html

@@ -14,7 +14,7 @@
     <ion-icon name="lock-closed-outline"></ion-icon>
     <ion-icon name="lock-closed-outline"></ion-icon>
     <ion-input [(ngModel)]="userPwd" type="password" placeholder="请输入密码"></ion-input>
     <ion-input [(ngModel)]="userPwd" type="password" placeholder="请输入密码"></ion-input>
   </ion-item>
   </ion-item>
-  <ion-item style="padding-left: 20px;">
+  <ion-item style="padding-left: 20px;" *ngIf="wxUserId">
     <ion-checkbox [(ngModel)]="isBindWxUser"></ion-checkbox>
     <ion-checkbox [(ngModel)]="isBindWxUser"></ion-checkbox>
     <ion-label style="padding-left: 10px;">绑定微信账号
     <ion-label style="padding-left: 10px;">绑定微信账号
       <span>{{wxUserId}}</span>
       <span>{{wxUserId}}</span>

+ 14 - 8
parth5/parth5/src/app/views/login/login.page.ts

@@ -10,6 +10,7 @@ import {UsemodularService} from "../../service/usemodular.service";
 import {WxpayService} from "../../service/wxpay.service";
 import {WxpayService} from "../../service/wxpay.service";
 import {getUrlParams} from "../../utils/urlUtils";
 import {getUrlParams} from "../../utils/urlUtils";
 import {AccountApi} from "../../api/account";
 import {AccountApi} from "../../api/account";
+import {AccountService} from "../../service/account.service";
 
 
 @Component({
 @Component({
   selector: 'app-login',
   selector: 'app-login',
@@ -30,7 +31,7 @@ export class LoginPage implements OnInit {
   constructor(private router: Router, private route: ActivatedRoute,
   constructor(private router: Router, private route: ActivatedRoute,
               private configService: ConfigService, private userService: UserService, private jsBridgeService: JsBridgeService,
               private configService: ConfigService, private userService: UserService, private jsBridgeService: JsBridgeService,
               private desService: DesService, private loadingController: LoadingController, private usemodularService: UsemodularService,
               private desService: DesService, private loadingController: LoadingController, private usemodularService: UsemodularService,
-              private wxpayService: WxpayService, private accountApi: AccountApi) {
+              private wxpayService: WxpayService, private accountApi: AccountApi, private accountService: AccountService) {
     this.route.queryParams.subscribe(params => {
     this.route.queryParams.subscribe(params => {
 
 
     });
     });
@@ -63,23 +64,28 @@ export class LoginPage implements OnInit {
     });
     });
 
 
     //return;//注释掉服务器方法
     //return;//注释掉服务器方法
-    this.configService.HttpPostRomote(this.userInfoUrl, model).subscribe(req => {
+    this.configService.HttpPostRomote(this.userInfoUrl, model).subscribe(res => {
       loading.then(l => l.dismiss());
       loading.then(l => l.dismiss());
-      if (req.success) {
-        req.item.curRoleId = req.extdata.userRoles[0].roleid;
+      if (res.success) {
+        /*req.item.curRoleId = req.extdata.userRoles[0].roleid;
         this.userService.SetUser(req.item);
         this.userService.SetUser(req.item);
         this.userService.SetExt(req.extdata);
         this.userService.SetExt(req.extdata);
         this.userService.setToken(req.item.logintoken);
         this.userService.setToken(req.item.logintoken);
         this.userService.ReadUserDataScope(req.item.curRoleId, this.configService);
         this.userService.ReadUserDataScope(req.item.curRoleId, this.configService);
-        this.usemodularService.getButtonList();
-        //this.configService.HttpPostRomote()
+        this.usemodularService.getButtonList();*/
+
+        this.accountService.loginSuccessBack(res);
+
         if (this.isBindWxUser) {
         if (this.isBindWxUser) {
-          this.accountApi.bindWxUserId(this.userService.GetUser().userid, this.wxUserId).subscribe(e=>{});
+          this.accountApi.bindWxUserId(this.userService.GetUser().userid, this.wxUserId).subscribe(e => {
+          });
+        } else {
+          this.userService.setWxUserID('');
         }
         }
         this.router.navigate(['/tapp/tabs/tabMain']);
         this.router.navigate(['/tapp/tabs/tabMain']);
       } else {
       } else {
         this.errorShow = true;
         this.errorShow = true;
-        this.msg += req.msg;
+        this.msg += res.msg;
       }
       }
     });
     });
   }
   }

+ 4 - 3
parth5/parth5/src/app/views/tapp/tabs/tabs.module.ts

@@ -58,7 +58,8 @@ import {routes as MainRoutes} from "../tab-main/tab-main.route";
 import {routes as StudyRoutes} from "../tab-study/tab-study.route";
 import {routes as StudyRoutes} from "../tab-study/tab-study.route";
 import {routes as UserRoutes} from "../tab-user/tab-user.route";
 import {routes as UserRoutes} from "../tab-user/tab-user.route";
 import {CardComponent} from "../../pages/examtest/show/card/card.component";
 import {CardComponent} from "../../pages/examtest/show/card/card.component";
-import {ResultComponent} from "../../pages/examtest/show/result/result.component";
+import {ResultComponent as ExamtestResultComponent} from "../../pages/examtest/show/result/result.component";
+import {ResultComponent as ExamonlineResultComponent} from "../../pages/examonline/showpaper/result/result.component";
 
 
 import { ExamtestComponent} from "../../pages/examtest/examtest.component";
 import { ExamtestComponent} from "../../pages/examtest/examtest.component";
 import {DzzfcListComponent} from "../../pages/propagandawork/dzzfc/list.component";
 import {DzzfcListComponent} from "../../pages/propagandawork/dzzfc/list.component";
@@ -97,11 +98,11 @@ const pageComponents = [
   ExamtestComponent,
   ExamtestComponent,
   ExamtestShowComponent,
   ExamtestShowComponent,
   CardComponent,
   CardComponent,
-  ResultComponent,
+  ExamtestResultComponent,
   ExamonlineComponent,
   ExamonlineComponent,
   ShowpaperComponent,
   ShowpaperComponent,
   ShowpaperCardComponent,
   ShowpaperCardComponent,
-  ResultComponent,
+  ExamonlineResultComponent,
   DzzfcListComponent,
   DzzfcListComponent,
   DzzfcEditComponent,
   DzzfcEditComponent,
   DzzfcDetailComponent
   DzzfcDetailComponent

+ 1 - 1
parth5/parth5/src/assets/appconfig.json

@@ -1,7 +1,7 @@
 {
 {
   "webSite": "partyH5App",
   "webSite": "partyH5App",
   "webServerHost": "http://localhost:8062",
   "webServerHost": "http://localhost:8062",
-  "siteUrl": "http://localhost:8062/mobile/#",
+  "siteUrl": "http://localhost:8062/mobile",
   "isWxPay": true,
   "isWxPay": true,
   "isDev": true
   "isDev": true
 }
 }

+ 17 - 129
src/main/java/com/ghsc/partybuild/controller/AppController.java

@@ -7,7 +7,8 @@ import com.ghsc.partybuild.service.RoleService;
 import com.ghsc.partybuild.service.UserService;
 import com.ghsc.partybuild.service.UserService;
 import com.ghsc.partybuild.shiro.JwtUtils;
 import com.ghsc.partybuild.shiro.JwtUtils;
 import com.ghsc.partybuild.util.RemoteHelper;
 import com.ghsc.partybuild.util.RemoteHelper;
-import org.apache.commons.lang3.StringUtils;
+import com.ghsc.partybuild.util.StringUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,11 +21,13 @@ import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.io.FileInputStream;
 import java.io.FileInputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
+@Slf4j
 @Controller
 @Controller
 @RequestMapping(value = "/")
 @RequestMapping(value = "/")
 public class AppController {
 public class AppController {
@@ -47,14 +50,13 @@ public class AppController {
     @Autowired
     @Autowired
     RemoteHelper remoteHelper;
     RemoteHelper remoteHelper;
 
 
+    @Autowired
+    private StringUtils stringUtils;
+
     public AppController() {
     public AppController() {
         logger = LoggerFactory.getLogger(this.getClass());
         logger = LoggerFactory.getLogger(this.getClass());
     }
     }
 
 
-    @GetMapping("mobile")
-    public String Wechat(){
-        return "redirect:/mobile/index.html";
-    }
 
 
     @GetMapping("")
     @GetMapping("")
     public String Web(HttpServletRequest request, HttpServletResponse response) {
     public String Web(HttpServletRequest request, HttpServletResponse response) {
@@ -62,132 +64,18 @@ public class AppController {
         return "redirect:/app/main/index.html";
         return "redirect:/app/main/index.html";
     }
     }
 
 
-    @GetMapping("jxCasLogin")
-    public String JXCasLogin(HttpServletRequest request, HttpServletResponse response,@RequestParam(required=false)String ticket) {
-
-        try {
-
-            String casUrlParam=URLEncoder.encode(appConfig.jxLocationUrl,"UTF-8");
-
-            if (StringUtils.isBlank(ticket)) {
-                //lyuapSever
-                String casLoginUrl = "redirect:" + appConfig.jxCasUrl + "/lyuapServer/login?service=" + casUrlParam;
-                logger.info("JXCasLogin,casLoginUrl:" + casLoginUrl);
-                return casLoginUrl;
-            } else {
-
-                String validateUrl=appConfig.jxCasUrl+"/lyuapServer/serviceValidate";
-                logger.info("JXCasLogin,ticket:" + ticket);
-                Map<String,String> mapParams=new HashMap<>();
-                mapParams.put("ticket",ticket);
-                mapParams.put("service",appConfig.jxLocationUrl);
-                FileInputStream streamCer=new FileInputStream(appConfig.certPath+"/lyuap.cer");
-                String reqData=remoteHelper.SSLGet(mapParams,validateUrl,"UTF-8",streamCer);
-                //String reqData="<cas:authenticationSuccess><cas:user>2001001www</cas:user><cas:attributes>...</cas:attributes></cas:authenticationSuccess>";
-                int i=reqData.indexOf("<cas:user>");
-                int j=reqData.indexOf("</cas:user>");
-
-                String userId=reqData.substring(i+"<cas:user>".length(),j);
-
-                logger.info("JXCasLogin,userId:" + userId);
-
-                CfUsers User=userService.getUserByKey(userId);
-                if(StringUtils.isBlank(User.getUserid())) {
-                    User = userService.getUserByOAName(userId);
-                }
-                if (User != null && StringUtils.isNotBlank(User.getUsername())) {
-
-                    Cookie cookie = new Cookie(jwtUtils.getTokenName(), jwtUtils.generateToken(User.getUserid()));
-                    cookie.setHttpOnly(true);
-                    cookie.setPath("/");
-                    response.addCookie(cookie);
-
-                    List<HashMap<String, Object>> roleList = this.roleService.getRoleByUserName(User.getUsername());
-                    if (roleList == null || roleList.isEmpty()) {
-                        this.roleService.insertUserRole(User.getUsername(), "0b45886a-a8db-4f85-af76-61a8ea7c1dab");
-
-                    }
-                    userService.loginForceStatu(User.getUserid(), 0);
-                    logService.log("用户登录", User.getUserid(), "login");
-                    return "redirect:/app/main/index.html";
-
-                } else {
-                    logger.info("JXCasLogin,单点登陆失败!");
-                    return "redirect:/app/main/index.html";
-                }
-
-            }
-
-        }catch (Exception ex){
-
-            return "单点验证错误:"+ex.getMessage();
-        }
-
-        //return "redirect:/app/main/index.html";
+    @GetMapping("web")
+    public String Web() {
+        return "redirect:/mobile/index.html";
     }
     }
-    /*
-    @GetMapping("KongLogin")
-    public String KongLogin(HttpServletRequest request, HttpServletResponse response){
-        String jstoken = request.getHeader("Kong-Access-Token");
-        String errToken = request.getHeader("Kong-Access-Token-Error");
-
-        response.addHeader("Pragma", "no-cache");
-        response.addHeader("Cache-Control", "no-cache");
-
-        if(StringUtils.isNotBlank(jstoken)) {
-            try {
-                int firstPeriod = jstoken.indexOf('.');
-                int lastPeriod = jstoken.lastIndexOf('.');
-                jstoken = jstoken.substring(firstPeriod + 1, lastPeriod);
-                if (firstPeriod > 0 && lastPeriod > firstPeriod) {
-                    String tokenDecode = Charset.forName("UTF-8").decode(ByteBuffer.wrap
-                            (Base64.getUrlDecoder().decode(jstoken))).toString();
-                    logger.info("KongLogin,tekenDecode:" + tokenDecode);
-                    JsonNode result = JsonMapper.GetJsonNode(tokenDecode);
-
-                    CfUsers User = userService.getUserByOAName(result.get("user_name").asText());
-
-                    if (StringUtils.isBlank(User.getUsername())) {
-                        User = userService.getUserByMobile(result.get("mobile").asText());
-                    }
-
-                    if (User != null && StringUtils.isNotBlank(User.getUsername())) {
-
-                        Cookie cookie = new Cookie(jwtUtils.getTokenName(), jwtUtils.generateToken(User.getUserid()));
-                        cookie.setHttpOnly(true);
-                        cookie.setPath("/");
-                        response.addCookie(cookie);
-
-                        List<HashMap<String, Object>> roleList = this.roleService.getRoleByUserName(User.getUsername());
-                        if (roleList == null || roleList.isEmpty()) {
-                            this.roleService.insertUserRole(User.getUsername(), "0b45886a-a8db-4f85-af76-61a8ea7c1dab");
-
-                        }
 
 
-                        userService.loginForceStatu(User.getUserid(), 0);
-
-                        logService.log("用户登录", User.getUserid(), "login");
-                        return "redirect:/app/main/index.html";
-
-                    } else {
-                        return "无该用户";
-                    }
-                }
-
-            } catch (Exception ex) {
-
-                logger.error("KongLogin", ex);
-            }
-        }
-
-        if(StringUtils.isNotBlank(errToken)){
-            String tokenDecode = Charset.forName("UTF-8").decode(ByteBuffer.wrap
-                    (Base64.getUrlDecoder().decode(errToken))).toString();
-
-            return tokenDecode;
-        }
+    @GetMapping("mobile")
+    public String mobile(String routePath, String code) throws UnsupportedEncodingException {
+        log.info("mobile:routePath=" + routePath + ",code=" + code);
+        if (!stringUtils.IsNullOrEmpty(routePath))
+            return "redirect:/mobile/index.html/#/index?routePath=" + URLEncoder.encode(routePath, "UTF-8") + "&code=" + code;
 
 
-        return "redirect:/app/main/index.html";
+        return "redirect:/mobile/index.html/#/index?code=" + (!stringUtils.IsNullOrEmpty(code) ? code : "");
     }
     }
-    */
+
 }
 }

+ 1 - 0
src/main/java/com/ghsc/partybuild/controller/wechat/WxCpController.java

@@ -36,6 +36,7 @@ public class WxCpController {
 
 
     @GetMapping("getWxCpUserId")
     @GetMapping("getWxCpUserId")
     public BaseResponse<String> getWxCpUserId(String code) throws WxErrorException {
     public BaseResponse<String> getWxCpUserId(String code) throws WxErrorException {
+        log.info("getWxCpUserId-request:code=" + code);
         return RespGenerstor.success(wechatCpService.getWxCpUserId(code));
         return RespGenerstor.success(wechatCpService.getWxCpUserId(code));
     }
     }
 
 

+ 6 - 3
src/main/java/com/ghsc/partybuild/service/wechat/WechatCpServiceImpl.java

@@ -1,11 +1,13 @@
 package com.ghsc.partybuild.service.wechat;
 package com.ghsc.partybuild.service.wechat;
 
 
 import com.ghsc.partybuild.util.DateUtils;
 import com.ghsc.partybuild.util.DateUtils;
+import com.ghsc.partybuild.util.JsonMapper;
 import com.ghsc.partybuild.util.StringUtils;
 import com.ghsc.partybuild.util.StringUtils;
 import com.ghsc.partybuild.util.UrlUtils;
 import com.ghsc.partybuild.util.UrlUtils;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.cp.api.WxCpChatService;
 import me.chanjar.weixin.cp.api.WxCpChatService;
 import me.chanjar.weixin.cp.api.WxCpService;
 import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,9 +42,10 @@ public class WechatCpServiceImpl implements WechatCpService {
 
 
     @Override
     @Override
     public String getWxCpUserId(String code) throws WxErrorException {
     public String getWxCpUserId(String code) throws WxErrorException {
-        String userId = wxCpService.getOauth2Service().getAuthUserInfo(code).getUserId();
-        logger.info("getWxCpUserId:code=" + code + ",userId=" + userId);
-        return userId;
+        //WxCpOauth2UserInfo userInfo = wxCpService.getOauth2Service().getAuthUserInfo(code);新接口返回null,使用旧接口
+        WxCpOauth2UserInfo userInfo = wxCpService.getOauth2Service().getUserInfo(code);
+        logger.info("getWxCpUserId-return:code=" + code + ",userId=" + userInfo.getUserId());
+        return userInfo.getUserId();
     }
     }
 
 
 }
 }

+ 1 - 1
src/main/resources/application.yml

@@ -163,7 +163,7 @@ wx:
   cp:
   cp:
     configs:
     configs:
       corpId: wwb4941d05cf8473e4
       corpId: wwb4941d05cf8473e4
-      corpsecret: corpsecretid
+      corpsecret: ohU54VhB-POaD5g4h-ZT3M72BgdAp279VuW_l-v6FWI
       agentId: 1000004
       agentId: 1000004
       redirectUrl: www.bowintek.com/ghsc/mobile
       redirectUrl: www.bowintek.com/ghsc/mobile
 
 

+ 18 - 0
src/main/resources/static/app/main/bigdata/showDjdsj/home.js

@@ -41,6 +41,24 @@
         };
         };
         $scope.load_dwxx();
         $scope.load_dwxx();
 
 
+        //党组织信息
+        $scope.dzz_total = {};
+        $scope.load_dzzcount = function () {
+            $http
+            ({
+                method: 'get',
+                url: '../../api/bigdata/getDzzxxCount',
+                params: {
+
+                }
+            }).then(function (result) {
+                if (result.data != null) {
+                    $scope.dzz_total = result.data;
+                }
+            });
+        };
+        $scope.load_dzzcount();
+
 
 
         //党员信息
         //党员信息
         $scope.dyxx = {};
         $scope.dyxx = {};