From df92c9c29e264ccfe1c6dd913eda3706e20b62c2 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Fri, 23 Oct 2020 16:29:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../financial/hrauth/config/WeChatConfig.java | 6 ++ .../hrms/service/impl/UserServiceImpl.java | 12 +-- .../src/main/resources/bootstrap.properties | 82 +++++++++---------- 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java index f719ef78..73153950 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/config/WeChatConfig.java @@ -37,6 +37,12 @@ public class WeChatConfig implements Serializable { @Value("${wxopen.redirect_url}") private String openRedirectUrl; + /** + * 绑定微信回调url + */ + @Value("${wxopen.wechat_binding_redirect_url}") + private String weChatBindingRedirectUrl; + /** * 微信开放平台二维码连接 */ diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java index 43592986..4ed15308 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java @@ -58,7 +58,7 @@ public class UserServiceImpl extends ServiceImpl implements if (weChatConfig == null){ employeeAndUser.setWechatId("二维码获取失败,请稍后重试"); }else { - employeeAndUser.setWechatId(String.format(weChatConfig.get("open_QRCODE_URL").toString(),weChatConfig.get("openAppid"), + employeeAndUser.setWechatId(String.format(weChatConfig.get("OPEN_QRCODE_URL").toString(),weChatConfig.get("openAppid"), weChatConfig.get("openRedirectUrl"),weChatConfig.get("openAppsecret"))); } }else { @@ -214,7 +214,7 @@ public class UserServiceImpl extends ServiceImpl implements } String code = (int)((Math.random() * 9 + 1) * 100000)+ ""; // 发送短信 - Boolean result = SendSMS.sendCode(phone,"SMS_204986402",code); + Boolean result = SendSMS.sendCode(phone,"SMS_204155294",code); if (result){ RedisUtil.setEx(phone,code,PromptSuccess.OVERDUE_TIME); return true; @@ -251,15 +251,15 @@ public class UserServiceImpl extends ServiceImpl implements public Boolean weChatCallback(String code, HttpServletResponse response) { log.info("微信回调成功---------------------------------------"); + JSONObject responseResult = hrmsAuthFeignService.getWeChatConfig(); JSONObject weChatConfig = responseResult.getJSONObject("data"); - String accessTokenUrl = String.format(String.valueOf(weChatConfig.get("open_ACCESS_TOKEN_URL")), weChatConfig.get("openAppid"), weChatConfig.get("openAppsecret"), code); + String accessTokenUrl = String.format(weChatConfig.get("OPEN_ACCESS_TOKEN_URL").toString(), weChatConfig.get("openAppid"), weChatConfig.get("openAppsecret"), code); //获取access_token Map baseMap = HttpUtils.doGet(accessTokenUrl); - if(baseMap == null || baseMap.isEmpty()){ - return false; - } + + if(baseMap == null || baseMap.isEmpty()){ return false; } String openId = (String) baseMap.get("openid"); /*HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String token = request.getHeader("token"); diff --git a/dq-financial-hrms/src/main/resources/bootstrap.properties b/dq-financial-hrms/src/main/resources/bootstrap.properties index 18172a22..06998181 100644 --- a/dq-financial-hrms/src/main/resources/bootstrap.properties +++ b/dq-financial-hrms/src/main/resources/bootstrap.properties @@ -1,61 +1,61 @@ +##服务名称 +#spring.application.name=dq-financial-hrms +##配置中心地址 +#spring.cloud.nacos.config.server-addr=192.168.31.142:8848 +#spring.cloud.nacos.config.namespace=4c56c2f9-b6a3-4e7b-88b8-b1001e86dfd6 +##spring.cloud.nacos.config.group=prod +# +#spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml +#spring.cloud.nacos.config.ext-config[0].group=dev +#spring.cloud.nacos.config.ext-config[0].refresh=true +# +#spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml +#spring.cloud.nacos.config.ext-config[1].group=dev +#spring.cloud.nacos.config.ext-config[1].refresh=true +# +#spring.cloud.nacos.config.ext-config[2].data-id=other.yml +#spring.cloud.nacos.config.ext-config[2].group=dev +#spring.cloud.nacos.config.ext-config[2].refresh=true +# +#spring.redis.host=127.0.0.1 +#spring.redis.port=6379 +#spring.redis.password=123456 +#spring.redis.database=0 +#spring.redis.timeout=30000 +#spring.redis.jedis.pool.max-active=8 +#spring.redis.jedis.pool.max-wait=-1 +#spring.redis.jedis.pool.max-idle=8 +#spring.redis.jedis.pool.min-idle=0 +# +#spring.servlet.multipart.max-file-size=10MB +#spring.servlet.multipart.max-request-size=10MB + +# 正式环境(prod) #服务名称 spring.application.name=dq-financial-hrms #配置中心地址 -spring.cloud.nacos.config.server-addr=192.168.31.142:8848 -spring.cloud.nacos.config.namespace=4c56c2f9-b6a3-4e7b-88b8-b1001e86dfd6 +spring.cloud.nacos.config.server-addr=120.78.127.12:8848 +spring.cloud.nacos.config.namespace=69614b55-1521-421c-ac58-dbe4a5b01b43 #spring.cloud.nacos.config.group=prod spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml -spring.cloud.nacos.config.ext-config[0].group=dev +spring.cloud.nacos.config.ext-config[0].group=prod spring.cloud.nacos.config.ext-config[0].refresh=true spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml -spring.cloud.nacos.config.ext-config[1].group=dev +spring.cloud.nacos.config.ext-config[1].group=prod spring.cloud.nacos.config.ext-config[1].refresh=true spring.cloud.nacos.config.ext-config[2].data-id=other.yml -spring.cloud.nacos.config.ext-config[2].group=dev +spring.cloud.nacos.config.ext-config[2].group=prod spring.cloud.nacos.config.ext-config[2].refresh=true -spring.redis.host=192.168.232.128 +spring.redis.host=127.0.0.1 spring.redis.port=6379 -spring.redis.password= +spring.redis.password=dq123456 spring.redis.database=0 spring.redis.timeout=30000 spring.redis.jedis.pool.max-active=8 spring.redis.jedis.pool.max-wait=-1 spring.redis.jedis.pool.max-idle=8 -spring.redis.jedis.pool.min-idle=0 - -spring.servlet.multipart.max-file-size=10MB -spring.servlet.multipart.max-request-size=10MB - -#正式环境(prod) -#服务名称 -#spring.application.name=dq-financial-hrms -###配置中心地址 -##spring.cloud.nacos.config.server-addr=120.78.127.12:8848 -##spring.cloud.nacos.config.namespace=69614b55-1521-421c-ac58-dbe4a5b01b43 -###spring.cloud.nacos.config.group=prod -## -##spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml -##spring.cloud.nacos.config.ext-config[0].group=prod -##spring.cloud.nacos.config.ext-config[0].refresh=true -## -##spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml -##spring.cloud.nacos.config.ext-config[1].group=prod -##spring.cloud.nacos.config.ext-config[1].refresh=true -## -##spring.cloud.nacos.config.ext-config[2].data-id=other.yml -##spring.cloud.nacos.config.ext-config[2].group=prod -##spring.cloud.nacos.config.ext-config[2].refresh=true -## -##spring.redis.host=127.0.0.1 -##spring.redis.port=6379 -##spring.redis.password=dq123456 -##spring.redis.database=0 -##spring.redis.timeout=30000 -##spring.redis.jedis.pool.max-active=8 -##spring.redis.jedis.pool.max-wait=-1 -##spring.redis.jedis.pool.max-idle=8 -##spring.redis.jedis.pool.min-idle=0 \ No newline at end of file +spring.redis.jedis.pool.min-idle=0 \ No newline at end of file