From 9c6db53e13d46995ce972090ef665439842e155f Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Tue, 2 Feb 2021 09:49:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=BF=94=E5=9B=9EunionId=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E7=AE=A1=E7=90=86=E5=88=97=E8=A1=A8=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=BA=E5=A4=87=E4=BB=BD=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/BusinessApplicationRequest.java | 3 + .../util/MyBatisPlusCodeGenerator.java | 2 +- .../src/main/resources/bootstrap.properties | 6 +- .../guarantee/DgApplyAmountListMapper.xml | 5 +- .../guarantee/DgAssetsInvestigationMapper.xml | 5 +- .../guarantee/DgBusinessCompanyMapper.xml | 1 + .../DgComplianceInvestigationMapper.xml | 9 +- .../guarantee/DgGuaranteeAssignUserMapper.xml | 5 +- .../DgGuaranteeLetterAssignUserMapper.xml | 5 +- .../DgLoanCommitteeConsiderMapper.xml | 9 +- .../mapper/guarantee/DgLoanNoticeMapper.xml | 5 +- .../DgMessageInvestigationMapper.xml | 5 +- .../DgPaymentConfirmationConsiderMapper.xml | 5 +- .../DgWorkConferenceConsiderMapper.xml | 9 +- dq-financial-hrms-auth/pom.xml | 29 ++++ .../controller/UserLoginController.java | 11 +- .../financial/hrauth/model/XccLoginReq.java | 25 ++++ .../hrauth/service/UserLoginService.java | 2 +- .../service/impl/UserLoginServiceImpl.java | 96 +++++++++++- .../hrauth/service/impl/UserServiceImpl.java | 3 +- .../financial/hrauth/util/AesCbcUtil.java | 92 ++++++++++++ .../financial/hrauth/util/HttpRequest.java | 137 ++++++++++++++++++ .../DqFinancialHrmsAuthApplicationTests.java | 47 ++++-- .../domain/guarantee/DgBusinessCompany.java | 5 + 24 files changed, 464 insertions(+), 57 deletions(-) create mode 100644 dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/model/XccLoginReq.java create mode 100644 dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/AesCbcUtil.java create mode 100644 dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/HttpRequest.java diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/BusinessApplicationRequest.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/BusinessApplicationRequest.java index f61f9e7e..37f4af09 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/BusinessApplicationRequest.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/BusinessApplicationRequest.java @@ -335,4 +335,7 @@ public class BusinessApplicationRequest implements Serializable { @ApiModelProperty(value = "联系电话(指个人或企业的)") private String phone; + @ApiModelProperty(value = "客户基本信息表id") + private Long customerId; + } diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/MyBatisPlusCodeGenerator.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/MyBatisPlusCodeGenerator.java index 6a43ebfe..1e7baa11 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/MyBatisPlusCodeGenerator.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/util/MyBatisPlusCodeGenerator.java @@ -25,7 +25,7 @@ public class MyBatisPlusCodeGenerator { public static final String PACKAGE_NAME = "com.daqing.financial.guarantee"; public static void main(String[] args) { - String[] tables = new String[] {"dg_business_company"};//表名数组 + String[] tables = new String[] {"dg_customer_related"};//表名数组 String[] tablePrefixs = new String[] {""};//去掉前缀 executeCode(PACKAGE_NAME,tables,tablePrefixs); } diff --git a/dq-financial-guarantee/src/main/resources/bootstrap.properties b/dq-financial-guarantee/src/main/resources/bootstrap.properties index 69a06a1a..564738e1 100644 --- a/dq-financial-guarantee/src/main/resources/bootstrap.properties +++ b/dq-financial-guarantee/src/main/resources/bootstrap.properties @@ -30,9 +30,9 @@ ribbon.ConnectTimeout: 120000 # 上传文件总的最大值 -#spring.servlet.multipart.max-request-size=10MB -## 单个文件的最大值 -#spring.servlet.multipart.max-file-size=10MB +spring.servlet.multipart.max-request-size=10MB +# 单个文件的最大值 +spring.servlet.multipart.max-file-size=10MB # ##正式环境(prod) ##服务名称 diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgApplyAmountListMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgApplyAmountListMapper.xml index a83cc50c..e8e56b79 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgApplyAmountListMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgApplyAmountListMapper.xml @@ -21,8 +21,9 @@ au.status,au.operating_status,cc.name,cc.phone,ps.business_status from dg_apply_amount_list au left join dg_apply_amount_info ai on au.business_id = ai.id - left join crms_company_customer ccl on ai.company_id = ccl.id - left join crms_customer cc on cc.id = ccl.customer_id + left join dg_business_company cc on cc.business_id = ai.id +/* left join crms_company_customer ccl on ai.company_id = ccl.id + left join crms_customer cc on cc.id = ccl.customer_id*/ left JOIN dg_business_process_status ps ON ps.business_id = au.business_id au.role_id in diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgAssetsInvestigationMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgAssetsInvestigationMapper.xml index dbc83ed0..f2406605 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgAssetsInvestigationMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgAssetsInvestigationMapper.xml @@ -37,8 +37,9 @@ au.status,au.operating_status,cc.name,cc.phone,ps.business_status from dg_assets_investigation au left join dg_apply_amount_info ai on au.business_id = ai.id - left join crms_company_customer ccl on ai.company_id = ccl.id - left join crms_customer cc on cc.id = ccl.customer_id + left join dg_business_company cc on cc.business_id = ai.id +/* left join crms_company_customer ccl on ai.company_id = ccl.id + left join crms_customer cc on cc.id = ccl.customer_id*/ left JOIN dg_business_process_status ps ON ps.business_id = au.business_id au.role_id in diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgBusinessCompanyMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgBusinessCompanyMapper.xml index cf9bbec3..5609bf42 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgBusinessCompanyMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgBusinessCompanyMapper.xml @@ -28,6 +28,7 @@ + diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgComplianceInvestigationMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgComplianceInvestigationMapper.xml index 4eeb9e6e..03103f2e 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgComplianceInvestigationMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgComplianceInvestigationMapper.xml @@ -23,14 +23,15 @@ FROM dg_compliance_investigation AS i LEFT JOIN dg_apply_amount_info AS a ON a.id = i.business_id - LEFT JOIN crms_company_customer AS cc + left join dg_business_company c on c.business_id = a.id +/* LEFT JOIN crms_company_customer AS cc ON a.company_id = cc.id LEFT JOIN crms_customer AS c - ON c.id = cc.customer_id + ON c.id = cc.customer_id*/ LEFT JOIN dg_business_process_status AS b ON b.business_id = a.id - WHERE c.del_or_not = 0 - AND (i.user_id = #{userId} OR i.user_id IS NULL) + WHERE /*c.del_or_not = 0*/ + /*AND */(i.user_id = #{userId} OR i.user_id IS NULL) AND i.role_id IN #{roleId} diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeAssignUserMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeAssignUserMapper.xml index 2a2aee97..5f9e292a 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeAssignUserMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeAssignUserMapper.xml @@ -24,8 +24,9 @@ au.status,au.operating_status,cc.name,cc.phone,ps.business_status from dg_guarantee_assign_user au left join dg_apply_amount_info ai on au.business_id = ai.id - left join crms_company_customer ccl on ai.company_id = ccl.id - left join crms_customer cc on cc.id = ccl.customer_id + left join dg_business_company cc on cc.business_id = ai.id +/* left join crms_company_customer ccl on ai.company_id = ccl.id + left join crms_customer cc on cc.id = ccl.customer_id*/ left JOIN dg_business_process_status ps ON ps.business_id = au.business_id au.role_id in diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeLetterAssignUserMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeLetterAssignUserMapper.xml index 539f437c..3630a7d9 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeLetterAssignUserMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgGuaranteeLetterAssignUserMapper.xml @@ -38,8 +38,9 @@ aai.bank,lcc.passing_time,lcc.file,lau.audit_opinion,lau.operating_status,bps.business_status,lau.business_id,lau.role_id from dg_guarantee_letter_assign_user lau left join dg_apply_amount_info aai on lau.business_id = aai.id - left join crms_company_customer ccc on lau.company_id = ccc.id - left join crms_customer cc on ccc.customer_id = cc.id + left join dg_business_company cc on cc.business_id = aai.id +/* left join crms_company_customer ccc on lau.company_id = ccc.id + left join crms_customer cc on ccc.customer_id = cc.id*/ left join dg_loan_committee_consider lcc on lau.business_id = lcc.business_id left join dg_business_process_status bps on lau.business_id = bps.business_id diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanCommitteeConsiderMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanCommitteeConsiderMapper.xml index a2b7be84..e3b69611 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanCommitteeConsiderMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanCommitteeConsiderMapper.xml @@ -26,14 +26,15 @@ FROM dg_loan_committee_consider AS l LEFT JOIN dg_apply_amount_info AS a ON a.id = l.business_id - LEFT JOIN crms_company_customer AS cc + left join dg_business_company c on c.business_id = a.id +/* LEFT JOIN crms_company_customer AS cc ON a.company_id = cc.id LEFT JOIN crms_customer AS c - ON cc.customer_id = c.id + ON cc.customer_id = c.id*/ LEFT JOIN dg_business_process_status AS b ON b.business_id = a.id - WHERE c.del_or_not = 0 - AND (l.consider_id = #{userId} OR l.consider_id IS NULL) + WHERE /*c.del_or_not = 0*/ + /*AND*/ (l.consider_id = #{userId} OR l.consider_id IS NULL) AND l.role_id IN #{roleId} diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanNoticeMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanNoticeMapper.xml index 6bc4de73..74832c58 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanNoticeMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgLoanNoticeMapper.xml @@ -37,8 +37,9 @@ aai.create_time,ln.status,aai.bank,ln.audit_opinion,ln.operating_status,bps.business_status,ln.business_id,lcc.passing_time from dg_loan_notice ln left join dg_apply_amount_info aai on ln.business_id = aai.id - left join crms_company_customer ccc on ln.company_id = ccc.id - left join crms_customer cc on ccc.customer_id = cc.id + left join dg_business_company cc on cc.business_id = aai.id +/* left join crms_company_customer ccc on ln.company_id = ccc.id + left join crms_customer cc on ccc.customer_id = cc.id*/ left join dg_loan_committee_consider lcc on ln.business_id = lcc.business_id left join dg_business_process_status bps on ln.business_id = bps.business_id diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgMessageInvestigationMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgMessageInvestigationMapper.xml index a51ea9d7..19d7e49c 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgMessageInvestigationMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgMessageInvestigationMapper.xml @@ -23,8 +23,9 @@ au.status,au.operating_status,cc.name,cc.phone,ps.business_status from dg_message_investigation au left join dg_apply_amount_info ai on au.business_id = ai.id - left join crms_company_customer ccl on ai.company_id = ccl.id - left join crms_customer cc on cc.id = ccl.customer_id + left join dg_business_company cc on cc.business_id = ai.id +/* left join crms_company_customer ccl on ai.company_id = ccl.id + left join crms_customer cc on cc.id = ccl.customer_id*/ left JOIN dg_business_process_status ps ON ps.business_id = au.business_id au.role_id in diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgPaymentConfirmationConsiderMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgPaymentConfirmationConsiderMapper.xml index 5eda1a53..cd9764ef 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgPaymentConfirmationConsiderMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgPaymentConfirmationConsiderMapper.xml @@ -40,8 +40,9 @@ aai.bank,lcc.passing_time,lcc.file,pcc.audit_opinion,pcc.operating_status,bps.business_status,pcc.business_id,pcc.img_file,pcc.role_id from dg_payment_confirmation_consider pcc left join dg_apply_amount_info aai on pcc.business_id = aai.id - left join crms_company_customer ccc on pcc.company_id = ccc.id - left join crms_customer cc on ccc.customer_id = cc.id + left join dg_business_company cc on cc.business_id = aai.id +/* left join crms_company_customer ccc on pcc.company_id = ccc.id + left join crms_customer cc on ccc.customer_id = cc.id*/ left join dg_loan_committee_consider lcc on pcc.business_id = lcc.business_id left join dg_business_process_status bps on pcc.business_id = bps.business_id diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgWorkConferenceConsiderMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgWorkConferenceConsiderMapper.xml index 26f3dab8..0c914bd1 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgWorkConferenceConsiderMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/DgWorkConferenceConsiderMapper.xml @@ -22,10 +22,11 @@ FROM dg_work_conference_consider AS w LEFT JOIN dg_apply_amount_info AS a ON a.id = w.business_id - LEFT JOIN crms_company_customer AS cc + left join dg_business_company c on c.business_id = a.id +/* LEFT JOIN crms_company_customer AS cc ON a.company_id = cc.id LEFT JOIN crms_customer AS c - ON cc.customer_id = c.id + ON cc.customer_id = c.id*/ LEFT JOIN dg_business_process_status AS b ON b.business_id = a.id LEFT JOIN (SELECT business_id,SUM(CASE role_id WHEN 59 THEN emp_id ELSE 0 END) AS A, @@ -38,8 +39,8 @@ ON a.id = ass.business_id LEFT JOIN dg_message_investigation AS m ON a.id = m.business_id - WHERE c.del_or_not = 0 - AND (w.user_id = #{userId} OR w.user_id IS NULL) + WHERE /*c.del_or_not = 0*/ + /*AND*/ (w.user_id = #{userId} OR w.user_id IS NULL) AND w.role_id IN #{roleId} diff --git a/dq-financial-hrms-auth/pom.xml b/dq-financial-hrms-auth/pom.xml index 1e7f00ba..2d1f050e 100644 --- a/dq-financial-hrms-auth/pom.xml +++ b/dq-financial-hrms-auth/pom.xml @@ -82,6 +82,35 @@ org.springframework.boot spring-boot-starter-web + + + cn.hutool + hutool-all + 5.3.8 + + + + org.codehaus.xfire + xfire-core + 1.2.6 + + + com.vaadin.external.google + android-json + 0.0.20131108.vaadin1 + compile + + + org.bouncycastle + bcprov-jdk16 + 1.46 + + + org.springframework.boot + spring-boot-test + 2.3.5.RELEASE + test + diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java index f4a4f6b6..73f493b4 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.daqing.financial.hrauth.UserLoginControllerApi; import com.daqing.financial.hrauth.config.WeChatConfig; import com.daqing.financial.hrauth.feign.HrmsFeignService; +import com.daqing.financial.hrauth.model.XccLoginReq; import com.daqing.financial.hrauth.service.UserLoginService; import com.daqing.financial.hrauth.service.UserService; import com.daqing.framework.domain.hrms.EmployeeEntity; @@ -217,14 +218,16 @@ public class UserLoginController implements UserLoginControllerApi { /** * 微信小程序获取openid和session_key授权登录 - * @param code + * @param * @return */ @PostMapping(value = "/wxAuthLogin") - public ResponseResult wxAuthLogin(@RequestBody String code){ + public ResponseResult wxAuthLogin(@RequestBody XccLoginReq xccLoginReq){ - String openid = userLoginService.wxAuthLogin(code); + String encryptedData = xccLoginReq.getEncryptedData(); + String code = xccLoginReq.getCode(); + String iv = xccLoginReq.getIv(); + String openid = userLoginService.wxAuthLogin(encryptedData,iv,code); return ResponseResult.SUCCESS(openid); } - } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/model/XccLoginReq.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/model/XccLoginReq.java new file mode 100644 index 00000000..d506f98c --- /dev/null +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/model/XccLoginReq.java @@ -0,0 +1,25 @@ +package com.daqing.financial.hrauth.model; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 访问记录表 + *

+ * + * @author Qyq + * @since 2021-01-12 + */ +@Data +public class XccLoginReq implements Serializable { + + private String encryptedData;//明文,加密数据 + private String iv;//加密算法的初始向量 + private String code;//用户允许登录后,回调内容会带上 code(有效期五分钟),开发者需要将 code 发送到开发者服务器后台 + // ,使用code 换取 session_key api,将 code 换成 openid 和 session_key + +} diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java index 0f41b478..4bc1693a 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java @@ -23,5 +23,5 @@ public interface UserLoginService extends IService { int isPhoneExist(String mobile); - String wxAuthLogin(String code); + String wxAuthLogin(String encryptedData, String iv,String code); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java index da918f7e..3fd05d67 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java @@ -1,5 +1,6 @@ package com.daqing.financial.hrauth.service.impl; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -13,17 +14,17 @@ import com.daqing.financial.hrauth.model.HrmsAccessRecordsLog; import com.daqing.financial.hrauth.service.LoginLogService; import com.daqing.financial.hrauth.service.TokenService; import com.daqing.financial.hrauth.service.UserLoginService; -import com.daqing.framework.domain.guarantee.response.EmployeeMessageResponse; +import com.daqing.financial.hrauth.util.AesCbcUtil; +import com.daqing.financial.hrauth.util.HttpRequest; +import com.daqing.financial.hrauth.util.HttpUtils; import com.daqing.framework.domain.hrms.*; import com.daqing.framework.domain.hrms.request.*; import com.daqing.framework.domain.hrms.response.HrmsCode; import com.daqing.framework.domain.hrms.response.LoginResponse; import com.daqing.framework.exception.ExceptionCast; -import com.daqing.framework.model.response.CommonCode; import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.util.JwtUtils; import com.daqing.framework.util.Md5Util; -import com.daqing.framework.util.RedisUtil; import com.daqing.framework.util.SendUtil; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; @@ -316,14 +317,75 @@ public class UserLoginServiceImpl extends ServiceImpl return userLoginDao.selectCount(mobile); } - @Override - public String wxAuthLogin(String code) { - System.out.println(code); +/* @Override + public String wxAuthLogin(String encryptedData, String iv,String code) { + System.out.println("code==="+code+"encryptedData==="+encryptedData+"iv===="+iv); System.out.println("来了小程序登录------------------------------------"); //微信那边的接口,grant_type=authorization_code是固定的 -/* String url="https://api.weixin.qq.com/sns/jscode2session?appid="+APPID+ - "&secret="+SECRET+"&js_code="+ code +"&grant_type=authorization_code";*/ + String url = String.format(weChatConfig.getWX_AUTH_URL(),weChatConfig.getXcxAppid(),weChatConfig.getXcxAppsecret(),code); + System.out.println("url==============="+url); + + //向微信服务器 使用登录凭证 code 获取 session_key 和 openid + // 请求参数 + String params = "appid=" + weChatConfig.getXcxAppid() + "&secret=" + weChatConfig.getXcxAppsecret() + "&js_code=" + code + "&grant_type=" + + "authorization_code"; + // 发送请求 + String sr = HttpRequest.sendGet("https://api.weixin.qq.com/sns/jscode2session", params); + + System.out.println("sr==================="+sr); + // 解析相应内容(转换成json对象) + //JSONObject json = JSON.parseObject(url); + cn.hutool.json.JSONObject json = new cn.hutool.json.JSONObject(sr); + // 获取会话密钥(session_key) + String session_key = json.get("session_key").toString(); + // 用户的唯一标识(openid) + String openid = (String) json.get("openid"); + + System.out.println("session_key======"+session_key+"openid===="+openid); + + Map map = new HashMap(); + + //对encryptedData加密数据进行AES解密 + try { + String result = AesCbcUtil.decrypt(encryptedData, session_key, iv, "UTF-8"); + if (null != result && result.length() > 0) { + map.put("status", 1); + map.put("msg", "解密成功"); + + //JSONObject userInfoJSON = JSON.parseObject(result); + cn.hutool.json.JSONObject userInfoJSON = new cn.hutool.json.JSONObject(result); + Map userInfo = new HashMap(); + userInfo.put("openId", userInfoJSON.get("openId")); + userInfo.put("nickName", userInfoJSON.get("nickName")); + userInfo.put("gender", userInfoJSON.get("gender")); + userInfo.put("city", userInfoJSON.get("city")); + userInfo.put("province", userInfoJSON.get("province")); + userInfo.put("country", userInfoJSON.get("country")); + userInfo.put("avatarUrl", userInfoJSON.get("avatarUrl")); + // 解密unionId & openId; + + System.out.println("userInfoJSON==============="+userInfoJSON); + System.out.println("unionId============"+userInfoJSON.get("unionId")); + userInfo.put("unionId", userInfoJSON.get("unionId")); + map.put("userInfo", userInfo); + } else { + map.put("status", 0); + map.put("msg", "解密失败"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("map===================="+map.get("unionId")); + return null; + }*/ + +/* @Override + public String wxAuthLogin(String encryptedData, String iv,String code) { + System.out.println(code); + System.out.println("来了小程序登录------------------------------------"); + //微信那边的接口,grant_type=authorization_code是固定的 String url = String.format(weChatConfig.getWX_AUTH_URL(),weChatConfig.getXcxAppid(),weChatConfig.getXcxAppsecret(),code); System.out.println("url==============="+url); @@ -356,6 +418,24 @@ public class UserLoginServiceImpl extends ServiceImpl } return result.toString(); + }*/ + + @Override + public String wxAuthLogin(String encryptedData, String iv,String code) { + System.out.println(code); + System.out.println("来了小程序登录------------------------------------"); + //微信那边的接口,grant_type=authorization_code是固定的 + String url = String.format(weChatConfig.getWX_AUTH_URL(),weChatConfig.getXcxAppid(),weChatConfig.getXcxAppsecret(),code); + + System.out.println("url==============="+url); + Map baseMap = HttpUtils.doGet(url); + if(baseMap == null || baseMap.isEmpty()){ return null; } + String accessToken = (String)baseMap.get("access_token"); + String openId = (String) baseMap.get("openid"); + String unionId = (String) baseMap.get("unionid"); + System.out.println("小程序登录openId============="+openId+"unionId=============="+unionId+"baseMap============"+baseMap); + + return unionId; } } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java index 33b5a1c6..d1642a07 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java @@ -58,7 +58,8 @@ public class UserServiceImpl extends ServiceImpl imple if(baseMap == null || baseMap.isEmpty()){ return null; } String accessToken = (String)baseMap.get("access_token"); String openId = (String) baseMap.get("openid"); - System.out.println("微信扫码加密前openId============="+openId); + String unionId = (String) baseMap.get("unionid"); + System.out.println("微信扫码加密前openId============="+openId+"unionId=============="+unionId+"baseMap============"+baseMap); //对code(回调过来的openid)加密 String md5OpenId = Md5Util.md5(openId); log.info("accessToken========> "+accessToken+"openId========> "+openId+"code=======> "+code+"md5OpenId============>"+md5OpenId); diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/AesCbcUtil.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/AesCbcUtil.java new file mode 100644 index 00000000..7dc84c7c --- /dev/null +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/AesCbcUtil.java @@ -0,0 +1,92 @@ +package com.daqing.financial.hrauth.util; + +import org.apache.commons.codec.binary.Base64; +import org.bouncycastle.jce.provider.BouncyCastleProvider; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.security.*; +import java.security.spec.InvalidParameterSpecException; + +/** + * Created by yfs on 2018/3/25. + *

+ * AES-128-CBC 加密方式 + * 注: + * AES-128-CBC可以自己定义“密钥”和“偏移量“。 + * AES-128是jdk自动生成的“密钥”。 + */ +public class AesCbcUtil { + + + static { + //BouncyCastle是一个开源的加解密解决方案,主页在http://www.bouncycastle.org/ + Security.addProvider(new BouncyCastleProvider()); + } + + /** + * AES解密 + * + * @param data //密文,被加密的数据 + * @param key //秘钥 + * @param iv //偏移量 + * @param encodingFormat //解密后的结果需要进行的编码 + * @return + * @throws Exception + */ + public static String decrypt(String data, String key, String iv, String encodingFormat) throws Exception { +// initialize(); + + //被加密的数据 + byte[] dataByte = Base64.decodeBase64(data); + //加密秘钥 + byte[] keyByte = Base64.decodeBase64(key); + //偏移量 + byte[] ivByte = Base64.decodeBase64(iv); + + + try { + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); + //Cipher cipher = Cipher.getInstance("AES/ECB/ZeroBytePadding"); + + SecretKeySpec spec = new SecretKeySpec(keyByte, "AES"); + + AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES"); + parameters.init(new IvParameterSpec(ivByte)); + + cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化 + //cipher.init(Cipher.ENCRYPT_MODE,key,new IvParameterSpec( java.util.Base64.Decoder.decode(IV.getBytes("UTF-8")))); + + byte[] resultByte = cipher.doFinal(dataByte); + if (null != resultByte && resultByte.length > 0) { + String result = new String(resultByte, encodingFormat); + return result; + } + return null; + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (NoSuchPaddingException e) { + e.printStackTrace(); + } catch (InvalidParameterSpecException e) { + e.printStackTrace(); + } catch (InvalidKeyException e) { + e.printStackTrace(); + } catch (InvalidAlgorithmParameterException e) { + e.printStackTrace(); + } catch (IllegalBlockSizeException e) { + e.printStackTrace(); + } catch (BadPaddingException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return null; + } + +} \ No newline at end of file diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/HttpRequest.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/HttpRequest.java new file mode 100644 index 00000000..217f5c59 --- /dev/null +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/HttpRequest.java @@ -0,0 +1,137 @@ +package com.daqing.financial.hrauth.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +public class HttpRequest { + + public static void main(String[] args) { + //发送 GET 请求 + String s=HttpRequest.sendGet("http://v.qq.com/x/cover/kvehb7okfxqstmc.html?vid=e01957zem6o", ""); + System.out.println(s); + +// //发送 POST 请求 +// String sr=HttpRequest.sendPost("http://www.toutiao.com/stream/widget/local_weather/data/?city=%E4%B8%8A%E6%B5%B7", ""); +// JSONObject json = JSONObject.fromObject(sr); +// System.out.println(json.get("data")); + } + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } +} \ No newline at end of file diff --git a/dq-financial-hrms-auth/src/test/java/com/daqing/financial/hrauth/DqFinancialHrmsAuthApplicationTests.java b/dq-financial-hrms-auth/src/test/java/com/daqing/financial/hrauth/DqFinancialHrmsAuthApplicationTests.java index 6ea6444c..23d264aa 100644 --- a/dq-financial-hrms-auth/src/test/java/com/daqing/financial/hrauth/DqFinancialHrmsAuthApplicationTests.java +++ b/dq-financial-hrms-auth/src/test/java/com/daqing/financial/hrauth/DqFinancialHrmsAuthApplicationTests.java @@ -1,13 +1,34 @@ -//package com.daqing.financial.hrauth; -// -//import org.junit.Test; -//import org.springframework.boot.test.context.SpringBootTest; -// -//@SpringBootTest -//class DqFinancialHrmsAuthApplicationTests { -// -// @Test -// void contextLoads() { -// } -// -//} +package com.daqing.financial.hrauth; + +import com.daqing.financial.hrauth.util.AesCbcUtil; +import org.junit.Test; +import org.springframework.boot.test.context.SpringBootTest; + +/*@SpringBootTest +class DqFinancialHrmsAuthApplicationTests { + + @Test + void contextLoads() throws Exception { + + String encryptedData="m7CF698f222KiEse8aFLIwSiXjxojbFesVpHltvrKPqKH3OclT7Qc+UhOw+MbxRAOSKgMb+erVYXYcrPwQ6TSF4VBt9Lzv0GdxJf82876SgANFURjVZBXKSwp0snxw/9wdfTGV2t7nIbpbUfBFD0QEi4rrsD8hZdPr4s/WLtHcpcvRkJvb3KDRw+PsnTyBtFOnXnv5sOJW84uy9OGuTTV8s0miqZCy//xZU2DJ3EZsg3Rp9E5xe0jMLtLOfvQEf5tM/pPw9hCkWbbBJEBSUn5IkSgkt3jAasjoWOSuDzw+MAJvnT7byJ7bvOSbEY14RAZzX6sZYw8Rd/n9fOssZivfF+F2HIfHhWuBNcGhNYTIYXtJsvmhtT5Wo4mMnq0j/TElZOoAjc385xkluHNRB/T+PVo+FEkRZgiugAOzOPn24WjZU7nbPrtoEYH5Bcdfcf3quP4hQAIQd6EvkfdnRti+Mfn925llWSS+fa+AV3hx0mwtFkk1VFMBuLPjL2nvvvUl4NkoMVzw0NRGPpeiS+DA=="; + String iv="jh3Io5uYeMSbU903QXpewA=="; + String session_key="LKv54UbAoCTx4yz5mi6S1A=="; + + + String result = AesCbcUtil.decrypt(encryptedData, session_key, iv, "UTF-8"); + System.out.println(result); + } + +}*/ + +class DqFinancialHrmsAuthApplicationTests{ + public static void main(String[] args) throws Exception { + String encryptedData="m7CF698f222KiEse8aFLIwSiXjxojbFesVpHltvrKPqKH3OclT7Qc+UhOw+MbxRAOSKgMb+erVYXYcrPwQ6TSF4VBt9Lzv0GdxJf82876SgANFURjVZBXKSwp0snxw/9wdfTGV2t7nIbpbUfBFD0QEi4rrsD8hZdPr4s/WLtHcpcvRkJvb3KDRw+PsnTyBtFOnXnv5sOJW84uy9OGuTTV8s0miqZCy//xZU2DJ3EZsg3Rp9E5xe0jMLtLOfvQEf5tM/pPw9hCkWbbBJEBSUn5IkSgkt3jAasjoWOSuDzw+MAJvnT7byJ7bvOSbEY14RAZzX6sZYw8Rd/n9fOssZivfF+F2HIfHhWuBNcGhNYTIYXtJsvmhtT5Wo4mMnq0j/TElZOoAjc385xkluHNRB/T+PVo+FEkRZgiugAOzOPn24WjZU7nbPrtoEYH5Bcdfcf3quP4hQAIQd6EvkfdnRti+Mfn925llWSS+fa+AV3hx0mwtFkk1VFMBuLPjL2nvvvUl4NkoMVzw0NRGPpeiS+DA=="; + String iv="jh3Io5uYeMSbU903QXpewA=="; + String session_key="LKv54UbAoCTx4yz5mi6S1A=="; + + + String result = AesCbcUtil.decrypt(encryptedData, session_key, iv, "UTF-8"); + System.out.println(result); + } +} \ No newline at end of file diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/DgBusinessCompany.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/DgBusinessCompany.java index 60524fd0..b0a72436 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/DgBusinessCompany.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/DgBusinessCompany.java @@ -142,4 +142,9 @@ public class DgBusinessCompany implements Serializable { * 联系电话(指个人或企业的) */ private String phone; + + /** + * 客户基本信息表id + */ + private Long customerId; }