Переглянути джерело

Merge remote-tracking branch 'origin/master'

lizeyu 7 місяців тому
батько
коміт
9a38e6241b

+ 4 - 0
lib/数据更新脚本.txt

@@ -188,3 +188,7 @@ INSERT INTO `cf_menu` (`MENUID`, `APPLICATIONID`, `PARENTMENUID`, `MNUSYSTEM`, `
 INSERT INTO `cf_dictionary` (`DICTIONARYID`, `DICKEY`, `DICVALUE`, `DICTYPEKEY`, `DICTYPE`, `APPLICATIONID`, `DICNOTE`, `OPERATETIME`, `OPERATESTATE`, `SYNCSTATE`) VALUES ('058a7fc0-0000-0001-9999-bdb74a278a72', 1, '媒体报道', 'fcType', 2, 'f0c4fa7f9f3c4fb6bd56aac608b7ad3f', '风采类型', '2019-09-26 15:13:15', 'M', 'N');
 INSERT INTO `cf_dictionary` (`DICTIONARYID`, `DICKEY`, `DICVALUE`, `DICTYPEKEY`, `DICTYPE`, `APPLICATIONID`, `DICNOTE`, `OPERATETIME`, `OPERATESTATE`, `SYNCSTATE`) VALUES ('058a7fc0-0000-0001-9999-bdb74a278a72', 1, '媒体报道', 'fcType', 2, 'f0c4fa7f9f3c4fb6bd56aac608b7ad3f', '风采类型', '2019-09-26 15:13:15', 'M', 'N');
 INSERT INTO `cf_dictionary` (`DICTIONARYID`, `DICKEY`, `DICVALUE`, `DICTYPEKEY`, `DICTYPE`, `APPLICATIONID`, `DICNOTE`, `OPERATETIME`, `OPERATESTATE`, `SYNCSTATE`) VALUES ('058a7fc0-0000-0002-9999-bdb74a278a72', 2, '其他', 'fcType', 2, 'f0c4fa7f9f3c4fb6bd56aac608b7ad3f', '风采类型', '2019-09-26 15:13:15', 'M', 'N');
 INSERT INTO `cf_dictionary` (`DICTIONARYID`, `DICKEY`, `DICVALUE`, `DICTYPEKEY`, `DICTYPE`, `APPLICATIONID`, `DICNOTE`, `OPERATETIME`, `OPERATESTATE`, `SYNCSTATE`) VALUES ('058a7fc0-0000-0002-9999-bdb74a278a72', 2, '其他', 'fcType', 2, 'f0c4fa7f9f3c4fb6bd56aac608b7ad3f', '风采类型', '2019-09-26 15:13:15', 'M', 'N');
 
 
+
+-- 2024.7.19
+alter table cf_users add wxUserId varchar(50);
+

+ 28 - 0
parth5/parth5/src/app/api/account/index.ts

@@ -0,0 +1,28 @@
+import {ConfigService, RequsetData} from "../../service/config.service";
+import {Injectable} from "@angular/core";
+import {Observable} from "rxjs";
+import {DESModel, DesService} from "../../service/des.service";
+
+@Injectable({providedIn: 'root'})
+export class AccountApi {
+  constructor(private configService: ConfigService, private desService: DesService) {
+  }
+
+  login(model: DESModel): Observable<RequsetData> {
+    return this.configService.HttpGetRomote('/appApi/home/login', model);
+  }
+
+  loginByWxUserId(wxUserId: string): Observable<RequsetData> {
+    let desModel = this.desService.GetToken(wxUserId);
+    return this.configService.HttpPostRomote('/appApi/home/loginByWxUserId', desModel);
+  }
+
+  bindWxUserId(userId: string, wxUserId: string): Observable<RequsetData> {
+    return this.configService.HttpPostRomote('/appApi/home/bindWxUserId', {
+      userId: userId,
+      wxUserId: wxUserId
+    });
+  }
+
+}
+

+ 23 - 0
parth5/parth5/src/app/api/wechat/index.ts

@@ -0,0 +1,23 @@
+import {ConfigService, RequsetData} from "../../service/config.service";
+import {Injectable} from "@angular/core";
+import {Observable} from "rxjs";
+
+@Injectable({providedIn: 'root'})
+export class WechatApi {
+  constructor(private configService: ConfigService) {
+  }
+
+  getOAuthUrl(redirectUrl:string):Observable<RequsetData> {
+    return this.configService.HttpGetRomote('/wxapi/cp/getOAuthUrl', {
+      redirectUrl
+    });
+  }
+
+  getWxCpUserId(code:string):Observable<RequsetData> {
+    return this.configService.HttpGetRomote('/wxapi/cp/getWxCpUserId', {
+      code
+    });
+  }
+
+}
+

+ 2 - 1
parth5/parth5/src/app/app-routing.module.ts

@@ -3,7 +3,8 @@ import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
 
 
 const routes: Routes = [
 const routes: Routes = [
   { path: 'tapp', loadChildren: () => import('./views/tapp/tabs/tabs.module').then(m => m.TabsPageModule)},
   { path: 'tapp', loadChildren: () => import('./views/tapp/tabs/tabs.module').then(m => m.TabsPageModule)},
-  { path: '', loadChildren: () => import('./views/login/login.module').then(m => m.LoginPageModule) },
+  { path: 'login', loadChildren: () => import('./views/login/login.module').then(m => m.LoginPageModule) },
+  { path: '', loadChildren: () => import('./views/index/index.module').then(m => m.IndexPageModule) },
   {
   {
     path: '**',
     path: '**',
     redirectTo: ''
     redirectTo: ''

+ 2 - 11
parth5/parth5/src/app/app.component.ts

@@ -1,13 +1,4 @@
 import {Component} from '@angular/core';
 import {Component} from '@angular/core';
-import {ActivatedRoute, Router} from "@angular/router";
-import {ConfigService} from "./service/config.service";
-import {UserService} from "./service/user.service";
-import {JsBridgeService} from "./service/js-bridge.service";
-import {DesService} from "./service/des.service";
-import {LoadingController} from "@ionic/angular";
-import {UsemodularService} from "./service/usemodular.service";
-import {WxpayService} from "./service/wxpay.service";
-
 
 
 @Component({
 @Component({
   selector: 'app-root',
   selector: 'app-root',
@@ -15,10 +6,10 @@ import {WxpayService} from "./service/wxpay.service";
   styleUrls: ['app.component.scss'],
   styleUrls: ['app.component.scss'],
 })
 })
 export class AppComponent {
 export class AppComponent {
-  constructor(private router: Router, private route: ActivatedRoute, private userService: UserService, private wxpayService: WxpayService) {
+  constructor() {
   }
   }
 
 
   ngOnInit() {
   ngOnInit() {
-    this.wxpayService.getWechatCode();
+
   }
   }
 }
 }

+ 57 - 0
parth5/parth5/src/app/service/account.service.ts

@@ -0,0 +1,57 @@
+import {Injectable, Inject} from '@angular/core';
+import {DOCUMENT} from '@angular/common';
+import {ConfigService, RequsetData} from "./config.service";
+import {from, Observable} from "rxjs";
+import * as moment from "./work.service";
+import {Router} from "@angular/router";
+import {AlertController} from "@ionic/angular";
+import {AccountApi} from "../api/account";
+import {UsemodularService} from "./usemodular.service";
+import {AlertModal} from "../comm/modal/alert";
+import {UserService} from "./user.service";
+
+
+@Injectable({providedIn: 'root'})
+export class AccountService {
+
+  constructor(private router: Router, private userService: UserService,
+              private configService: ConfigService, private accountApi: AccountApi, private usemodularService: UsemodularService, private alertModal: AlertModal) {
+
+  }
+
+
+  /**
+   * 根据微信用户id登录系统,如果未绑定则跳转到登陆页面
+   * @param wxUserId 企业微信用户id
+   * @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 {
+        this.alertModal.alert('微信用户未绑定或验证失败,请输入账号密码登录');
+        this.router.navigate(['/login']);
+      }
+    }, () => {
+      loading.dismiss();
+      this.alertModal.alert('微信用户未绑定或验证失败,请输入账号密码登录');
+      this.router.navigate(['/login']);
+    });
+  };
+
+
+}

+ 9 - 0
parth5/parth5/src/app/service/user.service.ts

@@ -16,6 +16,7 @@ export class UserService {
   userDataScope: string = '/appApi/home/UserDataScope';
   userDataScope: string = '/appApi/home/UserDataScope';
   tokenName = "logintoken";
   tokenName = "logintoken";
   openIDName = "userOpenID";
   openIDName = "userOpenID";
+  wxUserIdName = "wxUserId";
 
 
   constructor(@Inject(DOCUMENT) private document: any, private router: Router, private  alertController: AlertController) {
   constructor(@Inject(DOCUMENT) private document: any, private router: Router, private  alertController: AlertController) {
     this.win = this.document.defaultView;
     this.win = this.document.defaultView;
@@ -85,6 +86,14 @@ export class UserService {
     return this.lStorage[this.openIDName];
     return this.lStorage[this.openIDName];
   }
   }
 
 
+  setWxUserID(wxUserId: string) {
+    this.lStorage[this.wxUserIdName] = wxUserId;
+  }
+
+  getWxUserID() {
+    return this.lStorage[this.wxUserIdName];
+  }
+
   verifyToken() {
   verifyToken() {
     let token = this.lStorage[this.tokenName];
     let token = this.lStorage[this.tokenName];
     let url = location.href.split("#");
     let url = location.href.split("#");

+ 75 - 0
parth5/parth5/src/app/service/wxcp.service.ts

@@ -0,0 +1,75 @@
+import {Inject, Injectable} from '@angular/core';
+import {ConfigService, RequsetData} from "./config.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 {AlertController, LoadingController} from "@ionic/angular";
+import {ActivatedRoute, Router} from "@angular/router";
+import {AlertModal} from "../comm/modal/alert";
+import {WechatApi} from "../api/wechat";
+import {getUrlParams} from "../utils/urlUtils";
+
+@Injectable({
+  providedIn: 'root'
+})
+
+export class WxcpService {
+  private siteUrl: string = '';
+
+  constructor(@Inject(DOCUMENT) private document: any, private router: Router, private configService: ConfigService, private userService: UserService
+    , private alertModal: AlertModal, private wechatApi: WechatApi, private routeInfo: ActivatedRoute) {
+    this.configService.GetConfig().subscribe((config) => {
+      this.siteUrl = config.siteUrl;
+    });
+  }
+
+  isWechat = () => {
+    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"];
+
+      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("微信授权失败!");
+              }
+            });
+          } 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}
+              });
+            });
+          }
+        }
+      }
+
+      return "";
+    } catch (e) {
+      return Promise.reject(null);
+    }
+  }
+}

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

@@ -0,0 +1,73 @@
+/**
+ * 将对象添加当作参数拼接到URL上面
+ * @param baseUrl 需要拼接的url
+ * @param obj 参数对象
+ * @returns {string} 拼接后的对象
+ * 例子:
+ *  let obj = {a: '3', b: '4'}
+ *  setObjToUrlParams('www.baidu.com', obj)
+ *  ==>www.baidu.com?a=3&b=4
+ */
+export function setObjToUrlParams(baseUrl: string, obj: any): string {
+  let parameters = '';
+  let url = '';
+  for (const key in obj) {
+    parameters += `${key}=${encodeURIComponent(obj[key])}&`;
+  }
+  parameters = parameters.replace(/&$/, '');
+  if (/\?$/.test(baseUrl)) {
+    url = baseUrl + parameters;
+  } else {
+    url = baseUrl.replace(/\/?$/, '?') + parameters;
+  }
+  return url;
+}
+
+/**
+ * 将路径中重复的正斜杆替换成单个斜杆隔开的字符串
+ * @param path 要处理的路径
+ * @returns {string} 将/去重后的结果
+ */
+export const uniqueSlash = (path: string) => path.replace(/(https?:\/)|(\/)+/g, '$1$2');
+// Safari 不支持以下正则(反向否定查找) shit!
+// export const uniqueSlash = (path: string) => path.replace(/(?<!:)\/{2,}/g, '/');
+
+
+export function getUrlParams() {
+  /*let href = decodeURIComponent(location.href);
+  href = decodeURIComponent(href);*/
+  const href = location.href;
+
+  /*alert("href:"+href);*/
+  const theRequest = new Object();
+  let urls = [];
+  if (href.indexOf("#") != -1) {
+    const index = href.indexOf("#");
+    urls = [href.slice(0, index), href.slice(index + 1)];
+  } else {
+    urls = [href];
+  }
+
+  urls.forEach(url => {
+    if (url.indexOf("?") != -1) {
+      const index = url.indexOf("?");
+      const splits = [url.slice(0, index), url.slice(index + 1)];
+      const paramsUrl = splits[1];
+      const strs = paramsUrl.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
+        theRequest[paramsSplits[0]] = paramsSplits[1];
+      }
+    }
+  });
+
+  console.log(theRequest);
+
+  return theRequest;
+}

+ 17 - 0
parth5/parth5/src/app/views/index/index-routing.module.ts

@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+
+import { IndexPage } from './index.page';
+
+const routes: Routes = [
+  {
+    path: '',
+    component: IndexPage
+  }
+];
+
+@NgModule({
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule],
+})
+export class IndexPageRoutingModule {}

+ 20 - 0
parth5/parth5/src/app/views/index/index.module.ts

@@ -0,0 +1,20 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+
+import { IonicModule } from '@ionic/angular';
+
+import { IndexPageRoutingModule } from './index-routing.module';
+
+import { IndexPage } from './index.page';
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    IndexPageRoutingModule
+  ],
+  declarations: [IndexPage]
+})
+export class IndexPageModule {}

+ 3 - 0
parth5/parth5/src/app/views/index/index.page.html

@@ -0,0 +1,3 @@
+<ion-content>
+  系统加载中,请稍等...
+</ion-content>

+ 0 - 0
parth5/parth5/src/app/views/index/index.page.scss


+ 47 - 0
parth5/parth5/src/app/views/index/index.page.ts

@@ -0,0 +1,47 @@
+import {Component, OnInit} from '@angular/core';
+import {getUrlParams} from "../../utils/urlUtils";
+import {WxcpService} from "../../service/wxcp.service";
+import {ActivatedRoute, Router} from "@angular/router";
+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";
+
+@Component({
+  selector: 'app-index',
+  templateUrl: './index.page.html',
+  styleUrls: ['./index.page.scss'],
+})
+export class IndexPage implements OnInit {
+  private routePath = '';
+
+
+  constructor(private router: Router, private route: ActivatedRoute, private wxcpService: WxcpService, private userService: UserService,
+              private accountService: AccountService) {
+  }
+
+  ngOnInit() {
+  }
+
+  ionViewWillEnter() {
+    const urlParams = getUrlParams() as any;
+    this.routePath = urlParams["routePath"] || '/login';
+    this.routePath = decodeURIComponent(this.routePath);
+
+    if (this.wxcpService.isWechat() && this.routePath.indexOf("wxMessage") < 0) {
+      const wxUserId = urlParams["wxUserId"] || this.userService.getWxUserID();
+      if (wxUserId) {
+        //根据微信用户id登录系统
+        this.accountService.loginByWxUserId(wxUserId, null).then(e => {
+        });
+      } else {
+        this.wxcpService.wxAuth(this.routePath);
+      }
+    } else {
+      this.router.navigate([this.routePath], {queryParams: {random: Math.random()}});
+    }
+  }
+
+}

+ 6 - 0
parth5/parth5/src/app/views/login/login.page.html

@@ -14,6 +14,12 @@
     <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-checkbox [(ngModel)]="isBindWxUser"></ion-checkbox>
+    <ion-label style="padding-left: 10px;">绑定微信账号
+      <span>{{wxUserId}}</span>
+    </ion-label>
+  </ion-item>
   <div style="text-align: center;padding-top: 30px;">
   <div style="text-align: center;padding-top: 30px;">
     <ion-button clickLog logTitle="app.login-click" [logUserid]="userLid" logOpmodule="用户登录" fill="solid"
     <ion-button clickLog logTitle="app.login-click" [logUserid]="userLid" logOpmodule="用户登录" fill="solid"
                 (click)="Login()" style="width: 80%;font-size: 20px;font-weight: bold;--border-radius: 18px;height: 40px;--background:#E80000" >登    录
                 (click)="Login()" style="width: 80%;font-size: 20px;font-weight: bold;--border-radius: 18px;height: 40px;--background:#E80000" >登    录

+ 13 - 1
parth5/parth5/src/app/views/login/login.page.ts

@@ -8,6 +8,8 @@ import {DESModel, DesService} from '../../service/des.service';
 import {LoadingController} from '@ionic/angular';
 import {LoadingController} from '@ionic/angular';
 import {UsemodularService} from "../../service/usemodular.service";
 import {UsemodularService} from "../../service/usemodular.service";
 import {WxpayService} from "../../service/wxpay.service";
 import {WxpayService} from "../../service/wxpay.service";
+import {getUrlParams} from "../../utils/urlUtils";
+import {AccountApi} from "../../api/account";
 
 
 @Component({
 @Component({
   selector: 'app-login',
   selector: 'app-login',
@@ -22,11 +24,13 @@ export class LoginPage implements OnInit {
   userLid: string = '';
   userLid: string = '';
   userPwd: string = '';
   userPwd: string = '';
   isDev: boolean = false;
   isDev: boolean = false;
+  wxUserId: string = '';
+  isBindWxUser: boolean = false;
 
 
   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 wxpayService: WxpayService, private accountApi: AccountApi) {
     this.route.queryParams.subscribe(params => {
     this.route.queryParams.subscribe(params => {
 
 
     });
     });
@@ -36,6 +40,11 @@ export class LoginPage implements OnInit {
     });
     });
   }
   }
 
 
+  ionViewWillEnter() {
+    const urlParams = getUrlParams() as any;
+    this.wxUserId = urlParams["wxUserId"] || this.userService.getWxUserID();
+  }
+
   /*ionViewWillEnter(){
   /*ionViewWillEnter(){
     this.wxpayService.getWechatCode();
     this.wxpayService.getWechatCode();
   }*/
   }*/
@@ -64,6 +73,9 @@ export class LoginPage implements OnInit {
         this.userService.ReadUserDataScope(req.item.curRoleId, this.configService);
         this.userService.ReadUserDataScope(req.item.curRoleId, this.configService);
         this.usemodularService.getButtonList();
         this.usemodularService.getButtonList();
         //this.configService.HttpPostRomote()
         //this.configService.HttpPostRomote()
+        if (this.isBindWxUser) {
+          this.accountApi.bindWxUserId(this.userService.GetUser().userid, this.wxUserId).subscribe(e=>{});
+        }
         this.router.navigate(['/tapp/tabs/tabMain']);
         this.router.navigate(['/tapp/tabs/tabMain']);
       } else {
       } else {
         this.errorShow = true;
         this.errorShow = true;

+ 91 - 57
src/main/java/com/ghsc/partybuild/controller/app/AppHomeController.java

@@ -471,80 +471,114 @@ public class AppHomeController {
             if (cfUsers == null)
             if (cfUsers == null)
                 throw new Exception("");
                 throw new Exception("");
 
 
-            request.setAttribute("UserLoginId", desDatas[0]);
+            res = loginSuccessBack(response, request, cfUsers);
+        } catch (Exception ex) {
+            res.setSuccess(false);
+            res.setMsg("用户名或密码错误!");
+        }
 
 
-            user.put("id", cfUsers.getUserid());
-            user.putAll(userService.extendUserPartyInfo((String) user.get("id")));
-            user.put("userid", user.get("id"));
-            user.put("username", user.get("name"));
+        return res;
+    }
 
 
+    @PostMapping("/loginByWxUserId")
+    public RequsetData<Map<String, Object>> loginByWxUserId(HttpServletResponse response, HttpServletRequest request, @RequestBody DesModel model) {
+        RequsetData<Map<String, Object>> res = new RequsetData<>();
+        Map<String, Object> user = new HashMap<>();
+
+        try {
+            String dataLogin = commonService.DesTokenData(model.getToken(), dateUtils.DateToDateTime(model.getTm()));
+            String[] desDatas = dataLogin.split("\\|");
 
 
-            List<CfRoles> userRoles = roleService.getRolesByUid(user.get("id").toString());
-            Map<String, Object> ext = new HashMap<>();
-            ext.put("userRoles", userRoles);
+            CfUsers cfUsers = userService.loginByWxUserId(desDatas[0]);
+            if (cfUsers == null)
+                throw new Exception("");
 
 
-            if (userRoles.size() > 0 && user.get("id") != null) {
-                String dataDzzdm = userService.getUserDzzdmForShowData(user.get("id").toString(), userRoles.get(0).getRoleid()), dataDzzmc = "";
-                if (!stringUtils.IsNullOrEmpty(dataDzzdm)) {
-                    ZzZzqkxx party = partyService.getPartyByDm(dataDzzdm);
-                    dataDzzmc = party != null ? party.getDzzmc() : "";
-                }
+            res = loginSuccessBack(response, request, cfUsers);
 
 
-                user.put("dataDzzdm", dataDzzdm);//数据范围
-                user.put("dataDzzmc", dataDzzmc);//数据范围
-                user.put("dataScope", userService.getUserDataScope(user.get("id").toString(), userRoles.get(0).getRoleid()));//数据范围
-            }
-            if (user.get("DZZDM") != null) {
-                //个人所属党委
-                ZzZzqkxx dwModel = partyService.getUserDwInfo(user.get("DZZDM").toString());
-                if (dwModel != null) {
-                    user.put("dwdm", dwModel.getDzzdm());
-                    user.put("dwmc", dwModel.getDzzmc());
-                }
+        } catch (Exception ex) {
+            res.setSuccess(false);
+            res.setMsg("用户名或密码错误!");
+        }
 
 
-                //个人所属党支部(总支)
-                ZzZzqkxx dzzModel = partyService.getUserDZZInfo(user.get("DZZDM").toString());
-                if (dzzModel != null) {
-                    user.put("dzbdm", dzzModel.getDzzdm());
-                    user.put("dzbmc", dzzModel.getDzzmc());
-                }
+        return res;
+    }
+
+    public RequsetData<Map<String, Object>> loginSuccessBack(HttpServletResponse response, HttpServletRequest request, CfUsers cfUsers) {
+        RequsetData<Map<String, Object>> res = new RequsetData<>();
+        Map<String, Object> user = new HashMap<>();
+
+        request.setAttribute("UserLoginId", cfUsers.getUsername());
+
+        user.put("id", cfUsers.getUserid());
+        user.putAll(userService.extendUserPartyInfo((String) user.get("id")));
+        user.put("userid", user.get("id"));
+        user.put("username", user.get("name"));
+
+        List<CfRoles> userRoles = roleService.getRolesByUid(user.get("id").toString());
+        Map<String, Object> ext = new HashMap<>();
+        ext.put("userRoles", userRoles);
+
+        if (userRoles.size() > 0 && user.get("id") != null) {
+            String dataDzzdm = userService.getUserDzzdmForShowData(user.get("id").toString(), userRoles.get(0).getRoleid()), dataDzzmc = "";
+            if (!stringUtils.IsNullOrEmpty(dataDzzdm)) {
+                ZzZzqkxx party = partyService.getPartyByDm(dataDzzdm);
+                dataDzzmc = party != null ? party.getDzzmc() : "";
             }
             }
 
 
-            ext.put("userInfo", partyUserService.getUserInfo(cfUsers.getUserid()));
-            res.setExtdata(ext);
+            user.put("dataDzzdm", dataDzzdm);//数据范围
+            user.put("dataDzzmc", dataDzzmc);//数据范围
+            user.put("dataScope", userService.getUserDataScope(user.get("id").toString(), userRoles.get(0).getRoleid()));//数据范围
+        }
+        if (user.get("DZZDM") != null) {
+            //个人所属党委
+            ZzZzqkxx dwModel = partyService.getUserDwInfo(user.get("DZZDM").toString());
+            if (dwModel != null) {
+                user.put("dwdm", dwModel.getDzzdm());
+                user.put("dwmc", dwModel.getDzzmc());
+            }
 
 
-            CfLog log = new CfLog();
+            //个人所属党支部(总支)
+            ZzZzqkxx dzzModel = partyService.getUserDZZInfo(user.get("DZZDM").toString());
+            if (dzzModel != null) {
+                user.put("dzbdm", dzzModel.getDzzdm());
+                user.put("dzbmc", dzzModel.getDzzmc());
+            }
+        }
 
 
-            log.setRequestip(IpUtils.getIpAddr(request));
-            log.setOpmodule("用户登录");
-            log.setUserid(user.get("id").toString());
-            log.setLogtitle("login");
-            log.setClientinfo("App");
-            log.setResponsetime(0);
-            log.setIserror(0);
-            logService.SaveLog(log);
+        ext.put("userInfo", partyUserService.getUserInfo(cfUsers.getUserid()));
+        res.setExtdata(ext);
 
 
-            UsernamePasswordToken userToken = new UsernamePasswordToken(desDatas[0], desDatas[1].toUpperCase());
-            org.apache.shiro.subject.Subject currentUser = SecurityUtils.getSubject();
-            currentUser.login(userToken);
-            String token = jwtUtils.generateToken(cfUsers.getUserid());
+        CfLog log = new CfLog();
+        log.setRequestip(IpUtils.getIpAddr(request));
+        log.setOpmodule("用户登录");
+        log.setUserid(user.get("id").toString());
+        log.setLogtitle("login");
+        log.setClientinfo("App");
+        log.setResponsetime(0);
+        log.setIserror(0);
+        logService.SaveLog(log);
 
 
-            /*Cookie cookie = new Cookie(jwtUtils.getTokenName(), token);
-            cookie.setHttpOnly(true);
-            cookie.setPath("/");
-            response.addCookie(cookie);*/
+        UsernamePasswordToken userToken = new UsernamePasswordToken(cfUsers.getUsername(), cfUsers.getUserpwd().toUpperCase());
+        org.apache.shiro.subject.Subject currentUser = SecurityUtils.getSubject();
+        currentUser.login(userToken);
+        String token = jwtUtils.generateToken(cfUsers.getUserid());
 
 
-            user.put(jwtUtils.getTokenName(), token);
+        user.put(jwtUtils.getTokenName(), token);
 
 
-            res.setItem(user);
+        res.setItem(user);
 
 
-            res.setSuccess(true);
+        res.setSuccess(true);
 
 
-        } catch (Exception ex) {
-            res.setSuccess(false);
-            res.setMsg("用户名或密码错误!");
-        }
 
 
         return res;
         return res;
     }
     }
+
+    @PostMapping("/bindWxUserId")
+    public void bindWxUserId(@RequestBody Map<String, Object> reqMap) {
+        String userId = reqMap.get("userId").toString();
+        String wxUserId = reqMap.get("wxUserId").toString();
+
+        userService.bindWxUserId(userId, wxUserId);
+    }
+
 }
 }

+ 10 - 0
src/main/java/com/ghsc/partybuild/model/CfUsers.java

@@ -21,6 +21,8 @@ public class CfUsers {
 
 
     private String oausersfz;
     private String oausersfz;
 
 
+    private String wxuserid;
+
     public String getUserid() {
     public String getUserid() {
         return userid;
         return userid;
     }
     }
@@ -92,4 +94,12 @@ public class CfUsers {
     public void setOausersfz(String oausersfz) {
     public void setOausersfz(String oausersfz) {
         this.oausersfz = oausersfz == null ? null : oausersfz.trim();
         this.oausersfz = oausersfz == null ? null : oausersfz.trim();
     }
     }
+
+    public String getWxuserid() {
+        return wxuserid;
+    }
+
+    public void setWxuserid(String wxuserid) {
+        this.wxuserid = wxuserid == null ? null : wxuserid.trim();
+    }
 }
 }

+ 70 - 0
src/main/java/com/ghsc/partybuild/model/CfUsersExample.java

@@ -704,6 +704,76 @@ public class CfUsersExample {
             addCriterion("OAUSERSFZ not between", value1, value2, "oausersfz");
             addCriterion("OAUSERSFZ not between", value1, value2, "oausersfz");
             return (Criteria) this;
             return (Criteria) this;
         }
         }
+
+        public Criteria andWxuseridIsNull() {
+            addCriterion("wxUserId is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridIsNotNull() {
+            addCriterion("wxUserId is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridEqualTo(String value) {
+            addCriterion("wxUserId =", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridNotEqualTo(String value) {
+            addCriterion("wxUserId <>", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridGreaterThan(String value) {
+            addCriterion("wxUserId >", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridGreaterThanOrEqualTo(String value) {
+            addCriterion("wxUserId >=", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridLessThan(String value) {
+            addCriterion("wxUserId <", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridLessThanOrEqualTo(String value) {
+            addCriterion("wxUserId <=", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridLike(String value) {
+            addCriterion("wxUserId like", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridNotLike(String value) {
+            addCriterion("wxUserId not like", value, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridIn(List<String> values) {
+            addCriterion("wxUserId in", values, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridNotIn(List<String> values) {
+            addCriterion("wxUserId not in", values, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridBetween(String value1, String value2) {
+            addCriterion("wxUserId between", value1, value2, "wxuserid");
+            return (Criteria) this;
+        }
+
+        public Criteria andWxuseridNotBetween(String value1, String value2) {
+            addCriterion("wxUserId not between", value1, value2, "wxuserid");
+            return (Criteria) this;
+        }
     }
     }
 
 
     public static class Criteria extends GeneratedCriteria {
     public static class Criteria extends GeneratedCriteria {

+ 4 - 0
src/main/java/com/ghsc/partybuild/service/UserService.java

@@ -412,4 +412,8 @@ public interface UserService {
 
 
     CfUsers login(String account,String password);
     CfUsers login(String account,String password);
 
 
+    CfUsers loginByWxUserId(String wxUserId);
+
+    void bindWxUserId(String userId,String wxUserId);
+
 }
 }

+ 15 - 0
src/main/java/com/ghsc/partybuild/service/impl/UserServiceImpl.java

@@ -1280,4 +1280,19 @@ public class UserServiceImpl implements UserService {
 
 
         return cfUsersMapper.selectByExample(exp).stream().findFirst().orElse(null);
         return cfUsersMapper.selectByExample(exp).stream().findFirst().orElse(null);
     }
     }
+
+    public CfUsers loginByWxUserId(String wxUserId) {
+        CfUsersExample exp = new CfUsersExample();
+        CfUsersExample.Criteria cri = exp.or();
+        cri.andWxuseridEqualTo(wxUserId.trim());
+
+        return cfUsersMapper.selectByExample(exp).stream().findFirst().orElse(null);
+    }
+
+    public void bindWxUserId(String userId, String wxUserId) {
+        CfUsers cfUsers = cfUsersMapper.selectByPrimaryKey(userId);
+        cfUsers.setWxuserid(wxUserId);
+
+        cfUsersMapper.updateByPrimaryKey(cfUsers);
+    }
 }
 }

+ 40 - 25
src/main/resources/mapping/CfUsersMapper.xml

@@ -11,6 +11,7 @@
     <result column="FORCELOGINOUT" jdbcType="DECIMAL" property="forceloginout" />
     <result column="FORCELOGINOUT" jdbcType="DECIMAL" property="forceloginout" />
     <result column="OAUSERID" jdbcType="VARCHAR" property="oauserid" />
     <result column="OAUSERID" jdbcType="VARCHAR" property="oauserid" />
     <result column="OAUSERSFZ" jdbcType="VARCHAR" property="oausersfz" />
     <result column="OAUSERSFZ" jdbcType="VARCHAR" property="oausersfz" />
+    <result column="wxUserId" jdbcType="VARCHAR" property="wxuserid" />
   </resultMap>
   </resultMap>
   <sql id="Example_Where_Clause">
   <sql id="Example_Where_Clause">
     <where>
     <where>
@@ -72,7 +73,7 @@
   </sql>
   </sql>
   <sql id="Base_Column_List">
   <sql id="Base_Column_List">
     USERID, APPLICATIONID, USERNAME, ISANONYMOUS, LASTACTIVITYDATE, USERPWD, FORCELOGINOUT, 
     USERID, APPLICATIONID, USERNAME, ISANONYMOUS, LASTACTIVITYDATE, USERPWD, FORCELOGINOUT, 
-    OAUSERID, OAUSERSFZ
+    OAUSERID, OAUSERSFZ, wxUserId
   </sql>
   </sql>
   <select id="selectByExample" parameterType="com.ghsc.partybuild.model.CfUsersExample" resultMap="BaseResultMap">
   <select id="selectByExample" parameterType="com.ghsc.partybuild.model.CfUsersExample" resultMap="BaseResultMap">
     select
     select
@@ -89,7 +90,7 @@
     </if>
     </if>
   </select>
   </select>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
-    select
+    select 
     <include refid="Base_Column_List" />
     <include refid="Base_Column_List" />
     from cf_users
     from cf_users
     where USERID = #{userid,jdbcType=VARCHAR}
     where USERID = #{userid,jdbcType=VARCHAR}
@@ -105,14 +106,14 @@
     </if>
     </if>
   </delete>
   </delete>
   <insert id="insert" parameterType="com.ghsc.partybuild.model.CfUsers">
   <insert id="insert" parameterType="com.ghsc.partybuild.model.CfUsers">
-    insert into cf_users (USERID, APPLICATIONID, USERNAME,
-                          ISANONYMOUS, LASTACTIVITYDATE, USERPWD,
-                          FORCELOGINOUT, OAUSERID, OAUSERSFZ
-    )
-    values (#{userid,jdbcType=VARCHAR}, #{applicationid,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
-            #{isanonymous,jdbcType=INTEGER}, #{lastactivitydate,jdbcType=TIMESTAMP}, #{userpwd,jdbcType=VARCHAR},
-            #{forceloginout,jdbcType=DECIMAL}, #{oauserid,jdbcType=VARCHAR}, #{oausersfz,jdbcType=VARCHAR}
-           )
+    insert into cf_users (USERID, APPLICATIONID, USERNAME, 
+      ISANONYMOUS, LASTACTIVITYDATE, USERPWD, 
+      FORCELOGINOUT, OAUSERID, OAUSERSFZ, 
+      wxUserId)
+    values (#{userid,jdbcType=VARCHAR}, #{applicationid,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, 
+      #{isanonymous,jdbcType=INTEGER}, #{lastactivitydate,jdbcType=TIMESTAMP}, #{userpwd,jdbcType=VARCHAR}, 
+      #{forceloginout,jdbcType=DECIMAL}, #{oauserid,jdbcType=VARCHAR}, #{oausersfz,jdbcType=VARCHAR}, 
+      #{wxuserid,jdbcType=VARCHAR})
   </insert>
   </insert>
   <insert id="insertSelective" parameterType="com.ghsc.partybuild.model.CfUsers">
   <insert id="insertSelective" parameterType="com.ghsc.partybuild.model.CfUsers">
     insert into cf_users
     insert into cf_users
@@ -144,6 +145,9 @@
       <if test="oausersfz != null">
       <if test="oausersfz != null">
         OAUSERSFZ,
         OAUSERSFZ,
       </if>
       </if>
+      <if test="wxuserid != null">
+        wxUserId,
+      </if>
     </trim>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="userid != null">
       <if test="userid != null">
@@ -173,6 +177,9 @@
       <if test="oausersfz != null">
       <if test="oausersfz != null">
         #{oausersfz,jdbcType=VARCHAR},
         #{oausersfz,jdbcType=VARCHAR},
       </if>
       </if>
+      <if test="wxuserid != null">
+        #{wxuserid,jdbcType=VARCHAR},
+      </if>
     </trim>
     </trim>
   </insert>
   </insert>
   <select id="countByExample" parameterType="com.ghsc.partybuild.model.CfUsersExample" resultType="java.lang.Long">
   <select id="countByExample" parameterType="com.ghsc.partybuild.model.CfUsersExample" resultType="java.lang.Long">
@@ -211,6 +218,9 @@
       <if test="record.oausersfz != null">
       <if test="record.oausersfz != null">
         OAUSERSFZ = #{record.oausersfz,jdbcType=VARCHAR},
         OAUSERSFZ = #{record.oausersfz,jdbcType=VARCHAR},
       </if>
       </if>
+      <if test="record.wxuserid != null">
+        wxUserId = #{record.wxuserid,jdbcType=VARCHAR},
+      </if>
     </set>
     </set>
     <if test="_parameter != null">
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
       <include refid="Update_By_Example_Where_Clause" />
@@ -219,14 +229,15 @@
   <update id="updateByExample" parameterType="map">
   <update id="updateByExample" parameterType="map">
     update cf_users
     update cf_users
     set USERID = #{record.userid,jdbcType=VARCHAR},
     set USERID = #{record.userid,jdbcType=VARCHAR},
-    APPLICATIONID = #{record.applicationid,jdbcType=VARCHAR},
-    USERNAME = #{record.username,jdbcType=VARCHAR},
-    ISANONYMOUS = #{record.isanonymous,jdbcType=INTEGER},
-    LASTACTIVITYDATE = #{record.lastactivitydate,jdbcType=TIMESTAMP},
-    USERPWD = #{record.userpwd,jdbcType=VARCHAR},
-    FORCELOGINOUT = #{record.forceloginout,jdbcType=DECIMAL},
-    OAUSERID = #{record.oauserid,jdbcType=VARCHAR},
-    OAUSERSFZ = #{record.oausersfz,jdbcType=VARCHAR}
+      APPLICATIONID = #{record.applicationid,jdbcType=VARCHAR},
+      USERNAME = #{record.username,jdbcType=VARCHAR},
+      ISANONYMOUS = #{record.isanonymous,jdbcType=INTEGER},
+      LASTACTIVITYDATE = #{record.lastactivitydate,jdbcType=TIMESTAMP},
+      USERPWD = #{record.userpwd,jdbcType=VARCHAR},
+      FORCELOGINOUT = #{record.forceloginout,jdbcType=DECIMAL},
+      OAUSERID = #{record.oauserid,jdbcType=VARCHAR},
+      OAUSERSFZ = #{record.oausersfz,jdbcType=VARCHAR},
+      wxUserId = #{record.wxuserid,jdbcType=VARCHAR}
     <if test="_parameter != null">
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
       <include refid="Update_By_Example_Where_Clause" />
     </if>
     </if>
@@ -258,19 +269,23 @@
       <if test="oausersfz != null">
       <if test="oausersfz != null">
         OAUSERSFZ = #{oausersfz,jdbcType=VARCHAR},
         OAUSERSFZ = #{oausersfz,jdbcType=VARCHAR},
       </if>
       </if>
+      <if test="wxuserid != null">
+        wxUserId = #{wxuserid,jdbcType=VARCHAR},
+      </if>
     </set>
     </set>
     where USERID = #{userid,jdbcType=VARCHAR}
     where USERID = #{userid,jdbcType=VARCHAR}
   </update>
   </update>
   <update id="updateByPrimaryKey" parameterType="com.ghsc.partybuild.model.CfUsers">
   <update id="updateByPrimaryKey" parameterType="com.ghsc.partybuild.model.CfUsers">
     update cf_users
     update cf_users
     set APPLICATIONID = #{applicationid,jdbcType=VARCHAR},
     set APPLICATIONID = #{applicationid,jdbcType=VARCHAR},
-        USERNAME = #{username,jdbcType=VARCHAR},
-        ISANONYMOUS = #{isanonymous,jdbcType=INTEGER},
-        LASTACTIVITYDATE = #{lastactivitydate,jdbcType=TIMESTAMP},
-        USERPWD = #{userpwd,jdbcType=VARCHAR},
-        FORCELOGINOUT = #{forceloginout,jdbcType=DECIMAL},
-        OAUSERID = #{oauserid,jdbcType=VARCHAR},
-        OAUSERSFZ = #{oausersfz,jdbcType=VARCHAR}
+      USERNAME = #{username,jdbcType=VARCHAR},
+      ISANONYMOUS = #{isanonymous,jdbcType=INTEGER},
+      LASTACTIVITYDATE = #{lastactivitydate,jdbcType=TIMESTAMP},
+      USERPWD = #{userpwd,jdbcType=VARCHAR},
+      FORCELOGINOUT = #{forceloginout,jdbcType=DECIMAL},
+      OAUSERID = #{oauserid,jdbcType=VARCHAR},
+      OAUSERSFZ = #{oausersfz,jdbcType=VARCHAR},
+      wxUserId = #{wxuserid,jdbcType=VARCHAR}
     where USERID = #{userid,jdbcType=VARCHAR}
     where USERID = #{userid,jdbcType=VARCHAR}
   </update>
   </update>
 </mapper>
 </mapper>