fix 会员门户端登录
This commit is contained in:
+5
-5
@@ -208,20 +208,20 @@ public class ThirdLoginController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@RequestMapping(value = "/getLoginUser/{token}/{thirdType}", method = RequestMethod.GET)
|
@RequestMapping(value = "/getLoginUser/{token}", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<JSONObject> getThirdLoginUser(@PathVariable("token") String token,@PathVariable("thirdType") String thirdType) throws Exception {
|
public Result<JSONObject> getThirdLoginUser(@PathVariable("token") String token) throws Exception {
|
||||||
Result<JSONObject> result = new Result<JSONObject>();
|
Result<JSONObject> result = new Result<JSONObject>();
|
||||||
String username = JwtUtil.getUsername(token);
|
String username = JwtUtil.getUsername(token);
|
||||||
|
|
||||||
//1. 校验用户是否有效
|
//1. 校验用户是否有效
|
||||||
SysUser sysUser = sysUserService.getUserByName(username);
|
SysUser sysUser = sysUserService.getUserByNameOrPhone(username);
|
||||||
result = sysUserService.checkUserIsEffective(sysUser);
|
result = sysUserService.checkUserIsEffective(sysUser);
|
||||||
if(!result.isSuccess()) {
|
if(!result.isSuccess()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//update-begin-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
|
//update-begin-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
|
||||||
LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<>();
|
/*LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(SysThirdAccount::getSysUserId,sysUser.getId());
|
query.eq(SysThirdAccount::getSysUserId,sysUser.getId());
|
||||||
query.eq(SysThirdAccount::getThirdType,thirdType);
|
query.eq(SysThirdAccount::getThirdType,thirdType);
|
||||||
SysThirdAccount account = sysThirdAccountService.getOne(query);
|
SysThirdAccount account = sysThirdAccountService.getOne(query);
|
||||||
@@ -230,7 +230,7 @@ public class ThirdLoginController {
|
|||||||
}
|
}
|
||||||
if(oConvertUtils.isEmpty(sysUser.getAvatar())){
|
if(oConvertUtils.isEmpty(sysUser.getAvatar())){
|
||||||
sysUser.setAvatar(account.getAvatar());
|
sysUser.setAvatar(account.getAvatar());
|
||||||
}
|
}*/
|
||||||
//update-end-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
|
//update-end-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
//用户登录信息
|
//用户登录信息
|
||||||
|
|||||||
+3
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
|
import com.jero.common.system.vo.LoginUser;
|
||||||
import com.jero.common.system.vo.SysUserCacheInfo;
|
import com.jero.common.system.vo.SysUserCacheInfo;
|
||||||
import com.jero.modules.pay.company.entity.PayContactsManagement;
|
import com.jero.modules.pay.company.entity.PayContactsManagement;
|
||||||
import com.jero.modules.system.entity.SysUser;
|
import com.jero.modules.system.entity.SysUser;
|
||||||
@@ -65,6 +66,8 @@ public interface ISysUserService extends IService<SysUser> {
|
|||||||
|
|
||||||
public SysUser getUserByName(String username);
|
public SysUser getUserByName(String username);
|
||||||
|
|
||||||
|
SysUser getUserByNameOrPhone(String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加用户和用户角色关系
|
* 添加用户和用户角色关系
|
||||||
* @param user
|
* @param user
|
||||||
|
|||||||
+32
-4
@@ -23,6 +23,8 @@ import com.jero.modules.system.mapper.*;
|
|||||||
import com.jero.modules.system.model.SysUserSysDepartModel;
|
import com.jero.modules.system.model.SysUserSysDepartModel;
|
||||||
import com.jero.modules.system.service.ISysUserService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
import com.jero.modules.system.vo.SysUserDepVo;
|
import com.jero.modules.system.vo.SysUserDepVo;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@@ -30,7 +32,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -127,8 +128,35 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
return userMapper.getUserByName(username);
|
return userMapper.getUserByName(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysUser getUserByNameOrPhone(String username) {
|
||||||
|
if(oConvertUtils.isEmpty(username)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
SysUser sysUser = userMapper.getUserByName(username);
|
||||||
|
if(sysUser==null) {
|
||||||
|
PayContactsManagement contactsManagement = userMapper.getPayContactsManagementByPhone(username);
|
||||||
|
if (contactsManagement == null){
|
||||||
|
return null;
|
||||||
|
}else {
|
||||||
|
BeanUtils.copyProperties(contactsManagement, loginUser);
|
||||||
|
loginUser.setIsCompanyUser(true);
|
||||||
|
loginUser.setUsername(contactsManagement.getPhone());
|
||||||
|
loginUser.setRealname(contactsManagement.getName());
|
||||||
|
loginUser.setRoleCode("企业用户");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
BeanUtils.copyProperties(sysUser, loginUser);
|
||||||
|
List<String> roleByUserName = sysUserRoleMapper.getRoleByUserName(username);
|
||||||
|
loginUser.setRoleCode(StringUtils.join(roleByUserName, ","));
|
||||||
|
loginUser.setIsCompanyUser(false);
|
||||||
|
}
|
||||||
|
return sysUser;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void addUserWithRole(SysUser user, String roles) {
|
public void addUserWithRole(SysUser user, String roles) {
|
||||||
this.save(user);
|
this.save(user);
|
||||||
@@ -380,11 +408,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//情况3:根据用户信息查询,该用户已冻结
|
//情况3:根据用户信息查询,该用户已冻结
|
||||||
if (CommonConstant.USER_FREEZE.equals(sysUser.getStatus())) {
|
/*if (CommonConstant.USER_FREEZE.equals(sysUser.getStatus())) {
|
||||||
baseCommonService.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null);
|
baseCommonService.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null);
|
||||||
result.error500("该用户已冻结");
|
result.error500("该用户已冻结");
|
||||||
return result;
|
return result;
|
||||||
}
|
}*/
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user