Merge remote-tracking branch 'origin/master'

master
shijie 4 years ago
commit ab374ac524
  1. 2
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java
  2. 1
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  3. 16
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java
  4. 4
      dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml

@ -29,4 +29,6 @@ public interface UserLoginDao extends BaseMapper<UserEntity> {
String getTokenByUserId(Long userId); String getTokenByUserId(Long userId);
Boolean updateUserLogin(@Param("userId") Long userId, @Param("date") Date date); Boolean updateUserLogin(@Param("userId") Long userId, @Param("date") Date date);
Integer countWeChatId(String weChatId);
} }

@ -169,6 +169,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
loginLog.setNewestTime(new Date()); loginLog.setNewestTime(new Date());
loginLogService.updateById(loginLog); loginLogService.updateById(loginLog);
} }
// 更新用户登录信息 // 更新用户登录信息
this.getBaseMapper().updateUserLogin(userEntity.getId(),new Date()); this.getBaseMapper().updateUserLogin(userEntity.getId(),new Date());

@ -130,7 +130,7 @@ public class UserServiceImpl extends ServiceImpl<UserLoginDao, UserEntity> imple
*/ */
@Override @Override
public Boolean weChatBinding(String code, HttpServletResponse response,String state) { 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); String accessTokenUrl = String.format(weChatConfig.getOPEN_ACCESS_TOKEN_URL(),weChatConfig.getOpenAppid(),weChatConfig.getOpenAppsecret(),code);
//获取access_token //获取access_token
@ -139,10 +139,20 @@ public class UserServiceImpl extends ServiceImpl<UserLoginDao, UserEntity> imple
return false; return false;
} }
String openId = (String) baseMap.get("openid"); 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("绑定成功---------------------------------------"); log.info("绑定成功---------------------------------------");
if (result){ if (result){
String token = this.getBaseMapper().getTokenByUserId(Long.parseLong(state));
if (token != null){ if (token != null){
try { try {
log.info("转发成功---------------------------------------"); log.info("转发成功---------------------------------------");

@ -58,4 +58,8 @@
UPDATE hrms_user SET login_num = login_num + 1,lasttime = #{date} WHERE id = #{userId} UPDATE hrms_user SET login_num = login_num + 1,lasttime = #{date} WHERE id = #{userId}
</update> </update>
<select id="countWeChatId" parameterType="string" resultType="integer">
SELECT COUNT(id) FROM hrms_user WHERE wechat_id = #{weChatId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save