fix 会员门户端登录
This commit is contained in:
+5
-5
@@ -208,20 +208,20 @@ public class ThirdLoginController {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "/getLoginUser/{token}/{thirdType}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/getLoginUser/{token}", method = RequestMethod.GET)
|
||||
@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>();
|
||||
String username = JwtUtil.getUsername(token);
|
||||
|
||||
//1. 校验用户是否有效
|
||||
SysUser sysUser = sysUserService.getUserByName(username);
|
||||
SysUser sysUser = sysUserService.getUserByNameOrPhone(username);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
if(!result.isSuccess()) {
|
||||
return result;
|
||||
}
|
||||
//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::getThirdType,thirdType);
|
||||
SysThirdAccount account = sysThirdAccountService.getOne(query);
|
||||
@@ -230,7 +230,7 @@ public class ThirdLoginController {
|
||||
}
|
||||
if(oConvertUtils.isEmpty(sysUser.getAvatar())){
|
||||
sysUser.setAvatar(account.getAvatar());
|
||||
}
|
||||
}*/
|
||||
//update-end-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
|
||||
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.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.system.vo.SysUserCacheInfo;
|
||||
import com.jero.modules.pay.company.entity.PayContactsManagement;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
@@ -65,6 +66,8 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
|
||||
public SysUser getUserByName(String username);
|
||||
|
||||
SysUser getUserByNameOrPhone(String username);
|
||||
|
||||
/**
|
||||
* 添加用户和用户角色关系
|
||||
* @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.service.ISysUserService;
|
||||
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.Value;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -30,7 +32,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
@@ -127,8 +128,35 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
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
|
||||
public void addUserWithRole(SysUser user, String roles) {
|
||||
this.save(user);
|
||||
@@ -380,11 +408,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return result;
|
||||
}
|
||||
//情况3:根据用户信息查询,该用户已冻结
|
||||
if (CommonConstant.USER_FREEZE.equals(sysUser.getStatus())) {
|
||||
/*if (CommonConstant.USER_FREEZE.equals(sysUser.getStatus())) {
|
||||
baseCommonService.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null);
|
||||
result.error500("该用户已冻结");
|
||||
return result;
|
||||
}
|
||||
}*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user