fix(tenant): 修复多租户登录问题
This commit is contained in:
parent
e57128401e
commit
46a6f340fd
@ -2,6 +2,7 @@ package org.dromara.web.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -51,6 +52,7 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
String emailCode = loginBody.getEmailCode();
|
||||
// 多租户时页面不在选择租户,后端通过邮箱查询用户的默认租户
|
||||
String tenantId = userMapper.selectTenantIdByEmail(email);
|
||||
Assert.notBlank(tenantId, () -> new UserException("登录用户:" + email + " 不存在."));
|
||||
// 校验租户
|
||||
if(!"app".equals(client.getClientKey())){
|
||||
loginService.checkTenant(tenantId);
|
||||
|
@ -3,6 +3,7 @@ package org.dromara.web.service.impl;
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -57,8 +58,9 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
String uuid = loginBody.getUuid();
|
||||
// 多租户时页面不在选择租户,后端通过用户名查询用户的默认租户
|
||||
String tenantId = userMapper.selectTenantIdByUserName(username);
|
||||
Assert.notBlank(tenantId, () -> new UserException("登录用户:" + username + " 不存在."));
|
||||
// 校验租户
|
||||
if(!"app".equals(client.getClientKey())){
|
||||
if (!"app".equals(client.getClientKey())) {
|
||||
loginService.checkTenant(tenantId);
|
||||
}
|
||||
boolean captchaEnabled = captchaProperties.getEnable();
|
||||
|
@ -2,6 +2,7 @@ package org.dromara.web.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
@ -58,6 +59,7 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
String smsCode = loginBody.getSmsCode();
|
||||
// 多租户时页面不在选择租户,后端通过邮箱查询用户的默认租户
|
||||
String tenantId = userMapper.selectTenantIdByPhonenumber(phonenumber);
|
||||
Assert.notBlank(tenantId, () -> new UserException("登录用户:" + phonenumber + " 不存在."));
|
||||
LoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
if("app".equals(client.getClientKey())){
|
||||
//会员登录
|
||||
|
@ -28,7 +28,7 @@ public interface ProductMapper extends BaseMapper<Product> {
|
||||
*/
|
||||
List<Product> selectByEntity(Product product);
|
||||
|
||||
IPage<ProductVO> getlist(@Param("page") Page<Product> page, @Param("query") ProductBo query,Long tenantId);
|
||||
IPage<ProductVO> getlist(@Param("page") Page<Product> page, @Param("query") ProductBo query,String tenantId);
|
||||
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
@Override
|
||||
public IPage<ProductVO> getList(ProductBo query, Page<Product> page) {
|
||||
|
||||
Long tenantId = Long.valueOf(LoginHelper.getTenantId());
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
IPage<ProductVO> getlist = productMapper.getlist(page, query, tenantId);
|
||||
return getlist;
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
|
||||
//推荐商品要根据算法获取
|
||||
|
||||
Long tenantId = Long.valueOf(LoginHelper.getTenantId());
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
return productMapper.getlist(page,new ProductBo(),tenantId);
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
LEFT JOIN pms_product_category pc ON p.category_id = pc.id
|
||||
LEFT JOIN pms_sku s ON p.id = s.product_id
|
||||
WHERE 1=1
|
||||
<if test="tenantId != '000000'">
|
||||
AND s.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<!-- <if test="tenantId != '000000'">-->
|
||||
<!-- AND s.tenant_id = #{tenantId}-->
|
||||
<!-- </if>-->
|
||||
<if test="query.nameLike != null and query.nameLike != ''">
|
||||
AND p.name LIKE CONCAT('%', #{query.nameLike}, '%')
|
||||
</if>
|
||||
|
@ -64,7 +64,7 @@ public class SysTenantController extends BaseController {
|
||||
/**
|
||||
* 导出租户列表
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
// @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:export")
|
||||
@Log(title = "租户管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
@ -80,7 +80,7 @@ public class SysTenantController extends BaseController {
|
||||
* @param id 主键
|
||||
*/
|
||||
@Tag(name ="获取租户表详细信息")
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
// @SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public R<TenantDTO> getInfo(@PathVariable("id") Long id) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user