...
|
...
|
@@ -18,6 +18,7 @@ import com.example.client.security.LoginUser; |
|
|
import com.example.client.security.TokenService;
|
|
|
import com.example.client.service.LonginService;
|
|
|
import com.example.client.service.UserService;
|
|
|
import com.example.client.utils.HttpUtils;
|
|
|
import com.example.client.utils.ip.IpUtils;
|
|
|
import com.example.client.utils.sign.Md5Utils;
|
|
|
import com.example.client.utils.verification.PhoneUtils;
|
...
|
...
|
@@ -37,6 +38,12 @@ import java.util.concurrent.TimeUnit; |
|
|
*/
|
|
|
@Service
|
|
|
public class LonginServiceImpl implements LonginService {
|
|
|
public static final String url = "https://api.weixin.qq.com/sns/oauth2/access_token";
|
|
|
|
|
|
public static final String APPID = "";
|
|
|
|
|
|
public static final String SECRET = "";
|
|
|
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
@Autowired
|
...
|
...
|
@@ -166,13 +173,14 @@ public class LonginServiceImpl implements LonginService { |
|
|
|
|
|
/**
|
|
|
* 删除缓存
|
|
|
*
|
|
|
* @param key
|
|
|
* @return
|
|
|
*/
|
|
|
public AjaxResult logOut(String key ) {
|
|
|
public AjaxResult logOut(String key) {
|
|
|
|
|
|
|
|
|
String cacheObject = (String)redisCache.getCacheObject(key);
|
|
|
String cacheObject = (String) redisCache.getCacheObject(key);
|
|
|
//刪除等記錄
|
|
|
redisCache.deleteObject(key);
|
|
|
//退出
|
...
|
...
|
@@ -181,6 +189,7 @@ public class LonginServiceImpl implements LonginService { |
|
|
|
|
|
return AjaxResult.success(true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult forget(UpdatePasswordDTO dto) {
|
|
|
|
...
|
...
|
@@ -222,9 +231,9 @@ public class LonginServiceImpl implements LonginService { |
|
|
|
|
|
CUserVo cUserVo = userService.queryById(userId);
|
|
|
|
|
|
if(cUserVo==null){
|
|
|
return AjaxResult.error("非法进入");
|
|
|
}
|
|
|
if (cUserVo == null) {
|
|
|
return AjaxResult.error("非法进入");
|
|
|
}
|
|
|
CUserBo cUserBo = new CUserBo();
|
|
|
cUserBo.setUserId(userId);
|
|
|
//修改密码
|
...
|
...
|
@@ -236,7 +245,7 @@ public class LonginServiceImpl implements LonginService { |
|
|
//判断是否登录
|
|
|
Object cacheObject = redisCache.getCacheObject(key);
|
|
|
//删除缓存 重新登录
|
|
|
if(cacheObject != null ){
|
|
|
if (cacheObject != null) {
|
|
|
logOut(key);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -250,11 +259,11 @@ public class LonginServiceImpl implements LonginService { |
|
|
if (loginBo.getType() != null && loginBo.getType() == 1) {
|
|
|
UserTrVo userTrVo = new UserTrVo();
|
|
|
CUserVo cUserVo = userService.queryById(UserContext.currentUserId());
|
|
|
if( user != null){
|
|
|
if (user != null) {
|
|
|
AjaxResult.error("这个微信号已经绑定了账号");
|
|
|
}
|
|
|
|
|
|
if (cUserVo != null ) {
|
|
|
if (cUserVo != null) {
|
|
|
CUserBo cUserBo = new CUserBo();
|
|
|
cUserBo.setUserId(UserContext.currentUserId());
|
|
|
cUserBo.setOpenId(loginBo.getOpenId());
|
...
|
...
|
@@ -274,7 +283,7 @@ public class LonginServiceImpl implements LonginService { |
|
|
UserService.insert(cUser1);
|
|
|
}*/
|
|
|
|
|
|
if(user !=null){
|
|
|
if (user != null) {
|
|
|
LoginTokenVO vo = new LoginTokenVO();
|
|
|
//不返回密码
|
|
|
user.setUserPassword(null);
|
...
|
...
|
@@ -302,18 +311,16 @@ public class LonginServiceImpl implements LonginService { |
|
|
CUserVo user = userService.queryById(userId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//账号和密码来做key
|
|
|
String key = user.getAccount() + user.getUserPassword();
|
|
|
|
|
|
String cacheObject = (String)redisCache.getCacheObject(key);
|
|
|
String cacheObject = (String) redisCache.getCacheObject(key);
|
|
|
//
|
|
|
CUserBo cUserBo = new CUserBo();
|
|
|
cUserBo.setUserId(UserContext.currentUserId());
|
|
|
cUserBo.setOpenId(null);
|
|
|
//解除微信绑定
|
|
|
userService.updateOpenId(userId);
|
|
|
userService.updateOpenId(userId);
|
|
|
userService.updateByBo(cUserBo);
|
|
|
|
|
|
//刪除等記錄
|
...
|
...
|
@@ -327,6 +334,12 @@ public class LonginServiceImpl implements LonginService { |
|
|
|
|
|
@Override
|
|
|
public AjaxResult loginCode(LoginBo loginBo) {
|
|
|
return null;
|
|
|
|
|
|
String param = "appid=" + APPID + "&secret=" + SECRET + "&code=" + loginBo.getOpenId() + "&grant_type=authorization_code";
|
|
|
String s = HttpUtils.mySendGet(url, param);
|
|
|
|
|
|
System.out.println("======================================================="+s);
|
|
|
|
|
|
return AjaxResult.success(s);
|
|
|
}
|
|
|
} |
...
|
...
|
|