openId判重加密

master
river 4 years ago
parent caeb3fbf64
commit 68a8cd23cf
  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. 17
      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);
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());
loginLogService.updateById(loginLog);
}
// 更新用户登录信息
this.getBaseMapper().updateUserLogin(userEntity.getId(),new Date());

@ -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<UserLoginDao, UserEntity> 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<UserLoginDao, UserEntity> 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("转发成功---------------------------------------");

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