From 68a8cd23cf36bf3d90255f631ec112de99f83c81 Mon Sep 17 00:00:00 2001 From: river <1376754470@qq.com> Date: Thu, 29 Oct 2020 11:03:08 +0800 Subject: [PATCH] =?UTF-8?q?openId=E5=88=A4=E9=87=8D=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../financial/hrauth/dao/UserLoginDao.java | 2 ++ .../service/impl/UserLoginServiceImpl.java | 1 + .../hrauth/service/impl/UserServiceImpl.java | 17 ++++++++++++++--- .../resources/mapper/hrauth/UserLoginMapper.xml | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java index 32b115ec..ec65bf6e 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java @@ -29,4 +29,6 @@ public interface UserLoginDao extends BaseMapper { String getTokenByUserId(Long userId); Boolean updateUserLogin(@Param("userId") Long userId, @Param("date") Date date); + + Integer countWeChatId(String weChatId); } 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 01369f4d..a5bad024 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 @@ -169,6 +169,7 @@ public class UserLoginServiceImpl extends ServiceImpl loginLog.setNewestTime(new Date()); loginLogService.updateById(loginLog); } + // 更新用户登录信息 this.getBaseMapper().updateUserLogin(userEntity.getId(),new Date()); 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 4b35ead3..22c976c2 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 @@ -12,6 +12,7 @@ import com.daqing.framework.domain.hrms.UserEntity; import com.daqing.framework.domain.hrms.request.LoginRequest; import com.daqing.framework.domain.hrms.response.LoginResponse; import com.daqing.framework.model.response.ResponseResult; +import com.daqing.framework.util.Md5Util; import com.daqing.framework.util.RedisUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -127,7 +128,7 @@ public class UserServiceImpl extends ServiceImpl imple */ @Override public Boolean weChatBinding(String code, HttpServletResponse response,String state) { - + //String md5Code = Md5Util.md5(code); String accessTokenUrl = String.format(weChatConfig.getOPEN_ACCESS_TOKEN_URL(),weChatConfig.getOpenAppid(),weChatConfig.getOpenAppsecret(),code); //获取access_token @@ -136,10 +137,20 @@ public class UserServiceImpl extends ServiceImpl imple return false; } String openId = (String) baseMap.get("openid"); - Boolean result = this.getBaseMapper().updateWeChat(Long.parseLong(state), openId); + String md5OpenId = Md5Util.md5(openId); + Integer countWeChatId = this.getBaseMapper().countWeChatId(md5OpenId); + String token = this.getBaseMapper().getTokenByUserId(Long.parseLong(state)); + if (countWeChatId > 0){ + try { + response.sendRedirect("http://www.huorantech.cn/dq/index.html#/workbench-manpower?token="+token+"&message=1"); + } catch (IOException e) { + e.printStackTrace(); + } + } + Boolean result = this.getBaseMapper().updateWeChat(Long.parseLong(state), md5OpenId); log.info("绑定成功---------------------------------------"); if (result){ - String token = this.getBaseMapper().getTokenByUserId(Long.parseLong(state)); + if (token != null){ try { log.info("转发成功---------------------------------------"); diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml index c7ea5f93..855878f7 100644 --- a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml @@ -58,4 +58,8 @@ UPDATE hrms_user SET login_num = login_num + 1,lasttime = #{date} WHERE id = #{userId} + + \ No newline at end of file